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 )
);
Related
mysql query
CREATE TABLE IF NOT EXISTS 'sadakin'.'gcm_users' (
'id' int( 11 ) NOT NULL AUTO_INCREMENT ,
'gcm_regid' text,
'name' varchar( 50 ) NOT NULL ,
'email' varchar( 255 ) NOT NULL ,
'imei' varchar( 20 ) NOT NULL ,
'created_at' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( 'id' ) ,
KEY 'imei' ( 'imei' )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
Error message:
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 ''sadakin'.'gcm_users' (
'id' int( 11 ) NOT NULL AUTO_INCREMENT ,
'gcm_' at line 1
I don't find error. Help me!
Use backticks to enclose identifiers. Quotes are just for strings:
CREATE TABLE IF NOT EXISTS `sadakin`.`gcm_users` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`gcm_regid` text,
`name` varchar( 50 ) NOT NULL ,
`email` varchar( 255 ) NOT NULL ,
`imei` varchar( 20 ) NOT NULL ,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `id` ) ,
KEY `imei` ( `imei` )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
There is no need of any single quotes on column names
CREATE TABLE IF NOT EXISTS sadakin.gcm_users (
id int( 11 ) NOT NULL AUTO_INCREMENT ,
gcm_regid text,
name varchar( 50 ) NOT NULL ,
email varchar( 255 ) NOT NULL ,
imei varchar( 20 ) NOT NULL ,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( id ) ,
KEY imei ( imei )
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
You have to use back-ticks instead of single quotes. Quotes are used for string literals.
Check this: http://dev.mysql.com/doc/refman/5.0/en/string-literals.html
A string is a sequence of bytes or characters, enclosed within either
single quote (“'”) or double quote (“"”)
Try:
CREATE TABLE IF NOT EXISTS `sadakin`.`gcm_users` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`gcm_regid` TEXT,
`name` VARCHAR( 50 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`imei` VARCHAR( 20 ) NOT NULL ,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `id` ) ,
KEY `imei` ( `imei` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
I cant get this syntax 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 '(id) ENGINE=MyISAM)' at line 15
CREATE TABLE IF NOT EXISTS `destination_cdr` (
`id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
`calldate` DATETIME NOT NULL ,
`source` VARCHAR( 80 ) NOT NULL ,
`destination` VARCHAR( 80 ) NOT NULL ,
`account_code` VARCHAR( 30 ) DEFAULT NULL ,
`pincode` VARCHAR( 45 ) NOT NULL ,
`duration_call` BIGINT( 20 ) NOT NULL DEFAULT '0',
`duration_talk` BIGINT( 20 ) NOT NULL ,
`disposition` VARCHAR( 255 ) NOT NULL ,
`clid` VARCHAR( 80 ) DEFAULT NULL ,
`cdr_id` BIGINT( 20 ) DEFAULT NULL ,
`vxcdr_id` BIGINT( 20 ) DEFAULT NULL ,
`provider` INT( 11 ) NOT NULL DEFAULT '0' PRIMARY KEY ( `id` )) ENGINE = MYISAM
;
You need a commma between provider and primary Key:
`provider` INT( 11 ) NOT NULL DEFAULT '0', PRIMARY KEY ( `id` )) ENGINE = MYISAM
Missing comma before primary key clause.
`provider` INT( 11 ) NOT NULL DEFAULT '0', PRIMARY KEY ( `id` ))
Error
SQL query:
--
-- Database: wadud
--
-- Table structure for table destination
CREATE TABLE destination (
id bigint(20) NOT NULL,
country varchar(255) NOT NULL,
photo text NOT NULL,
tours varchar(255) NOT NULL,
created_at timestamp NULL DEFAULT NULL,
updated_at timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL said: Documentation
1050 - Table 'destination' already exists
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
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.
This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
I am getting the following error whenever I want to create a table in 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 '( 32 ) NOT NULL DEFAULT CURRENT_TIMESTAMP , `visitor_day` SMALLINT( 2 ) NOT NUL' at line 7
code:
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP( 32 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) TYPE = MYISAM ;
Couple of errors fixed here:
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) ENGINE = MYISAM ;
TIMESTAMP does not support precision. Not until MySQL 5.6, that is, where sub-second resolution is possible.
Remove the ( 32 ) from the TIMESTAMP definition.
TIMESTAMP does not have a size and you should use engine instead of type
CREATE TABLE `visitors_table` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visitor_ip` VARCHAR( 32 ) NULL ,
`visitor_browser` VARCHAR( 255 ) NULL ,
`visitor_hour` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT( 2 ) NOT NULL DEFAULT '00',
`visitor_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`visitor_day` SMALLINT( 2 ) NOT NULL ,
`visitor_month` SMALLINT( 2 ) NOT NULL ,
`visitor_year` SMALLINT( 4 ) NOT NULL ,
`visitor_refferer` VARCHAR( 255 ) NULL ,
`visitor_page` VARCHAR( 255 ) NULL
) engine = MYISAM ;