Home » SQL & PL/SQL » SQL & PL/SQL » Constraint Naming
Constraint Naming [message #198754] Wed, 18 October 2006 07:44 Go to next message
collis
Messages: 11
Registered: October 2006
Junior Member
How does one force the system to name a constraint? For instance I'm trying to add a foreign key:

ALTER TABLE stomachContents ADD CONSTRAINT c1
    FOREIGN KEY (donutId) REFERENCES donuts(id);


I really want the system to give it a name instead of my 'c1', but I'm not sure how to do it. If I remove c1 I get:

ORA-00902: invalid datatype


The documentation I've found online always seems to assume that you want to name your constraint, but i can't find anything that says how to do it if you don't.
Re: Constraint Naming [message #198755 is a reply to message #198754] Wed, 18 October 2006 07:57 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
The syntax is
ALTER TABLE table ADD [CONSTRAINT constraint] type (column);

[] means the text is optional

By
Vamsi.
Re: Constraint Naming [message #198760 is a reply to message #198755] Wed, 18 October 2006 08:06 Go to previous message
collis
Messages: 11
Registered: October 2006
Junior Member
vamsi kasina wrote on Wed, 18 October 2006 07:57
The syntax is
ALTER TABLE table ADD [CONSTRAINT constraint] type (column);

[] means the text is optional

By
Vamsi.


Great thanks
Previous Topic: SQL*Plus Question
Next Topic: SQL query doubt ..
Goto Forum:
  


Current Time: Sat Dec 10 05:09:20 CST 2016

Total time taken to generate the page: 0.09202 seconds