SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Truncate table


Truncate table

Author
Message
mehta.saurabhj
mehta.saurabhj
SSC Veteran
SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)

Group: General Forum Members
Points: 264 Visits: 33
When we truncate the table does the indexes made on them exists in memory??Can we check whether they exist or no???
Sean Lange
Sean Lange
SSC Guru
SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)

Group: General Forum Members
Points: 147533 Visits: 18565
mehta.saurabhj (3/21/2013)
When we truncate the table does the indexes made on them exists in memory??Can we check whether they exist or no???


Not really sure what you mean about indexes being in memory? Truncate will simply deallocate pages from the table. Any indexes are not removed from the table.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
tim_harkin
tim_harkin
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1211 Visits: 941
If you are talking about the index definitions, then yes they are still there. Index data is gone - their pages are deallocated as well.
prathibha_aviator
prathibha_aviator
SSC-Addicted
SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)SSC-Addicted (418 reputation)

Group: General Forum Members
Points: 418 Visits: 271
TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain..

--Pra:-):-)--------------------------------------------------------------------------------
mehta.saurabhj
mehta.saurabhj
SSC Veteran
SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)

Group: General Forum Members
Points: 264 Visits: 33
tim_harkin (3/21/2013)
If you are talking about the index definitions, then yes they are still there. Index data is gone - their pages are deallocated as well.


I mean to say that suppose it i create a non clustered index on column 'name' and then when i truncate the table then will this index remain in memory..or not??? That is will the key and value pair as in case of hash tree will remain or not??
Sean Lange
Sean Lange
SSC Guru
SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)

Group: General Forum Members
Points: 147533 Visits: 18565
mehta.saurabhj (3/21/2013)
tim_harkin (3/21/2013)
If you are talking about the index definitions, then yes they are still there. Index data is gone - their pages are deallocated as well.


I mean to say that suppose it i create a non clustered index on column 'name' and then when i truncate the table then will this index remain in memory..or not??? That is will the key and value pair as in case of hash tree will remain or not??


Yes the index will remain on the table. I still don't understand what you mean about in memory.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
mehta.saurabhj
mehta.saurabhj
SSC Veteran
SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)

Group: General Forum Members
Points: 264 Visits: 33
@sean lange As per my knowledge when you create a non clustered index on a table column they occupy some space in memory as a hash tree or binary tree..So according to this concept when you truncate a table all its data gets removed from table..So i have the doubt that does the table index that i created earlier remains in memory in the form of hash tree or not?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)SSC Guru (546K reputation)

Group: General Forum Members
Points: 546232 Visits: 47729
mehta.saurabhj (3/21/2013)
@sean lange As per my knowledge when you create a non clustered index on a table column they occupy some space in memory as a hash tree or binary tree.


Balanced tree, not hash or binary. Not necessarily in memory any more than the table itself is. The index just consists of index pages in a b-tree structure, the same rules apply to the index pages as to the data pages of the table.

So according to this concept when you truncate a table all its data gets removed from table..So i have the doubt that does the table index that i created earlier remains in memory in the form of hash tree or not?


When you truncate a table, all data and index pages are deallocated (on disk and if applicable in memory)

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


mehta.saurabhj
mehta.saurabhj
SSC Veteran
SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)

Group: General Forum Members
Points: 264 Visits: 33
Thank you my doubt is now clear!!!
kevaburg
kevaburg
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10583 Visits: 1211
Sean Lange (3/21/2013)
mehta.saurabhj (3/21/2013)
tim_harkin (3/21/2013)
If you are talking about the index definitions, then yes they are still there. Index data is gone - their pages are deallocated as well.


I mean to say that suppose it i create a non clustered index on column 'name' and then when i truncate the table then will this index remain in memory..or not??? That is will the key and value pair as in case of hash tree will remain or not??


Yes the index will remain on the table. I still don't understand what you mean about in memory.


Clustered indexes are stored within the referenced table and not in memory. Memory is volatile so if the indexes were stored there they would have to rebuilt every time the server was started anew!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search