0

I'm trying to create tables using mysql Scripts but I'm getting errors like this:

Exception ESQLiteNativeException in module ActivityPlan.exe at 0051A80E.

[FireDAC][Phys][SQLite] ERROR: near "CODICE": syntax error.

CREATE TABLE anag_giac (CODICE char(30) DEFAULT NULL,
                        COD_TECNICO char(10) DEFAULT NULL,
                        DESCRIZION char(100) DEFAULT NULL,
                        PREZZO double DEFAULT NULL,
                        UM char(20) DEFAULT NULL,
                        STATO char(1) DEFAULT NULL,
                        KEY IANAG_GIAC (CODICE,COD_TECNICO) )

Any Ideas?

TLama
  • 75,147
  • 17
  • 214
  • 392
Gianluca Colombo
  • 717
  • 17
  • 38
  • Remove all of the `DEFAULT NULL`, to start. The default is **always** NULL unless you specify otherwise. After that, a [visit to the documentation](https://www.sqlite.org/lang_createtable.html) should explain the problem, particularly [foreign_key_clause](https://www.sqlite.org/syntax/foreign-key-clause.html). – Ken White Nov 07 '14 at 17:04
  • Just done but nothing changed!! I've got the same error – Gianluca Colombo Nov 07 '14 at 17:06
  • It seems a problem around the key creation.. Removing the string "KEY IANAG_GIAC (CODICE,COD_TECNICO)" it works... – Gianluca Colombo Nov 07 '14 at 17:11
  • 1
    Yes, as I said: see the documentation for [foreign_key_clause](https://www.sqlite.org/syntax/foreign-key-clause.html). – Ken White Nov 07 '14 at 17:13

1 Answers1

1

Try this:

CREATE TABLE anag_giac (
  CODICE CHAR(30) NOT NULL,
  COD_TECNICO CHAR(10) NOT NULL,
  DESCRIZION CHAR(100) NULL,
  PREZZO DOUBLE PRECISION NULL,
  UM CHAR(20) NULL,
  STATO CHAR(1) NULL,
  CONSTRAINT PrimaryKey1 PRIMARY KEY (CODICE,COD_TECNICO)
);
TLama
  • 75,147
  • 17
  • 214
  • 392