USE [test]GO/****** Object: Table [dbo].[T_Student] Script Date: 10/12/2010 19:28:09 ******//****** Sqlserver 2008 *********/
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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]GOEXEC 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'GOEXEC 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'GOEXEC 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'GOEXEC 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'GOEXEC 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 CASCADEON DELETE CASCADEGOALTER TABLE [dbo].[T_Student] CHECK CONSTRAINT [FK_T_STUDEN_REFERENCE_T_TEACHE]GO