Results 1 to 2 of 2

Thread: foreign key

  1. #1
    Join Date
    Feb 2004
    Posts
    19

    Unanswered: foreign key

    hi
    i would like to know the foreign key syntax iin sql.


    thanks
    kiran

  2. #2
    Join Date
    Feb 2004
    Location
    Hong Kong
    Posts
    15

    Re: foreign key

    Originally posted by tlael
    Create Constraint constraint_name Foreign Key (fk_column_list) Refrences pk_table

    optionally On Delete Cascade| Set Null
    There are 3 ways foreign key can be created in Oracle as follows:
    Whilst creating table at column level:

    create table <tablename> (
    column <column type, width> constraint <constraint name> references <Parent Table (column name)>)

    Whilst creating table at table level:

    create table <tablename> (
    column1 <column type, width>,
    Column2 <column type, widht>,
    constraint <constraint name> foreign key (column1) references <Parent
    Table (column name)>)

    Whilst altering table:
    alter table < table name>
    add constraint <constraint name> foreign key (column1) references <Parent
    Table (column name)>)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •