Skip to content

Instantly share code, notes, and snippets.

@mattwigway
Created November 12, 2011 17:33
Show Gist options
  • Save mattwigway/1360850 to your computer and use it in GitHub Desktop.
Save mattwigway/1360850 to your computer and use it in GitHub Desktop.
Convert time varchar(19) to time::timestamp
ALTER TABLE nextbus RENAME COLUMN time TO time_orig; -- save the old column
ALTER TABLE nextbus ADD COLUMN time timestamp; -- create the new column
UPDATE acrt.nextbus SET time = time_orig::timestamp; -- set the timestamps. This takes a VERY VERY LONG time; for a 395k point table, it took over 654 (!) seconds
ALTER TABLE nextbus DROP COLUMN time_orig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment