I am really new to this so don't laugh .
I am trying to input a command in MySQL but I keep getting this syntax error.
It is prolly stupid, but I have little to no knowledge in sql.
CREATE TABLE `serial`.`serial`(
`id` INT NOT NULL AUTO_INCREMENT,
`serial` VARCHAR NOT NULL,
`hwid` VARCHAR NOT NULL,
PRIMARY KEY(`id`)
)
It keeps giving me :
**
#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,
`hwid` VARCHAR NOT NULL,
PRIMARY KEY(`id`)
)' at line 3
If someone could help me, it would be really appreciated. :)
varchar needs to be declared with a length:
CREATE TABLE `serial`.`serial` (
`id` INT NOT NULL AUTO_INCREMENT,
`serial` VARCHAR(255) NOT NULL,
`hwid` VARCHAR(255) NOT NULL,
PRIMARY KEY(`id`)
);
Here is a little SQL Fiddle showing it.
Related
This is my query.
CREATE TABLE `requirements`
(
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`requirement_id` VARCHAR NOT NULL,
`state` VARCHAR NOT NULL,
`city` VARCHAR NOT NULL,
`salary_per_anum` FLOAT NOT NULL,
`is_closed` TINYINT(1) NOT NULL,
`created_updated` DATETIME NOT NULL,
CONSTRAINT `pk_requirements` PRIMARY KEY(`id`)
);
and this is the 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 'NOT NULL, `state` VARCHAR NOT NULL, `city` VARCHAR NOT NULL, `salary_per_anum` F' at line 1
how can I debug what seems to be the issue?
You need to define a length of the string colum like
`requirement_id` VARCHAR(100)
and the same with column state and city.
But since requirement_id looks like a number id column it must be of the same type as id in table requirements, probably int.
Also your constraint seems to be defined wrong. It should refer to the table requirements.
I am using Sequel Pro with MySQL on my Mac. I return the error: "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 ')' " every time I attempt to run this sql query. The Database is created successfully, but the table is not. Can anyone advise where the error in my syntax is? I simply do not see it:
CREATE DATABASE bamazon
USE bamazon;
CREATE TABLE products
(
`id` int NOT NULL AUTO_INCREMENT,
`product_name` varchar(45) NOT NULL,
`department_name` varchar(45) NOT NULL,
`price` int NOT NULL,
`stock_quantity` int NOT NULL,
PRIMARY KEY (id),
);
Please remove the ',' after PRIMARY KEY (id). It should be like this
CREATE TABLE products
(
id int NOT NULL AUTO_INCREMENT,
product_name varchar(45) NOT NULL,
department_name varchar(45) NOT NULL,
price int NOT NULL,
stock_quantity int NOT NULL,
PRIMARY KEY (id)
);
The query does not work because there is an extra comma (,) at the end. Remove that and it will work. The correct syntax will be:
CREATE TABLE products
(
id int NOT NULL AUTO_INCREMENT,
product_name varchar(45) NOT NULL,
department_name varchar(45) NOT NULL,
price int NOT NULL,
stock_quantity int NOT NULL,
PRIMARY KEY (id)
);
I have the following SQL to create a table on a MySQL 5.6.13 instance:
CREATE TABLE 'exchange' (
'id' int NOT NULL AUTO_INCREMENT,
'abbrev' varchar(32) NOT NULL,
'name' varchar(255) NOT NULL,
'city' varchar(255) NULL,
'country' varchar(255) NULL,
'currency' varchar(128) NULL,
'time_zone_offset' time NULL,
'created_date' datetime NOT NULL,
'last_updated_date' datetime NOT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
However, I keep getting the following unhelpful 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
''exchange' ( 'id' int NOT NULL AUTO_INCREMENT,
'abbrev' varchar(32) NOT NULL, 'n' at line 1
I must be missing something glaringly obvious...
Any ideas where I'm going wrong?
Try :
CREATE TABLE exchange (
Ref:
http://dev.mysql.com/doc/refman/5.1/en/create-table.html
Remove all quotes, this helped me on a windows machine command line
I'm trying to create this table in SQL,
CREATE TABLE `online_status` (
`fk_user_id` int(10) unsigned NOT NULL default '0',
`last_activity` timestamp(14) NOT NULL,
PRIMARY KEY (`fk_user_id`)
) ENGINE=MyISAM;
but is returning 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 '(14) NOT NULL,
PRIMARY KEY (fk_user_id)
) ENGINE=MyISAM' at line 3
I've changed the commas, but the error continues. Can you help me on what is wrong?
`last_activity` timestamp(14) NOT NULL,
should be
`last_activity` timestamp NOT NULL,
I'm trying to create a table in my gym_system database. Here is the code I'm using:
CREATE TABLE `Gym_System`.`login` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(30) NOT NULL,
`password` CHAR(128) NOT NULL,
) ENGINE = InnoDB;
However, I keep getting 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 ') ENGINE = InnoDB' at line 5
Can anyone see why?
Remove the last comma
CREATE TABLE `login` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(30) NOT NULL,
`password` CHAR(128) NOT NULL
) ENGINE = InnoDB;
See fiddle demo