Search code examples
sqlsyntaxmariadbmysql-error-1064

Error 1064 sql phpmyadmin


This is my sql query:

CREATE TABLE estados (
    id int IDENTITY(1,1) PRIMARY KEY,
    nombre VARCHAR(20) NOT NULL,
    paridad int NOT NULL
);

and it keeps telling me:

#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 '(1,1) PRIMARY KEY, nombre VARCHAR(20) NOT NULL, paridad int NOT NULL

I don't know why is this, I am using 10.1.10-MariaDB. I don't know why I have syntax error, and if this has to do with the versions.


Solution

  • IDENTITY is for SQL Server. You should use AUTO_INCREMENT instead:

    CREATE TABLE estados (
        id int AUTO_INCREMENT PRIMARY KEY,
        nombre VARCHAR(20) NOT NULL,
        paridad int NOT NULL
    );