Error Code: 1064. MYSQL WORKBENCH

Asked

Viewed 1,329 times

-3

Hello I’m trying to create the following table:

CREATE TABLE produtos(
id integer primary key auto_increment unique ,
nome varchar(255) unique,
descricao varchar(255),
preco varchar(10,2) ,
validade date  
);

And the following sql error is pointed out:

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 '2) , validade date   )' at line 5
  • Why the preco is as varchar(10, 2)? Shouldn’t be a numerical type?

  • @Andersoncarloswoss and by the way, probably DECIMAL, because using FLOAT will cause another problem (not syntax). Dear Mark, change preco varchar(10,2) for preco decimal(10,2) ... Of course you have to see what average prices the system will accept and adjust as needed.

1 answer

0


Preco varchar(10,2)

varchar accepts one parameter only. I believe what you’re looking for is the guy decimal(10,2)

  • Thanks Buddy, I noticed now this detail

  • To make it easier for those next to you who have the same problem, if that’s solved, mark it as an answer. If not, add the answer and mark it as correct.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.