phpMyAdmin: #1064 - SQL syntax when creating a new table - mysql

I've wanted to build a new table in my database using the phpMyAdmin build-in feature but after I complete all the fields and hit Go - this error occurs:
#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, `data` DATETIME NOT NULL , `link_picture` VARCHAR( 250 ) NOT NULL , ' at line 6
..and I have no ideea why.
Here's the SQL code:
CREATE TABLE `prod`.`info_prod` (
`id` INT( 100 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`prod_name` VARCHAR( 250 ) NOT NULL ,
`link_prod` VARCHAR( 250 ) NOT NULL ,
`pd` VARCHAR( 10 ) NOT NULL ,
`price` DOUBLE( 250 ) NOT NULL ,
`data` DATETIME NOT NULL ,
`link_picture` VARCHAR( 250 ) NOT NULL ,
`link_picture2` VARCHAR( 250 ) NOT NULL ,
INDEX ( `pd` ) ,
UNIQUE (
`prod_name`
)
) ENGINE = INNODB;
What is the problem with this code?

It seems like it's just the syntax.
`price` DOUBLE( 250,0 ) NOT NULL
Reference

Related

I have exported a Mysql Database, and am having syntax issues importing to a newer version

I am trying to import a Mysql DB into a new instance on an updated domain. I am getting the below syntax error, I cant work out what is wrong and everythig I try isnt working.
can you help?
SQL query:
--
-- Database: 'pringlerfe'
-- -- --------------------------------------------------------
--
-- Table structure for table `adverts`
--
CREATE TABLE `adverts` (
`advers_id` INT( 11 ) NOT NULL ,
`advers_name` VARCHAR( 50 ) DEFAULT NULL ,
`advers_sqimg` VARCHAR( 50 ) DEFAULT NULL ,
`advers_squrl` VARCHAR( 100 ) DEFAULT NULL ,
`advers_towerimg` VARCHAR( 50 ) DEFAULT NULL ,
`advers_url` VARCHAR( 100 ) DEFAULT NULL ,
`advers_des` VARCHAR( 100 ) DEFAULT NULL ,
`advers_display` VARCHAR( 50 ) DEFAULT NULL
) ENGINE = MYISAM DEFAULT CHARSET = latin1;
MySQL said: Documentation
#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 '
--
-- Table struc' at line 3 `
CREATE TABLE adverts (
advers_id int NOT NULL,
advers_name varchar( 50 ) DEFAULT NULL,
advers_sqimg VARCHAR( 50 ) DEFAULT NULL,
advers_squrl VARCHAR( 100 ) DEFAULT NULL,
advers_towerimg VARCHAR( 50 ) DEFAULT NULL,
advers_url VARCHAR( 100 ) DEFAULT NULL,
advers_des VARCHAR( 100 ) DEFAULT NULL,
advers_display VARCHAR( 50 ) DEFAULT NULL
);

#1064 MySQL error on webhost

I am getting the following error on MySQL:
#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 '(6) NOT NULL,
`Modified` datetime(6) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHA' at line 14
I have a SQL script that creates a database and some tables. It uploads perfectly on my localhost but when I import it on my web host using phpmyadmin it gives the above errror.
The code it highlights from the script is:
CREATE TABLE IF NOT EXISTS `dbo_countries` (
`CountryId` INT( 11 ) NOT NULL ,
`Code` VARCHAR( 50 ) DEFAULT NULL ,
`ISO2` VARCHAR( 10 ) DEFAULT NULL ,
`ISO3` VARCHAR( 10 ) DEFAULT NULL ,
`RegionId` INT( 11 ) DEFAULT NULL ,
`Name` VARCHAR( 255 ) DEFAULT NULL ,
`Created` DATETIME( 6 ) NOT NULL ,
`Modified` DATETIME( 6 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8 AUTO_INCREMENT =243;
The MySQL DATETIME datatype doesn't accept a length, size, digit specifier. The error is being thrown because it's a syntax violation.
To declare a DATETIME column, do it like this, without any following parens:
`Created` DATETIME NOT NULL

How do I eliminate error message 1064 when trying to create table with BLOB type columns?

I keep getting an error for this table. I've never created a table using blob's before so I do not understand the error message. Can someone explain the error?
CREATE TABLE `teamc`.`newsletter` (
`title` VARCHAR( 100 ) NOT NULL ,
`subtitle` VARCHAR( 100 ) NOT NULL ,
`date` DATE NOT NULL ,
`jpg` BLOB BINARY NULL DEFAULT NULL ,
`pdf` BLOB BINARY NULL DEFAULT NULL ,
PRIMARY KEY ( `title` , `date` )
) ENGINE = InnoDB;
MySQL gives me the following error:
Documentation 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 'BINARY NULL DEFAULT NULL, pdf BLOB BINARY NULL DEFAULT NULL, PRIMARY KEY (`tit' at line 1
BINARY is a type, BLOB is a type - and you cannot specify multiple types for the same column. You pick one:
CREATE TABLE `newsletter` (
`title` VARCHAR( 100 ) NOT NULL ,
`subtitle` VARCHAR( 100 ) NOT NULL ,
`date` DATE NOT NULL ,
`jpg` BLOB NULL DEFAULT NULL ,
`pdf` BLOB NULL DEFAULT NULL ,
PRIMARY KEY ( `title` , `date` )
) ENGINE = InnoDB;

mysql 1064 error ou have an error in your SQL syntax;

creating a table in phpmyadmin it shows following error![enter image description here][1]
Error
SQL query:
CREATE TABLE `user` (
`usrID` BIGINT( 11 ) NOT NULL ,
`name` VARCHAR( 100 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`mobile` VARCHAR( 10 ) NOT NULL ,
`gender` CHAR( 10 ) NOT NULL ,
`countryID` INT( 11 ) NULL ,
`stateID` INT( 11 ) NULL ,
`cityID` INT( 11 ) NULL ,
`pincode` VARCHAR( 6 ) NULL ,
`place` VARCHAR( 100 ) NULL ,
`address` VARCHAR( 200 ) NULL ,
`usertype` VARCHAR( 5 ) NULL ,
`pass` VARCHAR( 20 ) NULL ,
`edate` DATETIME NULL ,
`eusrID` INT( 11 ) NULL ,
`busrID` INT( 11 ) NULL ,
`adminID` INT( 11 ) NULL ,
`active` SET( 1 ) NOT NULL
) ENGINE = innodb
MySQL said: Documentation
#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 '1) NOT NULL) ENGINE = innodb' at line 1
The value of 1 should be wrap with single quote. See here for details.
`active` SET( '1' ) NOT NULL
SQLFiddle Demo
SET takes a number of possible string values for the column, for example;
`color` SET('red', 'green', 'blue')
This would mean that the column could have the values 'red', 'red,blue', 'red,green,blue' etc.
Your definition;
`active` SET(1)
doesn't really make any sense. Either you're looking for a boolean flag (INT(1)) or you need to list the possible values the field can have. Note that SET('yes','no') would allow all of the values 'yes', 'no' and 'yes,no' (the combination), which may not be the best choice for an active flag.

SQL syntax error when creating new table in MySQL

I wont to create sql tables but I receive 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
'CREATE TABLE `articles_ratings` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `a' at line 10
CREATE TABLE `articles` (
`ID` int( 11 ) NOT NULL AUTO_INCREMENT ,
`a_title` varchar( 255 ) ,
`a_subtitle` tinytext,
`a_content` text,
PRIMARY KEY ( `ID` )
)
CREATE TABLE `articles_ratings` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`article_id` int( 11 ) NOT NULL ,
`rating_value` tinyint( 2 ) NOT NULL ,
`rater_ip` varchar( 20 ) NOT NULL ,
)
Add the primary key to your articles ratings statement or remove the last comma.
CREATE TABLE articles (
ID int( 11 ) NOT NULL AUTO_INCREMENT ,
a_title varchar( 255 ) ,
a_subtitle tinytext,
a_content text,
PRIMARY KEY ( ID )
);
CREATE TABLE articles_ratings (
ID INT( 11 ) NOT NULL AUTO_INCREMENT ,
article_id int( 11 ) NOT NULL ,
rating_value tinyint( 2 ) NOT NULL ,
rater_ip varchar( 20 ) NOT NULL ,
PRIMARY KEY ( ID )
);