[pgsql] pgsql export to csv

To export PostgreSQL data to csv file using psql interactive terminal.

open terminal
su postgres
psql <db_name>
\f ','
\a
\t
\o outputfile.csv
select ..... (your sql select statement)
\o
\q


Additional notes: If you want a TAB delimited file instead of comma, use \f 'Ctrl-V TAB'. \f sets the field separator. \a echo all. \t tuples(rows) only. \q quit.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by ⓒ쟁이™

2008/10/31 18:38 2008/10/31 18:38
, ,
Response
No Trackback , No Comment
RSS :
http://funix.net/rss/response/32

[mysql] 쿼리 결과를 파일로 저장하기

SELECT colname INTO OUTFILE "~/outfile.csv" FIELDS TERMINATED BY ',' FROM table;

09. 02. 23 added

mysql db의 user권한 중 파일 핸들링 가능토록 조정

$ mysql -uroot -pxxxx mysql

update user set File_priv='Y' where user='userid';

flush privileges;

금지!

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by ⓒ쟁이™

2008/07/11 16:41 2008/07/11 16:41
, , , ,
Response
No Trackback , No Comment
RSS :
http://funix.net/rss/response/21


Archives

Recent Trackbacks

129

94

-14 days

today : 114

Creative Commons License

이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.