Use referencing columns : Create Table « Table « Oracle PL/SQL Tutorial






SQL>
SQL> create table I1(n number primary key, v varchar2(10));


SQL> create table I2(n number primary key, v varchar2(10));


SQL>
SQL> create table MAP
  2  (n number primary key,
  3   i1 number referencing I1(n),
  4   i2 number referencing I2(n));

SQL>
SQL> create unique index IDX_MAP on MAP(i1, i2);

SQL>
SQL> insert into i1
  2  select rownum, rpad('*',10,'*') from all_objects;

12651 rows created.

SQL>
SQL> insert into i2
  2  select rownum, rpad('*',10,'*') from all_objects;

12651 rows created.

SQL>
SQL> insert into map
  2  select rownum, rownum, rownum from all_objects;

12651 rows created.

SQL>
SQL>
SQL>
SQL> select *
  2    from i1, map, i2
  3   where  i1.n = map.i1
  4     and i2.n = map.i2
  5     and i1.v = 'x'
  6     and i2.v = 'y';

no rows selected

SQL>
SQL>
SQL> drop table i1 cascade constraint;

Table dropped.

SQL> drop table map cascade constraint;

Table dropped.

SQL> drop table i2 cascade constraint;

Table dropped.








6.1.Create Table
6.1.1.Creating a Table
6.1.2.Create table with storage setting
6.1.3.Create table with storage setting 2
6.1.4.Create an external table
6.1.5.Create copy table
6.1.6.Create a table from one or more other tables
6.1.7.Rename a table
6.1.8.One column with three constraints
6.1.9.Use referencing columns
6.1.10.Create a table based on a hash cluster
6.1.11.Create table with 'organization index OVERFLOW'
6.1.12.Create table with 'organization index'
6.1.13.Cascade delete setting
6.1.14.Demonstrate a simple External table
6.1.15.Create intermediate table for calculation
6.1.16.Make myCode a CACHE table.