1. 程式人生 > >實驗11-03 創建借閱表

實驗11-03 創建借閱表

eap kdt afn span amd reference vsm hab lsb

請在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]

  

實驗11-03 創建借閱表