Jake Akanbi Jake Akanbi - 3 months ago 15
MySQL Question

MySQL said: Documentation (#1064) - You have an error in your SQL syntax;

I am trying to create a table in my mysql database and I keep getting this error. Please help, code is below:

CREATE TABLE 'Test'.'Sensor' (
'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'time' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'value' VARCHAR( 10 ) NOT NULL,
)


The Error is:

MySQL said: Documentation
#1064 - 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 ''Test'.'Sensor' ( 'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'time' TIMES' at line 1

Answer

Remove the single quotes and try like this:-

CREATE TABLE Test.Sensor ( 
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
    value VARCHAR( 10 ) NOT NULL 
);