powerdesigner 设置唯一约束
作者:yan
代碼生成:
/*==============================================================*/
/* Index: "UQ_providerid" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */
/*==============================================================*/
create unique index "UQ_providerid" on "tab" (
? ?"xx" ASC,
? ?"xxx" ASC,
? ?"xxxx" ASC,
? ?"xxxxx" ASC
);
代碼生成:
/*==============================================================*/
/* Table: "jg_emp_jobgrade" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */
/*==============================================================*/
create table "jg_emp_jobgrade" ?(
? ?"id" ? ? ? ? ? ? ? ? CHAR(32) ? ? ? ? ? ? ? ? ? ? ? ?not null,
? ?"emp_id" ? ? ? ? ? ? CHAR(32),
? ?"jg_id" ? ? ? ? ? ? ?CHAR(32),
? ?"jobfamily_branch_id" CHAR(32),
? ?"job_grade" ? ? ? ? ?varchar(32),
? ?constraint PK_JG_EMP_JOBGRADE primary key ("id"),
? ?constraint AK_KEY_2_JG_EMP_J unique ("emp_id", "jg_id", "jobfamily_branch_id")
);
Oracle?10g中unique與index的問題
create table test
(
? x integer,
? y integer,
? z integer
);
alter table test add constraint primary key (x); --產(chǎn)生一個(gè)約束,并產(chǎn)生一個(gè)同名索引
create unique index index01 on test(x,y);
--create unique index index02 on test(x,y); --不允許完全相同的索引,即使索引名稱不同
create unique index index03 on test(y,z);
create unique index index04 on test(z,y); --index04 是與index03互不相同的索引
alter table test add constraint cons01 unique(x,y,z) ; --產(chǎn)生一個(gè)約束,并自動(dòng)產(chǎn)生一個(gè)名為cons01 的UNIQUE索引
alter table test add constraint cons01 unique(x,y) ; --產(chǎn)生一個(gè)約束,但因與index01 重復(fù)(自動(dòng)產(chǎn)生的索引不區(qū)分順序),因此不能自動(dòng)產(chǎn)生索引
alter table test add constraint cons01 unique(y,x) ; --產(chǎn)生一個(gè)約束,但因與index01 重復(fù),因此不能自動(dòng)產(chǎn)生索引
--create unique index cons01 on test(x,y);? --不能執(zhí)行,因?yàn)樗饕齝ons01 已經(jīng)被約束cons01 自動(dòng)創(chuàng)建的索引占用
alter table test add constraint cons012 check (x>100);
alter table test add constraint cons013 check (x>100);? --check可以內(nèi)容完全相同
處理辦法:
提取所有約束(UCPR)
提取名稱不在約束表中的所有索引
總結(jié)
以上是生活随笔為你收集整理的powerdesigner 设置唯一约束的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 特斯拉最豪黑粉,超级碗砸 400 万炮轰
- 下一篇: ESP8266 SDK开发: 外设篇-G