我们想要使用如下例所示的 SQL 语句来压缩表。而且,为了防止压缩后发生任何问题,我们需要回滚到最后一个好的点。我们该怎么做呢?
我们的问题:
对于下面的压缩SQL语句,我们如何撤消压缩呢?
请参阅下面的“附加信息”。
我暂时认为 GUI Management Studio 会生成错误的 SQL 来撤消索引上的压缩。我是否看到与其他人相同的症状?
细节:
行级压缩的示例 SQL 语句:
-- To row-level compress the table
USE [database-under-test]
ALTER TABLE [schema].[sales_order] REBUILD PARTITION = ALL
WITH
(DATA_COMPRESSION = ROW
)
-- To row-level compress one index, and
-- the other indices of the table are similar
USE [database-under-test]
ALTER INDEX [SALES_ORDER_CREATED_AT] ON [schema].[sales_order] REBUILD PARTITION = ALL WITH (
PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF,
ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON,
DATA_COMPRESSION = ROW
)
-- Compression statements are similar for the other indices of the table
-- ...
附加信息:
我暂时认为 GUI Management Studio 会生成错误的 SQL 来撤消索引上的压缩。
例如,通过“存储管理”向导,我们将压缩设置为“无”,它会得到:
ALTER INDEX [SALES_ORDER_UPDATED_AT] ON [schema].[sales_order] REBUILD PARTITION = ALL WITH (
PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
SORT_IN_TEMPDB = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON
)
DATA_COMPRESSION = NONE
注意到语句中没有,执行命令后索引仍然显示行级压缩。
我是否看到与其他人相同的症状?
使用DATA_COMPRESSION = NONE重建表或索引
https://learn.microsoft.com/en-us/sql/relational-databases/data-compression/disable-compression-on-a-table-or-index?view=sql-server-ver16#TsqlProcedure