ERROR 1064 (42000) in creating table using MySQL 8.0 command line - mysql

I'm trying to create a table Order but somehow I am encountering the error code below:
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 'Order(
OrderId int,
CustId int,
OrderDate datetime,
RequiredDate datetime,
Shipp' at line 1
I use the following code to create my table:
create table Order(
-> OrderId int,
-> CustId int,
-> OrderDate datetime,
-> RequiredDate datetime,
-> ShippedDate datetime,
-> Status varchar(12),
-> Comments varchar(255)
-> );
We don't need to set primary key or foreign key but I don't know what went wrong with my code. Please advice thanks!

Thanks #jarlh I didn't know it was a reserve word. I just started SQL.

Related

mySQL - create table error 1064(42000): syntax error

I'm trying to create the table below but I get an error. I double checked and the data types are valid, and a table with this name doesn't currently exist in the database. I even closed and re-opened my terminal in case this was a glitch. But still no luck. Any idea what's wrong here?
create table order (order_no int, purch_amt decimal(6,2), order_date date, customer_id int, salesman_id int);
Error message I get:
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 'order (order_no int, purch_amt decimal(6,2), order_date date, customer_id int, s' at line 1
order is SQL keyword. I would suggest calling the table orders. I would suggest:
create table orders (
order_no int,
purch_amt decimal(6,2),
order_date date,
customer_id int,
salesperson_id int
);

MySQL error 1064 table creation

This seems a fairly trivial problem but I am having no luck in running the following query:
create table if not exists tweet_data (
created_at DATETIME,
user_name VARCHAR(20),
retweet_count INT,
favourite_count INT,
tweet_followers_count INT,
is_retweet BOOLEAN,
tweet_source VARCHAR(256),
user_location VARCHAR(256),
tweet_mentioned_count INT,
tweet_ID VARCHAR(256) NOT NULL,
tweet_text VARCHAR(140),
UNIQUE (tweet_ID) );
When I run this I get the following error message:
Error Code: 1064. 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 '(20), retweet_count INT, favourite_count INT,
tweet_followers_count ' at line 3
When I hover over the error tag on line 3 it says:
Syntax error : unexpected '(' (opening parenthesis)
I'm sure this is a simple fix, any help would be great!
Turned out to be an error with mySQL Workbench
create table if not exists tweet_data (
created_at DATETIME,
user_name VARCHAR (20),
retweet_count INT,
favourite_count INT,
tweet_followers_count INT,
is_retweet BOOLEAN,
tweet_source VARCHAR(256),
user_location VARCHAR(256),
tweet_mentioned_count INT,
tweet_ID VARCHAR(256) NOT NULL,
tweet_text VARCHAR(140),
UNIQUE (tweet_ID) );
Man this code is running perfectly.
go to this link and check it your self
http://rextester.com/l/mysql_online_compiler

MySQL syntax error, can't figure out what's wrong

Hello and thanks for reading my question! I am receiving a syntax error with this code but I cannot figure out what's wrong. Any insight is greatly appreciated.
mysql> create table match (
-> event_id int not null,
-> player1_id int,
-> player2_id int,
-> player1_score int,
-> player2_score int,
-> winner_id int,
-> foreign key (event_id) references event(id)
-> );
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 'match (
event_id int not null,
player1_id int,
player2_id int,
player1_score int' at line 1
I can't find any missing commas, and the event table definitely exists with an id column. Any ideas what I'm missing? Thank you!
Match is a reserved word. Enclose it in backticks:
create table `match` ...

MySQL CREATE TABLE 'You have an error in your SQL syntax' error [duplicate]

This question already has answers here:
Error creating table: You have an error in your SQL syntax near 'order( order_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id ' at line 1 [duplicate]
(2 answers)
Closed 5 years ago.
I am pulling my hair out over this. I have connected to a MySQL server and am trying to create a table on it:
CREATE TABLE order (
order_id INT,
order_is_overnight BIT,
order_quantity INT,
order_amount DOUBLE,
order_timestamp DATETIME
);
When I run this I get:
Error: 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 'order (
order_id INT,
order_is_overnight BIT,
order_quantity INT,
order_amou' at line 1
SQLState: 42000
ErrorCode: 1064
This is the world's vaguest error message, akin to a Java exception that says "Whoops, something went wrong somewhere in your code!"
Any ideas where I'm going awry?! I have checked, and rechecked, and rechecked and this seems to be a perfectly valid/legal CREATE TABLE statement (don't worry about performance, indexes, keys, etc.; this is just a dummy/test table).
order is an reserved word, you must enclose it name in back quotes
CREATE TABLE `order` (
order_id INT,
order_is_overnight BIT,
order_quantity INT,
order_amount DOUBLE,
order_timestamp DATETIME
);

Error 1064 Syntax Error MySQL Table Creation

Creating a table in MySQL results in error 1064. I do not have restricted words for table name.
mysql> create database NamesInc
-> ;
Query OK, 1 row affected (0.10 sec)
mysql> create table NameInfo(
-> Name_ID NUMBER(8),
-> Language VARCHAR2(10),
-> Status VARCHAR2(10),
-> Standard VARCHAR2(10),
-> Place_ID Number(8) NOT NULL,
-> Supplier_ID NUMBER(8) NOT NULL,
-> Date Supplied DATE,
-> PRIMARY KEY (Name_ID),
-> );
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 'NUMBER(8),
Language VARCHAR2(8),
Status VARCHAR2(10),
PL' at line 2
Please let me know if I can provide additional information.
After create db statement do:
USE NamesInc;
create table NameInfo(
Name_ID INT(8),
Language VARCHAR(10),
Status VARCHAR(10),
Standard VARCHAR(10),
Place_ID INT(8) NOT NULL,
Supplier_ID INT(8) NOT NULL,
Date_Supplied DATE,
PRIMARY KEY (Name_ID)
);