0

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
);
2
  • 4
    "String" is not a valid MySQL column type. See MySQL string data types. Commented May 26, 2020 at 8:16
  • 1
    idd, you probably want something like varchar Commented May 26, 2020 at 8:16

3 Answers 3

2

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
);
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.