oracle-初级使用(表操作)

来源:互联网 发布:怎么查看服务器域名 编辑:程序博客网 时间:2024/06/05 07:43

1.复制一张表

create table my_test as(select * from t_test);--如果只想要表结构,不想要数据create table my_test as(select * from t_test where 1=2);--加上一个不可能实现的条件就可以。

2.在已有的表里面增加列

alter table my_test add(test_flag char);--在最后一列添加了 char(1)的 test_flag;--如果想在指定的列添加,可以创建新表,插入数据。

3.修改已有的列的属性

alter table my_test modify(test_flag char(2));

4.修改表名

rename my_test to your_test;

5.清空一张表的操作

delete from my_test;--delete 是需要commit的,如果数据量比较大会占用很大的缓冲区,TRUNCATE TABLE my_test;--truncate 是ddl语言,不能回退,速度快。

6.删除表
drop table my_test;

原创粉丝点击