0
我有一個數據庫,我正試圖在SQL Server 2008(不是R2)上進行清理。目前,所有表都駐留在dbo模式中。有些表格名稱是單數,其他表格是複數。SQL比較部署腳本不包含所有ALTER SCHEMA命令
我創建了一個新的模式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架構...轉接。 ..已經複數表的命令,不需要執行sp_rename命令。
有沒有其他人看到過這個?