oracle create table

--backup table
create table table_bak as select * from table;
insert into table select * from table_bak ;


------------------create talbe --------------------start---------------------
--将一个表改名:
ALTER TABLE 当前表名 RENAME TO 新表名;
如:
ALTER TABLE bouns RENAME TO bonus_new
 
--增加一个列:
ALTER TABLE 表名 ADD(列名 数据类型);
如:
ALTER TABLE temp ADD(weight NUMBER(38,0));


--修改一个列的数据类型(一般限于修改长度,修改为一个不同类型时有诸多限制):
ALTER TABLE 表名 MODIFY(列名 数据类型);
如:
ALTER TABLE temp MODIFY(weight NUMBER(3,0) NOT NULL);


--给列改名:
ALTER TABLE 表名 RENAME COLUMN 当前列名 TO 新列名;
如:
ALTER TABLE temp RENAME COLUMN weight TO weight_new;
--或者
SP_RENAME 'temp.weight', weight_new


--删除一个列:
ALTER TABLE 表名 DROP COLUMN 列名;
如:
ALTER TABLE emp DROP COLUMN weight_new;


--delete table,including table structure
drop table temp_table;


--delete table's contents
truncate table temp_table;




-----------------------insert into 的两种方式
1.一次输入一笔资料的语法如下:
---------------------
INSERT INTO "表格名" ("栏位1", "栏位2", .. .) VALUES ("值1", "值2", .. .);


2.一次输入多笔的资料的语法是:
---------------------
INSERT INTO "表格1" ("栏位1", "栏位2", .. .) SELECT "栏位3", "栏位4",.. . FROM "表格2";


eg:
insert into table_bak select * from table where rownum < 101;
insert into table_bak select seq_table.nextval, sysdate, 'aaaaaaa',2,1,1,sysdate from c_examinequestion where rownum < 11;







你可能感兴趣的:(oracle create table)