You have an error in your SQL syntax [MariaDB] [closed] - mysql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm getting this error while developing a javaEE application with MariaDB.
The error is:
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 'STARTING DATE, TITLE VARCHAR(255), CREATOR VARCHAR(255), LOCATION BIGINT, FORECA' at line 1
This is the problematic query:
CREATE TABLE EVENT
(
ID VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255),
ENDING DATE,
ISALLDAY TINYINT(1) default 0,
PUBLICEVENT TINYINT(1) default 0,
STARTING DATE,
TITLE VARCHAR(255),
CREATOR VARCHAR(255),
LOCATION BIGINT,
FORECAST BIGINT,
PRIMARY KEY (ID);
I can't figure out what is the problem...

You have a two typos:
STARTING - is a reserved word - use backticks
you forget closing parenthesis
This script should work:
CREATE TABLE EVENT
(
ID VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255),
ENDING DATE,
ISALLDAY TINYINT(1) default 0,
PUBLICEVENT TINYINT(1) default 0,
`STARTING` DATE,
TITLE VARCHAR(255),
CREATOR VARCHAR(255),
LOCATION BIGINT,
FORECAST BIGINT,
PRIMARY KEY (ID)
);

Related

Error #1064 MySQL Something is wrong in your syntax near '' accesslogh ' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I got this MySQL error 1064:
# 1064 - Something is wrong in your syntax near '' accesslogh '(
id INT (30) PRIMARY KEY AUTO_INCREMENT NOT NULL,
nam ... 'on line 1
When i ran
CREATE TABLE 'accesslogh' (
id INT(30) PRIMARY KEY AUTO_INCREMENT NOT NULL,
name VARCHAR(255),
result VARCHAR(255),
type VARCHAR(255),
code VARCHAR(255),
epoch INT(30),
timestamp DATE DEFAULT CURRENT_TIMESTAMP);
I know it is a syntax error but I have tried to solve it following the correct theory but I can't solve it.
Remove quotes around table name.
CREATE TABLE accesslogh (
id INT(30) PRIMARY KEY AUTO_INCREMENT NOT NULL,
name VARCHAR(255),
result VARCHAR(255),
type VARCHAR(255),
code VARCHAR(255),
epoch INT(30),
timestamp DATE DEFAULT CURRENT_TIMESTAMP);
You are confusing the backtick ` with the single quote '. In SQL the single quote is used for string literals, in specifically MySQL the backtick is used to denote a quoted identifier, to allow you to use special characters, white space and reserved words for identifiers. What you probably intended to do was this:
CREATE TABLE `accesslogh` (
id INT(30) PRIMARY KEY AUTO_INCREMENT NOT NULL,
name VARCHAR(255),
result VARCHAR(255),
type VARCHAR(255),
code VARCHAR(255),
epoch INT(30),
timestamp DATE DEFAULT CURRENT_TIMESTAMP);
While it's not needed for your example it's a good practice to get into if your queries are going to be generated in some other code.
This really only applies to MySQL, other SQL DBMS tend to use square brackets [ ] to enclose identifiers that use reserved words or characters not otherwise allowed.

Why does my SQL gave an error when i am using VARCHAR as primary key? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
This is my code
CREATE TABLE mactor(
pid VARCHAR(30) UNSIGNED NOT NULL AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname VARCHAR(30) NOT NULL,
gender VARCHAR(20) NOT NULL,
PRIMARY KEY (pid));
and this is the error
#1064 - 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 'UNSIGNED NOT null AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname...' at line 2.
I am very confused and I don't want to use any other values as my primary key other than VARCHAR. please help!
Remove the UNSIGNED; unsigned can only apply to numeric types, not character or binary types. You will also need to get rid of AUTO_INCREMENT; you can't auto increment a character type.

MySQL error code: 1064 during CREATE TABLE in MySQL Workbench [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Trying to create a table in MySQL workbench and I keep getting this 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 ')' at line 7"
Here is what I have input...what am I doing wrong?
create table members (
id varchar (255) primary key,
pswd varchar(255) not null,
email varchar(255) not null,
member_since timestamp default now() not null,
payment_due decimal (6, 2) not null default 0,
)
;
There is extra comma at the end.
Just remove it and everything works fine.
create table members (
id varchar (255) primary key,
pswd varchar(255) not null,
email varchar(255) not null,
member_since timestamp default now() not null,
payment_due decimal (6, 2) not null default 0)
Db<>fiddle

What is wrong with this Create Table statement [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
please could you help me with this piece of code, I don't know what's wrong with it. It seems correct at simple glance but it just gets me #1064 syntax error. The MySQL version am running is 5.5
CREATE TABLE mytablename(
-> id SMALLINT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(100) NOT NULL,
-> submission_date NOT NULL TIMESTAMP,
-> PRIMARY KEY (id)
-> )ENGINE=InnoDB;
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 '-> id SMALLINT NOT NULL AUTO_INCREMENT, -> name CHAR(100), ->
submission' at line 2
Remove those arrows and try escaping the column names with backticks:
CREATE TABLE mytablename(
`id` SMALLINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`submission_date` NOT NULL TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;

Error #1064 mysql when creating table [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I tried to find out why this error is keep showing when i create the DB.
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
'NUMBER(10) not null,
email varchar(50) not null,'
at line 4
here is the table that has the error:
create table students
(
name varchar(30) not null,
studentID NUMBER(10) not null,
email varchar(30) not null,
mobile NUMBER(15) not null,
GPA DOUBLE not null,
courseID varchar(6) not null,
membershipType varchar
groupID NUMBER
finalMark number
Check (courseID='SWE496' OR courseID = 'SWE497')
primary key (id)
);
There are quite a few errors here:
There is no such thing as NUMBER. Use NUMERIC or DECIMAL.
You are missing commas after the lines for membershipType, groupID, finalMark and Check.
membershipType is a varchar, but you didn't specify the length.
There is no field called "id", though you are trying to declare it as the primary key
This will work:
CREATE TABLE students
(
id INTEGER AUTO_INCREMENT NOT NULL,
NAME VARCHAR(30) NOT NULL,
studentID NUMERIC(10) NOT NULL,
email VARCHAR(30) NOT NULL,
mobile DECIMAL(15) NOT NULL,
GPA DOUBLE NOT NULL,
courseID VARCHAR(6) NOT NULL,
membershipType VARCHAR(10),
groupID DECIMAL,
finalMark DECIMAL,
CHECK (courseID='SWE496' OR courseID = 'SWE497'),
PRIMARY KEY (id)
);