1,增加列:相同
alter table test add mail varchar(128);
2,删除列:
oracle 与mysql相同:alter table test drop column mail;
db2 :不提供删除列功能(解决办法是删除表,重建)
3,更改列名
oracle : alter table test rename column mail to mail2;
mysql : alter talbe test change mail mail2 varchar(128);
db2 : 不提供更改列名功能(解决办法同删除,或者通过建立一个新视图解决)
4,更改列类型
oracle :alter table test modify column (mail2 integer);
mysql :alter table test modify column mail2 integer;
db2 :alter table test alter mail varchar(256) 只可以加宽,不能更改类型
5,更改列的限制(主键、非空)
db2 :alter table test alter mail null/not null;
mysql :alter table test modify mail2 varchar(29) not null;
oracle:alter table test modify mail2 null/not null;
alter table test add mail varchar(128);
2,删除列:
oracle 与mysql相同:alter table test drop column mail;
db2 :不提供删除列功能(解决办法是删除表,重建)
3,更改列名
oracle : alter table test rename column mail to mail2;
mysql : alter talbe test change mail mail2 varchar(128);
db2 : 不提供更改列名功能(解决办法同删除,或者通过建立一个新视图解决)
4,更改列类型
oracle :alter table test modify column (mail2 integer);
mysql :alter table test modify column mail2 integer;
db2 :alter table test alter mail varchar(256) 只可以加宽,不能更改类型
5,更改列的限制(主键、非空)
db2 :alter table test alter mail null/not null;
mysql :alter table test modify mail2 varchar(29) not null;
oracle:alter table test modify mail2 null/not null;
本文介绍了在Oracle、MySQL和DB2中进行表结构修改的方法,包括增加、删除、重命名列,以及修改列类型和限制等内容。
1036

被折叠的 条评论
为什么被折叠?



