資料庫對比軟體 SQL Delta 4
阿新 • • 發佈:2019-01-04
使用SQL Delta比較兩個資料庫結構,並生成SQL指令碼。
點選選單列表————》New,建立比較專案。
本例中:db_Mail 資料庫為最新。db_Mail2資料庫版本為 舊版本。
填寫完成後,點選Compare Databases進行比較。
介面如下:
已知db_Mail 資料庫中有兩張表,MailInfo,UserInfo 。而db_Mail2資料庫中無表。
然後點選————》Sync則進入如下介面。
對比後,點選 Save 則建立預設的表的SQL語句。Run則將db_Mail2的資料結構統一為db_Mail。
BEGIN TRANSACTION GO SET TRANSACTION ISOLATION LEVEL SERIALIZABLE GO PRINT 'Creating dbo.MailInfo Table' GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON GO SET NUMERIC_ROUNDABORT OFF GO CREATE TABLE [dbo].[MailInfo] ( [id] [int] IDENTITY (1, 1) NOT NULL, [uname] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL, [usex] [int] NULL, [qq] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL, [email] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL, [address] [nvarchar] (500) COLLATE Chinese_PRC_CI_AS NULL, [UserID] [int] NULL CONSTRAINT [UserID] DEFAULT (0.00) ) GO IF @@ERROR <> 0 IF @@TRANCOUNT = 1 ROLLBACK TRANSACTION GO IF @@TRANCOUNT = 1 ALTER TABLE [dbo].[MailInfo] ADD CONSTRAINT [PK_MailInfo] PRIMARY KEY CLUSTERED ([id]) GO IF @@ERROR <> 0 IF @@TRANCOUNT = 1 ROLLBACK TRANSACTION GO IF @@TRANCOUNT = 1 BEGIN PRINT 'dbo.MailInfo Table Added Successfully' COMMIT TRANSACTION END ELSE BEGIN PRINT 'Failed To Add dbo.MailInfo Table' END GO
BEGIN TRANSACTION GO SET TRANSACTION ISOLATION LEVEL SERIALIZABLE GO PRINT 'Creating dbo.UserInfo Table' GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON GO SET NUMERIC_ROUNDABORT OFF GO CREATE TABLE [dbo].[UserInfo] ( [rid] [int] IDENTITY (1, 1) NOT NULL, [uname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL, [usex] [int] NULL, [email] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ) GO IF @@ERROR <> 0 IF @@TRANCOUNT = 1 ROLLBACK TRANSACTION GO IF @@TRANCOUNT = 1 BEGIN PRINT 'dbo.UserInfo Table Added Successfully' COMMIT TRANSACTION END ELSE BEGIN PRINT 'Failed To Add dbo.UserInfo Table' END GO