Mariadb语法错误1064(42000) [英] Mariadb syntax error 1064 (42000)

查看:787
本文介绍了Mariadb语法错误1064(42000)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当我尝试在MariaDB中运行此脚本时遇到以下错误:"ERROR 1064(42000):您的SQL语法有错误;请查看与您的MariaDB服务器版本相对应的手册以获取相关信息.在

So I'm getting an error when trying to run this script in MariaDB that reads as follows: "ERROR 1064 (42000):You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near

CREATE TABLE customers (
  customer_id int NOT NULL,
  customer_f

第1行

奇怪的是,MariaDB似乎正在读取命令的第一行,然后将下一行的一点读为1行.整个脚本如下:如果有人可以帮助,我将不胜感激.

The weird thing is that MariaDB seems to be reading the first line of the command and then a little bit of the next line as 1 line. The whole script is below: if anyone could help I would greatly appreciate it.

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)
); 

推荐答案

我遇到了类似的挫败感,发现我需要在程序周围更改定界符.也许它也可以在这里工作.

I had a similar frustration and discovered I needed to change my delimiter around my procedure. Perhaps it'll work here too.

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

这篇关于Mariadb语法错误1064(42000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆