Search code examples
mysqlddl

Syntax Error in SQL in Table Creation Code (i don't see an error...)


I'm getting a Syntax Error in the following Test-SQL-Code at 'CREATE TABLE ORDER(':

CREATE TABLE CLIENT(
    CLIENT_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
    LAST_NAME VARCHAR(16) NOT NULL,
    FIRST_NAME VARCHAR(16) NOT NULL,
    STREET_ADDRESS VARCHAR(100) NOT NULL,
    APARTMENT_NUMBER VARCHAR(20) NOT NULL,
    CITY VARCHAR(50) NOT NULL,
    ZIP_CODE VARCHAR(10) NOT NULL
);

CREATE TABLE ORDER(
    ORDER_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
    CLIENT_ID BIGINT NOT NULL,
    DATE_ORDERED BIGINT NOT NULL,
    SUM FLOAT NOT NULL
);

Solution

  • order is a keyword better to not use it but if needed then use double quote

    CREATE TABLE "ORDER"(
        ORDER_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
        CLIENT_ID BIGINT NOT NULL,
        DATE_ORDERED BIGINT NOT NULL,
        SUM FLOAT NOT NULL
    );