Is it possible to rename a table in the middle of a clustered index rebuild?
This really feels like a bad idea, but we have very large table which is currently rebuilding an index, I don't want to stop the rebuild, but we need to change the table name from dbo.My_Table_New to dbo.My_Table. T开发者_StackOverflow社区houghts?
No.
What are you expecting?? Wait for it to finish, then go for it.
To check, you can start a new session and run
sp_lock 52
(if 52 is the process doing the index rebuild). You will see among the locks
spid objid type mode resource
52 27147142 TAB X
52 0 MD Sch-S 1(19e3b86:0:0)
Where
- object_name(27147142) gives you the table being restructured,
- X is the exclusive lock
- Sch-S is a schema stability lock, preventing any changes to schema (on the page related to the table)
Just an idea... Create a view, use the view, then when you can rename, delete the view.
精彩评论