Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

GIVING CUSTOM NAME TO KEY CONSTRAINTS using SQL CREATE Statement.

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

Tags:
Not what you were looking for? View more on this topic or Ask a question