Skip to content

Instantly share code, notes, and snippets.

@itomg
Created September 3, 2014 03:55
Show Gist options
  • Save itomg/b659b8a159e5a29b6040 to your computer and use it in GitHub Desktop.
Save itomg/b659b8a159e5a29b6040 to your computer and use it in GitHub Desktop.
PostgreSQL 导出导入表中指定查询数据
psql:
1.创建临时表
create table test_view as select * from test where date(to_timestamp(endtime))>='2012-09-02';
2.导出临时表数据为文本
copy test_view to '/home/postgres/test_view.txt' with delimiter as '|';
3.导入文件数据到数据库中指定表
delete from test;
copy test from '/home/postgres/test_view.txt' with delimiter as '|';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment