数据库脚本文件创建数据库
程序代码:
高手指点一下: 下面程序错在哪里/? 运行总是出错 USE [db_DrinkeryManage] GO /****** Object: Table [dbo].[tb_menu] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_menu]( [num] [char](8) NOT NULL, [sort_id] [int] NOT NULL, [name] [varchar](20) NOT NULL, [code] [varchar](10) NOT NULL, [unit] [varchar](4) NOT NULL, [unit_price] [int] NOT NULL, [state] [char](4) NOT NULL, CONSTRAINT [PK_TB_MENU] PRIMARY KEY CLUSTERED ( [num] 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 /****** Object: Table [dbo].[tb_desk] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_desk]( [num] [varchar](5) NOT NULL, [seating] [int] NOT NULL, CONSTRAINT [PK_TB_DESK] PRIMARY KEY CLUSTERED ( [num] 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 /****** Object: Table [dbo].[tb_user] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_user]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](8) NOT NULL, [sex] [char](2) NOT NULL, [birthday] [datetime] NOT NULL, [id_card] [varchar](20) NOT NULL, [password] [varchar](20) NOT NULL, [freeze] [char](4) NOT NULL, CONSTRAINT [PK_TB_USER] 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 SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[tb_sort] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_sort]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](20) NOT NULL, CONSTRAINT [PK_TB_SORT] 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 SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[tb_order_form] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_order_form]( [num] [char](11) NOT NULL, [desk_num] [varchar](5) NOT NULL, [datetime] [datetime] NULL, [money] [int] NOT NULL, [user_id] [int] NOT NULL, CONSTRAINT [PK_TB_ORDER_FORM] PRIMARY KEY CLUSTERED ( [num] 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 /****** Object: Table [dbo].[tb_order_item] Script Date: 06/03/2012 15:22:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tb_order_item]( [id] [int] IDENTITY(1,1) NOT NULL, [order_form_num] [char](11) NOT NULL, [menu_num] [char](8) NOT NULL, [amount] [int] NOT NULL, [total] [int] NOT NULL, CONSTRAINT [PK_TB_ITEMIZE] 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 SET ANSI_PADDING OFF GO /****** Object: ForeignKey [FK_TB_ORDER_REFERENCE_TB_DESK] Script Date: 06/03/2012 15:22:35 ******/ ALTER TABLE [dbo].[tb_order_form] WITH CHECK ADD CONSTRAINT [FK_TB_ORDER_REFERENCE_TB_DESK] FOREIGN KEY([desk_num]) REFERENCES [dbo].[tb_desk] ([num]) GO ALTER TABLE [dbo].[tb_order_form] CHECK CONSTRAINT [FK_TB_ORDER_REFERENCE_TB_DESK] GO /****** Object: ForeignKey [FK_TB_ORDER_REFERENCE_TB_USER] Script Date: 06/03/2012 15:22:35 ******/ ALTER TABLE [dbo].[tb_order_form] WITH NOCHECK ADD CONSTRAINT [FK_TB_ORDER_REFERENCE_TB_USER] FOREIGN KEY([user_id]) REFERENCES [dbo].[tb_user] ([id]) GO ALTER TABLE [dbo].[tb_order_form] CHECK CONSTRAINT [FK_TB_ORDER_REFERENCE_TB_USER] GO /****** Object: ForeignKey [FK_TB_ITEMI_REFERENCE_TB_MENU] Script Date: 06/03/2012 15:22:35 ******/ ALTER TABLE [dbo].[tb_order_item] WITH NOCHECK ADD CONSTRAINT [FK_TB_ITEMI_REFERENCE_TB_MENU] FOREIGN KEY([menu_num]) REFERENCES [dbo].[tb_menu] ([num]) GO ALTER TABLE [dbo].[tb_order_item] CHECK CONSTRAINT [FK_TB_ITEMI_REFERENCE_TB_MENU] GO /****** Object: ForeignKey [FK_TB_ITEMI_REFERENCE_TB_ORDER] Script Date: 06/03/2012 15:22:35 ******/ ALTER TABLE [dbo].[tb_order_item] WITH NOCHECK ADD CONSTRAINT [FK_TB_ITEMI_REFERENCE_TB_ORDER] FOREIGN KEY([order_form_num]) REFERENCES [dbo].[tb_order_form] ([num]) GO ALTER TABLE [dbo].[tb_order_item] CHECK CONSTRAINT [FK_TB_ITEMI_REFERENCE_TB_ORDER] GO