Reputation: 345
I am looking for a way to append two tables in postgresql
table_1 is like
name | age | grade
aaa 20 A
bbb 21 B
And table_2 is like
name | age | grade
ccc 20 C
ddd 22 A
What i am trying to do is append table_2 to table_1, so that table_1 will be
name | age | grade
aaa 20 A
bbb 21 B
ccc 20 C
ddd 22 A
Done these things. Like create a "sample.sql" file and try to run
database_name=# \i /path/to/sample.sql
It resulted in error. The statements in sample.sql file is
select * from table_1
union
select * from table_2
insert into table_1;
I am new to the database thing.
Upvotes: 3
Views: 13449
Reputation:
insert into table_1 (name, age, grade)
select name, age, grade
from table_2;
Upvotes: 10