473,396 Members | 1,966 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,396 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 2231
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.