Oracle 索引的定义与约束相同

发布于 2024-08-28 21:48:35 字数 3727 浏览 7 评论 0原文

我在使用 Oracle SQL Developer 时遇到问题,每当我转到表 TLCASENOTE 的索引部分时,它都会告诉我索引“索引 PK_TBLCASENOTE 的定义与约束 PK_TLCASENOTES 相同”。

我发现了这个 Oracle 表单帖子 但似乎没有人有解决方案。 这是用于制作表格的 DDL

CREATE TABLE "DSAC"."TBLCASENOTES" (
    "PRIMARYID" NUMBER(11,0), 
    "CLIENTID" NUMBER(11,0), 
    "INTAKEID" NUMBER(11,0), 
    "AGENCYID" NUMBER, 
    "CREATEDDATE" DATE, 
    "CREATEDBY" VARCHAR2(30 BYTE), 
    "MODIFIEDBY" VARCHAR2(30 BYTE), 
    "MODIFIEDDATE" DATE, 
    "TCN" NUMBER DEFAULT 1, 
    "STAFF" VARCHAR2(30 BYTE), 
    "CASENOTETYPE" VARCHAR2(20 BYTE), 
    "CONTACTDATE" DATE, 
    "CONTACTHOUR" VARCHAR2(2 BYTE) DEFAULT null, 
    "CONTACTMIN" VARCHAR2(2 BYTE) DEFAULT null, 
    "CONTACTAMPM" VARCHAR2(2 BYTE) DEFAULT null, 
    "DHOUR" VARCHAR2(2 BYTE) DEFAULT null, 
    "DMIN" VARCHAR2(2 BYTE) DEFAULT null, 
    "BFDATE" DATE, 
    "NOTES" CLOB, 
    CHECK ("PRIMARYID" IS NOT NULL) ENABLE, 
    CHECK ("CLIENTID" IS NOT NULL) ENABLE, 
    CHECK ("INTAKEID" IS NOT NULL) ENABLE, 
    CONSTRAINT "PK_TBLCASENOTES" PRIMARY KEY ("PRIMARYID")
    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 "CONTACT"  ENABLE, 
    CONSTRAINT "CASENOTES_CLIENT_FK" FOREIGN KEY ("CLIENTID") REFERENCES "DSAC"."TBLCLIENT" ("CLIENTID") ON DELETE CASCADE ENABLE, 
    CONSTRAINT "CASENOTES_INTAKE_FK" FOREIGN KEY ("INTAKEID") REFERENCES "DSAC"."TBLINTAKE" ("INTAKEID") ON DELETE CASCADE ENABLE
) 
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CONTACT" 
LOB ("NOTES") STORE AS (
    TABLESPACE "CONTACT" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
    NOCACHE LOGGING 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
);

CREATE INDEX "DSAC"."CASENOTESAGENCYINDEX" ON "DSAC"."TBLCASENOTES" ("AGENCYID") 
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 "CONTACT";

CREATE UNIQUE INDEX "DSAC"."PK_TBLCASENOTE" ON "DSAC"."TBLCASENOTES" ("PRIMARYID") 
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 "CONTACT";

CREATE UNIQUE INDEX "DSAC"."SYS_IL0000059271C00019$$" ON "DSAC"."TBLCASENOTES" (
PCTFREE 10 INITRANS 2 MAXTRANS 255 
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CONTACT" 
PARALLEL (DEGREE 0 INSTANCES 0);

CREATE INDEX "DSAC"."TBLCASENOTESCLIENTINDEX" ON "DSAC"."TBLCASENOTES" ("CLIENTID") 
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 "CONTACT";

CREATE INDEX "DSAC"."TBLCASENOTESINTAKEINDEX" ON "DSAC"."TBLCASENOTES" ("INTAKEID") 
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 "CONTACT";

I am having an issue with Oracle SQL Developer where it keeps telling me my index "Index PK_TBLCASENOTE is defined identically to constraint PK_TBLCASENOTES" whenever I go to the Indexes section of my table TBLCASENOTE.

I found this Oracle form post but no one seems to have a solution. This is the DDL for making the table.

CREATE TABLE "DSAC"."TBLCASENOTES" (
    "PRIMARYID" NUMBER(11,0), 
    "CLIENTID" NUMBER(11,0), 
    "INTAKEID" NUMBER(11,0), 
    "AGENCYID" NUMBER, 
    "CREATEDDATE" DATE, 
    "CREATEDBY" VARCHAR2(30 BYTE), 
    "MODIFIEDBY" VARCHAR2(30 BYTE), 
    "MODIFIEDDATE" DATE, 
    "TCN" NUMBER DEFAULT 1, 
    "STAFF" VARCHAR2(30 BYTE), 
    "CASENOTETYPE" VARCHAR2(20 BYTE), 
    "CONTACTDATE" DATE, 
    "CONTACTHOUR" VARCHAR2(2 BYTE) DEFAULT null, 
    "CONTACTMIN" VARCHAR2(2 BYTE) DEFAULT null, 
    "CONTACTAMPM" VARCHAR2(2 BYTE) DEFAULT null, 
    "DHOUR" VARCHAR2(2 BYTE) DEFAULT null, 
    "DMIN" VARCHAR2(2 BYTE) DEFAULT null, 
    "BFDATE" DATE, 
    "NOTES" CLOB, 
    CHECK ("PRIMARYID" IS NOT NULL) ENABLE, 
    CHECK ("CLIENTID" IS NOT NULL) ENABLE, 
    CHECK ("INTAKEID" IS NOT NULL) ENABLE, 
    CONSTRAINT "PK_TBLCASENOTES" PRIMARY KEY ("PRIMARYID")
    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 "CONTACT"  ENABLE, 
    CONSTRAINT "CASENOTES_CLIENT_FK" FOREIGN KEY ("CLIENTID") REFERENCES "DSAC"."TBLCLIENT" ("CLIENTID") ON DELETE CASCADE ENABLE, 
    CONSTRAINT "CASENOTES_INTAKE_FK" FOREIGN KEY ("INTAKEID") REFERENCES "DSAC"."TBLINTAKE" ("INTAKEID") ON DELETE CASCADE ENABLE
) 
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CONTACT" 
LOB ("NOTES") STORE AS (
    TABLESPACE "CONTACT" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
    NOCACHE LOGGING 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
);

CREATE INDEX "DSAC"."CASENOTESAGENCYINDEX" ON "DSAC"."TBLCASENOTES" ("AGENCYID") 
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 "CONTACT";

CREATE UNIQUE INDEX "DSAC"."PK_TBLCASENOTE" ON "DSAC"."TBLCASENOTES" ("PRIMARYID") 
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 "CONTACT";

CREATE UNIQUE INDEX "DSAC"."SYS_IL0000059271C00019$" ON "DSAC"."TBLCASENOTES" (
PCTFREE 10 INITRANS 2 MAXTRANS 255 
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CONTACT" 
PARALLEL (DEGREE 0 INSTANCES 0);

CREATE INDEX "DSAC"."TBLCASENOTESCLIENTINDEX" ON "DSAC"."TBLCASENOTES" ("CLIENTID") 
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 "CONTACT";

CREATE INDEX "DSAC"."TBLCASENOTESINTAKEINDEX" ON "DSAC"."TBLCASENOTES" ("INTAKEID") 
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 "CONTACT";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

菊凝晚露 2024-09-04 21:48:35

问题是因为如果不存在索引,Oracle 会自动为主键创建索引。冲突是因为尝试在同一列上创建索引,尽管名称略有不同。

我的最后一个地方是与表创建分开设置约束,这意味着您将使用以下步骤:

  1. 创建表(无约束,包括主键)
  2. 创建索引
  3. 应用约束

The issue is because Oracle automatically creates an index for a primary key if no index already exists. The collision is because of attempting to create an index on the same column, though slightly different name.

My last place set constraints separately from the table creation, which meant that you'd use the following steps:

  1. Create table (no constraints, incl. primary key)
  2. Create index(es)
  3. Apply constraints
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文