MySQL用命令行創建數據庫和表失敗
老師,請問下,我根據本節教程,創建數據庫和數據表,但都無法創建,是什么原因,我的代碼如下:
CREATE DATABASE IF NOT EXISTS 'shopImooc';
USE 'shopImooc';
--管理員表
DROP TABLE IF EXISTS 'imooc_admin';
CREATE TABLE 'imooc_admin'(
'id' tinyint unsigned auto_increment key,
'username' varchar(20) not null unique,
'password' char(32) not null,
'email' varchar(50) not null
);
--分類表
DROP TABLE IF EXISTS 'imooc_cate';
CREATE TABLE 'imooc_cate'(
'id' smallint unsigned auto_increment key,
'cName' varchar(50) not null unique
);
--商品表
DROP TABLE IF EXISTS 'imooc_pro';
CREATE TABLE 'imooc_pro'(
'id' int unsigned auto_increment key,
'pName' varchar(50) not null unique,
'pSn' varchar(50) not null,
'pNum' int unsigned default 1,
'mPrice' decimal(10,2) not null,
'iPrice' decimal(10,2) not null,
'pDesc' text,
'pImg' varchar(50) not null,
'pubTime' int unsigned not null,
'isShow' tinyint(1) default 1,
'isHot' tinyint(1) default 0,
'cId' smallint unsigned not null
);
--用戶表
DROP TABLE IF EXISTS 'imooc_user';
CREATE TABLE 'imooc_user'(
'id' int unsigned auto_increment key,
'username' varchar(20) not null unique,
'password' char(32) not null,
'sex' enum("男","女","保密") not null default "保密",
'face' varchar(50) not null,
'regTime' int unsigned not null
);
--相冊表
DROP TABLE IF EXISTS 'imooc_album';
CREATE TABLE 'imooc_album'(
'id' int unsigned auto_increment key,
'pid' int unsigned not null,
'albumPath' varchar(50) not null
);
我通過CMD命令行連接數據庫,并把以上代碼粘貼過去,結果都是失敗的,如下圖所示:
2015-05-20
第一:表名和字段名用反引號,而不是單引號
第二:注釋表的時候--和文字之間至少空出一個空格