Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 545 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 440 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Export a PK with autocreated index.

Im using SQLDeveloper Versión 3.2.20.09
Is there a way of generate an export DDL script to preserve the original authomatic created index of a primary key?. When I generate the export DDL script it always generates explicit indexes no matter if they were originally created implicity or explicity.
My problem is related whit this migration issue https://forums.oracle.com/message/1223619#1223619 but in my case I'm using the script on a different instance with the same versión of Oracle (10.2g). I know that using explicit DROP INDEX option on ALTER DROP statement resolves the problem, but I thought tha withthe export facility, I'd have exactly the same DB on both servers.
Thanks in advance.
Answers
-
Please post a specific, simple example of the DDL you are getting and the DDL you want to get.
-
/*******************************************************************************
*CASE A
*******************************************************************************/
--A.1 Manual Script
CREATE TABLE TAB_A(
pk number(*,0),
x number,
y varchar(20),
constraint TAB_A_PK primary key (pk)
);
--A.2 Export Script
--------------------------------------------------------
-- DDL for Table TAB_A
--------------------------------------------------------CREATE TABLE "TAB_A"
( "PK" NUMBER(*,0),
"X" NUMBER,
"Y" VARCHAR2(20)
) ;
/
--------------------------------------------------------
-- DDL for Index TAB_A_PK
--------------------------------------------------------CREATE UNIQUE INDEX "TAB_A_PK" ON "TAB_A" ("PK")
;
/
--------------------------------------------------------
-- Constraints for Table TAB_A
--------------------------------------------------------ALTER TABLE "TAB_A" ADD CONSTRAINT "TAB_A_PK" PRIMARY KEY ("PK") ENABLE;
//*******************************************************************************
* CASE B
*******************************************************************************/
--B.1 Manual Script
CREATE TABLE TAB_B(
pk number(*,0),
x number,
y varchar(20)
);ALTER TABLE TAB_B ADD constraint TAB_B_PK primary key (pk);
--B.2 Export Script
--------------------------------------------------------
-- DDL for Table TAB_B
--------------------------------------------------------CREATE TABLE "TAB_B"
( "PK" NUMBER(*,0),
"X" NUMBER,
"Y" VARCHAR2(20)
);
/
--------------------------------------------------------
-- DDL for Index TAB_B_PK
--------------------------------------------------------CREATE UNIQUE INDEX "TAB_B_PK" ON "TAB_B" ("PK");
/
--------------------------------------------------------
-- Constraints for Table TAB_B
--------------------------------------------------------ALTER TABLE "TAB_B" ADD CONSTRAINT "TAB_B_PK" PRIMARY KEY ("PK") ENABLE;
//*******************************************************************************
* CASE C
********************************************************************************/
--C.1 Manual Script
CREATE TABLE TAB_C(
pk number(*,0),
x number,
y varchar(20)
);CREATE UNIQUE INDEX TAB_C_PK ON TAB_C(pk);
ALTER TABLE TAB_C ADD constraint TAB_C_PK primary key (pk) USING INDEX TAB_C_PK;
--C.2 Export Script
--------------------------------------------------------
-- DDL for Table TAB_C
--------------------------------------------------------CREATE TABLE "TAB_C"
( "PK" NUMBER(*,0),
"X" NUMBER,
"Y" VARCHAR2(20)
) ;
/
--------------------------------------------------------
-- DDL for Index TAB_C_PK
--------------------------------------------------------CREATE UNIQUE INDEX "TAB_C_PK" ON "TAB_C" ("PK")
;
/
--------------------------------------------------------
-- Constraints for Table TAB_C
--------------------------------------------------------ALTER TABLE "TAB_C" ADD CONSTRAINT "TAB_C_PK" PRIMARY KEY ("PK") ENABLE;
//*******************************************************************************
* THE PROBLEM: When I execute an alter script to change the pk on tables that* were created with the manual version, I only get the error "ORA-02264: name already used by an existing..."
* on TAB_C, but if I execute the alter script over tables created with the exported
* version, then I get the same error but on all tables.
* Using DROP INDEX option works as expected in the three tables on both versions
* of script, but I think SQLDeveloper should generate the a better script cause
* Oracle decides deleting an index depending if it was previously created or not.
*******************************************************************************/
ALTER TABLE TAB_A DROP PRIMARY KEY;
ALTER TABLE TAB_A ADD CONSTRAINT TAB_A_PK PRIMARY KEY(pk,x,y);ALTER TABLE TAB_B DROP PRIMARY KEY;
ALTER TABLE TAB_B ADD CONSTRAINT TAB_B_PK PRIMARY KEY(pk,x,y);ALTER TABLE TAB_C DROP PRIMARY KEY;
ALTER TABLE TAB_C ADD CONSTRAINT TAB_B_PK PRIMARY KEY(pk,x,y);