我们在导出功能(来自门户)的 Azure SQL 中遇到了一个奇怪的问题。如果我们将那里的数据库导出到存储在 blob 容器中的 Bacpac 文件中,则并非所有索引都被导出。我们使用 SqlPackage.exe 将它们导入本地 SQL Server 实例。
下面举两个例子。这个被导出和导入:
CREATE NONCLUSTERED INDEX [nci_wi_st_person_AC4A694B12B4F4657C4CFA5FE6A67EA4] ON [dbo].[st_person]
(
[deleted] ASC,
[customer_status_id] ASC
)
INCLUDE([company_id],[created_date],[email],[first_name],[is_female],[job_title],[last_name],[pic_version],[work_phone]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
而这个不是:
CREATE NONCLUSTERED INDEX [nci_wi_st_element_audit_log_41BBD3962CA4D455E09F7E3BCA557BD5] ON [dbo].[st_element_audit_log]
(
[element_type_id] ASC,
[element_id] ASC
)
INCLUDE([entry_type_id],[field_name],[field_type],[new_state_str],[previous_state_str],[recorded],[user_id]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
如果我们导出数据库
SqlPackage.exe /a:Export /ssn:$SourceServerName /sdn:$DatabaseName /tf:$TargetFilePath /su:$SourceServerUserName /sp:$SourceServerPassword
有用。只是通过 Azure 门户,一些(不是全部)索引丢失了。在门户上,我们使用导出功能,如下所示: