DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Truncating Tables & Indices

  1. #1
    Join Date
    Apr 2000
    Location
    Boston, MA 01803
    Posts
    24

    Question

    Hi,

    If I have a table "Foo" with an index on "id", does the index become invalid if I truncate the table? If so, why is that? If not, is the index still valid?

    Thanks in advance,
    (much appreciated)
    Tracy

  2. #2
    Join Date
    Feb 2000
    Location
    Washington DC
    Posts
    1,843
    Index is VALID, if you truncate the table, But constraints have to be disabled on the table in order to use TRUNCATE on 'foo'.
    You must disable the constraint before truncating the table.


  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    [QUOTE][i]Originally posted by sreddy [/i]
    [B]Index is VALID, if you truncate the table, But constraints have to be disabled on the table in order to use TRUNCATE on 'foo'.
    You must disable the constraint before truncating the table.
    [/B][/QUOTE]

    No, not constraintson table 'foo', only foreign keys from other tables referencing the table to be truncated! You can leave any constraint that is defined on the truncating table intact.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  4. #4
    Join Date
    Feb 2000
    Location
    Washington DC
    Posts
    1,843

    Jmodic,

    What if table 'foo' is a parent table of enabled referential integrity constraint ? To truncate table 'foo' one must disable referential integrity constraint. Am I right ?

  5. #5
    Join Date
    Dec 2000
    Posts
    43

    Wink

    Thats what jmodic said ;-)

  6. #6
    Join Date
    Feb 2000
    Location
    Washington DC
    Posts
    1,843
    Now I got it. We meant the same. Its just english we are discussing about. I meant the same. Constraints on table 'foo' meant referencing tables. I would have taken little care in phrasing my sentence saying referencing tables. I will watch out next time when write something on Referential Integrity.

    sorry for confusion.thx for pointing out...

Posting Permissions

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


Click Here to Expand Forum to Full Width