CREATE TABLE info(id KEY AUTO_INCREMENT, email VARCHAR(20), name VARCHAR(20));
While using this code, in Ubuntu terminal, i am getting error like below
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 'KEY AUTO_INCREMENT, email VARCHAR(20), name
VARCHAR(20))' at line 1
pls do help me for this problem. Thanks to replies in advance
try this:
CREATE TABLE info(
id int not null AUTO_INCREMENT,
email VARCHAR(20),
name VARCHAR(20),
primary key(id)
);
Try that:
CREATE TABLE info(id INT NOT null AUTO_INCREMENT, email VARCHAR(20), name VARCHAR(20),primary key(id));
You have a problem with your "primary key" sintax on MySQL:
CREATE TABLE info(id not null AUTO_INCREMENT,
email VARCHAR(20),
name VARCHAR(20),
Primary Key(id));
Related
I want to create a script written by someone else in order to create tables and entries etc. in my own database.
The command I want to run is:
mysql -h localhost -u root shop < C:/myInstance/web/website/sql/myWeb.sql
I got this line by reading a couple of posts on SO. Yet I got these 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 'mysql -h localhost -u root shop < C:/myInstance/web/website/sql/myWeb.sql' at line 1
This suggests that there is clearly a syntax error, at this point I'm not even sure if the error is within my command of that file. Can you help me? I'm quite new to this, here is that file:
create table store_product
(
id bigint auto_increment primary key,
name varchar(32) not null,
description varchar(500),
imageSrc varchar(500),
price double not null
);
create table store_user
(
id bigint auto_increment primary key,
name varchar(32) unique not null,
password varchar(16) not null,
address varchar(100),
postCode varchar(10),
email varchar(50),
homePhone varchar(32),
cellPhone varchar(32),
officePhone varchar(32),
type varchar(20),
workNo varchar(20)
);
insert into store_user values(1,'throne212','123',' XXX ','621000','throne212#xxx.com','123456789','123456789','123456789','common',null);
insert into store_user values(2,'admin','123','','','admin#xxx.com','','','','admin','001');
create table store_order(
id bigint primary key,
orderNum varchar(17) unique not null,
status integer not null,
user_id bigint references store_user(id),
cost double(10,2)
);
create table store_order_item(
id bigint auto_increment primary key,
amount integer not null,
product_id bigint references store_product(id),
order_id bigint references store_order(id)
);
$sql1= "CREATE TABLE bookapp(
id int NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber int(11),
emailID VARCHAR(50),
reg_date datetime()
PRIMARY KEY(id)
)";
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 ''', NULL)' at line 1
You can use the following to create the table:
CREATE TABLE bookapp(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber INT(11),
emailID VARCHAR(50),
reg_date DATETIME,
PRIMARY KEY(id)
);
Explanation:
( and ) on DATETIME is invalid. DATETIME doesn't need a length.
You have to seperate the column definitions with ,. You forgot this after column reg_date.
Hint (to your error message):
Your given CREATE TABLE throws another error message, that is different to yours:
Error Code: 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 ') PRIMARY KEY(id) )' at line 6
I try to create a table in MySQL:
mysql> create table order ( ID varchar(30) not null,
-> Cname varchar(100) not null,
-> name varchar(30),
-> Type varchar(30),
-> primary key(ID, Cname));
but an error occured:
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 'order ( ID varchar(30) not null, Cname
varchar(100) not null, name varchar(30), ' at line 1
I have checked for thousand time and I still find no error here.
Can anyone help me?
Its is because of the table name order.
There is an order by reserved word. Change the table name and it will work fine.
If you want order as table name use back ticks around the table name. It will workfine
I create a physical model in powerdesigner
and then generate the code for mysql5, and now in
phpmyadmin Im getting an 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 'create table CARD
Do you see why this can be happening?
Im creating my tables like this:
create table books
(
COD_BOOK int not null auto_increment,
TITLE_BOOK varchar(50),
ISBN _BOOK varchar(20),
CATEGORY_BOOK varchar(20),
primary key (COD_BOOK)
)
And the problem seems like is in this part: int not null auto_increment,
You're missing the semi-colon at the end of your create statement. This makes the first line of the create statement for the next table an error which is what that error message is trying to tell you.
create table books
(
COD_BOOK int not null auto_increment,
TITLE_BOOK varchar(50),
ISBN_BOOK varchar(20),
CATEGORY_BOOK varchar(20),
primary key (COD_BOOK)
);
The problem is the space after ISBN:
create table books
(
COD_BOOK int not null auto_increment,
TITLE_BOOK varchar(50),
ISBN_BOOK varchar(20),
CATEGORY_BOOK varchar(20),
primary key (COD_BOOK)
)
Here is a SQL Fiddle.
I try to create a table but I keep getting an SQL Error but I can't figure out why.
This is the error:
check the manual that corresponds to your MySQL server version for the
right syntax to use near '+491634170770 (Id INT NOT NULL PRIMARY KEY
AUTO_INCREMENT,Type VARCHAR(20),Conte' at line 1 ERROR 1064 (42000):
You have an error in your SQL syntax;
This is my statement:
CREATE TABLE +491234175789 (
Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Type VARCHAR(20),
Content MEDIUMBLOB
);
I already tried to find a solution here, but my syntax seems to be correctly. I think its because of the name of the table. But using backticks like this ´+491234175789´ didn't work.
This is the backtick `:
CREATE TABLE `+491234175789` (
Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Type VARCHAR(20),
Content MEDIUMBLOB
);
However, don't create a table name that requires backticks. It is just bad form and makes queries harder to read and write -- you are creating problems for the future. Call it something like:
CREATE TABLE t_491234175789 (
Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Type VARCHAR(20),
Content MEDIUMBLOB
);