oracle 添加、修改、删除、约束-语法

创建表结构:

create table test1
(id varchar2(20) not null);

向表中添加主键约束

alter table test1 add constraint pk_test1 primary key(id);

向表中添加Sequences

create sequence SEQ_TX_ASKCUSTTYPE
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;

添加字段的语法:

alter table test1 add (column datatype [default value][null/not null],….);

修改字段的语法:

修改列的名称
alter table TABLE_NAME rename column FIELD_NAME to NEW_FIELD_NAME;
修改列的属性
alter table test1 modify (column datatype [default value][null/not null],….);

删除字段的语法:

alter table test1 drop (column);

添加、修改、删除多列的话,用逗号隔开。

alter table test1 add (
name varchar2(30) default ‘无名氏' not null,
age integer default 22 not null,
has_money number(9,2)
);
posted @ 2018-01-12 18:10  游园拾忆  阅读(33)  评论(0编辑  收藏  举报