首页 > 代码库 > oracle

oracle

====================序列

//查询当前用户序列

select from user_sequences

//查询所有序列

select * from all_sequences;

//创建序列

语法:create sequence 表名_sequence increment by 1 start with 1 nomaxvalue nocycle; 

eg:

create sequence third_party_merchant_sequence  increment by 1 start with 1 nomaxvalue nocycle;

//查询该序列的下一个值

select THIRD_PARTY_MERCHANT_SEQUENCE.Nextval from dual;

删除序列:

drop sequence third_party_merchant_sequence;

 

========================check约束

//查询当前用户约束

select * from user_constraints;

 //创建表时添加约束

create table test

(id int,

name varchar2(10),

sex varchar2(10) check (sex in (‘男‘,‘女‘))

);

 //为表添加约束

alter table THIRD_PARTY_MERCHANT
add  constraint constraint_yn
check(yn in(1,2))enable validate;

oracle