PostgreSQLã¨MySQLã®Selectæã®çµæãããã¹ãåºåãã
Selectæã®çµæãããã¹ããã¡ã¤ã«ã¸åºåãããã£ãã®ã ãã調ã¹ããã§ãããã¨ãããã£ãã®ã§ããã®ã¡ã¢ã
PostgreSQL
copyã¨ããã³ãã³ãã使ããã
PostgreSQL-7.1-ja : COPY
PostgreSQL-8.1-ja : COPY
使ç¨ä¾
以ä¸ã®ä¾ã¯ãPostgreSQL Version 8.1.11 ã§å®é¨ãããã®ã§ãã
ãã¼ãã«ã丸ãã¨ããã¹ãã«åºåããä¾
postgres=# copy hoge_table to '/tmp/hoge_tbl_export.csv' CSV;
ä¸æãã¼ãã«ãå©ç¨ãã¦ãwhereå¥ãå©ç¨ããçµæãåºåããä¾
BEGIN; CREATE TEMP TABLE a_list_fugas AS SELECT * FROM hoge_table WHERE name LIKE 'fuga%'; COPY a_list_fugas TO '/tmp/hoge_tbl_export_fugas.csv' CSV; ROLLBACK;
PostgreSQL Vertion 8.2 ãã㯠以ä¸ã®ããã« Selectæã使ããããã«ãªã£ãããã§ãã
postgres=# copy (select * from hoge_table where id = 1) TO '/tmp/hoge_tbl_export.csv';
[PostgreSQLウォッチ]第30回 ベータ・テストが間近に迫ったPostgreSQL 8.2の新機能(4ページ目) | 日経 xTECH(クロステック)
MySQL
INTO OUTFILEç¯ãå©ç¨ããã°ãselectã®çµæããã¡ã¤ã«ã¸åºåã§ããã
MySQL :: MySQL 5.6 リファレンスマニュアル :: 13.2.9 SELECT 構文
mysql> select * from hoge_table into outfile 'FILE_NAME';
SELECT ... INTO OUTFILE ã¹ãã¼ãã¡ã³ãã®ç¨éã¯ã主ã«ããµã¼ããã·ã³ä¸ã®ãã¼ãã«ã®ãã³ãããããã¦è¿ éã«å®è¡ã§ããããã«ãããã¨ã§ããããµã¼ããã¹ã以å¤ã®ãã¹ãã«çµæã®ãã¡ã¤ã«ãä½æããå¿ è¦ãããã¨ãã«ã¯ãSELECT ... INTO OUTFILE ã¯ä½¿ç¨ã§ããªãããã®å ´åã代ããã«ãmysqldump --tab ã mysql -e "SELECT ..." > outfile ãªã©ã®ã¯ã©ã¤ã¢ã³ãããã°ã©ã ã使ç¨ãã¦ãã¡ã¤ã«ãçæããã
ããã¼ã便å©ãªæ©è½ããã¾ããã¼ã