Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2008
    Posts
    40

    Unanswered: Reg truncating a table

    hi,
    how can i truncate a table which has refernces to few table and it is being refered by many table using foreign keys. One Possible means is by droping the references to the table that i have to truncate. Is there any other means for truncating the desired table

    regards
    prakash

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Why would you want to truncate it? There is a reason the foreign keys are there, to ensure data integrity. If you truncate the table, the data is not consistent anymore.
    I'm not crazy, I'm an aeroplane!

  3. #3
    Join Date
    Sep 2008
    Posts
    40

    re truncate table

    but actually i want to truncate table in testserver and port data from production to testserver

  4. #4
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    but actually i want to truncate table in testserver and port data from production to testserver
    I think you have to decide whether :
    • A) You want a FK on the table ensuring that the data linkages are always correct
    • B) You don't want a FK but you want the ability to delete the data in the table.

    You choose

  5. #5
    Join Date
    Sep 2008
    Posts
    40
    Hi ,
    data has to be moved that is primary and consistency doesn't matters since it is a test data

  6. #6
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Looks like option B) then so I'd just drop the foreign key :

    Code:
    ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol;

  7. #7
    Join Date
    Sep 2008
    Posts
    40
    hi,
    i can just alter the table, if the problem is with foreignkey that is being referenced by the table where i have to port data to.
    but the problem is many table have references to the table to which i have to port the data to.............

  8. #8
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I'm unsure how to set up a loop in this forum but perhaps you could go back to post 4

    Mike

  9. #9
    Join Date
    Dec 2008
    Posts
    4
    is replication involved in this table?

  10. #10
    Join Date
    Sep 2008
    Posts
    40

    Reg: truncate

    No replication is involved

  11. #11
    Join Date
    Sep 2008
    Posts
    40
    hi all,
    i want to truncate a table which has reference constraint .
    i don't want a FK but you want the ability to delete the data in the table.

  12. #12
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Then just delete the foreign key constraint.
    I'm not crazy, I'm an aeroplane!

  13. #13
    Join Date
    Dec 2008
    Posts
    4
    just atter ur table n drop FK constraint thn u can only truncae ur table..

Posting Permissions

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