글 수 26
MySQL Table 을 다른 시스템을 이관하는경우 테이블내용을 Excel 이나 csv format File 로 내려 받으면 된다.
아래가 간단한 예제임.
mysql> select * into outfile "/outputpath/outputname.xls"
fields terminated by '\t'
lines terminated by '\n' from sourceDb.sourceTable;
fields terminated by '\t'
lines terminated by '\n' from sourceDb.sourceTable;
Query OK, 48561 rows affected (0.08 sec)
mysql> select * into outfile "/outputpath/outputname.csv"
fields terminated by ','
lines terminated by '\n' from sourceDb.sourceTable;
fields terminated by ','
lines terminated by '\n' from sourceDb.sourceTable;
Query OK, 48561 rows affected (0.09 sec)
파일 생성은 mysql 서버 측에서 생성되기 때문에 서버가 local이 아닌 remote일 경우에는 local에 파일을 생성하기 위해서는 별도로 query 결과를 받아서 파일을 생성해 주는 방법밖에는 없다. 용량이 많아서 메모리에 문제가 되는 경우에는 limit 명령을 활용하는 것도 좋은 방법이 될 것이다.