1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| SQL> create table p(px int primary key, py int check (py > 0), pz varchar2(10) n
ot null);
Table created.
SQL> create table e(ex int primary key);
Table created.
SQL> alter table e add constraint efk foreign key(ex) references p;
Table altered.
SQL>
SQL> insert into p values(1,1,'un');
1 row created.
SQL> insert into p values(2,2,'deux');
1 row created.
SQL>
SQL> insert into e values(2);
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> create table pp as select * from p where px >=2;
Table created.
SQL> alter table e drop constraint efk;
Table altered.
SQL> drop table p;
Table dropped.
SQL> alter table pp rename to p;
Table altered.
SQL> alter table p add primary key(px);
Table altered.
SQL> alter table e add constraint efk foreign key(ex) references p;
Table altered.
SQL>
SQL> set long 500
SQL> set pagesize 99
SQL> select dbms_metadata.get_ddl('TABLE', 'P', user) as ddl from dual;
DDL
--------------------------------------------------------------------------------
CREATE TABLE "HR"."P"
( "PX" NUMBER(*,0),
"PY" NUMBER(*,0),
"PZ" VARCHAR2(10) NOT NULL ENABLE,
PRIMARY KEY ("PX")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147
SQL>
SQL> |
Partager