What's wrong with this SQLite query ?



  • CREATE TABLE IF NOT EXISTS `Pages_has_Dependencies` (
      `page_ID` INT NOT NULL,
      `depe_ID` INT NOT NULL,
      PRIMARY KEY (`page_ID`, `depe_ID`),
      INDEX `fk_Pages_has_Dependencies_Dependencies1_idx` (`depe_ID` ASC),
      INDEX `fk_Pages_has_Dependencies_Pages_idx` (`page_ID` ASC),
      CONSTRAINT `fk_Pages_has_Dependencies_Pages`
        FOREIGN KEY (`page_ID`)
        REFERENCES `Pages` (`page_ID`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
      CONSTRAINT `fk_Pages_has_Dependencies_Dependencies1`
        FOREIGN KEY (`depe_ID`)
        REFERENCES `Dependencies` (`depe_ID`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION);
    

    Error that i am getting is :

    QSqlError("1", "Unable to execute statement", "near \"INDEX\": syntax error")
    

    Can anyone tell me what's wrong with this sql statements .


  • Qt Champions 2016

    Hi
    Maybe its called create index ?
    http://www.tutorialspoint.com/sqlite/sqlite_indexes.htm



  • @Qjay

    As far as I remember, it is not possible to create indices within a create table statement in sqlite. So you have to split this into the create table and the create index statement as mentioned by @mrjj



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.