This database.sql not working correctly? - mysql

I'm trying to get this to work but I don't understand how SQL works outside of the basics. Can you find the error in this?
CREATE TABLE lil_urls (
id varchar(255) NOT NULL default '',
url text,
date timestamp(14) NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
I'm currently getting this error in PhPMyAdmin:
#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 (id)' at line 4
Thanks for your help!

Correct syntax is
CREATE TABLE lil_urls (
id varchar(255) NOT NULL default '',
url text,
date timestamp NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM;
TYPE is no longer used and you need to use as ENGINE
And no need to specify length for timestamp

Related

Generated SQL script from workbench doesn`t work on MariaDB server

I created a scheme in mysql workbench and exported this scheme into SQL code.
.
When I want to generate table user on my server I am getting error.
Script:
CREATE TABLE IF NOT EXISTS 'user' (
'id' INT NOT NULL AUTO_INCREMENT,
'registerDate' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'login' VARCHAR(255) NOT NULL,
'password' VARCHAR(255) NOT NULL,
'status' TINYINT NOT NULL,
'credits' INT NOT NULL DEFAULT 0,
PRIMARY KEY ('id'),
UNIQUE INDEX 'login_UNIQUE' ('login' ASC) VISIBLE)
ENGINE = InnoDB;
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 ''user' ( 'id' INT NOT NULL AUTO_INCREMENT, 'registerDate' TIMESTAMP NOT NU' at line 1
I dont understand where is an error? I didnt see anything wrong.
Version on server: 10.1.32-MariaDB

MySQL Workbench schema synchronization causing error 1064

I'm using MySQL Workbench to try to create a schema for my database. When I try to sync it up to the server, I'm getting an error 1064. Here's the full log:
Executing SQL script in server
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 'VISIBLE,
PRIMARY KEY (`id`),
CONSTRAINT `buildings_rel`
FOREIGN KEY (`bu' at line 10
SQL Code:
CREATE TABLE IF NOT EXISTS `rentals`.`apartments` (
`beds` INT(11) NOT NULL,
`baths` INT(11) NOT NULL,
`area` INT(11) NOT NULL,
`price_min` INT(11) NOT NULL,
`price_max` INT(11) NOT NULL,
`available_now` BIT(1) NOT NULL,
`building_id` INT(11) NULL DEFAULT NULL,
`id` INT(11) NOT NULL AUTO_INCREMENT,
INDEX `buildings_rel_idx` (`building_id` ASC) VISIBLE,
PRIMARY KEY (`id`),
CONSTRAINT `buildings_rel`
FOREIGN KEY (`building_id`)
REFERENCES `rentals`.`buildings` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
I don't really know SQL so I'm having trouble figuring out what exactly is wrong here. I expected the Workbench to create correct code, I'm a little surprised that it seems to be this glitchy. Any help appreciated, thank you.
Got it! As some of the commentors said, I had to set a different target version in the MySQL Workbench settings. Thanks!
Change the Default Target MySQL Version to match your mysql version.
Home -> Edit -> Preferences -> Modeling -> MySQL -> Default Target MySQL Version

MySQL: SQL Syntax and other errors only in Linux server

Please have a look in below SQL code
DROP TABLE IF EXISTS `xxx`.`reminder` ;
CREATE TABLE IF NOT EXISTS `xxx`.`reminder` (
`idreminder` INT NOT NULL AUTO_INCREMENT,
`patient_idpatient` INT NOT NULL,
`remind_about` TEXT NOT NULL,
`reminder_time` TIME NOT NULL,
`reminder_date` DATE NOT NULL,
`active` TINYINT(1) NOT NULL,
`repeat_action` TINYINT(1) NOT NULL,
`date_created` TIMESTAMP NULL,
`last_updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`idreminder`),
INDEX `fk_Reminder_patient1_idx` (`patient_idpatient` ASC),
CONSTRAINT `fk_Reminder_patient1`
FOREIGN KEY (`patient_idpatient`)
REFERENCES `myglukose`.`patient` (`idpatient`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB;
When I copy this into PhpMyAdmin, I get 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 '`
I have 2 questions.
I really don't spot the error, what is it?
Important thing is that these auto generated SQL code from MySQL Work Bench!! All of these worked very well in Windows with XAMPP and all these issues are with Ubuntu running LAMP.Not only this error,in some tables I am also getting the error #1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Why all of this with Ubuntu (14.04)? I installed LAMP by following this - http://devoncmather.com/setting-aws-ec2-instance-lamp-git/
How to fix this, if any issue with installation, any recommended alternate tutorial?

PhPMyAdmin Error #1064; Syntax Error

I'm trying to put together a MySQL database for a forum, And when I try to make a section table I keep encountering a problem
#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 7
Here's the code:
CREATE TABLE sections (
sect_id INT(8) NOT NULL AUTO_INCREMENT,
sect_name VARCHAR(255) NOT NULL,
sect_desc VARCHAR(255) NOT NULL,
UNIQUE INDEX sect_name_unique (sect_name),
PRIMARY KEY (sect_id)
) TYPE=INNODB;
Use the following query
CREATE TABLE IF NOT EXISTS sections (
sect_id INT(8) NOT NULL AUTO_INCREMENT,
sect_name VARCHAR(255) NOT NULL,
sect_desc VARCHAR(255) NOT NULL,
UNIQUE INDEX sect_name_unique (sect_name),
PRIMARY KEY (sect_id)
) ENGINE=InnoDB
To mention the type of engine use ENGINE keyword.

Error creating MySQL table

I get an error when running the following create table:
CREATE TABLE Event (
id VARCHAR(10) NOT NULL,
title VARCHAR(100),
start_date DATE NOT NULL,
end_date DATE,
description TEXT,
url VARCHAR(200),
website VARCHAR(200),
location VARCHAR(32) NOT NULL;
PRIMARY KEY (id),
FOREIGN KEY (location) REFERENCES Location(id)
);
The error I get is this:
#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 9
I know that this error has to do with incompatibility with the syntax and the mysql version running, but I've checked every line and the syntax is correct according to the documentation. Am I missing something?
Thanks in advance for all your answers.
Try changing the semicolon on line:
location VARCHAR(32) NOT NULL;
to a comma.