I have a table that is already populated with data and I need to add a constraint to it. The problem is, there are already violations to the constraint in the table, so the ALTER TABLE command fails. I tried to work around it using the following steps:
1. Create a duplicate structure of the table.
2. Copy all records from the original to the duplicate.
3. Truncate the original table.
4. Apply the constraint to the original table.
5. Copy all records back from the duplicate.
At this point, that fails due constraint violation. I was hoping it would just not load the records that violated the constraint.
I have tried writing a "find duplicates" query, but it goes out into La La land and after about an hour and a half, and I killed it off.
I guess I need help writing a query that will load from the duplicate to the original without violating the constraint. The table structures are as follows:
The constraint is as follows:
Any assistance would be greatly appreciated... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
1. Create a duplicate structure of the table.
2. Copy all records from the original to the duplicate.
3. Truncate the original table.
4. Apply the constraint to the original table.
5. Copy all records back from the duplicate.
At this point, that fails due constraint violation. I was hoping it would just not load the records that violated the constraint.
I have tried writing a "find duplicates" query, but it goes out into La La land and after about an hour and a half, and I killed it off.
I guess I need help writing a query that will load from the duplicate to the original without violating the constraint. The table structures are as follows:
Code:
WALKAWAY
--------
UUID VARCHAR2 (7)
WALKAWAY_CODE VARCHAR2 (3)
WALKAWAY_DATE DATE
...
Code:
ALTER TABLE WALKAWAY
ADD CONSTRAINT WALKAWAY_UUID_DATE_IX
PRIMARY KEY (UUID, WALKAWAY_DATE)
USING INDEX TABLESPACE TCL_01_IDX
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.