绵竹信息网
娱乐
当前位置:首页 > 娱乐

SQL Server数据应用在不同的数据库中(2)

发布时间:2019-09-13 20:33:21 编辑:笔名

假设有一些行存在于Order_1中而不存在于Order_2中。你将上面的查询翻转,它也能工作,然而,随后你会得到两个查询和两个结果集,并结束你的查询,这些你都必须手动比较。如果每个表只有四行,这是不困难的,但是想象一下如果有4,000行记录的话,怎么使用这种不切实际的方法进行比较呢。你必须对两个表的每行没出现在另外那张表的记录进行检查。 CREATE DATABASE [Test_Cross_1] ON PRIMARY ( NAME = N'Test_Cross_1', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATATest_Cross_1.mdf', SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'Test_Cross_1_log', FILENAME = N'C:aProgram FilesMicrosoft SQL ServerMSSQL.1MSSQLDATATest_Cross_1_log.ldf', SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)GOUSE [Test_Cross_1]GOCREATE TABLE [dbo].[Orders_1]( [OrderNumber] [int] NOT NULL, [OrderDate] [datetime] NOT NULL, CONSTRAINT [PK_Orders_1] PRIMARY KEY CLUSTERED ( [OrderNumber] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]CREATE DATABASE [Test_Cross_2] ON PRIMARY ( NAME = N'Test_Cross_2', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATATest_Cross_2.mdf', SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'Test_Cross_2_log', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATATest_Cross_2_log.ldf', SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)GOCREATE TABLE [dbo].[Orders_2]( [OrderNo] [int] NOT NULL, [OrderDate] [datetime] NOT NULL CONSTRAINT [DF_Orders_2_OrderDate] DEFAULT (getdate()), CONSTRAINT [PK_Orders_2] PRIMARY KEY CLUSTERED ( [OrderNo] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

清单ASELECT * FROM Test_Cross_1.dbo.Orders_1INNER JOIN Test_Cross_2.dbo.Orders_2ON Test_Cross_1.dbo.Orders_1.OrderNumber

清单BSELECT * FROM Test_Cross_1.dbo.Orders_1LEFT OUTER JOIN Test_Cross_2.dbo.Orders_2ON Test_Cross_1.dbo.Orders_1.OrderNumber

清单CSELECT * FROM Test_Cross_2.dbo.Orders_2LEFT OUTER JOIN Test_Cross_1.dbo.Orders_1ON Test_Cross_2.dbo.Orders_2.OrderNo

清单D

宝宝消化不良又吐又拉
冠心病哪里治疗好
威门热淋清颗粒有用吗
小孩风寒感冒