分类:
2008-10-27 14:20:35
SQL> CREATE VIEW d10_emp
2 ( empno, ename, job,deptno,
3 CONSTRAINT pk_d10
4 PRIMARY KEY (ename)
5 RELY DISABLE NOVALIDATE
6 ) AS
7 SELECT empno, ename, job ,deptno
8 FROM emp
9 WHERE deptno = 10;
View created.
SQL> select * from d10_emp;
EMPNO ENAME JOB DEPTNO
---------- ---------- --------- ----------
7782 CLARK MANAGER 10
7839 KING PRESIDENT 10
7934 MILLER CLERK 10
SQL> select CONSTRAINT_NAME,TABLE_NAME,CONSTRAINT_TYPE from user_constraints
2 where table_name='D10_EMP';
CONSTRAINT_NAME TABLE_NAME C
------------------------------ ------------------------------ -
PK_D10 D10_EMP P
SQL> insert into d10_emp values(7777,'EYGLE','MANAGER',10);
1 row created.
SQL> insert into d10_emp values(8888,'EYGLE','MANAGER',10);
1 row created.
SQL> select * from d10_emp;
EMPNO ENAME JOB DEPTNO
---------- ---------- --------- ----------
7782 CLARK MANAGER 10
7839 KING PRESIDENT 10
7934 MILLER CLERK 10
7777 EYGLE MANAGER 10
8888 EYGLE MANAGER 10