码迷,mamicode.com
首页 > 数据库 > 详细

oracle

时间:2016-11-17 23:06:36      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:code   letter   tar   div   sel   char   use   sequence   arc   

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

//查询当前用户序列

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

标签:code   letter   tar   div   sel   char   use   sequence   arc   

原文地址:http://www.cnblogs.com/21heshang/p/6075622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!