Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Truncate table


Truncate table

Author
Message
mehta.saurabhj
mehta.saurabhj
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 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
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18490 Visits: 17192
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 Moden's 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
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 906
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-Enthusiastic
SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)

Group: General Forum Members
Points: 118 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
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 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
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18490 Visits: 17192
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 Moden's 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
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 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 (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)

Group: General Forum Members
Points: 55345 Visits: 44699
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
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 33
Thank you my doubt is now clear!!!
kevaburg
kevaburg
Right there with Babe
Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)

Group: General Forum Members
Points: 796 Visits: 944
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