AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi SQLite führt bestimmte Befehle nicht aus
Thema durchsuchen
Ansicht
Themen-Optionen

SQLite führt bestimmte Befehle nicht aus

Ein Thema von xZise · begonnen am 11. Mär 2009 · letzter Beitrag vom 13. Mär 2009
Antwort Antwort
Assertor

Registriert seit: 4. Feb 2006
Ort: Hamburg
1.296 Beiträge
 
Turbo C++
 
#1

Re: SQLite führt bestimmte Befehle nicht aus

  Alt 11. Mär 2009, 08:28
Hi,

Zitat von xZise:
ich möchte mit SQLite eine Datenbank verwenden, aber habe Probleme mit dem Umbenennen und Löschen von Spalten.

Wenn ich folgende SQL-Befehle ausführe,
Code:
ALTER TABLE <Tabelle> RENAME COLUMN &lt;Oldname&gt; TO &lt;Newname&gt;
ALTER TABLE &lt;Tabelle&gt; DROP COLUMN &lt;Spalte&gt;
Er meldet, einen Syntaxerror bei "near COLUMN" bzw. "near DROP".
Zurecht meldet er einen Fehler.

Von http://www.sqlite.org/lang_altertable.html:
Zitat:
It is not possible to rename a colum, remove a column, or add or remove constraints from a table.
Für die Tabelle selbst wäre es:
ALTER TABLE <Tabelle> RENAME TO <Neuer Tabellenname> Edit: Auch noch schnell in den FAQs folgendes gefunden...
Zitat:
(11) How do I add or delete columns from an existing table in SQLite.

SQLite has limited ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to make more complex changes in the structure of a table, you will have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table.

For example, suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following steps illustrate how this could be done:

SQL-Code:
BEGIN TRANSACTION;
  CREATE TEMPORARY TABLE t1_backup(a,b);
  INSERT INTO t1_backup SELECT a,b FROM t1;
  DROP TABLE t1;
  CREATE TABLE t1(a,b);
  INSERT INTO t1 SELECT a,b FROM t1_backup;
  DROP TABLE t1_backup;
COMMIT;
Gruß Assertor
Frederik
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz