Addition of constraint during creation of table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ponnurangam k

    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
  • mcstock

    #2
    Re: Addition of constraint during creation of table

    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

    "ponnuranga m k" <ponguru@yahoo. comwrote in message
    news:d4c2c513.0 311271151.bcfb9 31@posting.goog le.com...
    | 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


    Comment

    Working...