By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,384 Members | 801 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,384 IT Pros & Developers. It's quick & easy.

Addition of constraint during creation of table

P: n/a
Hi All,

I have few tables (abc, def) with with a specific structure and I need
to add constratint to the table I do it with

alter table abc
add constraint abc_columnname_fk
foreign key (columnname) references dec(columnname);

But my question is how to create a table with this constraint embedded
in the create table statement itself ? same, as in

CREATE TABLE abc
(columna PRIMARY KEY,
Column2 CHAR(50) ???????????? );

Can I embed the constraint during creation of the table only ?

Can somebody please throw light or solution

I am stuck with this problem.

Thanks in advance,,

PK
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
reference the CREATE TABLE statement in the SQL manual for the 2 possible
syntaxes -- one of which is very similar to the alter table add constraint
syntax

also look into options such as DISABLED

also be ready for some strong opinions on whether you should include the
constraints in the CREATE TABLE

-- Mark Stock

"ponnurangam k" <po*****@yahoo.com> wrote in message
news:d4*************************@posting.google.co m...
| Hi All,
|
| I have few tables (abc, def) with with a specific structure and I need
| to add constratint to the table I do it with
|
| alter table abc
| add constraint abc_columnname_fk
| foreign key (columnname) references dec(columnname);
|
| But my question is how to create a table with this constraint embedded
| in the create table statement itself ? same, as in
|
| CREATE TABLE abc
| (columna PRIMARY KEY,
| Column2 CHAR(50) ???????????? );
|
| Can I embed the constraint during creation of the table only ?
|
| Can somebody please throw light or solution
|
| I am stuck with this problem.
|
| Thanks in advance,,
|
| PK
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.