Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi SQLite führt bestimmte Befehle nicht aus (https://www.delphipraxis.net/130608-sqlite-fuehrt-bestimmte-befehle-nicht-aus.html)

xZise 11. Mär 2009 09:23

Datenbank: SqLite

SQLite führt bestimmte Befehle nicht aus
 
Hallo DP,

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[list=1] TO <Newname>
ALTER TABLE <Tabelle> DROP COLUMN <Spalte>
Er meldet, einen Syntaxerror bei "near COLUMN" bzw. "near DROP".

Was muss ich nun tun?

MfG
xZise

[edit=mkinzler] Mfg, mkinzler[/edit]

mkinzler 11. Mär 2009 09:24

Re: SQLite führt bestimmte Befehle nicht aus
 
Führst du die Befehle einzeln aus oder zusammen?

DP-Maintenance 11. Mär 2009 09:25

DP-Maintenance
 
Dieses Thema wurde von "mkinzler" von "Object-Pascal / Delphi-Language" nach "Datenbanken" verschoben.
Ist ein SQL-Problem

Assertor 11. Mär 2009 09:28

Re: SQLite führt bestimmte Befehle nicht aus
 
Hi,

Zitat:

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:
SQL-Code:
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

xZise 13. Mär 2009 15:28

Re: SQLite führt bestimmte Befehle nicht aus
 
Hallo ihr,

ich führe die Befehle einzeln aus. Und danke Assertor. Dann hoffe ich mal, dass es mal implementiert wird :)

MfG
xZise

Assertor 13. Mär 2009 17:18

Re: SQLite führt bestimmte Befehle nicht aus
 
Hi xZise,

Zitat:

Zitat von xZise
Und danke Assertor. Dann hoffe ich mal, dass es mal implementiert wird :)

Keine Ursache, gerne! Ja, SQLite3 ist eine tolle Software, die ich auch gerne einsetze. Aber es ist halt klein/schnell/schlank, daher sind manche Sachen nicht implementiert. Vielleicht kommt das ja in einer der nächsten Versionen, wenn man mal guckt wie viel inzwischen seit v2 schon drin ist, stehen die Chancen ja ganz gut.

Gruß Assertor,
<- der seit gestern in der linken Infospalte eine 30 trägt :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:57 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 by Thomas Breitkreuz