Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 truncate table

Author  Topic 

ghostrider
Starting Member

11 Posts

Posted - 2013-03-21 : 11:21:54
When we truncate the table does the indexes made on them exists in memory??Can we check whether they exist or no???

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-03-21 : 11:53:57
The indexes are rebuilt too. On disk also.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

ghostrider
Starting Member

11 Posts

Posted - 2013-03-21 : 13:34:06
quote:
Originally posted by SwePeso

The indexes are rebuilt too. On disk also.



N 56°04'39.26"
E 12°55'05.63"





Thank you sir for your reply but actually I didnt understand what you are trying to convey..Can you elaborate it please??
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-03-21 : 19:07:56
The indexes exist, just like the table still exists, but the indexes don't refer to any data since there is no data to refer to. Add data to the table and the indexes will act like they are supposed to.

=================================================
There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber
Go to Top of Page

ghostrider
Starting Member

11 Posts

Posted - 2013-03-22 : 11:25:59
quote:
Originally posted by Bustaz Kool

The indexes exist, just like the table still exists, but the indexes don't refer to any data since there is no data to refer to. Add data to the table and the indexes will act like they are supposed to.

=================================================
There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber

So they dont refer to addresess that contained the data before being truncated...or do they point to the addresses??
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-22 : 12:22:58
If your concern is whether there will be orphaned data/rows in the indexes, you do not need to worry about that. When you insert, delete, or update a row from a table (or when you truncate the table) SQL Server updates the indexes automatically as part of the operation in a single transaction. So the table and the indexes will always be in sync.
Go to Top of Page
   

- Advertisement -