Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constraint and Check Names 2

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

In a CREATE TABLE script when I indicate NOT NULL for a column a system generated name (SYS_C004567 etc.) is created for the corresponding constraint\check.

How can I indicate the name of the constraint\check rather than taking the system generated name (can you offer an example)?

Thanks,

Michael42

 

Try:
Code:
CREATE TABLE MyTable 
(Col1 Number CONSTRAINT Col1_chk NOT NULL
,...etc...);
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
And just a personal-preference addition to LK's excellent example:

Within the 30-character name limitation, I name my constraints as <table_name>_<column_name>_<constraint_type>, where <constraint_type> is:

NN - Not Null
CK - Other Check constraints
UK - Unique Constraint
PK - Primary Key
FK - Foreign Key


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
LKBrwnDBA, SantaMufasa,

Very useful!


Thanks for posting,

Michael42
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top