How do I remove the error in the workbench? [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 ')
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/

Related

Erro 1064 mysql erro [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 '
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

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,

error when creating table SQL

I'm trying to create a table in my gym_system database. Here is the code I'm using:
CREATE TABLE `Gym_System`.`login` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(30) NOT NULL,
`password` CHAR(128) NOT NULL,
) ENGINE = InnoDB;
However, I keep getting 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 ') ENGINE = InnoDB' at line 5
Can anyone see why?
Remove the last comma
CREATE TABLE `login` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(30) NOT NULL,
`password` CHAR(128) NOT NULL
) ENGINE = InnoDB;
See fiddle demo

Error 1064 <42000> on mysql when i'm trying to create table

CREATE TABLE `photos` (
`title` varchar(255) not null,
`id` int(11) not null,
`ph_path` varchar(255) not null,
`description` varchar(255) not null,
`privilange` varchar(20) not null,
`owner` varchar(60) not null,
`provoles` int(11),
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=greek;
I'm getting error 1064 <4200> and I'm not sure what is wrong.
You have a trailing comma in the primary key:
PRIMARY KEY (`id`), <--- remove that
The full error would read something like:
check the manual that corresponds to your MySQL server version for the right syntax to use near ') ENGINE=InnoDB
In MySQL, the position pointed to by the error message (near ')ENGINE) will show you the character immediately after where the error occurred. Look to the previous thing in your statement and you'll find your syntax error.
You will have to remove the comma after PRIMARY KEY (`id`).

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 ;