mysql Mariadb语法错误1064(42000)

fafcakar  于 2023-08-02  发布在  Mysql
关注(0)|答案(3)|浏览(181)

因此,当我试图在MariaDB中运行此脚本时,出现了如下错误:“错误1064(42000):您的SQL语法中有一个错误;检查与您的MariaDB服务器版本对应的手册,以了解在附近使用的正确语法

CREATE TABLE customers (
  customer_id int NOT NULL,
  customer_f

字符串
在第1行
奇怪的是,MariaDB似乎阅读命令的第一行,然后将下一行的一小部分作为1行。整个脚本如下:如果有人能帮忙,我将不胜感激。

DROP TABLE customers;
DROP TABLE orders;
DROP TABLE products;
DROP TABLE orderitem;
​
CREATE TABLE customers (
customer_id INT NOT NULL AUTO_INCREMENT,
customer_firstname VARCHAR(20) NOT NULL,
customer_lastname VARCHAR(40) NOT NULL,
customer_phone CHAR(10) NOT NULL,
customer_email VARCHAR(60) NOT NULL,
customer_address VARCHAR(40) NOT NULL,
customer_city VARCHAR(40) NOT NULL,
customer_state CHAR(2) NOT NULL,
customer_zip VARCHAR(10) NOT NULL,
customer_aptnum VARCHAR(5) NOT NULL,
customer_pass CHAR(40) NOT NULL,
customer_type VARCHAR(10) NOT NULL,
PRIMARY KEY (customer_id),
INDEX customer_fullname (customer_firstname, customer_lastname),
UNIQUE (customer_email)
); 
​
CREATE TABLE orders (
order_id INT NOT NULL AUTO_INCREMENT,
order_datetime DATETIME NOT NULL,
order_trackingnumber VARCHAR(20) NOT NULL,
order_shipdate DATETIME NOT NULL,
order_shipmethod VARCHAR(10) NOT NULL,
order_shipcarrier VARCHAR(10) NOT NULL,
order_totalprice DECIMAL,
customer_id  INT NOT NULL,
PRIMARY KEY (order_id),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
UNIQUE (order_trackingnumber)
); 
​
​
CREATE TABLE products (
product_id VARCHAR(30) NOT NULL AUTO_INCREMENT,
product_beginningstockdate DATETIME NOT NULL,
product_endstockdate DATETIME,
product_category VARCHAR(15) NOT NULL,
product_name VARCHAR(60) NOT NULL,
product_availablequantity SMALLINT NOT NULL,
product_totalquantity SMALLINT NOT NULL,
product_price  DECIMAL NOT NULL,
product_taxable DECIMAL NOT NULL,
product_itemstatus VARCHAR(15) NOT NULL,
product_discountpercent DECIMAL,
product_soldinstore char(3),
product_soldonwebsite char(3),
PRIMARY KEY (product_id),
UNIQUE (product_name)
); 
​
/*INSERT INTO products (product_description, product_beginningstockdate, product_endstockdate, product_category, product_name, product_availablequantity, product_totalquantity, product_price, product_taxable, product_itemstatus, product_discountpercent, product_soldinstore, product_soldonwebsite) 
VALUES 
(...),
(...),
........ */
​
CREATE TABLE orderitem (
orderitem_id INT NOT NULL AUTO_INCREMENT,
order_id INT NOT NULL,
product_id VARCHAR(30) NOT NULL,
orderitem_priceperunit DECIMAL NOT NULL,
orderitem_quantityordered TINYINT NOT NULL,
PRIMARY KEY (orderitem_id),
FOREIGN KEY (order_id) REFERENCES orders(order_id),
FOREIGN KEY (product_id) REFERENCES orders(product_id)
);

ne5o7dgx

ne5o7dgx1#

将代码复制并粘贴到NotePad中,然后在十六进制编辑器中查看它,可以看到语句之间的每一个空行中都有80 8b 0a
该字节序列是zero-width space字符的UTF-8编码形式。
你要把那些东西拿走-这样就能用了。
(If如果你使用的是NotePad
和十六进制编辑器插件,那么在十六进制视图中,你可以简单地用一个空字符串替换e2 80 8b。否则,在任何其他文本编辑器中,转到上一行的末尾,从那里选择空行直到下一行的开头的所有内容,然后通过按Enter键替换所选内容也应该是可行的。

ss2ws0br

ss2ws0br2#

我也遇到了类似的挫折,发现我需要更改我的过程周围的分隔符。或许在这里也能奏效。

DELIMITER //
CREATE PROCEDURE
....
BEGIN
END //
DELIMITER ;

字符串

sgtfey8w

sgtfey8w3#

select * FROM rides AS r INNER JOIN cities AS c on r.starting_city_id = c.city_id ; WHERE city_name in('Toulouse ','里昂',' Bordeaux');

相关问题