MySQL Version Related Syntax Errors - mysql

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

Related

MariaDB How to avoid error NOT NULL DEFAULT

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;

MariaDB - CONNECT ENGINE - ORDER BY error

I'm trying to get Asterisk CDR records from MySQL table (5.5.45) by CONNECT engine on other server running MariaDB (10.0.29).
I can create the connection between table easily:
CREATE TABLE `calls` engine=CONNECT table_type=MYSQL
CONNECTION='mysql://user#IP/asteriskcdrdb/calls';
When I run simple SELECT * FROM calls, everything works good, when I add some WHERE conditions, still everything okay.
But the problem start when I add ORDER BY column parameter, then I got this error from MariaDB:
#1032 - Can't find record in 'calls'
I checked MySQL log, MariaDB log - there are no errors at all.
Did I miss something?
Thank you!
Update: The whole query is simple:
SELECT * FROM `calls` ORDER BY `calldate`
The table structure:
CREATE TABLE `calls` (
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`uniqueid` varchar(32) NOT NULL default '',
`userfield` varchar(255) NOT NULL default '',
`recordingfile` varchar(255) NOT NULL default '',
`cnum` varchar(40) NOT NULL default '',
`cnam` varchar(40) NOT NULL default '',
`outbound_cnum` varchar(40) NOT NULL default '',
`outbound_cnam` varchar(40) NOT NULL default '',
`dst_cnam` varchar(40) NOT NULL default '',
`call_charge` float NOT NULL default '0',
`from_did` varchar(30) NOT NULL,
`did` varchar(50) NOT NULL default '',
`user_id` int(8) unsigned default NULL,
`client_id` int(8) unsigned default NULL,
KEY `IDX_UNIQUEID` (`uniqueid`),
KEY `src` (`src`),
KEY `dst` (`dst`),
KEY `calldate` (`calldate`),
KEY `uniqueid` (`uniqueid`),
KEY `userfield` (`userfield`),
KEY `from_did` (`from_did`),
KEY `user_id` (`user_id`),
KEY `client_id` (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Update #2: Update the table names, to don't confuse, but it's not the issue. The CONNECTION table is created okay.
Query works:
SELECT * FROM `calls`
Query works:
SELECT * FROM `calls` WHERE `user_id`=X
Query return error:
SELECT * FROM `calls` ORDER BY `calldate`
Update #3: The MySQL was updated to veriosn 5.5.45, the type was changed to InnoDB and the charset was converted to UTF8. But no success.
PROBLEM SOLVED
Well, it's MariaDB bug, when I changed to FederatedX engine (which is basically little bit limited version of CONNECT), everything works as expected.
In your query you do
SELECT * FROM calls
but in your table structure you have
CREATE TABLE cdr
and both have calldate column. Check if you querying the right table.

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 #1064 - You have an error in your SQL syntax at line 2

What's wrong on this code? I receive that message when try to import this sql:
#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 ''codigo' int(11) unsigned NOT NULL auto_increment, 'razao_social' varchar(11) N' at line 2
CREATE TABLE IF NOT EXISTS `char` (
'codigo' int(11) unsigned NOT NULL auto_increment,
'razao_social' varchar(11) NOT NULL DEFAULT '',
'fantasia' varchar(11) NOT NULL DEFAULT '',
'data_de_cadastro' datetime NOT NULL DEFAULT '',
'cep' varchar(11) NOT NULL DEFAULT '',
'logradouro' varchar(11) NOT NULL DEFAULT '',
'numero' varchar(11) NOT NULL DEFAULT '',
'complemento' varchar(11) NOT NULL DEFAULT '',
'bairro' varchar(11) NOT NULL DEFAULT '',
'cidade' varchar(11) NOT NULL DEFAULT '',
'uf' varchar(11) NOT NULL DEFAULT '',
'cnpj' varchar(11) NOT NULL DEFAULT '',
'insc_estadual' varchar(11) NOT NULL DEFAULT '',
'incs_municipal' varchar(11) NOT NULL DEFAULT '',
'telefone01' varchar(11) NOT NULL DEFAULT '',
'telefone02' varchar(11) NOT NULL DEFAULT '',
'contato' varchar(11) NOT NULL DEFAULT '',
'associados' varchar(11) NOT NULL DEFAULT '',
'funcionários' varchar(11) NOT NULL DEFAULT '',
'data_socio' datatime NOT NULL DEFAULT '',
'data_desligamento' datatime NOT NULL DEFAULT '',
'email' varchar(11) NOT NULL DEFAULT '',
'website' varchar(11) NOT NULL DEFAULT '',
'situacao' int(11) NOT NULL DEFAULT '',
PRIMARY KEY (`codigo`),
UNIQUE KEY `razao_social` (`razao_social`),
KEY `fantasia` (`account_id`),
KEY `cnpj` (`cnpj`),
KEY `insc_estadual` (`insc_estadual`),
KEY `incs_municipal` (`incs_municipal`)
) ENGINE=MySQL;
you should use backticks ` in MySQL to escape column name identifiers, not single quotes ' (actually, all identifiers, just like you've done with you table name);
you provide datatime as the datatype for data_socio and
data_desligamento, which is invalid (because it doesn't exist, I think you've meant datetime);
MySQL is not a valid engine option (maybe you've meant MyISAM?), here is a list of storage engines;
'' is not a valid default value for the datetime datatype (data_desligamento, data_socio and data_de_cadastro);
you are creating an index fantasia using a key for the column account_id that doesn't even exist in your table (or it is just a typo and either fantasia column should be called account_id or vice versa? - just guessing here).
SQLFiddle
Do not use single quotes(') in column names, instead use tild symbol (`).
For example:
this column 'razao_social' should be write as `razao_social`

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,