Table Creation Error [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Looking to fix the syntax error
Error Message:
force int(9) NOT NULL default '0', perm tinyint(1) NOT NULL default
'0', act' at line 11
My Table Syntax:
CREATE TABLE `ttp_sites` (
siteid int( 4 ) NOT NULL AUTO_INCREMENT ,
wname char( 64 ) NOT NULL default '',
email char( 64 ) NOT NULL default '',
siteurl char( 255 ) NOT NULL default '',
sitename char( 128 ) NOT NULL default '',
furl char( 255 ) NOT NULL default '',
icqnumb char( 20 ) default '',
icqname char( 20 ) default '',
sent int( 9 ) NOT NULL default '0',
FORCE int( 9 ) NOT NULL default '0',
perm tinyint( 1 ) NOT NULL default '0',
active tinyint( 1 ) NOT NULL default '0',
manage_type tinyint( 1 ) NOT NULL default '0',
send_ratio int( 4 ) NOT NULL default '0',
PRIMARY KEY ( siteid ) ,
KEY siteurl( siteurl ) ,
KEY sitename( sitename ) ,
KEY active( active )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;

The issue with your code is you have used a reserved keyword FORCE , you can use the reserve keyword to create a table column name is by giving the name within single quotes which takes the keyword as a name.
CREATE TABLE `ttp_sites` (
siteid int( 4 ) NOT NULL AUTO_INCREMENT ,
wname char( 64 ) NOT NULL default '',
email char( 64 ) NOT NULL default '',
siteurl char( 255 ) NOT NULL default '',
sitename char( 128 ) NOT NULL default '',
furl char( 255 ) NOT NULL default '',
icqnumb char( 20 ) default '',
icqname char( 20 ) default '',
sent int( 9 ) NOT NULL default '0',
`FORCE` int( 9 ) NOT NULL default '0',
perm tinyint( 1 ) NOT NULL default '0',
active tinyint( 1 ) NOT NULL default '0',
manage_type tinyint( 1 ) NOT NULL default '0',
send_ratio int( 4 ) NOT NULL default '0',
PRIMARY KEY ( siteid ) ,
KEY siteurl( siteurl ) ,
KEY sitename( sitename ) ,
KEY active( active )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
Sql Fiddle
P.s : Don't use keyword for naming a column.
Updated Query of your's in the comment
CREATE TABLE ttp_traffic
( siteid int(4) NOT NULL default '0',
ipaddr char(25) NOT NULL default '',
click int(3) NOT NULL default '0',
prox int(1) NOT NULL default '0',
refer char(255) NOT NULL default '',
datev timestamp NOT NULL,
KEY siteid (siteid),
KEY datev (datev),
KEY click (click),
KEY ipaddr (ipaddr) )ENGINE = MYISAM;
Timestamp should not have datatype size that was the error in your code
SQl Fiddle

Related

Database not importing

Error
##
--
-- Database: verticalned
-- --------------------------------------------------------
-- Table structure for table announcements
CREATE TABLE `announcements` (
`id` INT( 10 ) NOT NULL ,
`description` VARCHAR( 6000 ) DEFAULT NULL ,
`links` VARCHAR( 100 ) DEFAULT NULL ,
`first` TINYINT( 1 ) DEFAULT > NULL ,
`second` TINYINT( 1 ) DEFAULT NULL ,
`third` TINYINT( 1 ) DEFAULT NULL ,
`fourth` TINYINT( 1 ) DEFAULT NULL ,
`staff` VARCHAR( 22 ) DEFAULT NULL ,
`time` DATETIME( 2 ) DEFAULT NULL ,
`subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB 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 '(2) DEFAULT NULL, subject varchar(100) DEFAULT NULL )
ENGINE=InnoDB DEFAULT ' at line 20
version
Looks like the mysql version you are using (probably older than 5.6.4) does not accept precision (fractional seconds). You can bypass the issue by replacing ..., time DATETIME(2) DEFAULT NULL ,... with ... , time DATETIME DEFAULT NULL ,....
However, you should solve the issue by either changing the data type to timestamp or upgrading MySQL server to a version later than 5.6.4
CREATE TABLE `announcements` (
`id` INT(10) NOT NULL,
`description` VARCHAR(6000) DEFAULT NULL,
`links` VARCHAR(100) DEFAULT NULL,
`first` TINYINT( 1 ) DEFAULT NULL ,
`second` TINYINT( 1 ) DEFAULT NULL ,
`third` TINYINT( 1 ) DEFAULT NULL ,
`fourth` TINYINT( 1 ) DEFAULT NULL ,
`staff` VARCHAR( 22 ) DEFAULT NULL ,
`time` DATETIME( 2 ) DEFAULT NULL ,
`subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
obvoiusly theres nothing wrongn with your code. just add the slanted quotes
CREATE TABLE announcements (
id INT NOT NULL ,
description VARCHAR( 6000 ) DEFAULT NULL ,
links VARCHAR( 100 ) DEFAULT NULL ,
firstTINYINT DEFAULT NULL ,
secondTINYINT DEFAULT NULL,
thirdTINYINT DEFAULT NULL ,
fourthTINYINT DEFAULT NULL,
staffVARCHAR(22) DEFAULT NULL ,
timeDATETIME DEFAULT NULL ,
subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
Please remove character number from INT and TINYINT, and add the slanted quotes your code should work.

error upload .sql file of wordpress site

this is the 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 'AS ical subscribe access key,
created_on datetime DEFAULT NULL,
`updated' at line 20
Erreur
requĂȘte SQL:
-- --------------------------------------------------------
--
-- Structure de la table `pec_calendars`
--
CREATE TABLE `pec_calendars` (
`id` INT( 11 ) UNSIGNED NOT NULL ,
`type` ENUM( 'user', 'group', 'url' ) DEFAULT 'user',
`user_id` INT( 11 ) UNSIGNED DEFAULT NULL ,
`name` VARCHAR( 100 ) DEFAULT NULL ,
`description` TEXT,
`color` VARCHAR( 7 ) DEFAULT NULL ,
`admin_id` INT( 11 ) DEFAULT NULL ,
`status` ENUM( 'on', 'off' ) DEFAULT 'on',
`show_in_list` ENUM( '0', '1' ) DEFAULT NULL ,
`public` TINYINT( 3 ) UNSIGNED DEFAULT '0',
`reminder_message_email` TEXT,
`reminder_message_popup` TEXT,
`access_key` VARCHAR( 32 ) DEFAULT NULL COMMENT AS `ical subscribe access key` ,
`created_on` DATETIME DEFAULT NULL ,
`updated_on` DATETIME DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;
Guess your query should be:
CREATE TABLE pec_calendars
(
id INT(11) UNSIGNED NOT NULL,
type ENUM('user', 'group', 'url') DEFAULT 'user',
user_id INT(11) UNSIGNED DEFAULT NULL,
name VARCHAR(100) DEFAULT NULL,
description TEXT,
color VARCHAR(7) DEFAULT NULL,
admin_id INT(11) DEFAULT NULL,
status ENUM('on', 'off') DEFAULT 'on',
show_in_list ENUM('0', '1') DEFAULT NULL,
public TINYINT(3) UNSIGNED DEFAULT '0',
reminder_message_email TEXT,
reminder_message_popup TEXT,
access_key VARCHAR(32) DEFAULT NULL,
created_on DATETIME DEFAULT NULL,
updated_on DATETIME DEFAULT NULL
)
engine = innodb
DEFAULT charset = utf8;

Some help to find the error in this SQL statement [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Can anyone help me check this sql statement am getting this error:
Error
> SQL query:
>
> CREATE TABLE `dp_banks` (
> `id` int( 11 ) NOT NULL AUTO_INCREMENT ,
> `owner` int( 11 ) NOT NULL default '0',
> `bname` varchar( 128 ) NOT NULL default '',
> `baddress` varchar( 128 ) NOT NULL default '',
> `bcity` varchar( 64 ) NOT NULL default '',
> `bzip` varchar( 16 ) NOT NULL default '',
> `bcountry` char( 2 ) NOT NULL default '',
> `bstate` varchar( 32 ) NOT NULL default '',
> `bphone` varchar( 32 ) NOT NULL default '',
> `bnameacc` varchar( 128 ) NOT NULL default '',
> `baccount` varchar( 32 ) NOT NULL default '',
> `btype` char( 2 ) NOT NULL default '',
> `brtgnum` varchar( 9 ) NOT NULL default '',
> `bswift` varchar( 32 ) NOT NULL default '',
> `status` tinyint( 1 ) NOT NULL default '0',
> `default` tinyint( 1 ) NOT NULL default '0',
> PRIMARY KEY ( `id` )
> ) TYPE = MYISAM AUTO_INCREMENT =1;
>
> 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 'TYPE=MyISAM AUTO_INCREMENT=1' at line 19
Here is the main code:
--
-- Table structure for table `dp_banks`
--
DROP TABLE IF EXISTS `dp_banks`;
CREATE TABLE `dp_banks` (
`id` int(11) NOT NULL auto_increment,
`owner` int(11) NOT NULL default '0',
`bname` varchar(128) NOT NULL default '',
`baddress` varchar(128) NOT NULL default '',
`bcity` varchar(64) NOT NULL default '',
`bzip` varchar(16) NOT NULL default '',
`bcountry` char(2) NOT NULL default '',
`bstate` varchar(32) NOT NULL default '',
`bphone` varchar(32) NOT NULL default '',
`bnameacc` varchar(128) NOT NULL default '',
`baccount` varchar(32) NOT NULL default '',
`btype` char(2) NOT NULL default '',
`brtgnum` varchar(9) NOT NULL default '',
`bswift` varchar(32) NOT NULL default '',
`status` tinyint(1) NOT NULL default '0',
`default` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
I would appreciate any quick help. I have tried all possible best to get this debugged but all to no avail.
Thanks
The TYPE table option was deprecated in MySQL 4.0. You should use the ENGINE option instead:
ENGINE = MyISAM
From the MySQL docs:
The older TYPE option was synonymous with ENGINE. TYPE has been deprecated since MySQL 4.0 but is still supported for backward compatibility in MySQL 5.1 (excepting MySQL 5.1.7). Since MySQL 5.1.8, it produces a warning. It is removed in MySQL 5.5. You should not use TYPE in any new applications, and you should immediately begin conversion of existing applications to use ENGINE instead.
Source: http://dev.mysql.com/doc/refman/5.1/en/create-table.html
I'm guessing one of the two highlighted sentences explains the reasoning for the error you are seeing.
Correct syntax is:
ENGINE = MYISAM

Syntax error in create table query

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

#1067 - Invalid default value for 'membership'

I am using a SQL file included in my program and once I fixed an issue that I was able to find the answer to in here (THANK YOU).. I ran it again and got the following error:
SQL query:
# Create table structure for 'member' table
CREATE TABLE member(
memberID INT( 11 ) NOT NULL AUTO_INCREMENT ,
title VARCHAR( 80 ) NOT NULL DEFAULT '',
firstname VARCHAR( 80 ) NOT NULL DEFAULT '',
lastname VARCHAR( 80 ) NOT NULL DEFAULT '',
email VARCHAR( 80 ) NOT NULL DEFAULT '',
address VARCHAR( 80 ) NOT NULL DEFAULT '',
suburb VARCHAR( 80 ) NOT NULL DEFAULT '',
state VARCHAR( 80 ) NOT NULL DEFAULT '',
country VARCHAR( 80 ) NOT NULL DEFAULT '',
postcode VARCHAR( 11 ) NOT NULL DEFAULT '',
mobile VARCHAR( 80 ) NOT NULL DEFAULT '',
phone VARCHAR( 80 ) NOT NULL DEFAULT '',
fax VARCHAR( 80 ) NOT NULL DEFAULT '',
membership INT( 2 ) NOT NULL DEFAULT '',
payment INT( 2 ) NOT NULL DEFAULT '',
startdate BIGINT( 14 ) NOT NULL DEFAULT 0,
enddate BIGINT( 14 ) NOT NULL DEFAULT 0,
userID INT( 11 ) NOT NULL ,
PRIMARY KEY ( memberID ) ,
UNIQUE (
memberID
)
) ENGINE = MYISAM ;
MySQL said:
#1067 - Invalid default value for 'membership'
What do I need to change to make this work ? this is an older script, but I am not knowledgeable enough to know what needs to be changed for MySQL 5.5 version.
Thank you so much for your help!
And I'm sure there will be other errors popping up after I fix this one..
The membership column is an int, but you're giving it a default string value of ''. So change
membership INT( 2 ) NOT NULL DEFAULT '',
to
membership INT( 2 ) NOT NULL DEFAULT 0,
(0 or whatever default value you want for that field.)
I was getting:
Incorrect integer value: '' for column 'column_name' at row 1
I've fixed it editing /etc/mysql/my.cnf or /etc/mysql/mysql.conf.d/mysqld.cnf files. Then find the following line:
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
and replace it for
sql-mode=""
and restart MySQL: service mysql restart