Erro 1064 mysql erro [duplicate] - mysql

This question already has answers here:
MySQL Workbench: Error in query (1064): Syntax error near 'VISIBLE' at line 1
(3 answers)
Closed 3 years ago.
Executing SQL script in server
ERROR: 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 '
CONSTRAINT fk_telefone_usuario
FOREIGN KEY (usuario_id)
REFERENCE' at line 12
SQL Code:
CREATE TABLE IF NOT EXISTS dashboard_jr.telefone (
id INT(11) NOT NULL AUTO_INCREMENT,
ddd INT(2) NOT NULL,
telefone INT(9) NOT NULL,
operadora VARCHAR(45) NOT NULL,
tipo ENUM('f', 'm') NOT NULL,
status ENUM('a', 'i') NOT NULL,
usuario_id INT(11) NOT NULL,
created DATETIME NOT NULL,
modified DATETIME NULL DEFAULT NULL,
PRIMARY KEY (id),
INDEX fk_telefone_usuario_idx (usuario_id ASC) VISIBLE,
CONSTRAINT fk_telefone_usuario
FOREIGN KEY (usuario_id)
REFERENCES dashboard_jr.usuario (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB

The komma immediately before CONSTRAINT

Related

How do I remove the error in the workbench? [duplicate]

This question already has answers here:
MySQL Workbench: Error in query (1064): Syntax error near 'VISIBLE' at line 1
(3 answers)
Closed 3 years ago.
Executing SQL script in server
ERROR: 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 ')
ENGINE = InnoDB' at line 10
SQL Code:
-- -----------------------------------------------------
-- Table `limpieza_es`.`datos_comun`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `limpieza_es`.`datos_comun` (
`Nombre` VARCHAR(45) NOT NULL,
`Email` VARCHAR(45) NOT NULL,
`Mensaje` TEXT NOT NULL,
`Tel` INT(11) NOT NULL,
PRIMARY KEY (`Email`),
UNIQUE INDEX `Tel` (`Tel` ASC) VISIBLE)
ENGINE = InnoDB
Visible is not known in Mariadb invisible does, but even this you cannot use at that position.
So make simple
CREATE TABLE IF NOT EXISTS `limpieza_es`.`datos_comun` (
`Nombre` VARCHAR(45) NOT NULL,
`Email` VARCHAR(45) NOT NULL,
`Mensaje` TEXT NOT NULL,
`Tel` INT(11) NOT NULL,
PRIMARY KEY (`Email`),
UNIQUE INDEX `Tel` (`Tel` ASC) )
ENGINE = InnoDB
here the link to Mariadb and invisible columns https://mariadb.com/kb/en/library/invisible-columns/

ERROR TO CREATE TABLE IN MYSQL

I'm trying to create this table in SQL,
CREATE TABLE `online_status` (
`fk_user_id` int(10) unsigned NOT NULL default '0',
`last_activity` timestamp(14) NOT NULL,
PRIMARY KEY (`fk_user_id`)
) ENGINE=MyISAM;
but is returning this 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 '(14) NOT NULL,
PRIMARY KEY (fk_user_id)
) ENGINE=MyISAM' at line 3
I've changed the commas, but the error continues. Can you help me on what is wrong?
`last_activity` timestamp(14) NOT NULL,
should be
`last_activity` timestamp NOT NULL,

Syntax error when running a MySQL CREATE TABLE statement [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
CREATE TABLE users (
user_id INT(8) NOT NULL AUTO_INCREMENT,
user_name VARCHAR(30) NOT NULL,
user_pass VARCHAR(255) NOT NULL,
user_email VARCHAR(255) NOT NULL,
user_date DATETIME NOT NULL,
user_level INT(8) NOT NULL,
UNIQUE INDEX user_name_unique (user_name),
PRIMARY KEY (user_id)
) TYPE=INNODB;
When running this query on the SQL server, I am getting the following 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 'TYPE=INNODB' at line 10
Any help on why this is coming up?
Instead of
TYPE=INNODB
set
Engine=InnoDB
Use ENGINE=InnoDB;
http://dev.mysql.com/doc/refman/5.0/en/using-innodb-tables.html
The manual for CREATE TABLE doesn't include TYPE; it seems to use:
ENGINE = INNODB;
And that is the default engine, so you don't really need to specify it.
Try the following query:
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(8) NOT NULL AUTO_INCREMENT,
`user_name` varchar(30) NOT NULL,
`user_pass` varchar(255) NOT NULL,
`user_email` varchar(255) NOT NULL,
`user_date` datetime NOT NULL,
`user_level` int(8) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_name_unique` (`user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

MySQL statement syntax

I'm experiencing problems with this MySQL statement:
CREATE TABLE Articoli (Cod_Articolo char(10) NOT NULL,
Des_Articolo varchar(50) NOT NULL,
Cat_Articolo char(2) NOT NULL,
Ubi_Articolo char(6) NOT NULL,
PRIMARY KEY (Cod_Articolo)
FOREIGN KEY (Cat_Articolo) REFERENCES Categorie(Cod_Categoria) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB;
I get 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 'FOREIGN KEY
(Cat_Articolo) REFERENCES Categorie(Cod_Categoria) ON DELETE NO ACTI' at line 6
I don't see why...
Thanks, Mauro
You are missing a comma here:
PRIMARY KEY (Cod_Articolo)
Try this:
CREATE TABLE Articoli (Cod_Articolo char(10) NOT NULL,
Des_Articolo varchar(50) NOT NULL,
Cat_Articolo char(2) NOT NULL,
Ubi_Articolo char(6) NOT NULL,
PRIMARY KEY (Cod_Articolo),
FOREIGN KEY (Cat_Articolo) REFERENCES Categorie(Cod_Categoria) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB;

Syntax error trying to insert an SQL clause [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
I'm getting this error:
CREATE TABLE `libro`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`autor_id` INTEGER(11),
`titulo` VARCHAR(255),
`paginas` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`),
INDEX `libro_FI_1` (`autor_id`),
CONSTRAINT `libro_FK_1`
FOREIGN KEY (`autor_id`)
REFERENCES `autor` (`id`)
)Type=InnoDB
[propel-sql-exec] SQLSTATE[42000]: Syntax error or access violation: 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 'Type=InnoDB' at line 12
Any idea?
Regards
Javi
Shouldn't it be ENGINE=InnoDB?
Use ENGINE instead of Type
CREATE TABLE `libro`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`autor_id` INTEGER(11),
`titulo` VARCHAR(255),
`paginas` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`),
INDEX `libro_FI_1` (`autor_id`),
CONSTRAINT `libro_FK_1`
FOREIGN KEY (`autor_id`)
REFERENCES `autor` (`id`)
)ENGINE=InnoDB