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,
^^^
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 needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am new to MySQL and currently experimenting with MySQL workbench. I have been attempting to forward engineer a simple database schema from a model. Whenever I attempt to do this however it gives me the following error:
ERROR: Error 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 'NOT NULL,
`tbl_Arti_id_Arti` INT NOT NULL,
`tbl_Usr_id_Usr` INT NOT NULL,
' at line 6
I understand that the syntax is wrong, however i was wondering if anyone could point me as to how to fix it.
EDIT:
Please find below the auto generated create statement:
CREATE TABLE IF NOT EXISTS `AstuteSchema`.`tbl_authorArti` (
`id_usrArti` VARCHAR(45) NOT NULL,
`usrArti_IsPri` VARCHAR NOT NULL,
`tbl_Arti_id_Arti` INT NOT NULL,
`tbl_Usr_id_Usr` INT NOT NULL,
PRIMARY KEY (`id_usrArti`),
INDEX `fk_tbl_authorArti_tbl_Arti1_idx` (`tbl_Arti_id_Arti` ASC),
INDEX `fk_tbl_authorArti_tbl_Usr1_idx` (`tbl_Usr_id_Usr` ASC),
CONSTRAINT `fk_tbl_authorArti_tbl_Arti1`
FOREIGN KEY (`tbl_Arti_id_Arti`)
REFERENCES `AstuteSchema`.`tbl_Arti` (`id_Arti`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tbl_authorArti_tbl_Usr1`
FOREIGN KEY (`tbl_Usr_id_Usr`)
REFERENCES `AstuteSchema`.`tbl_Usr` (`id_Usr`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
Thanks in advance.
The error message tells you the exact location:
`usrArti_IsPri` VARCHAR NOT NULL,
^
Apparently, your model does not set a size for usrArti_IsPri and the code generator does not care validating it.
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
I'm trying but failing to create a table using Eclipse.
What can I do to fix this?
PreparedStatement create=conn.prepareStatement("CREATE TABLE IF NOT EXISTS
stud(id int unsigned not null auto_increment,
firstname varchar(25),
lastname varchar(25)");
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 '[IF NOT EXISTS] stud(id int unsigned not null auto_increment, firstname varchar(' at line 1
The issue is that your query for the table creation is missing a close bracket at the end, which makes the query syntactically invalid. The query should be:
PreparedStatement create=conn.prepareStatement("CREATE TABLE IF NOT EXISTS
stud(id int unsigned not null auto_increment,
firstname varchar(25),
lastname varchar(25))");
In my opinion, code formatting so brackets/braces and other general syntax can line up help to avoid these situations as you can see the opens and closes lining up:
PreparedStatement create=conn.prepareStatement("CREATE TABLE IF NOT EXISTS
stud(
id int unsigned not null auto_increment,
firstname varchar(25),
lastname varchar(25)
)");
However, some coding guidelines might not allow you to do this.
Although everybody is picking the missing parenthesis up, however, the error message does not relate to a missing parenthesis and ever answer and comment ignores what's in the error message.
I belive that the OP did not copy the exact code that is being executed because the error message says:
...check the manual that corresponds to your MySQL server version for the right syntax to use near '[IF NOT EXISTS]
Note that in the error message the if not exists clause is enclosed by square brackets as in the mysql manual on create table. In the manual it indicates that this clause is optional, but in the real life code the square brackets must not be there.
In the actual code there are no square brackets, this is why I belive that the OP did not copy the original code into the question. My answer is: remove the square brackets around the if not exists clause.
It simply lacks a closing paranthesis, as far as I can tell.
PreparedStatement create=conn.prepareStatement("CREATE TABLE IF NOT EXISTS
stud(id int unsigned not null auto_increment,
firstname varchar(25),
lastname varchar(25))");
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 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
when I am going to fire query for creating table in mySQL 5.0 I got following exception java.sql.sqlexception incorrect information in file frm Please give me solution for this?
CREATE TABLE IF NOT EXISTS tmp_vpedutech (srno INT(10) NOT NULL,
TheGroup VARCHAR(50) NULL,
make VARCHAR(50) NULL,
model VARCHAR(50) NULL,
description VARCHAR(255) NULL,
quantity VARCHAR(50) NULL,
modelNotKnown boolean NULL );
java.sql.SQLException: Incorrect information in file: './erp_vpedutech/tmp_vpedutech.frm'
It's working fine in mysql 5.1
It's working fine in SQL Fiddle check that