H
CREATE TABLE `order`(
order_id INT NOT NULL AUTO_INCREMENT,
customer_id INT NOT NULL,
agent_id INT NOT NULL,
date VARCHAR(50) NOT NULL,
HERE IS MY SCRIPT
CodePudding user response:
In spite of the comments above telling you that you need to delimit the word date
, they're wrong. date
is not a reserved keyword in MySQL. You can name a column date
easily, just as it is.
The confusion is that there's a difference between reserved keywords and nonreserved keywords. Reserved keywords require the delimiters if you want to use them as identifiers. The delimiters are optional for nonreserved keywords, or any other identifier.
order
is a reserved keyword, therefore you need to delimit it.
This is explained on the manual page: https://dev.mysql.com/doc/refman/8.0/en/keywords.html
Nonreserved keywords are permitted as identifiers without quoting. Reserved words are permitted as identifiers if you quote them as described in Section 9.2, “Schema Object Names”
That manual page also notes which keywords are reserved keywords with a "(R)" following them.
I tested your example CREATE TABLE statement, but I notice that it is incomplete. You have to finish it:
CREATE TABLE `order`(
order_id INT NOT NULL AUTO_INCREMENT,
customer_id INT NOT NULL,
agent_id INT NOT NULL,
date VARCHAR(50) NOT NULL,
PRIMARY KEY (order_id)
);
CodePudding user response:
You can try something like this:
INSERT INTO ORDERS1(order_id,customer_id,agent_id,date)
VALUES(1310232,5515,232,'2008-11-11');
I hope it solved your issue btw you should check the basic syntax of the date from here:HOW TO INSERT DATE IN SQL