RE: naming conventions (constraints and indexes)
Date: Thu, 10 Nov 2011 09:09:06 -0500
Message-ID: <C95D75DD2E01DD4D81124D104D317ACA1B8A2E23F2_at_JAXMSG01.crowley.com>
Interesting, and I have a couple observations from these urls.
- Yes, the ALTER TABLE ... DROP CONSTRAINT does have a "KEEP INDEX" clause.
- Hemant gives an example of the index and constraint name being different, but that when you drop the constraint, the ORA-0001 returns the index name. However, I interpret the results where, when they are the same name, that the index name is still returned... since the constraint was dropped, why would it be the constraint name, (they're the same -- I say it is the index name still).
I'm just not too sure how much it matters that the index be independent of the constraint. Indeed it seems like a good idea ... However, Freek points out that the using index clause has a side affect where if another index is present that can support the constraint, then oracle will not recreate the one defined in the using index clause during import. (kind of news to me though -- but it seems like almost a redundant index situation).
Joel Patterson
Database Administrator
904 727-2546
-----Original Message-----
From: Chitale, Hemant Krishnarao [mailto:Hemant.Chitale_at_sc.com]
Sent: Wednesday, November 09, 2011 11:09 PM
To: Patterson, Joel
Cc: oracle-l_at_freelists.org
Subject: RE: naming conventions (constraints and indexes)
I prefer to create the Index *before* defining the constraint. That way, the Index is independent of the constraint. So
a) the Index is preserved when I drop the constraint b) the Index can be non-Unique c) for composite definitions, the columns need not be in the same "order" in the Index definition
http://hemantoracledba.blogspot.com/2010/07/preserving-index-when-dropping.html
and
http://hemantoracledba.blogspot.com/2011/03/primary-key-and-index.html
Hemant K Chitale
-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Joel.Patterson_at_crowley.com
Sent: Thursday, November 10, 2011 3:21 AM
To: oracle-l_at_freelists.org
Subject: RE: naming conventions (constraints and indexes)
....deleted ....
CREATE TABLE EXAMPLE_TABLE (
PRIM_COL number constraint EXAMPLE_TABLE_PK primary key
using index ( CREATE INDEX EXAMPLE_TABLE_PX ON
EXAMPLE_TABLE(PRIM_COL)),
UNIQ_COL number constraint EXAMPLE_TABLE_UNIQ_COL_UK UNIQUE
using index ( create index EXAMPLE_TABLE_UNIQ_COL_UX on
EXAMPLE_TABLE(UNIQ_COL)),
junk varchar2(10)
);
select table_name, constraint_name, constraint_type, index_name
from user_constraints where table_name = 'EXAMPLE_TABLE';
TABLE_NAME CONSTRAINT_NAME C INDEX_NAME
------------------------- ------------------------- ------------------
EXAMPLE_TABLE EXAMPLE_TABLE_PK P EXAMPLE_TABLE_PX EXAMPLE_TABLE EXAMPLE_TABLE_UNIQ_COL_UK U EXAMPLE_TABLE_UNIQ_COL_UX
DBMON _at_ COSDEV> select table_name, index_name from user_indexes where table_name = 'EXAMPLE_TABL
TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
EXAMPLE_TABLE EXAMPLE_TABLE_PX EXAMPLE_TABLE EXAMPLE_TABLE_UNIQ_COL_UX
Joel Patterson
Database Administrator
904 727-2546
This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic.
Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB.
Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276.
If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions.
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Nov 10 2011 - 08:09:06 CST