Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: ER question

Re: ER question

From: Marc Blum <blum_at_marcblum.de>
Date: Fri, 07 May 2004 19:23:30 +0200
Message-ID: <sfhn901f3nsdue6hqusbdulva49lpdctbi@4ax.com>

SQL> set echo on
SQL> 
SQL> drop table emp cascade constraints;

Table dropped.

SQL> drop table dept cascade constraints;

Table dropped.

SQL> --
SQL> create table dept
  2 (dname varchar2(30) primary key,
  3 bigboss varchar2(30)
  4 );

Table created.

SQL>
SQL> create table emp
  2 (dname varchar2(30),
  3 ename varchar2(30) primary key);

Table created.

SQL>
SQL> ALTER table dept
  2 add constraint bb_nn
  3 check (bigboss is not null)
  4 deferrable
  5 initially deferred;

Table altered.

SQL>
SQL> alter table dept
  2 add constraint bb_fk
  3 foreign key (bigboss)
  4 references emp
  5 deferrable
  6 initially deferred;

Table altered.

SQL>
SQL> alter table emp
  2 add constraint d_fk
  3 foreign key (dname)
  4 references dept
  5 deferrable
  6 initially deferred;

Table altered.

SQL>
SQL> insert into dept
  2 values
  3 ('HQ','Larry');

1 row created.

SQL>
SQL> insert into emp
  2 values
  3 ('HQ','Larry');

1 row created.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> select * from dept;

DNAME                          BIGBOSS

------------------------------ ------------------------------
HQ Larry

SQL> select * from emp;

DNAME                          ENAME

------------------------------ ------------------------------
HQ Larry

SQL>
SQL>

--
Marc Blum
mailto:blumNOSPAM_at_marcblum.de
http://www.marcblum.de
Received on Fri May 07 2004 - 12:23:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US