Hello. Learning SQL with an example from NetBeans ConsultingAgency Tutorial. The script gives an error

CREATE TABLE recruiter ( recruiter_id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, email VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, client_name VARCHAR(50), client_department_number SMALLINT, CONSTRAINT recruiter_pk PRIMARY KEY ( recruiter_id ) ); 

Error code 1064, SQL position 42000: You have an error in your SQL syntax; Check out the manual for the right syntax to use for your email address. VARCHAR (50) NOT NULL, password

Tell me, please, what is wrong?

  • what DBMS is used? - DNS
  • this can be done in mysql> = 5.7 - Alexey Shimansky
  • Need to use AUTO_INCREMENT ??? (MySQL) - Nikolay Belyakov

1 answer 1

It is a pity that it is not specified which database is used. But if we consider MySQL, then there is clearly an erroneous definition of the primary key. DDL should be used in this form:

 CREATE TABLE recruiter ( recruiter_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, client_name VARCHAR(50), client_department_number SMALLINT, PRIMARY KEY ( recruiter_id ) );