Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]3442[/thread]

SQLite: neue spalte in tabelle einfügen



<< >> 4 Einträge, 1 Seite
Taulmarill
 2004-04-22 18:47
#32038 #32038
User since
2004-02-19
1750 Artikel
BenutzerIn

user image
gibt es eine elegante möglichkeit bei SQLite eine neue spalte in eine vorhandene tabelle einzufügen?
im moment sehe ich nur die möglichkeit die alten daten zu sichern und die tabelle zu löschen und dann mit ergänzter spalte neu anzulegen.
$_=unpack"B*",~pack"H*",$_ and y&1|0& |#&&print"$_\n"for@.=qw BFA2F7C39139F45F78
0A28104594444504400 0A2F107D54447DE7800 0A2110453444450500 73CF1045138445F4800 0
F3EF2044E3D17DE 8A08A0451412411 F3CF207DF41C79E 820A20451412414 83E93C4513D17D2B
renee
 2004-04-22 18:57
#32039 #32039
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Da SQLite solche Querys wie "ALTER TABLE..." nicht unterstützt, musst Du Dir wohl ein Workaround in Deinem Skript schreiben (Wie Du es schon beschrieben hast).
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
renee
 2004-04-22 18:59
#32040 #32040
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ich habe noch folgendes gefunden (bei http://www.sqlite.org/faq.html#q13):
Quote
(13) How do I add or delete columns from an existing table in SQLite.

SQLite does not support the "ALTER TABLE" SQL command. If you what to change the structure of a table, you 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:

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;
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Taulmarill
 2004-04-23 13:03
#32041 #32041
User since
2004-02-19
1750 Artikel
BenutzerIn

user image
jo, danke.
das hilft mir schon mal weiter
$_=unpack"B*",~pack"H*",$_ and y&1|0& |#&&print"$_\n"for@.=qw BFA2F7C39139F45F78
0A28104594444504400 0A2F107D54447DE7800 0A2110453444450500 73CF1045138445F4800 0
F3EF2044E3D17DE 8A08A0451412411 F3CF207DF41C79E 820A20451412414 83E93C4513D17D2B
<< >> 4 Einträge, 1 Seite



View all threads created 2004-04-22 18:47.