//-----------------------------------------------------------------------------
set ansi_nulls ON
go
set quoted_identiifier on //{第一部分内容,我在创建表的时候是否考虑这部分内容呢?}
go
set ansi_padding on
go
//-------------------------------------------------------------------------
create table[dbo].[tblPersonHR](//创建一个表
[FID] [int] NOT NULL, //字段
[FName] [varchar](40) NULL,//字段
constraint [pk_tblpersonHR] primary key nonclustered //{第二部分内容,这部分是创建表}
(
[fid] asc)with(pad_index=off,statistics_norecompute=off,
ignore_dup_key=off,allow_row_locks=on,
allow_page_locks=on,fillfactor=90)on [primary])
on [primary] textimage_on [primary]
)
go
//----------------------------------------------------------------------------
set ansi_padding off
go
alter table [dbo].[tblPersonHR] with nocheck add constraint [FK_tblPersonHR_tblDepart] foreign key([FDepartID])
references [dbo].[tblDepart] ([FId])
not for replication
go //{第三部分内容,这部分是与外表建立关联}//-----------------------------------------------------------------------------
alter table [dbo].[tblPersonHR] check constraint [FK_tblPersonHR_tblDepart]
go //{第四部分内容,这部分什么意思呢?}
//-------------------------------------------------------------------------------------------
set ansi_nulls ON
go
set quoted_identiifier on //{第一部分内容,我在创建表的时候是否考虑这部分内容呢?}
go
set ansi_padding on
go
//-------------------------------------------------------------------------
create table[dbo].[tblPersonHR](//创建一个表
[FID] [int] NOT NULL, //字段
[FName] [varchar](40) NULL,//字段
constraint [pk_tblpersonHR] primary key nonclustered //{第二部分内容,这部分是创建表}
(
[fid] asc)with(pad_index=off,statistics_norecompute=off,
ignore_dup_key=off,allow_row_locks=on,
allow_page_locks=on,fillfactor=90)on [primary])
on [primary] textimage_on [primary]
)
go
//----------------------------------------------------------------------------
set ansi_padding off
go
alter table [dbo].[tblPersonHR] with nocheck add constraint [FK_tblPersonHR_tblDepart] foreign key([FDepartID])
references [dbo].[tblDepart] ([FId])
not for replication
go //{第三部分内容,这部分是与外表建立关联}//-----------------------------------------------------------------------------
alter table [dbo].[tblPersonHR] check constraint [FK_tblPersonHR_tblDepart]
go //{第四部分内容,这部分什么意思呢?}
//-------------------------------------------------------------------------------------------
references [dbo].[tblDepart] ([FId])
not for replication
go //{第三部分内容,这部分是与外表建立关联} //-----------------------------------------------------------------------------
alter table [dbo].[tblPersonHR] check constraint [FK_tblPersonHR_tblDepart]
go //{第四部分内容,这部分什么意思呢?}
//------------------------------------------------------------------------------------------- 如果是重新启用约束那么:
第三部分已经建立了FK_tblPersonHR_tblDepart,为什么第四部分还要重新启用约束?
重新启用约束什么意思?
第四部分与第三部分什么关系?
go //{第四部分内容,这部分什么意思呢?}
执行数据操作时,会检查Check约束条件表达式结果是否为TRUE,不为TRUE则拒绝执行