Sqlplus operation--input and output of the file

Source: Internet
Author: User
Tags sqlplus

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.