Reputation: 523
I want to add a new column with data to existing rows to an existing table.
For example, add a new ADDRESS
column to the table below, then add data for Adam and Tim:
NAME AGE
Adam 25
Tim 30
I used the PgAdmin interface for now to do this directly to change the table without a script.
Upvotes: 6
Views: 10871
Reputation: 192
ALTER TABLE public.users
ADD COLUMN country_code text
// text datatype // if you want to give size of datatype then use int(11)
Upvotes: 1
Reputation: 1269463
The command to add a column to a table is alter table
:
alter table add column address varchar(255);
Or whatever your preferred data type is. Personally, I think this is easier than pointing and clicking through an interface to add a column.
(Also note that the column
keyword is strictly optional, and not even supported by all databases.)
Upvotes: 8