IF OBJECT_ID (N'StormyWeather', N'U') IS NOT NULL DROP TABLE StormyWeather GO CREATE TABLE StormyWeather ( StormID INT NOT NULL IDENTITY, StormHead NVARCHAR(50) NOT NULL, StormBody NVARCHAR(MAX) NOT NULL, ) GO
INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormy Weather Delays Travel', 'The stormy weather made travel by motor vehicle difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormier Weather on Monday', 'The stormier weather on Monday made vehicle travel difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormiest Weather in December', 'December can be the stormiest month, making automobile travel difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storm Grows Strong', 'The storm is growing strong.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storms Crossing the Pacific', 'The storms are lining up across the Pacific Ocean.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storm''s Wind Delays Travel', 'The storm''s wind made car travel difficult on Tuesday.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storms'' Flooding Delays Travel', 'The storms'' flooding made auto travel difficult throughout December.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Children Run from Room', 'The children often storm out of the room when upset.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Boy Runs from Room', 'The boy storms out of the room when his sister changes the channel.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Girl Ran from Room', 'The girl stormed out of the room when her brother ate the cookie.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Children Running from Room', 'The children were storming out of the room when the lights went out.') GO
create table #1 ( StormID INT NOT NULL IDENTITY, StormHead NVARCHAR(50) NOT NULL, StormBody NVARCHAR(MAX) NOT NULL, ) go INSERT INTO #1 (StormHead, StormBody) VALUES('Boy Runs from Room', 'The boy storms out of the room when his sister changes the channel.') INSERT INTO #1 (StormHead, StormBody) VALUES('Girl Ran from Room', 'The girl stormed out of the room when her brother ate the cookie.') INSERT INTO #1 (StormHead, StormBody) VALUES('Children Running from Room', 'The children were storming out of the room when the lights went out.')
我的问题是如何提高如下链接的join顺序 select * from StormyWeather a join #1 b on a.StormBody = b.StormBody
上面我建的两个表只是个例子,实际我们这个系统比较复杂,要操作的表没有主键,每一个instance都有好多不同版本的图,也就是有好多path,所以需要用path做关联。 这种数据库设计肯定不太理想,不过要改变表结构可能影响太大,所以现在的看有没有补救措施,当然加上类似MD5列做标示也是种可行方法。问题看有没有更好的方法,所以来征求各位大牛的意见。。。。 thanks very much.
通过checksum函数,得出一个值:
IF OBJECT_ID (N'StormyWeather', N'U') IS NOT NULL DROP TABLE StormyWeather GO
CREATE TABLE StormyWeather ( StormID INT NOT NULL IDENTITY, StormHead NVARCHAR(50) NOT NULL, StormBody NVARCHAR(MAX) NOT NULL, ) GO
INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormy Weather Delays Travel', 'The stormy weather made travel by motor vehicle difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormier Weather on Monday', 'The stormier weather on Monday made vehicle travel difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Stormiest Weather in December', 'December can be the stormiest month, making automobile travel difficult.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storm Grows Strong', 'The storm is growing strong.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storms Crossing the Pacific', 'The storms are lining up across the Pacific Ocean.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storm''s Wind Delays Travel', 'The storm''s wind made car travel difficult on Tuesday.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Storms'' Flooding Delays Travel', 'The storms'' flooding made auto travel difficult throughout December.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Children Run from Room', 'The children often storm out of the room when upset.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Boy Runs from Room', 'The boy storms out of the room when his sister changes the channel.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Girl Ran from Room', 'The girl stormed out of the room when her brother ate the cookie.') INSERT INTO StormyWeather (StormHead, StormBody) VALUES('Children Running from Room', 'The children were storming out of the room when the lights went out.') GO
create table #1 ( StormID INT NOT NULL IDENTITY, StormHead NVARCHAR(50) NOT NULL, StormBody NVARCHAR(MAX) NOT NULL, ) go INSERT INTO #1 (StormHead, StormBody) VALUES('Boy Runs from Room', 'The boy storms out of the room when his sister changes the channel.') INSERT INTO #1 (StormHead, StormBody) VALUES('Girl Ran from Room', 'The girl stormed out of the room when her brother ate the cookie.') INSERT INTO #1 (StormHead, StormBody) VALUES('Children Running from Room', 'The children were storming out of the room when the lights went out.') go
--用checksum计算一个值 select CHECKSUM(StormBody) from StormyWeather