-- 1.基本表操做表 drop table user1; create table user1( id number(5,3) not null, -- (N,M) N:一共幾位,M:小數後幾位 name varchar2(10) not null, tel number(11,0) not null ); truncate table user1; insert into user1(id,name,tel) values(23.456,'aaa',22); insert into user1(id,name,tel) values((select max(id) from user1)+1,'aaa',22); select * from user1; -- 2.建立表 create table user2 as select * from user1; -- 複製所有字段和數據 create table user3 as select id,name from user1; -- 複製指定字段和數據 create table user4 as select id gid ,name gname from user1; -- 新表字段設置爲新的名字 create table user5 as select id gid ,name gname from user1 where 1=2; -- 複製結構不復制數據 -- 3.alter -- 增長字段 ALTER TABLE "USER4" ADD ("tel" NUMBER(11) DEFAULT 13900001111 NOT NULL) ; -- 刪除字段 ALTER TABLE "USER4" DROP("tel"); -- 更改表名 ALTER TABLE "USER5" RENAME TO "USER55"; -- 更改字段名 ALTER TABLE "USER4" RENAME COLUMN "tel" TO "randomkey"; -- 變動屬性 ALTER TABLE "USER4" MODIFY ("randomkey" VARCHAR2(11) DEFAULT 'sha256' ); -- 修改默認值 ALTER TABLE "USER4" MODIFY ("GNAME" VARCHAR2(20),"randomkey" VARCHAR2(20));