Khrystyna Kosenko
Khrystyna Kosenko

Reputation: 121

How to save results of query into a new column, postgres

How to add results of selecting query to a new column in already existing table in PostgreSQL in pgAdmin?

Results of the select query is an alteration of over columns in the same table.

Upvotes: 2

Views: 3289

Answers (1)

Fabian Pijcke
Fabian Pijcke

Reputation: 3210

Just create the column and update data afterwards (using the command line bundled in pgadmin):

ALTER TABLE tablename ADD COLUMN colname coltype;
UPDATE tablename SET colname = yourexpression;

Upvotes: 1

Related Questions