gpt4 book ai didi

mysql - 错误 1064 (42000) : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax?

转载 作者:行者123 更新时间:2023-11-29 19:06:40 25 4
gpt4 key购买 nike

我想制作一个表格,但出现了这个错误。我需要解决什么问题?

mysql> create database mytest;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| performance_schema |
| phpmyadmin |
+--------------------+

5 rows in set (0.00 sec)
mysql> use mytest;
Database changed
mysql> create table price(NAME varchar2(60), PRICE number(10));
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 'varchar2(60), PRICE number(10))' at line 1

最佳答案

您的陈述中还有更多错误:

1) 如果您使用关键字作为字段名称(例如 name

),则必须使用反引号

2) 没有数据类型 VARCHAR2 使用 VARCHAR 代替

3) 没有数据类型 NUMBER,请使用 INT 代替:

CREATE TABLE price (
`NAME` VARCHAR(60),
`PRICE` INT(10)
);

示例

mysql> CREATE TABLE price (
-> `NAME` VARCHAR(60),
-> `PRICE` INT(10)
-> );
Query OK, 0 rows affected (0,03 sec)

mysql>

关于mysql - 错误 1064 (42000) : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43434538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com