如何以編程方式爲數據庫中的現有索引生成T-SQL CREATE語句? SQL Studio提供了一個「腳本指數原樣>創建爲」,在表格生成代碼的命令:爲現有索引生成T-SQL
IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = N'IX_myindex')
CREATE NONCLUSTERED INDEX [IX_myindex] ON [dbo].[mytable]
(
[my_id] ASC
)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
GO
你將如何做到這一點編程(最好是通過Python)的?