Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008

    Unanswered: Foreign Key Issue


    I am facing an issue regarding the implementation of foreign key constraints in ASE 15.0.3.

    I have got two tables Table1 and Table 2

    Table1 ( x int , y int) and column x is primary key for the table1
    This table has no data.

    Table2 ( a int , b int) and column a is primary key for the table2

    Table2 has some data like (1,1)

    Now Table2.b has to refer Table1.x (new requirement)

    so i create a FK with statement

    alter table Table2
    add constraint fk1 foreign key (b) references Table1(x)

    I execute the above script and it works fine. FK is created.

    But the problem is that table1 has got no data where as Table2 has a few rows but still FK was created.

    Can any one explain why ASE didn't give any error or warning.
    and how to make ASE give warning for pre-existing rows in child table

  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    Quote from
    Reference Manual: Commands
    alter table

    "Constraints do not apply to the data that already exists in the table at the time the constraint is added."

Posting Permissions

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