Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved What's wrong with this SQLite query ?

    General and Desktop
    qt5.5 sqlite3 sqlite database sqlite
    3
    3
    2546
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Qjay
      Qjay last edited by

      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 .

      the_ 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        1 Reply Last reply Reply Quote 2
        • the_
          the_ @Qjay last edited by

          @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

          -- No support in PM --

          1 Reply Last reply Reply Quote 1
          • First post
            Last post