MariaDB How to avoid error NOT NULL DEFAULT - mysql

i m trying to load a DB in my local server XAMPP but it keeps giving me this error.
My table
CREATE TABLE `transactions_client_view` (
`name` VARCHAR(255) NOT NULL DEFAULT '',
`surname` VARCHAR(255) NOT NULL DEFAULT '',
`actualcredit` DOUBLE(10) NOT NULL DEFAULT '0.00000',
`amount` DOUBLE(10) NOT NULL DEFAULT '0.00000',
`date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`error` VARCHAR(255) NOT NULL DEFAULT '',
`client_id` INT(11) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM;
ERROR
ERROR 1064 (42000) at line 361239: 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 DEFAULT '',
amount DOUBLE(10) NOT NULL DEFAULT '', `date' at line 4

try this
CREATE TABLE `transactions_client_view` (
`name` VARCHAR(255) NOT NULL DEFAULT '',
`surname` VARCHAR(255) NOT NULL DEFAULT '',
`actualcredit` DOUBLE NOT NULL DEFAULT '0.00000',
`amount` DOUBLE NOT NULL DEFAULT '0.00000',
`date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`error` VARCHAR(255) NOT NULL DEFAULT '',
`client_id` INT(11) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM;

Related

Getting Error during uploading Database to my server. SQL error #1064

Error
SQL query:
CREATE TABLE `crypto_files` (
`fileID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`fileTitle` varchar(100) NOT NULL DEFAULT '',
`active` tinyint(1) NOT NULL DEFAULT '1',
`fileName` varchar(100) NOT NULL DEFAULT '',
`fileSize` double(15,0) NOT NULL DEFAULT '0',
`fileText` text,
`priceUSD` double(10,2) NOT NULL DEFAULT '0.00',
`priceCoin` double(17,5) NOT NULL DEFAULT '0.00000',
`priceLabel` varchar(6) NOT NULL DEFAULT '',
`purchases` mediumint(8) NOT NULL DEFAULT '0',
`userFormat` enum('MANUAL','COOKIE','SESSION','IPADDRESS') NOT NULL,
`expiryPeriod` varchar(15) NOT NULL DEFAULT '',
`lang` varchar(2) NOT NULL DEFAULT '',
`defCoin` varchar(5) NOT NULL DEFAULT '',
`defShow` tinyint(1) NOT NULL DEFAULT '1',
`image` varchar(100) NOT NULL DEFAULT '',
`imageWidth` smallint(5) NOT NULL DEFAULT '0',
`priceShow` tinyint(1) NOT NULL DEFAULT '1',
`paymentCnt` smallint(5) NOT NULL DEFAULT '0',
`paymentTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`u[...]
MySQL said: Documentation
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 'TYPE=InnoDB AUTO_INCREMENT=1' at line 45
Getting this error while uploading sql file. Please help me
Thank You!
TYPE=InnoDB has changed to ENGINE=InnoDB.
Do not use DOUBLE(m,n) it leads to double rounding and has no benefits. Switch to either DOUBLE or DECIMAL(m,n).

MySQL Version Related Syntax Errors

When uploading a SQL script using MySQL version 5.5.23-55 and importing using phpMyadmin version 3.4.11.1, I am getting the following goofy errors:
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:
#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
Researching on the net, I found an article that recommended changing TYPE=MyISAM to ENGINE=MyISAM. Making this change now gives the following errors:
SQL query:
CREATE TABLE `dp_confirms` (
`id` int(11) NOT NULL auto_increment,
`newuser` varchar(32) NOT NULL default '',
`newpass` varchar(32) NOT NULL default '',
`newquestion` varchar(255) NOT NULL default '',
`newanswer` varchar(255) NOT NULL default '',
`newmail` varchar(255) NOT NULL default '',
`newfname` varchar(32) NOT NULL default '',
`newlname` varchar(32) NOT NULL default '',
`newcompany` varchar(128) NOT NULL default '',
`newregnum` varchar(32) NOT NULL default '',
`newdrvnum` varchar(32) NOT NULL default '',
`newaddress` varchar(128) NOT NULL default '',
`newcity` varchar(64) NOT NULL default '',
`newcountry` char(2) NOT NULL default '',
`newstate` varchar(32) NOT NULL default '',
`newzip` varchar(32) NOT NULL default '',
`newphone` varchar(64) NOT NULL default '',
`newfax` varchar(64) NOT NULL default '',
`sponsor` int(11) NOT NULL default '0',
`confirm` varchar(255) NOT NULL default '',
`cdate` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `newuser` (`newuser`),
KEY `newmail` (`newmail`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
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 '(14) NOT NULL, PRIMARY KEY (id), UNIQUE KEYnewuser(newuser), KEY ' at line 22
Thanks in advance for all help.
Other than changing TYPE to ENGINE change
`cdate` timestamp(14) NOT NULL,
^^^^
to
`cdate` timestamp NOT NULL,
Here is SQLFiddle demo
) TYPE=MyISAM AUTO_INCREMENT=1 ;
Replace this with
) ENGINE = MYISAM AUTO_INCREMENT =1;
Type has been replaced with engine.
TYPE keyword is depreciated (since 5.0) and not supported in MySQL5.5 (and I think even 5.1). Instead of TYPE keyword use ENGINE keyword.
My experience was that i had to change two things:
TYPE=MyISAM AUTO_INCREMENT=1 ;
Replace this with
ENGINE=MyISAM AUTO_INCREMENT=1;
AND
cdate timestamp(14) NOT NULL,
to
cdate timestamp NOT NULL,
That worked for me

Latest version of MySQL gives error 1064 on code that used to work fine

Many servers now a days have the latest version of MySQL - which is giving an error when running the following piece of code:
$drop_table = mysql_query("DROP TABLE IF EXISTS `$t_ads`");
$sqls[$t_ads] = "CREATE TABLE `$t_ads` (
`adid` int unsigned NOT NULL auto_increment,
`adtitle` varchar(100) NOT NULL default '',
`addesc` longtext NOT NULL,
`area` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`showemail` enum('0','1','2') NOT NULL default '0',
`password` varchar(50) NOT NULL default '',
`code` varchar(35) NOT NULL default '',
`cityid` smallint unsigned NOT NULL default '0',
`subcatid` smallint unsigned NOT NULL default '0',
`price` DECIMAL( 10, 2 ) NOT NULL default '0',
`othercontactok` enum('0','1') NOT NULL default '0',
`hits` int unsigned NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`verified` enum('0','1') NOT NULL default '0',
`abused` int unsigned NOT NULL default '0',
`enabled` enum('0','1') NOT NULL default '0',
`createdon` datetime NOT NULL default '0000-00-00 00:00:00',
`expireson` datetime NOT NULL default '0000-00-00 00:00:00',
`timestamp` timestamp(14) NOT NULL,
`paid` enum('0','1','2') NOT NULL default '2',
PRIMARY KEY (`adid`),
KEY `subcatid` (`subcatid`),
KEY `cityid` (`cityid`),
KEY `verified` (`verified`),
KEY `enabled` (`enabled`),
KEY `paid` (`paid`)
) TYPE=MyISAM;";
Servers with an older version of mysql seem to accept this, but the new version is not accepting it at all and giving an error. I have many errors related to it since the PHP database setup is little bigger. An example of the error is below:
#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 '(14) NOT NULL, paid enum, NOT NULL default '2', PRIMARY KEY (adid), K' at line 21
The plain SQL part of your code looks ok (just tested it with MySQL 5.6), though I'd generally advise not to use keywords like timestamp as a column name. The table will be created in MySQL 5.6, but you'll encounter two warnings:
The syntax TIMESTAMP(14) is deprecated and will be removed in
MySQL 6.0. Please use TIMESTAMP instead
The syntax TYPE=storage_engine is deprecated and will be removed in MySQL
6.0. Please use ENGINE=storage_engine instead
If this doesn't help, please post the actual MySQL version you're working with.
Change your column name it should not be mysql keyword 'timestamp' and
chnage
`timestamp` timestamp(14) NOT NULL,
to
`<SOME OTHERNAME>` timestamp NOT NULL,

trouble with import query to database

I have this query and I tried to import it to phpmyadmin. Can you tell me how to fix this? Thank you.
DROP TABLE IF EXISTS `dp_confirms`;
CREATE TABLE `dp_confirms` (
`id` int(11) NOT NULL auto_increment,
`newuser` varchar(32) NOT NULL default '',
`newpass` varchar(32) NOT NULL default '',
`newquestion` varchar(255) NOT NULL default '',
`newanswer` varchar(255) NOT NULL default '',
`newmail` varchar(255) NOT NULL default '',
`newfname` varchar(32) NOT NULL default '',
`newlname` varchar(32) NOT NULL default '',
`newcompany` varchar(128) NOT NULL default '',
`newregnum` varchar(32) NOT NULL default '',
`newdrvnum` varchar(32) NOT NULL default '',
`newaddress` varchar(128) NOT NULL default '',
`newcity` varchar(64) NOT NULL default '',
`newcountry` char(2) NOT NULL default '',
`newstate` varchar(32) NOT NULL default '',
`newzip` varchar(32) NOT NULL default '',
`newphone` varchar(64) NOT NULL default '',
`newfax` varchar(64) NOT NULL default '',
`sponsor` int(11) NOT NULL default '0',
`confirm` varchar(255) NOT NULL default '',
`cdate` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `newuser` (`newuser`),
KEY `newmail` (`newmail`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
Error I get:
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 '(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `newuser` (`newuser`),
K' at line 22
Specifying the length for a timestamp such as timestamp(14) was deprecated in MySQL 5.1, and is no longer supported from MySQL 5.5.
This is easily fixed by removing the length specification:
`cdate` timestamp NOT NULL,

MySQL syntax error I don't understand [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
MySQL generated by a dump of a v3.23.58 database:
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`DATE` date NOT NULL default '0000-00-00',
`SECTION_ID` smallint(6) NOT NULL default '0',
`PRIORITY` int(11) NOT NULL default '0',
`AUTHOR1` int(100) NOT NULL default '1',
`AUTHOR2` varchar(100) NOT NULL default '',
`AUTHOR3` varchar(100) NOT NULL default '',
`AUTHOR4` varchar(100) NOT NULL default '',
`AUTHOR5` varchar(100) NOT NULL default '',
`AUTHOR6` int(100) NOT NULL default '0',
`AUTHOR7` int(100) NOT NULL default '0',
`AUTHOR8` int(100) NOT NULL default '0',
`AUTHOR9` int(100) NOT NULL default '0',
`AUTHOR10` int(100) NOT NULL default '0',
`AUTHOR_JOB` int(11) NOT NULL default '0',
`TITLE` varchar(100) NOT NULL default '',
`SUBHEAD` varchar(200) NOT NULL default '',
`TEXT` text NOT NULL,
`PULLQUOTE` text NOT NULL,
`SERIES` int(10) unsigned zerofill NOT NULL default '0000000000',
`TYPE` int(10) unsigned zerofill NOT NULL default '0000000000',
`VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
`EMAILS` int(10) unsigned zerofill NOT NULL default '0000000000',
`BACKUPTEXT` text NOT NULL,
`BOWDOIN_VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
PRIMARY KEY (`DATE`,`SECTION_ID`,`PRIORITY`),
FULLTEXT KEY `article_full_text` (`TITLE`,`TEXT`)
) TYPE=MyISAM;
Attempting to import it into a v5.5.19 database, I get this error:
[ERROR in query 2] 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' at line 28
I've tried deconstructing it to a very basis skeleton but still get the error. Ought to be an obvious mistake if you have the eye for it.
Your version of MySQL probably requires that you edit query
replace
TYPE=MyISAM
with
ENGINE=MyISAM
if you are importing from script file then just:
Open script file
Find TYPE=MyISAM
Replace with ENGINE=MyISAM
save
Then try .
change last line
) TYPE=MyISAM;
to
) ENGINE=MyISAM
so all would be
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`DATE` date NOT NULL default '0000-00-00',
`SECTION_ID` smallint(6) NOT NULL default '0',
`PRIORITY` int(11) NOT NULL default '0',
`AUTHOR1` int(100) NOT NULL default '1',
`AUTHOR2` varchar(100) NOT NULL default '',
`AUTHOR3` varchar(100) NOT NULL default '',
`AUTHOR4` varchar(100) NOT NULL default '',
`AUTHOR5` varchar(100) NOT NULL default '',
`AUTHOR6` int(100) NOT NULL default '0',
`AUTHOR7` int(100) NOT NULL default '0',
`AUTHOR8` int(100) NOT NULL default '0',
`AUTHOR9` int(100) NOT NULL default '0',
`AUTHOR10` int(100) NOT NULL default '0',
`AUTHOR_JOB` int(11) NOT NULL default '0',
`TITLE` varchar(100) NOT NULL default '',
`SUBHEAD` varchar(200) NOT NULL default '',
`TEXT` text NOT NULL,
`PULLQUOTE` text NOT NULL,
`SERIES` int(10) unsigned zerofill NOT NULL default '0000000000',
`TYPE` int(10) unsigned zerofill NOT NULL default '0000000000',
`VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
`EMAILS` int(10) unsigned zerofill NOT NULL default '0000000000',
`BACKUPTEXT` text NOT NULL,
`BOWDOIN_VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
PRIMARY KEY (`DATE`,`SECTION_ID`,`PRIORITY`),
FULLTEXT KEY `article_full_text` (`TITLE`,`TEXT`)
) ENGINE=MyISAM;