Skip to content

Instantly share code, notes, and snippets.

@Adrek
Forked from iangow/column_reorder.sql
Created July 3, 2021 23:51
Show Gist options
  • Save Adrek/976a1d68d8b4c37b7e1091c765d7c602 to your computer and use it in GitHub Desktop.
Save Adrek/976a1d68d8b4c37b7e1091c765d7c602 to your computer and use it in GitHub Desktop.
Change order of columns in PostgreSQL
CREATE TABLE tone_data_temp AS
SELECT file_name, last_update, category, word_count, litigious,
positive, uncertainty, negative, modal_strong, modal_weak
FROM bgt.tone_data;
DROP TABLE bgt.tone_data;
ALTER TABLE tone_data_temp RENAME TO tone_data;
ALTER TABLE tone_data SET SCHEMA bgt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment