Reputation: 322
When creating a table in mysql query I get the error as 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 'String,
last_name String,
email_address String
)' at line 4
I could not understand what is causing this error. The query is as below.
CREATE TABLE employees
(
id long,
first_name String,
last_name String,
email_address String
);
Upvotes: 0
Views: 59
Reputation: 1058
As much as i know there is no DataType String in Sql Use varchar
See this for More https://www.journaldev.com/16774/sql-data-types
Upvotes: 1
Reputation: 522396
You appear to be using Java types in your create table statement. Try using proper MySQL types and it should work:
CREATE TABLE employees (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(55) NOT NULL,
last_name VARCHAR(55) NOT NULL,
email_address VARCHAR(255) NOT NULL
);
Upvotes: 2
Reputation: 821
String is not a mysql keyword. you need to use varchar, or char, or text, or longtext... depending on your needs.
Here's how it could look:
CREATE TABLE employees
(
id long,
first_name varchar(32),
last_name varchar(32),
email_address varchar(32)
);
Upvotes: 1