I use MySQL
5.6 command line client to create a simple database and I can create database yet to create my first table I have a syntax error that I cannot identify. Thanks for your help and sorry if there are English mispells it is not my first language.
Please find pasted the SQL
syntax error:
mysql> USE SYLVAINTEST
Database changed
mysql> CREATE TABLE students
-> (
-> studentid INT NOT NULL,
-> firstname VARCHAR,
-> lastname VARCHAR,
-> dob VARCHAR,
-> CONSTRAINT pk_students PRIMARY KEY (studentid)
-> );
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 ' lastname VARCHAR, dob VARCHAR, CONSTRAINT pk_students ' at line 4
mysql> CREATE TABLE students
-> (
-> studentid INT NOT NULL,
-> firstname VARCHAR ,
-> lastname VARCHAR ,
-> dob VARCHAR ,
-> CONSTRAINT pk_students PRIMARY KEY (studentid)
-> );
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 ' lastname VARCHAR , dob VARCHAR , CONSTRAINT pk_students PRIMARY KEY (' at line 4
You are missing length for VARCHAR datatypes
Also make sure to use proper datetime datatype to store datatetime values
You should specify lenght for
VARCHAR()
in following: