Help me find a bug in the database.

mysql

It gives error number 1064

# 1064 - You have an error in your SQL syntax; This is the syntax for the right syntax to use the 'link (') ( id() )))) ENGINE = InnoDB 'at line 1

What is the correct key name?

  • and what you did not like to write PRIMARY KEY ( id ) and everything? - tCode
  • Why so many brackets here (id())))) ? - Aleksey Shimanskyy
  • And weakly the request with the text was to insert? - Vladimir Martyanov
  • just (id) didn't help. anyway the error climbs out - Gavrenko Katerina
  • @GavrenkoKaterina and without ENGINE = InnoDB try another PRIMARY KEY ( id ); so - tCode 3:49

1 answer 1

When specifying the primary key at the end of the table creation, it is enough to specify the key in brackets and that's it.

Example

 CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ) ENGINE=InnoDB 

As you can see the PRIMARY KEY indicated and the name of the primary key (P_Id) in brackets once. Similarly, you need to do it.

And another tip, to write a request in several lines (as in the example above), to visually separate what is, and not to do a lot. And this will at least help with errors in the request.