Last answered:

16 Nov 2022

Posted on:

12 Jul 2021

0

cant't create table in sql

I wrote the exact same code as the 'creating a table' as follows using mysql 8.0:

create table sales
(
    purchase_number int not null primary key     auto_increment,
    date_of_purchase date not null,
    customer_id int,
    item_code int varchar(10) not null
);

However, error 1064 keeps popping up like this:
image.png
May I know what's going wrong?

4 answers ( 0 marked as helpful)
Posted on:

14 Jul 2021

1

need to add database name in front of table name in  MySql 8.0

Instructor
Posted on:

15 Jul 2021

1

Hi Longyin!

Thanks for reaching out.

Please remove the statement terminator (i.e. the semi-colon ;) after CREATE TABLE sales and retry.

Hope this helps.
Best,
Martin

Posted on:

14 Nov 2022

0

Hi
I had the same problem, you have to specify the name of the database in this way:
put "use [name of the database]" before the first sentence.

Instructor
Posted on:

16 Nov 2022

0

Hi Mehraveh!
Thanks for reaching out.

Thanks for sharing this piece of information with the Community!
The statement terminator (i.e. the semi-colon ;) after CREATE TABLE sales should be removed.

Hope this helps.
Best,
Tsvetelin

Submit an answer