#1064 error Mysql - PHPmyadmin - mysql

I'm getting this error
#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 ') NULL , `MaxTemp` DOUBLE(5) NULL , `MinTemp` DOUBLE(5) NULL , `MinRH` DOUBLE' at line 1
Code:
CREATE TABLE `dbweat`.`Stations` ( `StationId` INT NOT NULL AUTO_INCREMENT , `StationName` VARCHAR(25) NULL DEFAULT NULL , `EToin` DOUBLE(5) NULL , `MaxTemp` DOUBLE(5) NULL , `MinTemp` DOUBLE(5) NULL , `MinRH` DOUBLE(5) NULL , `SolarRad` DOUBLE(5) NULL , `RainFall` DOUBLE(5) NULL , `Wind4am` DOUBLE(5) NULL , `Wind4pm` DOUBLE(5) NULL , PRIMARY KEY (`StationId`)) ENGINE = InnoDB;

You have the same error several times.
When you define a DOUBLE field, you must specify both total number of digits (T) and number of digits after the decimal period (D). SO you use DOUBLE(T,D)
Instead of
DOUBLE(5)
use
DOUBLE(5,0)
However that will not give you any decimals. You may want to do DOUBLE(6,2) which gives 6 digits, two of which are decimals (1234.56)
If you want to store numbers between 0 and 1 with 5 decimal places precision you would do DOUBLE(5,5) for 0.12345
I hope that makes sense. Good luck.
https://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html

Related

How i can fix this error, when importing my database?

CREATE TABLE `oc_appconfig` (
`appid` VARCHAR( 32 ) DEFAULT '' NOT NULL ,
`configkey` VARCHAR( 64 ) DEFAULT '' NOT NULL ,
`configvalue` CLOB DEFAULT NULL ,
PRIMARY KEY ( `appid` , `configkey` )
);
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 'CLOB DEFAULT NULL, PRIMARY KEY(appid, configkey))' at line 1
How i can fix this error. Pls Guys. I need my NextCloud!
MySQL has no CLOB data type. Use TEXT.
See the doc

#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'

error message
#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 '() NOT NULL,
`content` varchar(255) NOT NULL,
`sent_by` varchar(30) NOT NULL' at line 4
sql
CREATE TABLE IF NOT EXISTS `chat` (
`id` INT( 10 ) NOT NULL ,
`member_id` VARCHAR( 30 ) NOT NULL ,
`time_sent` DATETIME( ) NOT NULL ,
`content` VARCHAR( 255 ) NOT NULL ,
`sent_by` VARCHAR( 30 ) NOT NULL ,
`seen` INT( 1 ) NOT NULL
) ENGINE = INNODB AUTO_INCREMENT =22 DEFAULT CHARSET = latin1;
what is the problem now?
I just import into my server and happened this..
In my localhost is no problem when I import the sql
syntax issue
mysql doesnt know how to parse data_type of datetime( ). it only understands datetime or datetime(0-6) as valid data_type s
fix
change
`time_sent` DATETIME( ) NOT NULL ,
to
`time_sent` DATETIME NOT NULL ,
sqlfiddle
create table syntax
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
(create_definition,...)
[table_options]
[partition_options]
create_definition:
col_name column_definition
...
column_definition:
data_type [NOT NULL | NULL] [DEFAULT default_value]
...
data_type:
...
| DATETIME[(fsp)]
...
fsp stands for fractional seconds part and must be between 0-6
from data_type syntax definition, mysql understands either
DATETIME(fsp)
or
DATETIME
but not
DATETIME()

MySQL import Database error time datatype error

I exported the database, disabling foreign key checks (as advised by the webhost) and then imported it from the cPanel phpMyadmin.
It threw up the error below
Error
SQL query:
-- --------------------------------------------------------
--
-- Table structure for table `club_listing`
--
CREATE TABLE IF NOT EXISTS `club_listing` (
`id` INT( 11 ) NOT NULL ,
`name` VARCHAR( 50 ) NOT NULL ,
`venue` VARCHAR( 100 ) NOT NULL ,
`time` TIME( 4 ) NOT NULL ,
`description1` VARCHAR( 15 ) NOT NULL ,
`description2` VARCHAR( 15 ) NOT NULL ,
`description3` VARCHAR( 15 ) NOT NULL ,
`memberid` INT( 11 ) NOT NULL COMMENT 'foreignkey for members id for management',
`photoid` INT( 11 ) NOT NULL COMMENT 'link to photo table',
`imagefile` VARCHAR( 200 ) NOT 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 '(4) NOT NULL,
description1 varchar(15) NOT NULL,
description2 varchar(15' at line 11
I zeroed the error to be the time datatype. However, I checked the mysql documentation and couldn't find anything that explains the error.
the webhost mysql is version 5.5 while xampp is 5.6
If you create it without the length it will compile, I would suggest that if you can get away with it, then just truncate the time to the correct precision in your sql calls. I was having the same error in phpmyadmin perhaps try it in command line.

MySql Syntax Error From AutoGenerated Creation

CREATE TABLE `db`.`Complete` (
`CompleteId` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`HoursTaken` DOUBLE( 5 ) NOT NULL ,
`DateFinished` DATETIME NOT NULL
) ENGINE = MYISAM
I am trying to create this simple table, however, I get an error. The above code is the code generated by a UI for a MySql database.
I get 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 ') NOT NULL ,
`DateFinished` DATETIME NOT NULL
) ENGINE = MYISAM' at line 4
I am not sure what to change.
You need to add the precision to the DOUBLE datatype, it should be DOUBLE(5,n) I think.
I solved this by using float instead of double, this was the generated code:
CREATE TABLE `db`.`Complete` (
`CompleteId` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`HoursTaken` FLOAT NOT NULL ,
`DateFinished` DATETIME NOT NULL
) ENGINE = MYISAM

What's wrong with these columns?

is there something that I'm missing? Thanks :)
Error
SQL query:
ALTER TABLE `venues`
ADD `IF_AIRCONDITIONING` BOOLEAN( 1 ) NOT NULL DEFAULT '0'
, ADD `IF_LIVE_MUSIC` BOOLEAN( 1 ) NOT NULL DEFAULT '0'
, ADD `IF_TABLE_FOOTBALL` BOOLEAN( 1 ) NOT NULL DEFAULT '0'
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
'(1) NOT NULL DEFAULT '0', ADD `IF_LIVE_MUSIC` BOOLEAN(1) NOT NULL DEFAULT '0', ' at line 1
Try getting rid of the quotes around 0 in DEFAULT '0', or use FALSE or false (also without quotes)
Also you shouldn't have to specify a length for boolean fields, try getting rid of ( 1 )