Skip to Content
0
Former Member
Jul 16, 2015 at 06:42 AM

GIVING CUSTOM NAME TO KEY CONSTRAINTS using SQL CREATE Statement.

12 Views

Hi Friends,

I know when Creating Table we define Primary and Foriegn keys (With system generated Constraint names like _SYS_CONSTRAINT_xxxxx_#xx_#F0)

And also we can view them by using following SQL Syntax

---For Primary key

SELECT * FROM “SYS”."CONSTRAINTS" WHERE SCHEMA_NAME = 'TEST';

---For foreign key

SELECT * FROM "SYS"."REFERENTIAL_CONSTRAINTS"WHERE SCHEMA_NAME = 'TEST';

Also we can assign names of these CONSTRAINTS if we they are created using ALTER COMMENDS.(Example given below)

ALTER TABLE Orders

ADD CONSTRAINT fk_PerOrders

FOREIGN KEY (P_Id)

REFERENCES Persons(P_Id)


NOTE:Here fk_PerOrders is the name of foreign key constraint given by me


Based on My knowledge we are able to define CONSTRAINT with CUSTOM NAMES only after creating tables by the use of ALTER TABLE.


My question Is Can we create CONSTRAINTS with CUSTOM NAMES while CREATING the TABLE itself.



regards


Nagarjuna