我有这个代码:
CREATE DATABASE IF NOT EXISTS courses;
USE 'courses'
CREATE TABLE IF NOT EXISTS teachers(
id INT(10) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
addr VARCHAR(255) NOT NULL,
phone INT NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS lessons(
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
room TINYINT NOT NULL,
length INT NOT NULL,
lesson_date DATETIME NOT NULL,
teacher INT NOT NULL,
course INT NOT NULL,
FOREIGN KEY(teacher) REFERENCES teachers(id),
FOREIGN KEY(course) REFERENCES courses(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS courses(
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
title VARCHAR(200) NOT NULL,
length INT NOT NULL,
description TEXT DEFAULT '',
previous INT NOT NULL,
FOREIGN KEY(previous) REFERENCES courses(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
执行此代码后,出现错误:Error 1005 (HY000) Can't create table 'courses.lessons' (errno: 150) 我做错了什么?