SQL Server?????Check???????????
???????????? ???????[ 2015/3/6 13:46:04 ] ????????????? SQL Server
??????SQL Server?У?SQL????????????????????????????м????????м???????????????????
???????????????????м???????У?????ο???????????????????Ч????м???????????????????м??????????Ч????ν????ο????????????????????????????????????????????Щ???????????????????а????????????Check?????
????????????????????м???????????ν?????????????????????????????????
????
?????1.?????
?????????????????1=2???????????????????????????????κ????????????б??????????1??м???????????????賣?????????1=2????false???????????
???????Check?????
????Check????????????л???е???????????????????Щ???Check???????????????????????????????????翴??????????
????
?????2.??Check??????????????????
?????2????????????????????????????????Check?????????????????????????£?
CREATE TABLE [dbo].[Test2007](
[ProductReviewID] [int] IDENTITY(1??1) NOT NULL??
[ReviewDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Test2007] WITH CHECK ADD CONSTRAINT [CK_Test2007] CHECK (([ReviewDate]>='2007-01-01' AND [ReviewDate]<='2007-12-31'))
GO
ALTER TABLE [dbo].[Test2007] CHECK CONSTRAINT [CK_Test2007]
GO
CREATE TABLE [dbo].[Test2008](
[ProductReviewID] [int] IDENTITY(1??1) NOT NULL??
[ReviewDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Test2008] WITH CHECK ADD CONSTRAINT [CK_Test2008] CHECK (([ReviewDate]>='2008-01-01' AND [ProductReviewID]<='2008-12-31'))
GO
ALTER TABLE [dbo].[Test2008] CHECK CONSTRAINT [CK_Test2008]
GO
INSERT INTO [Test2008] values('2008-05-06')
INSERT INTO [Test2007] VALUES('2007-05-06')
CREATE VIEW testPartitionView
AS
SELECT * FROM Test2007
UNION
SELECT * FROM Test2008
SELECT * FROM testPartitionView
WHERE [ReviewDate]='2007-01-01'
SELECT * FROM testPartitionView
WHERE [ReviewDate]='2008-01-01'
SELECT * FROM testPartitionView
WHERE [ReviewDate]='2010-01-01'
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11