Deleting a record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • littlemaster
    New Member
    • Apr 2010
    • 25

    Deleting a record

    I have a table 'a' and 'b'.
    If I try to delete the record from 'a', not able to do it. Because, 'b' table is referencing the 'a' table.

    create table a(id serial primary key,name varchar(10));

    create table b(id serial,pid integer references a,comment varchar(100));

    What is the way to delete a particular record from 'a' table?
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Originally posted by littlemaster
    I have a table 'a' and 'b'.
    If I try to delete the record from 'a', not able to do it. Because, 'b' table is referencing the 'a' table.

    create table a(id serial primary key,name varchar(10));

    create table b(id serial,pid integer references a,comment varchar(100));

    What is the way to delete a particular record from 'a' table?
    First delete related records from b, or drop foreign key in b table.

    Comment

    • littlemaster
      New Member
      • Apr 2010
      • 25

      #3
      No records in B table, but I cannot delete records from A table, But Deleting foreign key in B table is working fine. Thanks for ur reply....

      Comment

      Working...