Featured Categories Tags RSS Archive About
the usual
the usual
inconsistent at best
Tags / Sqlite
SQL Fast Column Add

I found a fast way to add a new column to a table.

MySQL

  1. Create the new table like the old table (foo), but with the new column you want in it. Make the new table with a different name (foo_new):

  2. Add the records from the old table into the new table:

     INSERT INTO foo_new (col1, col2, col3)
          SELECT col1, col2, col3 FROM foo
    
  3. If you have a lot of records, you can disable index updates during insert:

2013-05-23    
the usual
inconsistent at best
Featured Categories Tags RSS Archive About
Hugo Theme Diary by Rise
Ported from Makito's Journal.

© Scott Wiersdorf
keyboard_arrow_up dark_mode
Hugo Theme Diary by Rise
Ported from Makito's Journal.

© Scott Wiersdorf