为什么说我语法错误找半天了

为什么说我语法错误找半天了

Microsoft Windows [版本 10.0.17134.648]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Windows\system32>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
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> -- 创建慕课网 imoocCREATE DATABASE IF NOT EXISTS imooc DEFAULT CHARACTER SET 'UTF8';-- 打开imoocUSE imooc;-- 用户表 imooc_userCREATE TABLE IF NOT EXISTS imooc_user(id INT,username VARCHAR(20),password CHAR(32),email VARCHAR(50),age TINYINT,card CHAR(18),tel CHAR(11),salary FLOAT(8,2),married TINYINT(1),addr VARCHAR(100),sex ENUM('男','女','保密'))ENGINE=INNODB CHARSET=UTF8;
mysql> --创建慕课网 imooc
    ->
    -> CREATE TABLE IF NOT EXISTS imooc  DEFAULT CHARACTER SET 'UTF8';
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

CREATE TABLE IF NOT EXISTS imooc  DEFAULT CHARACTER SET' at line 1
mysql>
mysql> --打开imooc
    ->
    -> USE imooc;
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

USE imooc' at line 1
mysql>
mysql> --用户表 user
    ->
    -> CREATE TABLE IF NOT EXISTS imocc_user(
    ->   id INT,
    ->   username VARCHAR(20),
    ->   password CHAR(32),
    ->   email VARCHAR(50),
    ->   age TINYINT,
    ->   card CHAR(18),
    ->   tel CHAR(11),
    ->   salary FLOAT(8,2),
    ->   married TINYINT(1),
    ->   addr VARCHAR(100),
    ->   set ENUM('男','女','保密')
    -> )ENGINE=INNODB CHARSET=UTF8;
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 '--用户表 user

CREATE TABLE IF NOT EXISTS imocc_user(
  id INT,
  username VA' at line 1
mysql> SHOW DATABASESL
    -> S
    ->
    ->
    ->
    -> ;
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 'DATABASESL
S' at line 1
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bold               |
| invest             |
| invest1            |
| mysql              |
| performance_schema |
| test               |
+--------------------+
7 rows in set (0.00 sec)

mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS imooc  DEFAULT CHARACTER SET 'UTF8';
ERROR 1046 (3D000): No database selected
mysql>
mysql>
mysql>
mysql> USE imooc;
ERROR 1049 (42000): Unknown database 'imooc'
mysql>
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS imocc_user(
    ->   id INT,
    ->   username VARCHAR(20),
    ->   password CHAR(32),
    ->   email VARCHAR(50),
    ->   age TINYINT,
    ->   card CHAR(18),
    ->   tel CHAR(11),
    ->   salary FLOAT(8,2),
    ->   married TINYINT(1),
    ->   addr VARCHAR(100),
    ->   set ENUM('男','女','保密')
    -> )ENGINE=INNODB CHARSET=UTF8;
ERROR 1046 (3D000): No database selected
mysql>
mysql>
mysql> CREATE DATABASE IF NOT EXISTS imooc  DEFAULT CHARACTER SET 'UTF8';
Query OK, 1 row affected (0.09 sec)

mysql>
mysql>
mysql>
mysql> USE imooc;
Database changed
mysql>
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS imocc_user(
    ->   id INT,
    ->   username VARCHAR(20),
    ->   password CHAR(32),
    ->   email VARCHAR(50),
    ->   age TINYINT,
    ->   card CHAR(18),
    ->   tel CHAR(11),
    ->   salary FLOAT(8,2),
    ->   married TINYINT(1),
    ->   addr VARCHAR(100),
    ->   set ENUM('男','女','保密')
    -> )ENGINE=INNODB CHARSET=UTF8;
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 'set ENUM('男','女','保密')
)ENGINE=INNODB CHARSET=UTF8' at line 12
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bold               |
| imooc              |
| invest             |
| invest1            |
| mysql              |
| performance_schema |
| test               |
+--------------------+
8 rows in set (0.00 sec)

mysql>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
提问者 慕盖茨8087740 2019-03-23 19:57:36

错误一 set应是sex  错误二 , , 请问老师编码器不能报这类问题吗

  • 你好~请问同学的问题是否解决了呢?“请问老师编码器不能报这类问题吗”这句话是什么意思呢?建议同学详细的描述一下你的问题,方便老师具有针对性的为你解答,祝学习愉快~
    2019-03-24 10:11:45
  • 提问者 慕盖茨8087740 回复 chrismorgen #2
    就是请问标点符号中英符号编译器不报错
    2019-03-24 10:12:55
  • chrismorgen 回复 提问者 慕盖茨8087740 #3
    你好同学,mysql是严格区分中英文符号的,建议同学使用英文符号来编写sql语句哦,否则就会报错的,祝学习愉快~
    2019-03-25 09:51:33
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师