【问题标题】:SQL Compare deployment scripts do not include all ALTER SCHEMA commandsSQL 比较部署脚本不包括所有 ALTER SCHEMA 命令
【发布时间】:2013-11-07 10:07:05
【问题描述】:

我有一个要在 SQL Server 2008(不是 R2)上清理的数据库。目前,所有表都驻留在 dbo 模式中。有些表名是单数,有些是复数。

我创建了一个新架构 crm。我将所有表从 dbo 移动到 crm,并重命名了单数表名以匹配复数表名。当我在开发数据库和生产数据库之间执行 SQL 比较(版本 10.4.8.87)时,脚本包括以下内容:

PRINT N'Creating schemata' 
GO 
CREATE SCHEMA [crm] 
AUTHORIZATION [dbo] 
GO 

... 

(removes foreign key constraints, notice it removes them from the plural tables in dbo schema) 

PRINT N'Dropping foreign keys from [dbo].[CustomersCommittees]' 
GO 
ALTER TABLE [dbo].[CustomersCommittees] DROP CONSTRAINT [FK_CustCom_ComID] 
ALTER TABLE [dbo].[CustomersCommittees] DROP CONSTRAINT [FK_CustCom_CustID] 
GO 

... 

EXEC sp_rename N'[dbo].[Customer]',N'Customers',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Customers] 
EXEC sp_rename N'[dbo].[CustomerAddress]',N'Addresses',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Addresses] 
EXEC sp_rename N'[dbo].[Committee]',N'Committees',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Committees] 

... 

(adds foreign key contraints back, notice how it adds them to the plural tables in the new crm schema, but never included a statement to ALTER SCHEMA) 

PRINT N'Adding foreign keys to [crm].[CustomersCommittees]' 
GO 
ALTER TABLE [crm].[CustomersCommittees] ADD CONSTRAINT [FK_CustCom_ComID] FOREIGN KEY             ([CommitteeID]) REFERENCES [reference].[Committees] ([CommitteeID]) 
ALTER TABLE [crm].[CustomersCommittees] ADD CONSTRAINT [FK_CustCom_CustID] FOREIGN KEY ([CustomerID]) REFERENCES [crm].[Customers] ([CustomerID]) 
GO 

... 

如上所述,对于已经是复数且不需要执行 sp_rename 命令的表,它不包括任何 ALTER SCHEMA ... TRANSFER ... 命令。

还有其他人看过吗?

【问题讨论】:

    标签: sql-server redgate sqlcompare


    【解决方案1】:

    如果我知道 SQL Compare 如何处理这些其他表,也许我可以更准确地回答...换句话说,是否需要进行进一步的修改,是否需要重建表,还是完全忽略它们?

    对于正在以你喜欢的方式传输的表,是不是因为你使用了模式映射来强制 SQL Compare 将 dbo 映射到 crm?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-04
      • 1970-01-01
      相关资源
      最近更新 更多