powerdesigner 设置唯一约束

本文详细介绍了Oracle 10g中unique和index的区别与使用方法,包括创建、修改和删除操作,以及如何合理地利用它们优化数据库性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

者: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); --产生一个约束,并产生一个同名索引

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) ; --产生一个约束,并自动产生一个名为cons01 的UNIQUE索引

alter table test add constraint cons01 unique(x,y) ; --产生一个约束,但因与index01 重复(自动产生的索引不区分顺序),因此不能自动产生索引

alter table test add constraint cons01 unique(y,x) ; --产生一个约束,但因与index01 重复,因此不能自动产生索引

--create unique index cons01 on test(x,y);  --不能执行,因为索引cons01 已经被约束cons01 自动创建的索引占用

alter table test add constraint cons012 check (x>100);
alter table test add constraint cons013 check (x>100);  --check可以内容完全相同

处理办法:

提取所有约束(UCPR)

提取名称不在约束表中的所有索引


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xyzroundo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值