What's wrong with these columns? - mysql

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 )

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 error Mysql - PHPmyadmin

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

MySQL syntax error in the CREATE TABLE statement

SQL query:
CREATE TABLE `comment_threads` (
`comment_id` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0',
`updated` TIMESTAMP NOT NULL ,
`timestamp` TIMESTAMP NOT NULL ,
) ENGINE = MYISAM ;
This is an old file that I'm trying to run on HostGator through phpMyAdmin. I get an error that says:
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 ') ENGINE=MyISAM' at line 5
UPDATE:
If I change the statement to this, I still get an error:
CREATE TABLE comment_threads (
comment_id INT( 11 ) UNSIGNED NOT NULL DEFAULT '0',
updated TIMESTAMP( 14 ) NOT NULL ,
timestamp TIMESTAMP NOT NULL
PRIMARY KEY ( comment_id ) )
ENGINE = MYISAM ;
I get the error:
ERROR 1064 (42000): 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 ,
timestamp TIMESTAMP NOT NULL
PRIMARY KEY ( comment_id ) )
ENGI' at line 3
Your MySQL query is incorrect. Correcting it to this works.
CREATE TABLE `comment_threads` (
`comment_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`updated` TIMESTAMP NOT NULL ,
`timestamp` TIMESTAMP NOT NULL
) ENGINE=MyISAM;
To run this in phpMyAdmin, you can use the in-built table creator or enter the corrected SQL statement in the SQL query window.
Note that I removed the comma after the last TIMESTAMP NOT NULL line (immediately before the ending ).
UPDATE:
The second statement you posted corrects to this:
CREATE TABLE `comment_threads` (
`comment_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`updated` TIMESTAMP NOT NULL ,
`timestamp` TIMESTAMP NOT NULL,
PRIMARY KEY(`comment_id`)
) ENGINE=MyISAM;
Here are the problems you introduced in your second CREATE TABLE statement:
TIMESTAMP( 14 ) should just be TIMESTAMP (per the documentation)
You need a comma after the line TIMESTAMP NOT NULL line. The comma is necessary now because unlike in the first example, you're separated two parts of the statement: the TIMESTAMP NOT NULL line and the PRIMARY KEY declaration.
If you want more information on simple methods for debugging SQL statements, I strongly suggest you look at my answer to this question (see the section titled A bit more information on how to methodically fix errors like this).
Make sure that when you change a CREATE TABLE statement, or any piece of code, that you make changes in small enough increments that you're only "breaking at most one thing at a time." In the case of your second CREATE TABLE statement, there was no reason to change the first TIMESTAMP declaration, and doing so broke the code. That line was working; no need to change it.

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

Syntax to insert a column into a table

Is it possible to insert columns into a MySQL table??
I've created a table and named it "my_table" - I do not understand, why MySQL does not eats my syntax...
INSERT INTO "my_table"(
"item" char(1) NOT NULL DEFAULT '',
"price" int(10) NOT NULL DEFAULT '3000',
"level" int(10) NOT NULL DEFAULT '1000',
"super" char(1) NOT NULL DEFAULT '',
"play" char(1) NOT NULL DEFAULT ''
)
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 '"my_table"( "item" char(1) NOT NULL DEFAULT '', "price" i' at line 1
So what's wrong with my syntax ?
If you're trying to add columns to an already created table you must use ALTER.
ALTER TABLE my_table ADD item char(1) NOT NULL DEFAULT '';
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
http://www.techiecorner.com/560/mysql-how-to-add-column-to-existing-table/
As the documentation says quite clearly, INSERT is for inserting rows of data, not altering the schema.
Look at ALTER instead.
And table/field names are delimited with backticks, not quotation marks.