您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页12、DDL改变表结构操作

12、DDL改变表结构操作

来源:二三娱乐

创建表

Create table student( Sid number(10), Snamevarchar2(10) ) tablespace tt; 

以上 tablespace 不是必须的。默认不写,则创建在登录的用户所在的表空间上


使用子查询创建表

create table myemp as select * from emp;

create table myemp as select * from empwhere deptno=10;

create table myemp as select * from emp1=2;


添加字段

Alter table student add age number(5);


修改字段

Alter table student modify age number(10);

alter table table2 rename column result toresult2;


删除字段

Alter table student drop column age;


清空表数据

Truncate table student; 

正常情况下删除数据,如果发现删除错了,则可以通过 rollback 回滚。如果使用了截断表,则表示所有的数据不可恢复了.所以速度很快(更详细的说明可查看 Oracle 体系结构)


删除表

Drop table student;


重命名表

Rename student to student1; 

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务