oracle constraints(3)
oracle constraints 应用
oracle constraints可以设置为立即检查或者当时事务提交时检查。
可以在创建约束的时候指定是deferrable。然后通过set constraints xxx set deferred或者immediate,也可以在seesion级别设定所有约束为deferred或者immediate(alter seesion set constraints deferred/immediate)。
SQL> select t.constraint_name, t.status, t.validated, t.deferrable from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED DEFERRABLE
------------------------------ -------- ------------- --------------
SYS_C003765 ENABLED VALIDATED NOT DEFERRABLE
SYS_C003768 ENABLED NOT VALIDATED NOT DEFERRABLE
UK_T ENABLED NOT VALIDATED NOT DEFERRABLE
SQL> alter table t2 add primary key(vid) deferrable;
Table altered
SQL>
SQL> select t.constraint_name, t.status, t.validated, t.deferrable from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED DEFERRABLE
------------------------------ -------- ------------- --------------
SYS_C003765 ENABLED VALIDATED NOT DEFERRABLE
SYS_C003772 ENABLED VALIDATED DEFERRABLE
SYS_C003768 ENABLED NOT VALIDATED NOT DEFERRABLE
UK_T ENABLED NOT VALIDATED NOT DEFERRABLE
SQL> select * from t2;
VID VNAME VSEX
---------- ---------- ----------
1 a y
2 b
3 c x
SQL> insert into t2 values (1,'d','y');
insert into t2 values (1,'d','y')
ORA-00001: 违反唯一约束条件 (PORTALDB.SYS_C003772)
SQL> set constraints SYS_C003772 deferred;
Constraints set
SQL> insert into t2 values (1,'d','y');
1 row inserted
SQL> set constraints SYS_C003772 deferred;
Constraints set
SQL> commit;
commit
ORA-02091: 事务处理已重算
ORA-00001: 违反唯一约束条件 (PORTALDB
相关文档:
使用CodeSmith生成oracle数据库表的实体层(Model)
http://blog.csdn.net/dacong/archive/2009/01/27/3853663.aspx
自己写的,CodeSimth中的例子都是msSQL server的,所以自己写了个支持Oracle数据库表的,不一定很完善,适用就好,数据类型没有周全考虑,只考虑了常用的一些类型,增加了个表名字属性,采用的.net2.0我结 ......
数据库设计:
CREATE TABLE ADVERTISE_CATEGORY
(
CATEGORY_ID NUMBER PRIMARY KEY, --节点ID
CATEGORY_NAME VARCHAR2(500), &nb ......
1.OracleDBConsoleorcl oem控制台的服务进程
2.OracleJobSchedulerORCL 定时器的服务进程
3.OracleOraDb10g_home1iSQL*Plus isql*plus的服务进程
4.OracleOraDb10g_home1TNSListener 监听器的服务进程
5.Or ......
查询用户信息
SELECT USERNAME,DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE, PROFILE, ACCOUNT_STATUS, CREATED from dba_users; 查询用户空间使用和上限情况
SELECT username, tablespace_name, bytes/1024/1024 space_used_in_mb, max_bytes/1024/1024 max_space_in_mb from dba_ts_quotas; 创建 ......
oracle 约束的状态
oracle在创建约束后默认状态是enabled VALIDATED
SQL> create table T2
2 (
3 VID NUMBER,
4 VNAME VARCHAR2(10) not null,
5 VSEX VARCHAR2(10) not null
6 )
7 /
Table created
SQL> alter table t2 add constraints PK_T primary key (vid); ......