当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- Analysis of 8253a register
- Line number of Jenkins pipeline script execution exception
- 2022-2028 global ethylene oxide scrubber industry research and trend analysis report
- 五分钟搞懂探索式测试
- CTF tool (1) -- archpr -- including installation / use process
- Repetition is the mother of skill
- Red Hat将在Project Atomic上运用容器负载服务器
- 20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
- Don't worry about whether you can be a coder if you don't learn English well. Learn it first
- CSDN常用复杂公式模板记录
猜你喜欢

Line number of Jenkins pipeline script execution exception

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

6-1 exploit -ftp exploit

2022-2028 global carbon fiber room scraper system industry research and trend analysis report

New trend of embedded software development: Devops

2022-2028 global encrypted external hard disk industry research and trend analysis report

Why did kubernetes win? The changes in the container circle!

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

Wordpress blog uses volcano engine veimagex for static resource CDN acceleration (free)

8253A寄存器浅析
随机推荐
Summer Challenge [FFH] harmonyos mobile phone remote control Dayu development board camera
Redis based distributed lock
Using Excel to quickly generate SQL statements
2022-2028 global retro glass industry research and trend analysis report
Error 2059 when Navicat connects to MySQL
[leetcode] [SQL] notes
Luogu p1144 shortest circuit count
The college entrance examination in 2022 is over. Does anyone really think programmers don't need to study after work?
2022-2028 global plant peptone industry research and trend analysis report
Advanced mathematical modeling
[UML] UML class diagram
C WinForm program interface optimization example
CentOS install MySQL
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
To tell you the truth, ThreadLocal is really not an advanced thing
Redis - cache penetration, cache breakdown, cache avalanche
1175. prime number arrangement / Sword finger offer II 104 Number of permutations
New trend of embedded software development: Devops
Maxpool2d explanation -- Application in arrays and images
Cloud security daily 220630: the IBM data protection platform has found an arbitrary code execution vulnerability, which needs to be upgraded as soon as possible