Database not importing - mysql

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.

Related

When I am trying to import it to my phpmy admin am getting error #1067 - Invalid default value

Error
SQL query:
--
-- Database: gym
-- --------------------------------------------------------
-- Table structure for table admin_tbl
CREATE TABLE IF NOT EXISTS `admin_tbl` (
`adminid` int( 11 ) NOT NULL ,
`username` varchar( 20 ) NOT NULL ,
`password` varchar( 20 ) NOT NULL ,
`timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON
) ENGINE = InnoDB AUTO_INCREMENT =3 DEFAULT CHARSET = latin1;
MySQL said: Documentation
#1067 - Invalid default value for 'timestamp'
You have an extra ON which you likely copied from:
dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
When you remove the ON, it works fine.
So your result should be:
CREATE TABLE IF NOT EXISTS `admin_tbl` (
`adminid` int( 11 ) NOT NULL ,
`username` varchar( 20 ) NOT NULL ,
`password` varchar( 20 ) NOT NULL ,
`timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB AUTO_INCREMENT =3 DEFAULT CHARSET = latin1;
SQLFiddle
MySQL Documentation

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;

Why doesn't the follow SQL table creation work?

CREATE TABLE `auth_user` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`password` VARCHAR( 128 ) COLLATE utf8_bin NOT NULL ,
`last_login` DATETIME( 6 ) DEFAULT NULL ,
`is_superuser` TINYINT( 1 ) NOT NULL ,
`username` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
`first_name` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
`last_name` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
`email` VARCHAR( 254 ) COLLATE utf8_bin NOT NULL ,
`is_staff` TINYINT( 1 ) NOT NULL ,
`is_active` TINYINT( 1 ) NOT NULL ,
`date_joined` DATETIME( 6 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `username` ( `username` )
) ENGINE = INNODB AUTO_INCREMENT =2 DEFAULT CHARSET = utf8 COLLATE = utf8_bin;
*\#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) DEFAULT NULL,
`is_superuser` tinyint(1) NOT NULL,
`username` varchar(30)' at line 4***
This is the auth_user table from a django project. The SQL file was exported from my local MySQL database, but I can't import to the online mysql database. Could somebody can help me?
You do not need the length for datetime
`date_joined` DATETIME( 6 ) NOT NULL ,
should be
`date_joined` DATETIME NOT NULL ,
https://dev.mysql.com/doc/refman/5.0/en/datetime.html

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

SQL syntax error

CREATE TABLE `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`type` ENUM( `member` , `admin` ) NOT NULL ,
`username` VARCHAR( 30 ) NOT NULL ,
`email` VARCHAR( 80 ) NOT NULL ,
`pass` VARBINARY( 32 ) NOT NULL ,
`first_name` VARCHAR( 20 ) NOT NULL ,
`last_name` VARCHAR( 40 ) NOT NULL ,
`date_expires` DATE NOT NULL ,
`date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`date_modified` TIMESTAMP NOT NULL DEFAULT `0000-00-00 00:00:00` ,
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `username` ( `username` ) ,
UNIQUE KEY `email` ( `email` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8;
MySQL said:
#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 'member,admin) NOT NULL, username VARCHAR(30) NOT NULL,
email VARCHAR(80)' at line 3
The shared server I am using, uses 4.4. Thanks for reading. I am an absolute novice, having only been learning php/mysql for one month, so please speak in layman's terms.
You need to quote ENUM values
type ENUM( 'member' , 'admin' ) NOT NULL ,
not backtick them as you do now
Same thing for this line
`date_modified` TIMESTAMP NOT NULL DEFAULT `0000-00-00 00:00:00`
should be
`date_modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'
This page indicates that your ENUM values should be strings, so need to be surrounded by single quotes.
type ENUM( 'member' , 'admin' ) NOT NULL
okey fixed it here is it :)
CREATE TABLE `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
type ENUM( 'member' , 'admin' ) NOT NULL ,
`username` varchar(30) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`first_name` varchar (15) NOT NULL,
`last_name` varchar (30) NOT NULL,
`gender` ENUM('male', 'female') NOT NULL default 'male',
`email` varchar(50) NOT NULL default '',
`skype` varchar(50) NOT NULL default 'Not Specified',
`facebook` varchar(150) NOT NULL default 'Not Specified',
`location` varchar(100) NOT NULL default 'Not Specified',
PRIMARY KEY (`id`),
UNIQUE KEY (`email`),
KEY (`email`, `password`)
) ENGINE = MYISAM DEFAULT CHARSET = utf8;