为什么说我语法错误找半天了
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
错误一 set应是sex 错误二 , , 请问老师编码器不能报这类问题吗
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星