I will to execute this query :
CREATE TABLE `oc_appconfig` (`appid` VARCHAR(32) DEFAULT '' NOT NULL, `configkey` VARCHAR(64) DEFAULT '' NOT NULL, `configvalue` CLOB DEFAULT NULL, PRIMARY KEY(`appid`, `configkey`));
But I have this error :
ERROR 1064 (42000) at line 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 'CLOB DEFAULT NULL, PRIMARY KEY(appid, configkey))' at line 1
Have you a explication ? Thanks for your help
EwKilian
Related
I use phpMyAdmin and want to create a table. I use the visual interface for creating the table but I'm gonna post the code from "Preview SQL" option:
CREATE TABLE `baza`.`koncert` (
`koncert_id` INT(10) NOT NULL AUTO_INCREMENT ,
`koncert_naziv` VARCHAR(50) NULL ,
`koncert_lokacija` VARCHAR(50) NOT NULL ,
`koncert_datum` DATE NULL DEFAULT NULL ,
`koncert_cijena` DOUBLE(10) NOT NULL ,
`koncert_slika` VARCHAR(500) NOT NULL )
ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_croatian_ci;
And I get this error:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL version for the right syntax to use near ')' NOT NULL, 'koncert_slika' VARCHAR(500) NOT NULL ) ENGINE=InnoDB CHARSET=ut
I tried setting the 'koncert_datum' default value to CURRENT_TIMESTAMP, but then I get an error "Invalid default value for 'koncert_datum'". I just don't understand what could possibly be wrong (and I used the phpMyAdmin visual interface to try create the table!)
According to the documentation https://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html the DOUBLE type needs total digits and decimal digits. Something like
`koncert_cijena` DOUBLE(12,2) NOT NULL ,
Check the schema and ensure baza.koncert is present and try running them by removing "ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_croatian_ci" this.
I'm trying to use a simple CREATE TABLE statement to create a new table in my very first SQL-database. PHPmyadmin won't accept the code and gives me an error statement.
There doesn't appear to be anything wrong with the syntax of my SQL command. In fact, I receive the same error statement when I copy and past an example code from any internet tutorial to create a table.
this is my SQL command:
CREATE TABLE Guestbook(
ID int AUTO_INCREMENT PRIMARY KEY NOT NULL,
Name varchar(50) NOT NULL,
Message TEXT NOT NULL,
Date datetime,
Sport varchar(30),
Practicioner BOOLEAN default 0,
)
This is the error statement:
Static analysis:
3 errors were found during analysis.
A symbol name was expected! (near "Name" at position 74)
Unexpected beginning of statement. (near "50" at position 87)
Unrecognized statement type. (near "NOT NULL" at position 91)
SQL query:
CREATE TABLE Guestbook( ID int AUTO_INCREMENT PRIMARY KEY NOT NULL, Name varchar(50) NOT NULL, Message TEXT NOT NULL, Date datetime, Sport varchar(30), Practicioner BOOLEAN 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 ')' at line 8
I can't imagine why this won't work. I'd like to be able to use to command line in phpMyadmin. and this seems pretty straigtht forward. Yet I've been fiddling around with it for ages and I can't figure out how to create even the simplest possible table.
Can anyone help me out?
You should remove the last comma in your CREATE statement:
CREATE TABLE Guestbook(
ID int AUTO_INCREMENT PRIMARY KEY NOT NULL,
Name varchar(50) NOT NULL,
Message TEXT NOT NULL,
Date datetime,
Sport varchar(30),
Practicioner BOOLEAN default 0
)
This is driving me mad and I'm at the point where I'm thinking I must just be missing something very obvious. We are setting up a MonetDB environment with SQiurrel. I though the challenge would be wiring that all up and getting the drivers to work, but as it turns out that is running and I can see the DB in all its glory.
I have a DB in MySQL that I need to rebuild so I just generated the code:
CREATE TABLE "some_database"."some_table" (
key int(11) NOT NULL AUTO_INCREMENT,
column_1 varchar(10) DEFAULT NULL,
column_2 varchar(10) DEFAULT NULL,
column_3 varchar(10) DEFAULT NULL,
column_4 varchar(10) DEFAULT NULL,
column_5 varchar(10) DEFAULT NULL,
column_6 int(11) DEFAULT NULL,
column_7 decimal(10,2) DEFAULT NULL,
column_8 decimal(10,2) DEFAULT NULL,
column_9 int(11) DEFAULT NULL,
PRIMARY KEY (key)
) ENGINE=InnoDB AUTO_INCREMENT=20189170 DEFAULT CHARSET=utf8;
The only difference is that I've changed the column and table names. I'm not sure if this is all compatible for a start but I figured I would just work my way around it as it chucked errors. The first was about using a `. MonetDB seems to not like you.
I removed those and now I get:
Error: syntax error, unexpected '(', expecting ')' or ',' in: "create table "some_database"."some_table" (
SQLState: 42000
ErrorCode: 0
Error: fact_key int("
SQLState: 22000
ErrorCode: 0
For the "key" column I'm also getting the int(11) turn red and tell me I have an "EOF Expected"
If I quickly type out my own CREATE TABLE statement I can create a tables with a type varchar. As soon as I add in an int type it goes mad again.
So for example I just created this table in MonetDB:
CREATE TABLE "some_database"."some_table"
(
something varchar(10),
something2 varchar(10)
);
That worked fine. As soon as I add an int type:
CREATE TABLE "some_database"."some_table"
(
something varchar(10),
something2 varchar(10),
something3 int(10)
);
It goes a bit mental again:
Error: syntax error, unexpected '(', expecting ')' or ',' in: "create table "some_database"."some_table"
SQLState: 42000
ErrorCode: 0
Error: (
SQLState: 22000
ErrorCode: 0
Error: something varchar(10),
SQLState: 22000
ErrorCode: 0
Error: something2 varchar(10),
SQLState: 22000
ErrorCode: 0
Error: something3 int("
SQLState: 22000
ErrorCode: 0
So my question is have I set something up wrong? MonetDB seems to be running well and I can explore everything as one would expect in SQiurrel. I can create basic tables with varchar but as soon as I bring in an int the computer says no. I also don't understand what EOF means? I assumed it was expecting an , but it has that?
Thanks in advance. I'm hoping I just need a fresh mind who knows MonetDB to tell me why I'm missing the obvious!
I think I've worked out my issue. Hopefully someone who is learning their way around MonetDB may find this and save themselves some effort.
The syntax for an int is different.
Rather than:
int(11)
You must just type:
int
Once I removed the (11) from each int in my create statement it ran.
When am trying to set default date and default sysdate am getting following errors:
MySQL Query:
create table product_offer_type(object_id INT(19), snapshot_id INT(19), PRIMARY KEY(object_id,snapshot_id), enum_value VARCHAR(64) NOT NULL, external_name VARCHAR(64) NOT NULL, description VARCHAR(255), business_validation INT(1), valid_for_start_date_time DATE DEFAULT '1900-01-10', valid_for_end_date_time DATE DEFAULT '4712-01-01', mutation_date_time DATE SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER');
Error Message:
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 'SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER')' at line 1
Any pointer's would be highly appreciated.
If you're trying to track the last modification time of the row, I usually use something like
mutation_date_time timestamp default current_timestamp, on update current_timestamp
You might need slight modification if you really want Date and not timestamp.
Here is a table i have
CREATE TABLE `CUSTOMERSTATUSTYPES` (
`CustomerStatusId` int(1) unsigned NOT NULL auto_increment,
`CustomerStatusName` enum('ACTIVE','SUSPEND','TERMINATE','CANCEL') default NULL,
PRIMARY KEY (`CustomerStatusId`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
When i write
GROUP BY ... WHERE cst.CustomerStatusName<>'TERMINATE' ;
i get a syntax 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 'WHERE
cst.CustomerStatusName<>'TERMINATE''
at line 1
How do i correctly check this?
The WHERE clause must come before the GROUP BY clause.
You either need to put the WHERE clause before the GROUP BY clause, or you need to use the HAVING keyword.
See here for more info:
http://www.databasejournal.com/features/mysql/article.php/3469351/The-HAVING-and-GROUP-BY-SQL-clauses.htm