oracle DDL

一 改主键约束

3步

1.查询主键  select * from user_cons_columns c where c.table_name='表名';

2.删除主键 alter table 表名 drop constraint 主键名;

3.新建主键 alter table 表名 add constraint 主键名 primary key (字段1,字段2);

二 重命名类名(改列名)

1.直接改,主要rename后加column: alter table 表名 rename column 旧列名 to 新列名

三 表、列加注释

1.表加注释 comment on table 表名 is '字符串'

2.列加注释 comment on column 表名.列名 is '字符串'

四 增加列、减少列、修改列

1.修改列长度and不为空 alter table 表名 modify 列名 列类型(如number(16,4)) not null

2.增加列 alter table 表名 add 列名 列类型(如varchar2(500)) default '-' not null

3.删除列 alter table 表名 drop column 列名

原文地址:https://www.cnblogs.com/jiangqingfeng/p/6874304.html