execute the script SQL statement in Sqlplus and output the result to the ouput file--save time by turning off console outputSetTermoff;--The executed SQL statement is displayed in the output file againSetEcho on;--shows the time taken to execute each statementSetTiming on;--100 characters displayed per lineSetLinesize -;--query results every 100 pagesSetPageSize -;--spool Setting the output filespool d:\tempfile\oracle\output.txt;--executes the SQL statement inside the Input.txt@ d:\tempfile\oracle\input.txt;--Export the content from the cache to the file.SpoolifThis operation encountered a problem in output.txt garbled1when the Output.txt file is set to GBK character encoding, it is found that the Chinese characters are garbled in Input.txt2. When you set the Output.txt file to UTF-8 character encoding, describe EMP; Output statement inside the Chinese garbled finally put Input.txt (originally UTF-8The file character encoding is set to GBK; The main problem here is that the Sqlplus client character encoding is GBK, the output content is GBK encoded, if Output.txt is set to UTF-8 Sqlplus The contents of the client through the content is garbled, because the server and the client are GBK encoding, so input.txt all content does not appear character set conversion, so here choose to change the input.txt character set and Sqlplus client character set, And the output.txt set to the same as the Sqlplus client, it solves the garbled. Reason visible Oracle character encoding resolution one, query service-side character setSelectUserenv'language') fromdual; USERENV ('LANGUAGE') ----------------------------------------------------simplified Chinese_china. ZHS16GBK Two, the client Nls_lang parameter (that is, the parameter of Sqlplus) This parameter is used to indicate to Oracle the character set of the client operating system (Sqlplus client). Select * fromV$nls_parameterswhereParameter='Nls_characterset'; PARAMETER VALUE------------------------------ ------------------------------nls_characterset ZHS16GBK Setting up client Nls_lang C:\Users\85243>SetNls_lang=Simplified CHINESE_CHINA.ZHS16GBK C:\Users\85243>SetNls_lang=Simplified Chinese_china.al32utf8 Three, client operating system character set C:\Users\85243>chcp Activity code page:936936 represents the GBK encoding 65001 for the UTF-8
Sqlplus operation--input and output of the file