当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- 如何关闭一个开放的DNS解析器
- Self examination before school starts
- Detailed explanation of conv2d -- use in arrays and images
- New trend of embedded software development: Devops
- What does it mean to open an account online? Is it safe to open an account online?
- Development of wireless U-shaped ultrasonic electric toothbrush
- The programmer's girlfriend gave me a fatigue driving test
- Query points in MATLAB Delaunay triangulation
- In depth understanding of jetpack compose kernel: slottable system
- [untitled]
猜你喜欢
C WinForm program interface optimization example
[leetcode] [SQL] notes
Why did kubernetes win? The changes in the container circle!
ABAQUS 2022 latest edition - perfect realistic simulation solution
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
2022-2028 global PTFE lined valve industry research and trend analysis report
20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)
What should I do without 50W bride price
Combining online and offline, VR panorama is a good way to transform furniture online!
New trend of embedded software development: Devops
随机推荐
leetcode 474. Ones and zeroes (medium)
What SQL statements are supported for data filtering
Mysql database query optimization
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
[PHP] self developed framework qphp, used by qphp framework
2022-2028 global mobile scanning radiology room industry survey and trend analysis report
8253A寄存器浅析
1175. prime number arrangement / Sword finger offer II 104 Number of permutations
Basic data structure of redis
[leetcode] [SQL] notes
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
In depth understanding of jetpack compose kernel: slottable system
如何关闭一个开放的DNS解析器
Wechat official account development (1) introduction to wechat official account
2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
Red hat will apply container load server on project atomic
CSDN常用复杂公式模板记录
1. crawler's beautifulsoup parsing library & online parsing image verification code
2022-2028 global ethylene oxide scrubber industry research and trend analysis report