sql - Postgres - CREATE TABLE FROM SELECT -
i have 2 tables, 1 contains large list of ids , info regarding ids.
i have second table graph has 2 columns, each column contains aforementioned id numbers, multiple times. want trim size of info table selecting ids appear in graph , creating new smaller info table. there simple way of doing this?
create table select?
thanks!
a
it's easy as:
create table new_table select t1.col1, t2.col2 some_table t1 join t2 on t1.id = t2.some_id;
you can use select statement that. column names of new table defined column aliases used in th query.
more details in manual: http://www.postgresql.org/docs/current/static/sql-createtableas.html
Comments
Post a Comment