--创建公司表
create table dbo.Company2
(
CompanyID int identity(1,1) not null,
CompanyName varchar(50) null,
AddDate datetime null,
constraint PK_Company2_CompanyID primary key clustered (CompanyID)
)
--创建会员表
create table dbo.Member
(
MemberID int identity(1,1) not null,
CompanyID int not null,
MemberName varchar(20) null,
AddDate datetime null,
constraint PK_Member_MemberID primary key clustered (MemberId),--创建主键约束
constraint FK_ComMember foreign key (CompanyID) references Company2(CompanyID)--创建外键约束
)
--创建非聚集索引
create nonclustered index MemberIndex on Member(MemberID,MemberName)
--为字段绑定默认值
alter table dbo.Member add constraint DF_Member_AddDate default(getdate()) for AddDate