【问题标题】:Error when trying to publish database to Azure without clustered indexes尝试在没有聚集索引的情况下将数据库发布到 Azure 时出错
【发布时间】:2013-10-13 16:20:43
【问题描述】:

尝试将数据库发布到 Azure 站点时出现以下错误:

17:13:29: Could not publish the site. Unable to publish the database. For more information, see "http://go.microsoft.com/fwlink/?LinkId=205387"
17:13:29: Error detail:
17:13:29: An error occurred during execution of the database script. The error occurred between the following lines of the script: "332" and "334". The verbose log might have more information about the error. The command started with the following:
17:13:29: "INSERT [dbo].[DBStatus] ([LastIndex], [LastUpdated"
17:13:29:  Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again. http://go.microsoft.com/fwlink/?LinkId=178587
17:13:29:   Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.

此链接解释错误:http://blogs.msdn.com/b/sqlazure/archive/2010/04/29/10004618.aspx

是否有一种简单的方法可以将我的数据库转换为具有聚集索引,或者我应该只选择一个使用 SQL Server 2012 托管的主机?

【问题讨论】:

    标签: sql sql-server azure webmatrix


    【解决方案1】:

    我不会仅仅因为这个而更改您的托管选项。添加聚集索引。

    有一个叫SQL Database Migration Wizard的工具,可以分析SQL数据库,制作迁移脚本,甚至移动数据。它会做的一件事是建议在没有它们的表上使用聚集索引。但是,与任何工具一样,请务必查看它的建议,看看它在您的场景中是否有意义。

    我的建议是查看没有聚集索引的表并确定要创建的合理索引。像上面这样的工具可以提出建议,但它们只是建议,可能并不完全是您的表将从中受益的。

    Azure SQL 数据库对聚集索引的要求来自于它们一式三份地复制数据,而聚集索引使这一过程变得更快。

    【讨论】:

    【解决方案2】:

    我已经完成了这些步骤:

    1- 通过运行此查询获取没有主键的表列表:

    USE DatabaseName;
    GO
    
    SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName
    FROM sys.tables
    WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0
    ORDER BY SchemaName, TableName;
    GO`
    

    2- 为所有表创建警报表脚本,为它们添加一个身份字段并通过如下脚本将其设为主要:

     ALTER TABLE [dbo].[tableName]  ADD identityFieldName BIGINT IDENTITY;  
     ALTER TABLE [dbo].[tableName]  ADD CONSTRAINT  PK_Table_identityFieldName_1    PRIMARY KEY CLUSTERED (identityFieldName);      
    

    对所有没有主键的表重复上述查询

    【讨论】:

      猜你喜欢
      • 2014-05-15
      • 2019-04-18
      • 2011-06-19
      • 2014-01-17
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2015-07-04
      • 2018-08-02
      相关资源
      最近更新 更多