USE [test]
GO
/****** Object: Table [dbo].[T_Student] Script Date: 10/12/2010 19:28:09 ******/
/****** Sqlserver 2008 *********/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_Student](
[ID] [int] IDENTITY(1,1) NOT NULL,
[TeacherID] [int] NULL,
[Name] [nvarchar](50) NULL,
[Pwd] [nvarchar](50) NULL,
CONSTRAINT [PK_T_STUDENT] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_Student', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'教师ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_Student', @level2type=N'COLUMN',@level2name=N'TeacherID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_Student', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_Student', @level2type=N'COLUMN',@level2name=N'Pwd'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'T_Student' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_Student'
GO
/******** sqlserver 2005语法
execute sp_addextendedproperty 'MS_Description',
'姓名',
'user', 'dbo', 'table', 'T_Student', 'column', 'Name'
go
************/
--手动增加外键约束代码
ALTER TABLE [dbo].[T_Student] WITH CHECK ADD CONSTRAINT [FK_T_STUDEN_REFERENCE_T_TEACHE] FOREIGN KEY([TeacherID])
REFERENCES [dbo].[T_Teacher] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[T_Student] CHECK CONSTRAINT [FK_T_STUDEN_REFERENCE_T_TEACHE]
GO