Im trying to create a table with this code:
CREATE TABLE IF NOT EXISTS `entries` (
`id` int(10) NOT NULL auto_increment,
`atom_id` varchar(512) NOT NULL,
`title` varchar(256) NOT NULL,
`author` varchar(128) NOT NULL,
`link` varchar(512) NOT NULL,
`content` longtext NOT NULL,
`updated` varchar(25) NOT NULL,
`inserted` varchar(25) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `atom_id` (`atom_id`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `topics` (
`id` int(10) NOT NULL auto_increment,
`status` varchar(32) NOT NULL,
`hub` varchar(512) NOT NULL,
`topic` varchar(512) NOT NULL,
`lease` varchar(25) NOT NULL,
`secret` varchar(256) NOT NULL,
`token` varchar(40) NOT NULL,
`date` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
but i got 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=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1' at line 12
I can't figure what's going on, any advice?
Remove the comma after UNIQUE KEY 'atom_id' ('atom_id'), in line 11
UNIQUE KEY `atom_id` (`atom_id`),
^
Try losing the ","
Related
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double(11) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
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 ') NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT
CHARSET=latin1 AUTO_INCRE' at line 5
try using float without the number of showing digit
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
and for price could be you need a fixed decimal length so you should use decimal
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` decimal(10,2) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
You're missing a value in your double specifier:
`price` double(11) NOT NULL
It needs both the total digits and the digits following the decimal. Something like:
`price` double(11,2) NOT NULL
Though for currency values you may be better off using decimal instead:
`price` decimal(11,2) NOT NULL
As this uses a more fixed precision. Using a double may result in unexpected calculation results from how floating point arithmetic works.
my create table code is
CREATE TABLE IF NOT EXISTS `current_sabhay` (
`current_id` int(11) NOT NULL AUTO_INCREMENT,
`year_id` int(11) NOT NULL,
`parment_id` int(11) NOT NULL,
`photo` varchar(225) NOT NULL,
`desc` varchar(225) CHARACTER SET utf32 COLLATE utf32_croatian_ci NOT NULL,
PRIMARY KEY (`current_id`,`parment_id`),
KEY `year_id` (`year_id`),
KEY `current_sabhay_ibfk_2` (`parment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
I'm sort of confused here, what is wrong with my syntax?
CREATE TABLE `users` (
`userId` int(7) NOT NULL AUTO_INCREMENT,
`firstName` varchar(30) NOT NULL,
`lastName` varchar(30) NOT NULL,
`gender` varchar(1) NOT NULL,
`birthday` datetime NOT NULL,
`city` varchar(20) NOT NULL,
`province` varchar(20) NOT NULL,
`postalCode` varchar(6) NOT NULL,
`country` varchar(20) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(32) NOT NULL,
`bio` text NOT NULL,
`active` int(1) NOT NULL DEFAULT(0),
PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
This was auto generated from an SQL export. It gives 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 '(0), PRIMARY KEY (userId) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCR' at line 14
Specifying the default value is wrong.There is no need of braces
Replace
`active` int(1) NOT NULL DEFAULT (0),
with
`active` int(1) NOT NULL DEFAULT 0,
I've just exported the CREATE sql of a singular table using phpmyadmin. this is the result:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`register_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`account_type` int(11) NOT NULL,
`active` int(11) NOT NULL,
`email` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`login` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
But when i run this code on the very phpmyadmin i receive 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 '(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREME' at line 14
I have tried many ways, but my skills aren't enough.
You forgot to add comma before PRIMARY KEY (id)
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL, -- <== this
PRIMARY KEY (`id`)
add comma and it will work, see this fiddle (click link)
I have spent the past week mulling over this single MySQL document with no luck as to figuring out what/where the error is that's stopping it from properly installing it's self so I can have the chat system it's for up and running. I would go to the developer but he's essentially been unresponsive for over a year now so I have given up on help from him. The error I am getting upon trying to install it is the following :
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, userid int(11) default NULL, >banneduserid int(11) default NULL, r' at line 1
The MySQL file reads as follows :
#--------------------------------------------------------------------------
# Table structure for table `bans`
#--------------------------------------------------------------------------
CREATE TABLE `bans` (
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`banneduserid` int(11) default NULL,
`roomid` int(11) default NULL,
`ip` varchar(16) default NULL,
KEY `userid` (`userid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `connections`
#--------------------------------------------------------------------------
CREATE TABLE `connections` (
`id` varchar(32) NOT NULL default '',
`updated` timestamp(14) NOT NULL,
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`roomid` int(11) default NULL,
`state` tinyint(4) NOT NULL default '1',
`color` int(11) default NULL,
`start` int(11) default NULL,
`lang` char(2) default NULL,
`ip` varchar(16) default NULL,
`tzoffset` int(11) default '0',
`chatid` int(11) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `userid` (`userid`),
KEY `roomid` (`roomid`),
KEY `updated` (`updated`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `ignors`
#--------------------------------------------------------------------------
CREATE TABLE `ignors` (
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`ignoreduserid` int(11) default NULL,
KEY `userid` (`userid`),
KEY `ignoreduserid` (`ignoreduserid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `messages`
#--------------------------------------------------------------------------
CREATE TABLE `messages` (
`id` int(11) NOT NULL auto_increment,
`created` timestamp(14) NOT NULL,
`toconnid` varchar(32) default NULL,
`touserid` int(11) default NULL,
`toroomid` int(11) default NULL,
`command` varchar(255) NOT NULL default '',
`userid` int(11) default NULL,
`roomid` int(11) default NULL,
`txt` text,
PRIMARY KEY (`id`),
KEY `touserid` (`touserid`),
KEY `toroomid` (`toroomid`),
KEY `toconnid` (`toconnid`),
KEY `created` (`created`)
) ENGINE=MyISAM AUTO_INCREMENT=14 ;
#--------------------------------------------------------------------------
# Table structure for table `rooms`
#--------------------------------------------------------------------------
CREATE TABLE `rooms` (
`id` int(11) NOT NULL auto_increment,
`updated` timestamp(14) NOT NULL,
`created` timestamp(14) NOT NULL,
`name` varchar(64) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`ispublic` char(1) default NULL,
`ispermanent` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `ispublic` (`ispublic`),
KEY `ispermanent` (`ispermanent`),
KEY `updated` (`updated`)
) ENGINE=MyISAM AUTO_INCREMENT=5 ;
#--------------------------------------------------------------------------
# Table structure for table `users`
#--------------------------------------------------------------------------
CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`login` varchar(32) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`roles` int(11) NOT NULL default '0',
`profile` text,
PRIMARY KEY (`id`),
KEY `login` (`login`)
) ENGINE=MyISAM AUTO_INCREMENT=2 ;
My guess is that there is an older call/request that is out dated and no longer used for the version of MySQL I have installed on my host ( Version : 5.5.19 ). I really appreciate any help I can get with this so I can finally stop running off of a flat file ( the other install option this thing has ) and integrate it into my CMS. Thank you for your time!
-Reiz
Remove the (14) from all your timestamp types like that
... column_name timestamp NOT NULL ...
In MySQL versions after 4.1 the timestamp datatype has no properties added in brackets.
MySQL Docu 4.1
MySQL Docu 5.1
So in your case just drop the (14) after all appearances of timestamp in the sql. So, e.g., change this
`created` timestamp(14) NOT NULL,
to this
`created` timestamp NOT NULL,