0

我有一个试图在 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 

... 

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

有没有其他人看过这个?

4

1 回答 1

0

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

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

于 2013-10-29T09:57:06.743 回答