>
> 파일 언로드는 어떻게 하나요?
> LOAD DATA INFILE 'DATA.TXT' INTO TABLE TEST_TB FIELDS TERMINATED BY ';
> '
> 라는 식으로 로드는 되는데,
> 반대의 경우는 어떻게 하는지 알려주세요...
> 위의 문장과 다 반대로 해도 안되네요...
>
> UNLOAD DATA OUTFILE 'DATA.TXT' FROM TABLE TEST_TB FIELDS TERMINATED BY
> ';'
>
>
>
select 문을 참고하세요. 매뉴얼 좀만 찾아봐도 나오는 내용이네요.
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, and cannot already exist (among other things, this prevents database tables and files such as `/etc/passwd' from being destroyed). You must have the file privilege on the server host to use this form of SELECT. SELECT ... INTO OUTFILE is the complement of LOAD DATA INFILE; the syntax for the export_options part of the statement consists of the same FIELDS and LINES clauses that are used with the LOAD DATA INFILE statement. See section 7.16 LOAD DATA INFILE syntax. In the resulting text file, only the following characters are escaped by the ESCAPED BY character:
The ESCAPED BY character
The first character in FIELDS TERMINATED BY
The first character in LINES TERMINATED BY
Additionally, ASCII 0 is converted to ESCAPED BY followed by 0 (ASCII 48). The reason for the above is that you MUST escape any FIELDS TERMINATED BY, ESCAPED BY or LINES TERMINATED BY characters to reliably be able to read the file back. ASCII 0 is escaped to make it easier to view with some pagers. As the resulting file doesn't have to conform to the SQL syntax, nothing else need be escaped.
|