--主鍵是非分區(qū)索引,也可以看作是全局
create table test_par1
(
? tdate?? varchar2(8) primary key
)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
--主鍵是分區(qū)索引
create table test_par2
(
? tdate?? varchar2(8)
)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
create index i_tdate2 on test_par2(tdate) local;
alter table test_par2 add constraint pk_tdate2 primary key(tdate);
--查看test_par2的DDL
select dbms_metadata.get_ddl( 'TABLE', 'TEST_PAR2' ) from dual;
--整理如下
create table test_par3
(
? tdate?? varchar2(8),
? constraint pk_tdate3 primary key (tdate) using index local
)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
這個(gè)案例也告訴我們,在做DDL時(shí),盡量還是顯示的寫出屬性,一些簡易語法會引起不可知的定義。最后都用 get_ddl 再查一下,這才是Oracle真正執(zhí)行的DDL。