Oracle使用——Oracle表字段的增加、删除、修改和重命名

增加字段

  • 语法
    alter table tablename add (column datatype [default value][null/not null]);
  • 说明:alter table 表名 add (字段名 字段类型 默认值 是否为空);[ ]内参数可选
  • 例子
    alter table test_user add (userName varchar2(20) default '管理员' not null);
  • Next

修改字段

  • 语法
    alter table tablename modify (column datatype [default value][null/not null]);
  • 说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空);[ ]内参数可选
  • 例子
    alter table test_user modify (userName varchar2(50) default '超级管理员' not null);
  • Next

删除字段

  • 语法
    alter table tablename drop (column);
  • 说明:alter table 表名 drop 字段名
  • 例子
    alter table test_user drop (userName);
  • Next

字段重命名

  • 语法
    alter table tablename rename column column1 to column2;
  • 说明:alter table 表名 rename  column  列名 to 新列名
  • 例子
    alter table test_user rename column userName to user_name;
  • Next

表的重命名

  • 语法
    alter table tablename rename to tablename1;
  • 说明:alter table 表名 rename to  新表名
  • 例子
    alter table test_user rename to test_user_simple;
  • Next
posted @ 2019-11-15 17:40  话·醉月  阅读(472)  评论(0编辑  收藏  举报