Is this proper postgresql syntax to add a column to a table with a default value of false
ALTER TABLE users
ADD "priv_user" BIT
ALTER priv_user SET DEFAULT '0'
Thanks!
This question is related to
sql
postgresql
If you are using postgresql then you have to use column type BOOLEAN in lower case as boolean.
ALTER TABLE users ADD "priv_user" boolean DEFAULT false;
If you want an actual boolean column:
ALTER TABLE users ADD "priv_user" boolean DEFAULT false;
Just for future reference, if you already have a boolean column and you just want to add a default do:
ALTER TABLE users
ALTER COLUMN priv_user SET DEFAULT false;
In psql alter column query syntax like this
Alter table users add column priv_user boolean default false ;
boolean value (true-false) save in DB like (t-f) value .
Source: Stackoverflow.com