On 11/25/15, H?ctor Fiandor <hfiandor at ceniai.inf.cu> wrote:
> Dear members:
>
>
>
> I have asked previously about this matter but nobody answer me.
>
> I have a table to be copied in another one with other name as a temp.
>
> Then I drop the first one.
>
> Then I create another one with same as the dropped table.
>
> Then I copy from the temp to the new created.
>

Why not instead:

(1) BEGIN;
(2) ALTER TABLE table_to_change RENAME TO temporary_name;
(3) CREATE TABLE table_to_change(... new schema here....);
(4) INSERT INTO table_to_change SELECT ... FROM temporary_name;
(5) DROP TABLE temporary_name;
(6) COMMIT;

The BEGIN...COMMIT makes everything appear to happen all at once.

The use of ALTER TABLE in step (2) means that you only copy the data
once instead of twice.
-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to