为了账号安全,请及时绑定邮箱和手机立即绑定

建立数据库出现问题

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,
'eamil' varchar(50) not null
);

--分类表
DROP TABLE IF EXISTS 'imooc_cate';
CREATE TABLE 'imooc_cate'(
'id' smallint unsigned auto_increment key,
'cName' varchar(50) 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' amallint 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 EXISTA 'imooc_album';
CREATE TABLE 'imooc_album'(
'id' int unsigned auto_increment key,
'pid' int unsigned not null,
'albumPath' varchar(50) not null
);





结果返回:

SQL 查询:

CREATE DATABASE IF NOT EXISTS 'shopImooc';

MySQL 返回: 文档

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''shopImooc'' at line 1 

正在回答

3 回答

就是说要把所有的引号给去掉是吧?

0 回复 有任何疑惑可以回复我~
#1

乾坤龙心 提问者

哪个不是引号 数字键1左边那个
2016-09-04 回复 有任何疑惑可以回复我~

找出问题了

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,
eamil varchar(50) not null
);

DROP TABLE IF EXISTS imooc_cate;
CREATE TABLE imooc_cate(
id smallint unsigned auto_increment key,
cName varchar(50) 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("1","2","3") not null default "3",
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
);

1 回复 有任何疑惑可以回复我~


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.6.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE IF NOT EXISTS 'shopImooc';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''shopImooc'' at line 1
mysql> USE 'shopImooc';
ERROR 1049 (42000): Unknown database 'shopimooc'
mysql> --管理员表
    -> DROP TABLE IF EXISTS 'imooc_admin';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--管理员表
DROP TABLE IF EXISTS 'imooc_admin'' at line 1
mysql> CREATE TABLE 'imooc_admin'(
    -> 'id' tinyint unsigned auto_increment key,
    -> 'username' varchar(20) not null unique,
    -> 'password' char(32) not null,
    -> 'eamil' varchar(50) not null
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''imooc_admin'(
'id' tinyint unsigned auto_increment key,
'username' varchar(20) ' at line 1
mysql>
mysql> --分类表
    -> DROP TABLE IF EXISTS 'imooc_cate';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--分类表
DROP TABLE IF EXISTS 'imooc_cate'' at line 1
mysql> CREATE TABLE 'imooc_cate'(
    -> 'id' smallint unsigned auto_increment key,
    -> 'cName' varchar(50) unique
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''imooc_cate'(
'id' smallint unsigned auto_increment key,
'cName' varchar(50) uni' at line 1
mysql>
mysql> --商品表
    -> DROP TABLE IF EXISTS 'imooc_pro';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--商品表
DROP TABLE IF EXISTS 'imooc_pro'' at line 1
mysql> 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' amallint unsigned not null,
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''imooc_pro'(
'id' int unsigned auto_increment key,
'pName' varchar(50) not null ' at line 1
mysql>
mysql> --用户表
    -> DROP TABLE IF EXISTS 'imooc_user';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--用户表
DROP TABLE IF EXISTS 'imooc_user'' at line 1
mysql> 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
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''imooc_user'(
'id' int unsigned auto_increment key,
'username' varchar(20) not n' at line 1
mysql>
mysql> --相册表
    -> DROP TABLE IF EXISTA 'imooc_album';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--相册表
DROP TABLE IF EXISTA 'imooc_album'' at line 1
mysql> CREATE TABLE 'imooc_album'(
    -> 'id' int unsigned auto_increment key,
    -> 'pid' int unsigned not null,
    -> 'albumPath' varchar(50) not null
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''imooc_album'(
'id' int unsigned auto_increment key,
'pid' int unsigned not null' at line 1
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
手把手教你实现电商网站后台开发
  • 参与学习       117284    人
  • 解答问题       1999    个

手把手教你用PHP搭建电子商务平台,由浅入深教你搭建电商系统

进入课程

建立数据库出现问题

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信