Created
January 23, 2015 06:07
-
-
Save siteshen/db2098787a918de60f7c to your computer and use it in GitHub Desktop.
Example of adding default value to column having millions of rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- ALTER TABLE users ADD COLUMN deleted boolean NOT NULL DEFAULT false; | |
| ALTER TABLE users ADD COLUMN deleted boolean; | |
| ALTER TABLE users ALTER COLUMN deleted SET DEFAULT false; | |
| UPDATE users SET deleted = false WHERE deleted IS NULL; | |
| ALTER TABLE users ALTER COLUMN deleted SET NOT NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment