0

I have created one table in oracle data base my table script is

  CREATE TABLE wsc_widget_bundle (
    id VARCHAR (50),
    widgetBundle BLOB NULL, 
    devicesoftwareclass VARCHAR(30) NOT NULL,
    widgetProfileId VARCHAR (50) NOT NULL,
    bundleHash BLOB NULL,
    widgetLocale VARCHAR (6) NOT NULL ,
    status INT,  
        primary key(id),
        unique(widgetProfileId, devicesoftwareclass,status),
    foreign key(widgetProfileId) references wsc_widget_profile(id)
  );

When i create ddl for that is looks like

create table "DEV1"."WSC_WIDGET_BUNDLE"(
    "ID" VARCHAR2(50) not null,
   "WIDGETBUNDLE" BLOB,
   "DEVICESOFTWARECLASS" VARCHAR2(30) not null,
   "WIDGETPROFILEID" VARCHAR2(50) not null,
   "BUNDLEHASH" BLOB,
   "WIDGETLOCALE" VARCHAR2(6) not null,
   "STATUS" NUMBER,
    constraint "SYS_C00323290" primary key ("ID")
);

alter table "DEV1"."WSC_WIDGET_BUNDLE"  
    add constraint "SYS_C00323292" 
    foreign key ("WIDGETPROFILEID") 
    references "MTP440_DEV1"."WSC_WIDGET_PROFILE"("ID");
create unique index "MTP440_DEV1"."SYS_C00323290" on "MTP440_DEV1"."WSC_WIDGET_BUNDLE"("ID");
create unique index "MTP440_DEV1"."SYS_C00323291" on "MTP440_DEV1"."WSC_WIDGET_BUNDLE"("WIDGETPROFILEID","DEVICESOFTWARECLASS","STATUS");
create index "MTP440_DEV1"."TEST" on "MTP440_DEV1"."WSC_WIDGET_BUNDLE"("DEVICESOFTWARECLASS","STATUS","WIDGETLOCALE","WIDGETPROFILEID");

Now i want to write alter script to alter unique key constrain of my table but as at creation of table I didn't mention the name of my unique key name it is given by system like SYS_C00323291 So how can I write alter script to drop that unique key whose name is not known to me and generation new one

4

2 回答 2

0
Alter table x
drop constraint pk;

Alter table x
add constraint New_constraint_name PRIMARY KEY (colname);
于 2012-05-04T07:22:14.777 回答
0

You can find the name of the constraint by querying the user_constraints and user_cons_columns views.

于 2012-05-04T07:41:31.350 回答