Re: [sqlite] Why does the FAQ example use 2 copies for adding/deleting a column
Lothar Scholz <[EMAIL PROTECTED]> wrote: > Hello, > > The example for question 11 in the FAQ has this code for dropping an > existing table column 'c' > > 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; > > This is copying the whole table twice. Is there any reason why it > shouldn't be: > > BEGIN TRANSACTION; > CREATE TEMPORARY TABLE t1_backup(a,b); > INSERT INTO t1_backup SELECT a,b FROM t1; > DROP TABLE t1; > ALTER TABLE t1_backup RENAME TO t1; > COMMIT; > > Or is this just that ALTER TABLE RENAME did not exist when the FAQ was > created? > The latter. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Why does the FAQ example use 2 copies for adding/deleting a column
Hello, The example for question 11 in the FAQ has this code for dropping an existing table column 'c' 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; This is copying the whole table twice. Is there any reason why it shouldn't be: BEGIN TRANSACTION; CREATE TEMPORARY TABLE t1_backup(a,b); INSERT INTO t1_backup SELECT a,b FROM t1; DROP TABLE t1; ALTER TABLE t1_backup RENAME TO t1; COMMIT; Or is this just that ALTER TABLE RENAME did not exist when the FAQ was created? -- Best regards, Lothar Scholz mailto:[EMAIL PROTECTED] - To unsubscribe, send email to [EMAIL PROTECTED] -