sqlplus set命令

电玩女神 2022-08-24 01:53 439阅读 0赞

昨天追踪一条sql select语句执行很慢,发现sqlplus里set命令,有很多,也很好用。特查了一下,发现不少,先转一个如下:

SQL>set colsep’ ‘;     //-域输出分隔符

SQL>set echo off;     //显示start启动的脚本中的每个sql命令,缺省为on

SQL> set echo on //设置运行命令是是否显示语句

SQL> set feedback on; //设置显示“已选择XX行”

SQL>set feedback off;  //回显本次sql命令处理的记录条数,缺省为on

SQL>set heading off;   //输出域标题,缺省为on

SQL>set pagesize 0;   //输出每页行数,缺省为24,为了避免分页,可设定为0。

SQL>set linesize 80;   //输出一行字符个数,缺省为80

SQL>set numwidth 12;  //输出number类型域长度,缺省为10

SQL>set termout off;   //显示脚本中的命令的执行结果,缺省为on

SQL>set trimout on;   //去除标准输出每行的拖尾空格,缺省为off

SQL>set trimspool on;  //去除重定向(spool)输出每行的拖尾空格,缺省为off

SQL>set serveroutput on; //设置允许显示输出类似dbms_output

SQL> set timing on; //设置显示“已用时间:XXXX”

SQL> set autotrace on-; //设置允许对执行的sql进行分析

SQL> set verify off //可以关闭和打开提示确认信息old 1和new 1的显示.

以下为英文的,很全。

Set sqlplus system settings and defaults.

Syntax:

  1. SET option value
  2. SHO[W] option options: most of these have an abbreviated and a long form e.g. APPINFO or APPI will do the same thing
  3. You can get a list of the set options in sqlplus with the command
  4. HELP SET
  5. APPI[NFO]{ON|OFF|text}
  6. Application info for performance monitor (see DBMS_APPLICATION_INFO)
  7. ARRAY[SIZE] {
  8. 15|n}
  9. Fetch size (1 to 5000) the number of rows that will be retrieved in one go.
  10. AUTO[COMMIT] {
  11. OFF|ON|IMM[EDIATE]|n}
  12. Autocommit commits after each SQL command or PL/SQL block
  13. AUTOP[RINT] {
  14. OFF|ON}
  15. Automatic PRINTing of bind variables.(see PRINT)
  16. AUTORECOVERY [ON|OFF]
  17. Configure the RECOVER command to automatically apply
  18. archived redo log files during recovery - without any user confirmation.
  19. AUTOT[RACE] {
  20. OFF|ON|TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
  21. Display a trace report for SELECT, INSERT, UPDATE or DELETE statements
  22. EXPLAIN shows the query execution path by performing an EXPLAIN PLAN.
  23. STATISTICS displays SQL statement statistics.
  24. Using ON or TRACEONLY with no explicit options defaults to EXPLAIN STATISTICS
  25. BLO[CKTERMINATOR] {
  26. .|c|OFF|ON}
  27. Set the non-alphanumeric character used to end PL/SQL blocks to c
  28. CMDS[EP] {;|c|OFF|ON}
  29. Change or enable command separator - default is a semicolon (;)
  30. COLSEP {
  31. |text}
  32. The text to be printed between SELECTed columns normally a space.
  33. COM[PATIBILITY] {V5|V6|V7|V8|NATIVE}
  34. Version of oracle - see also init.ora COMPATIBILITY=
  35. You can set this back by up to 2 major versions e.g. Ora 9 supports 8 and 7
  36. CON[CAT] {
  37. .|c|OFF|ON}
  38. termination character for substitution variable reference
  39. default is a period.
  40. COPYC[OMMIT] {
  41. 0|n}
  42. The COPY command will fetch n batches of data between commits.
  43. (n= 0 to 5000) the size of each fetch=ARRAYSIZE.
  44. If COPYCOMMIT = 0, COPY will commit just once - at the end.
  45. COPYTYPECHECK {OFF|ON}
  46. Suppres the comparison of datatypes while inserting or appending to DB2
  47. DEF[INE] {
  48. &|c|OFF|ON}
  49. c = the char used to prefix substitution variables.
  50. ON or OFF controls whether to replace substitution variables with their values.
  51. (this overrides SET SCAN)
  52. DESCRIBE [DEPTH {
  53. 1|n|ALL}][LINENUM {ON|OFF}][INDENT {ON|OFF}]
  54. Sets the depth of the level to which you can recursively describe an object
  55. (1 to 50) see the DESCRIBE command
  56. ECHO {
  57. OFF|ON}
  58. Display commands as they are executed
  59. EMB[EDDED] {
  60. OFF|ON}
  61. OFF = report printing will start at the top of a new page.
  62. ON = report printing may begin anywhere on a page.
  63. ESC[APE] {
  64. \|c|OFF|ON}
  65. Defines the escape character. OFF undefines. ON enables.
  66. FEED[BACK] {
  67. 6|n|OFF|ON}
  68. Display the number of records returned (when rows > n )
  69. OFF (or n=0) turns the display off
  70. ON sets n=1
  71. FLAGGER {
  72. OFF|ENTRY|INTERMED[IATE]|FULL}
  73. Checks to make sure that SQL statements conform to the ANSI/ISO SQL92 standard.
  74. non-standard constructs are flagged as errors and displayed
  75. See also ALTER SESSION SET FLAGGER.
  76. FLU[SH] {OFF|ON}
  77. Buffer display output (OS)
  78. (no longer used in Oracle 9)
  79. HEA[DING] {OFF|ON}
  80. print column headings
  81. HEADS[EP] {
  82. ||c|OFF|ON}
  83. Define the heading separator character (used to divide a column heading onto > one line.)
  84. OFF will actually print the heading separator char
  85. see also: COLUMN command
  86. INSTANCE [instance_path|LOCAL]
  87. Change the default instance for your session, this command may only be issued when
  88. not already connected and requires Net8
  89. LIN[ESIZE] {
  90. 150|n}
  91. Width of a line (before wrapping to the next line)
  92. Earlier versions default to 80, Oracle 9 is 150
  93. LOBOF[FSET] {n|1}
  94. Starting position from which CLOB and NCLOB data is retrieved and displayed
  95. LOGSOURCE [pathname]
  96. Change the location from which archive logs are retrieved during recovery
  97. normally taken from LOG_ARCHIVE_DEST
  98. LONG {
  99. 80|n}
  100. Set the maximum width (in chars) for displaying and copying LONG values.
  101. LONGC[HUNKSIZE] {
  102. 80|n}
  103. Set the fetch size (in chars) for retrieving LONG values.
  104. MARK[UP] HTML [ON|OFF]
  105. [HEAD text] [BODY text] [TABLE text]
  106. [ENTMAP {
  107. ON|OFF}][SPOOL {ON|OFF}]
  108. [PRE[FORMAT] {ON|OFF}]
  109. Output HTML text, which is the output used by iSQL*Plus.
  110. NEWP[AGE] {1|n} NULL text
  111. The number of blank lines between the top of each page and the top title.
  112. 0 = a formfeed between pages.
  113. NULL text
  114. Replace a null value with 'text'
  115. The NULL clause of the COLUMN command will override this for a given column.
  116. NUMF[ORMAT] format
  117. The default number format.
  118. see COLUMN FORMAT.
  119. NUM[WIDTH] {10|n}
  120. The default width for displaying numbers.
  121. PAGES[IZE] {
  122. 14|n}
  123. The height of the page - number of lines.
  124. 0 will suppress all headings, page breaks, titles
  125. PAU[SE] {
  126. OFF|ON|text}
  127. press [Return] after each page
  128. enclose text in single quotes
  129. RECSEP {
  130. WR[APPED]|EA[CH]|OFF}
  131. Print a single line of the RECSEPCHAR between each record.
  132. WRAPPED = print only for wrapped lines
  133. EACH=print for every row
  134. RECSEPCHAR {_|c}
  135. Define the RECSEPCHAR character, default= ' '
  136. SCAN {OFF|ON}
  137. OFF = disable substitution variables and parameters
  138. SERVEROUT[PUT] {OFF|ON} [SIZE n] [FOR[MAT] {WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]}]
  139. whether to display the output of stored procedures (or PL/SQL blocks)
  140. i.e., DBMS_OUTPUT.PUT_LINE
  141. SIZE = buffer size (2000-1,000,000) bytes
  142. SHOW[MODE] {OFF|ON}
  143. Display old and new settings of a system variable SPA[CE] {1|n} The number of spaces between columns in output (1-10) SQLBL[ANKLINES] {ON|OFF}
  144. Allow blank lines within an SQL command. reverts to OFF after the curent command/block.
  145. SQLC[ASE] {
  146. MIX[ED]|LO[WER]|UP[PER]}
  147. Convert the case of SQL commands and PL/SQL blocks
  148. (but not the SQL buffer itself)
  149. SQLPLUSCOMPAT[IBILITY] {x.y[.z]}
  150. Set the behavior or output format of VARIABLE to that of the
  151. release or version specified by x.y[.z].
  152. SQLCO[NTINUE] {> |text}
  153. Continuation prompt (used when a command is continued on an additional line using a hyphen -)
  154. SQLN[UMBER] {OFF|ON}
  155. Set the prompt for the second and subsequent lines of a command or PL/SQL block.
  156. ON = set the SQL prompt = the line number.
  157. OFF = set the SQL prompt = SQLPROMPT.
  158. SQLPRE[FIX] {#|c}
  159. set a non-alphanumeric prefix char for immediately executing one line of SQL (#)
  160. SQLP[ROMPT] {
  161. SQL>|text}
  162. Set the command prompt.
  163. SQLT[ERMINATOR] {
  164. ;|c|OFF|ON}|
  165. Set the char used to end and execute SQL commands to c.
  166. OFF disables the command terminator - use an empty line instead.
  167. ON resets the terminator to the default semicolon (;).
  168. SUF[FIX] {SQL|text}
  169. Default file extension for SQL scripts
  170. TAB {OFF|ON}
  171. Format white space in terminal output.
  172. OFF = use spaces to format white space.
  173. ON = use the TAB char.
  174. Note this does not apply to spooled output files.
  175. The default is system-dependent. Enter SHOW TAB to see the default value.
  176. TERM[OUT] {OFF|ON}
  177. OFF suppresses the display of output from a command file
  178. ON displays the output.
  179. TERMOUT OFF does not affect the output from commands entered interactively.
  180. TI[ME] {OFF|ON}
  181. Display the time at the command prompt.
  182. TIMI[NG] {OFF|ON}
  183. ON = display timing statistics for each SQL command or PL/SQL block run.
  184. OFF = suppress timing statistics
  185. TRIM[OUT] {OFF|ON}
  186. Display trailing blanks at the end of each line.
  187. ON = remove blanks, improving performance
  188. OFF = display blanks.
  189. This does not affect spooled output.
  190. SQL*Plus ignores TRIMOUT ON unless you set TAB ON.
  191. TRIMS[POOL] {ON|OFF}
  192. Allows trailing blanks at the end of each spooled line.
  193. This does not affect terminal output.
  194. UND[ERLINE] {
  195. -|c|ON|OFF}
  196. Set the char used to underline column headings to c.
  197. VER[IFY] {OFF|ON}
  198. ON = list the text of a command before and after replacing substitution variables with values.
  199. OFF = dont display the command.
  200. WRA[P] {OFF|ON}
  201. Controls whether to truncate or wrap the display of long lines.
  202. OFF = truncate
  203. ON = wrap to the next line
  204. The COLUMN command (WRAPPED and TRUNCATED clause) can override this for specific columns.

The items in Bold on this page are deprecated or missing in Oracle 9 - also note that many of the above options have ‘gone missing’ from the official documentation set - HELP SET is a more accurate reference.

发表评论

表情:
评论列表 (有 0 条评论,439人围观)

还没有评论,来说两句吧...

相关阅读

    相关 sqlplus set命令

    昨天追踪一条sql select语句执行很慢,发现sqlplus里set命令,有很多,也很好用。特查了一下,发现不少,先转一个如下: SQL>set colsep' '

    相关 sqlplus set 参数详解

    SQL\PLUS维护系统变量,也称SET变量,利用它可为SQL\PLUS交互建立一个特殊的环境,如:设 置NUMBER数据的显示宽度;设置每页的行数;设置列的宽度等。可用S

    相关 sqlplus 命令

    对于oracle 数据库主要的使用命令,是sqlplus来完成。 在linux上的风格是: \[oracle@station ~\]$ sqlplus SQL\Plus

    相关 sqlplus的常用命令

    近要使用sqlplus来管理数据库,在此,把一些常常用到命令整理记录下来。 执行一个SQL脚本文件:start file\_name或@ file\_name  对当...