473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Addition of constraint during creation of table

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
1 2230
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: estevan | last post by:
1)I'm tring to create a new table but the creation fails because I insert as a wrong sintax the keyword 'constraint'. For example... TABLE xxxx field 1 cod field 2 name field 3 is_died...
2
by: adammitchell | last post by:
How can you indicate that a FOREIGN KEY constraint references two columns in two different tables? "SQL Server Books Online" show an example of how to reference two columns in the SAME table:...
4
by: Xela | last post by:
Hi I am facing the following problem. I load a fact table with around 25 millons lines, and 7 indexes. I load it with 3 million line subsets. I am on a quadriprocessor Solaris machine. The...
2
by: kaming | last post by:
Dear all, Is it possible to define a check constraint on a field that the field value must exist in another table non-unique field? how to write the create table DDL? i.e TABLE A TYPE,...
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
10
by: Laurence | last post by:
Hi there, How to differentiate between unique constraint and unique index? These are very similar but I cannot differentiate them? Could someone give me a hand? Thanks in advance
0
by: nimjerry | last post by:
i am using db2 udb V 9 on aix 5.3 and in db2diag.log alwas has this error occurr below is sample message 2008-03-03-09.45.34.366406+420 I306667A443 LEVEL: Warning PID : 835622 ...
1
by: ponnurangam k | last post by:
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...
2
by: rorajoey | last post by:
Violation of UNIQUE KEY constraint 'IX_surveyQuestions'. Cannot insert duplicate key in object 'dbo.surveyQuestions'. This might seem like a simple matter of trying to insert a row with ID=20 when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.