1.修改表结构
语法: alter table table_name modify (列名 数据类型)
示例:
9:54:25 SQL> alter table dbtest_dw_cust_order modify (co_seq number(4));
Table altered
9:55:22 SQL> alter table dbtest_dw_cust_order modify (co_seq number(2));
alter table dbtest_dw_cust_order modify (co_seq number(2))
ORA-01440: 要减小精度或标度, 则要修改的列必须为空
注意:修改表结构的时候注意精度,如果要减小精度或标度, 则要修改的列必须为空
2.增加一个列
语法:alter table table_name add (列名 数据类型)
10:12:18 SQL> alter table dbtest_dw_cust_order add (dbtest number);
Table altered
10:11:42 SQL> alter table dbtest_dw_cust_order add (dbtest number not null);
alter table dbtest_dw_cust_order add (dbtest number not null)
ORA-01758: 要添加必需的 (NOT NULL) 列, 则表必须为空
注意:要添加必需的 (NOT NULL) 列, 则表必须为空
3.修改列名
语法:alter table 表名 rename column 当前列名 to 新列名
示例:
10:23:40 SQL> alter table dbtest_dw_cust_order rename column dbtest to dbtest123;
Table altered
4.删除一个列
语法:alter table 表名 drop column 列名
示例:
10:24:30 SQL> alter table dbtest_dw_cust_order drop column dbtest123;
Table altered
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15720542/viewspace-605860/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15720542/viewspace-605860/