请在Exam数据库中创建借阅表,结构如下:
要求在bno和rno上建立外键关系。
USE [Exam] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[borrow]( [borrowno] [int] NOT NULL, [bno] [char](4) NULL, [rno] [char](4) NULL, [borrowdate] [datetime] NULL, CONSTRAINT [PK_borrow] PRIMARY KEY CLUSTERED ( [borrowno] 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 SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[borrow] WITH CHECK ADD CONSTRAINT [FK_borrow_book] FOREIGN KEY([bno]) REFERENCES [dbo].[book] ([bno]) GO ALTER TABLE [dbo].[borrow] CHECK CONSTRAINT [FK_borrow_book] GO ALTER TABLE [dbo].[borrow] WITH CHECK ADD CONSTRAINT [FK_borrow_reader] FOREIGN KEY([rno]) REFERENCES [dbo].[reader] ([rno]) GO ALTER TABLE [dbo].[borrow] CHECK CONSTRAINT [FK_borrow_reader]
原文地址:https://www.cnblogs.com/masterchd/p/9330676.html
时间: 2024-10-10 02:30:04