====================序列
//查询当前用户序列
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约束
启用约束: enable( validate) :启用约束,创建索引,对已有及新加入的数据执行约束. enable novalidate :启用约束,创建索引,仅对新加入的数据强制执行约束,而不管表中的现有数据.
禁用约束: disable( novalidate):关闭约束,删除索引,可以对约束列的数据进行修改等操作. disable validate :关闭约束,删除索引,不能对表进行 插入/更新/删除等操作.
//查询当前用户约束
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_yncheck(yn in(1,2))enable validate;//删除约束
alter table THIRD_PARTY_MERCHANT drop constraint constraint_yn;commit;//重新添加
alter table THIRD_PARTY_MERCHANT
add constraint constraint_yncheck(yn in(1,0))enable validate;