我使用 MySQL Workbench 生成一个数据库,现在我使用以下命令将它插入到命令行客户端:
mysql> . C:\Documents and Settings\kdegroote\My Documents\School\2008-2009\ICT2\Gegevensbanken\Labo\Hoofdstuk 3 oef 6\pizzasecondtry.sql
由于某种原因,最后一张桌子不会被接受。“无法创建表”是错误消息。
我手动将数据编辑为基本相同,只是没有 Workbench 添加的特殊选项,它就像那样工作。
我一直在研究原版,但我不明白为什么它不会显示表格。所以我想知道这里是否有人可以看看它。也许其他人会看到我忽略的内容。
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `PizzaDelivery` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `PizzaDelivery`;
CREATE TABLE IF NOT EXISTS `PizzaDelivery`.`Visitors` (
`visitor_id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NOT NULL ,
`adres` VARCHAR(45) NOT NULL ,
`telephone` MEDIUMBLOB NOT NULL ,
`email` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`visitor_id`))ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `PizzaDelivery`.`Employees` (
`employee_id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`employee_id`))ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `PizzaDelivery`.`Orders` (
`order_id` INT NOT NULL AUTO_INCREMENT ,
`pizza` VARCHAR(45) NOT NULL ,
`extra` VARCHAR(45) NULL ,
`kind` VARCHAR(45) NOT NULL ,
`amount` VARCHAR(45) NOT NULL ,
`visitor_id` INT NOT NULL ,
`employee_id` INT NOT NULL ,
`order_time` TIME NOT NULL ,
PRIMARY KEY (`order_id`) ,
INDEX `visitor_id` (`visitor_id` ASC) ,
INDEX `employee_id` (`employee_id` ASC) ,
CONSTRAINT `visitor_id`
FOREIGN KEY (`visitor_id` )
REFERENCES `PizzaDelivery`.`Visitors` (`visitor_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `employee_id`
FOREIGN KEY (`employee_id` )
REFERENCES `PizzaDelivery`.`Employees` (`employee_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `PizzaDelivery`.`Deliveries` (
`employee_id` INT NOT NULL ,
`order_id` INT NOT NULL ,
`voertuig_id` INT NOT NULL ,
`deliverytime` TIME NOT NULL ,
PRIMARY KEY (`employee_id`, `order_id`) ,
INDEX `employee_id` (`employee_id` ASC) ,
INDEX `order_id` (`order_id` ASC) ,
CONSTRAINT `employee_id`
FOREIGN KEY (`employee_id` )
REFERENCES `PizzaDelivery`.`Employees` (`employee_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `order_id`
FOREIGN KEY (`order_id` )
REFERENCES `PizzaDelivery`.`Orders` (`order_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)ENGINE=InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;