z6c - personal blog about topics

Christian Müller – Letzte Änderung: 08.11.2011 00:18 Uhr

sqlite3 UNIQUE entfernen

Bei Stackoverflow fand ich die Antwort auf die Frage "Wie entferne ich das UNIQUE Flag von Felder in sqlite3 Tabellen?"

SQLite does not support the alter table drop constraint command. You will need to create a new table without a constraint, transfer the data, then delete the old table. I think something like the following should work:

    CREATE TABLE child2 ( id INTEGER PRIMARY KEY, parent_id INTEGER, description TEXT ); 
      INSERT INTO child2 (id, parent_id, description) 
      SELECT id, parent_id, description FROM CHILD; 
    DROP TABLE child; 
    ALTER TABLE child2 RENAME TO child;

You could also leave out parent_id from all the statements above if you don't want it transferred.

Kommentare für diesen Artikel noch nicht freigeschaltet.

Bitte eine Email an kommentare@zentonic.org mit Betreff "Kommentare für Post 7"