当前位置:网站首页>Oracle-表的创建与管理
Oracle-表的创建与管理
2022-07-01 00:32:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

一、创建表
create table
1、创建一个学生表,其中有四个字段,第一个字段为id是number类型,第二个字段是name是varchar2类型,第三个字段是age是number类型,第四个字段是class是varchar2类型。
create table student(
id number,
name varchar2,
age number,
class varchar2
)
二、复制表
1、将学生表复制一份
复制表其实就是用来备份表的
create table student2 as select * from student;
2、将学生表的表结构复制出来一份,不要任何数据
我们有的时候需要复制表结构而不需要复制数据,这个时候我们只需要where条件后面什么数据都不满足即可
create table student2 as select * from student where 1 = 2;
三、截断表
oracle提供了事务是用来保护数据操作的,比如我们删除了一张表的数据,但是没有提交事务,这个时候数据不会立刻被删除,而是会占用一些资源保存在其中,当我们使用rollback会将数据回滚回来,但是当我们没有使用rollback回滚或者commit提交,但我们执行了一个表创建之类的数据定义操作,那么该事务会自动提交,所以我们可以使用truncate命令来截断表,将表的资源全部释放。
1、将学生表的资源释放
truncate table student;
四、重命名表名
1、将学生表student修改为student2
rename student to student2;
五、删除数据表
1、将学生表删除
drop table student;
六、闪回技术
oracle提供了闪回技术,主要为了用户在出现误删除的时候能够进行恢复。
1、查询删除过的表的信息
col object_name for A35;
col original_name for A35;
col type for A15;
select object_name,original_name,type,droptime from user_recyclebin;
2、恢复删除的student表
flashback table student to before drop;
3、彻底删除student表
drop table student purge;
--删除回收站中的表
purge table student;
4、清空回收站
purge recyclebin;
七、修改表结构
1、将学生表student的name字段修改为number类型
alter table student modify (name number);
2、将学生表student增加一列地址列add,字段类型为varchar2;
alter table student add(add varchar2);
八、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- 2022-2028 global single travel industry research and trend analysis report
- [UML] UML class diagram
- Random ball size, random motion collision
- When is it appropriate to replace a virtual machine with a virtual machine?
- $watch will not trigger data change - $watch not firing on data change
- Redis based distributed lock
- lvm-snapshot:基于LVM快照的备份
- 2022-2028 global herbal diet tea industry research and trend analysis report
- The principle and related problems of acid in MySQL
- 20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
猜你喜欢

让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北

女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!

MySQL variables, stored procedures and functions

深入理解 Jetpack Compose 内核:SlotTable 系统

Development of wireless U-shaped ultrasonic electric toothbrush

How does the VR cloud exhibition hall bring vitality to offline entities? What are the functions?

When is it appropriate to replace a virtual machine with a virtual machine?

20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)

What should I do without 50W bride price

Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
随机推荐
CentOS 6.3 x64 PHP 5.2.6 扩展安装OpenSSL出错的解决方法
2022-2028 global encrypted external hard disk industry research and trend analysis report
IFLYTEK active competition summary! (12)
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
Fh6908a negative pole turn off synchronous rectification analog low voltage drop diode control IC chip tsot23-6 ultra low power rectifier 1W power consumption < 100ua static replacement mp6908
Self examination before school starts
76 page comprehensive solution 2022 for smart Logistics Park (download attached)
让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北
需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
File reading and writing for rust file system processing - rust Practice Guide
Rust book materials - yazhijia Library
Redis based distributed lock
Luogu p1168 median
Redis - how to understand publishing and subscribing
2022-2028 global ethylene oxide scrubber industry research and trend analysis report
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
When we look at the industrial Internet, we always look at it from the opposite of the consumer Internet
Plot size and resolution with R markdown, knitr, pandoc, beamer
LVM snapshot: preparation of backup based on LVM snapshot
网上开华泰证券的股票账户是否安全呢?