SqlServer 表產生Creation sql, Foreign Key Definition, Sql

來源:互聯網
上載者:User
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
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.