Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Where can i find the manual for for MySQL 5.0 syntax? What i would need is the manual that corresponds to my MySQL server version (MySQL 5.0)?
Considering this: I am using MySQL 5.0 and NaviCat for GUI. If i run this query:
CREATE TABLE `genres` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`genre_name` VARCHAR( 25 ) NOT NULL
`description` VARCHAR( 100 ) NOT NULL
) ENGINE = innodb;
-> Navicat gives me a check your syntax error, and so does the sql prompt..
Where can i find info about SQL 5.0 syntax? I've tried the SQL site and Googled it but no luck. Maybe i am truly an idiot ;-)
http://dev.mysql.com/doc/refman/5.0/en/
More specifically, for the CREATE TABLE statement:
http://dev.mysql.com/doc/refman/5.0/en/create-table.html
How about http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html ?
There seem to be a missing coma (,) between 3rd and 4th lines in your query.
The official MySQL documentation is the best place. It has tutorials and references for everything
This should point you in the right direction: MySQL Statement Syntax
It looks like you're missing a comma at the end of this line (comma added):
`genre_name` VARCHAR( 25 ) NOT NULL,
You need a comma after every line except the last line of a create table statement.
Related
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 days ago.
Improve this question
I'm a beginner at mysql on linux (ubuntu 22.4), while checking a document with the basics i came across an example of how to create a primary key, but with the constraint keyword:
CREATE TABLE
Empleados (
IdEmpleado INTEGER CONSTRAINT IndicePrimario PRIMARY,
Nombre TEXT,
Apellidos TEXT,
FechaNacimiento DATETIME
)
But when i type the command, i get this error.
ERROR 1064 (42000): 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 'CONSTRAINT indice PRIMARY KEY)' at line 1
I tried some modifications such as "int" instead of integer, or "primary key" instead of just primary, adding "not null" and so on, but is still the same error.
I already tried to search why is it wrong, but can't figure it out. If anyone could help, id appreciate
Try adding constraint separately as shown below,
CREATE TABLE Empleados (
IdEmpleado int NOT NULL,
Nombre varchar(255),
Apellidos varchar(255),
FechaNacimiento datetime,
CONSTRAINT IndicePrimario PRIMARY KEY (IdEmpleado)
);
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
When I create a table using the following statement, I get an error.
CREATE TABLE HOTEL(ROOM_NUMBER, check_in_date, check_out_date)
Error:
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 ', check_in_date, check_out_date)' at line 1
What can I do to solve this?
you must have to define datatype like this:
CREATE TABLE HOTEL(
ROOM_NUMBER int,
check_in_date datetime,
check_out_date datetime
);
source
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 created a database for a nfl team. I created a table called players that holds bios info. Now i want to create a table called transactions that shows the trade transactions but players to the active roster based from the primary key of players. But i keep getting this error: 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 'KEY(idplayer) REFERENCES players(playersid))' at line 8.
`
create table transactions(
transid INT UNSIGNED NOT NULL AUTO_INCREMENT,
type VARCHAR(30),
fromteam VARCHAR(30),
toteam VARCHAR(30),
idplayer INT UNSIGNED NOT NULL,
PRIMARY KEY(transid),
FORIEGN KEY(idplayer) REFERENCES players(playersid));
Please could someone help me out on similar experiences.
I think you just misspelled FOREIGN :-)
Typo, change
FORIEGN KEY(idplayer) REFERENCES players(playersid));
to
FOREIGN KEY(idplayer) REFERENCES players(playersid));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am getting an error for the following code:
create table JOB_TBL(
JT_JOB_ID_FLD INT AUTO_INCREMENT,
JT_JOB_DESCRIPTION_FLD VARCHAR(4000),
JT_JOB_POSTER_FLD INT NOT NULL,
JT_JOB_POST_DATE_FLD DATE NOT NULL,
JT_JOB_CLOSE_DATE_FLD DATE NOT NULL,
PRIMARY KEY (JT_JOB_ID_FLD),
FOREIGN KEY (JT_JOB_POSTER_FLD)
REFERENCES USER_TBL(UT_USER_ID_FLD)
) ENGINE = INNODB;
At first I thought it had something to do with the NOT NULL on the two date fields, but it is still giving an error when I run the statement without those not nulls. Here is the error I receive:
#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 'FLD INT NOT NULL,
JT_JOB_POST_DATE_FLD DATE NOT NULL,
JT_JOB_CLOSE_DATE_FLD DA' at line 4
JT_JOB_POSTER_ FLD INT NOT NULL,
^----- what's this?
Mysql explicitly points you to the wrong place, next time just hold your breath and read it carefully.
There should not be a space between after the underscore in this line:
JT_JOB_POSTER_ FLD INT NOT NULL,
^^^
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 wrote the following query for mySQL :
mysql> Create table R_Matrix
(
image_name VARCHAR(25) NOT NULL REFERENCES Images(image_name),
Row INT,
Column INT,
Data INT,
PRIMARY KEY(image_name)
);
Where Images is a table in the same database and image_name is a column in it;
However I got the following error :
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 'Column INT, Data INT, PRIMARY KEY(image_name) )'
at line 1
I cannot find anything wrong with the query. What am I doing wrong ?
COLUMN is a reserved keyword. It must be escape using backtick,
Create table R_Matrix
(
image_name VARCHAR(25) NOT NULL REFERENCES Images(image_name),
Row INT,
`Column` INT,
Data INT,
PRIMARY KEY(image_name)
);
MySQL Reserved Keywords
The best option is to avoid using MySQL reserved words as identifiers. Since you are running a CREATE TABLE statement, changing the column name is the best solution. (Choose a different column name; or at a minimum, add an underscore to the end of the identifier.)
The problem with your statement (as JW correctly points out), is that COLUMN is a MySQL reserved word. Your statement is raising an error because MySQL is interpreting the token Column in your statement as a reserved word, rather than a column name; and, in that context, that reserved word is valid syntax.
A workaround (as JW also points out) to prevent MySQL as seeing that identifier as a reserved word is to enclose the identifier in backticks; alternatively, if sql_mode is set to ANSI, the identifier can be enclosed in double quotes.