Oracle SQL Plus The Definitive Guide- P42 doc

10 184 0
Oracle SQL Plus The Definitive Guide- P42 doc

Đang tải... (xem toàn văn)

Thông tin tài liệu

< previous page page_373 next page > Page 373 SET HEA[DING] [ON¦OFF] where: SETHEA[DING] Is the command, which may be abbreviated SET HEA. ON Causes column headings to print when you select data. OFF Suppresses column headings. This setting is on by default, so you normally get a column heading whenever you select or print data using either the SELECT command or the PRINT command. For example: SQL> SELECT * FROM dual; D - X Change the value to OFF, and your column headings go away. The following example shows this: SQL> SET HEADING OFF SQL> SELECT * FROM dual; X Issuing a SET PAGESIZE 0 command will also turn headings off. If you are trying to enable headings, and SET HEADING ON does not appear to be working, then you should check the pagesize as well. SETLINESIZE Use SET LINESIZE to control the number of characters SQL*Plus prints on one physical line. The default setting is 80. The maximum width is system-dependent. Under Windows 95, it is 32,767. SET LIN[ESIZE] line_width where: SET LIN[ESIZE] Is the command, which may be abbreviated to SET LIN. line_width Is the new line width, expressed as a number of characters. < previous page page_373 next page > < previous page page_374 next page > Page 374 The linesize setting is also referenced by SQL*Plus when you define any headers or footers (see TTITLE, BTITLE, REPHEADER, REPFOOTER) that are centered or right-justified. SET MAXDATA MAXDATA is an obsolete setting that should no longer be used. SQL*Plus supports it in order to be backward- compatible. MAXDATA controls the maximum row length SQL*Plus can handle. SET MAXD[ATA} max_row_width where: SETMAXD[ATA] Is the command, which may be abbreviated to SET MAXD. max_row_width Is the new setting for the maximum row width you expect to process. The default setting under Windows 95 is zero, but may vary from one operating system to the next. Under some operating systems, such as Windows 95, this setting seems to have no effect whatsoever on SQL*Plus's behavior. SETNEWPAGE Controls the manner in which the transition from one page to the next is marked. You can have SQL*Plus print a formfeed character at the start of each new page, skip a specific number of lines between pages, or do nothing at all when advancing from one page to another: SET NEWP[AGE] {lines_to_print¦NONE} where: SETNEWP[AGE] Is the command, which may be abbreviated to SET NEWP. lines_to_print Tells SQL*Plus to print a specific number of blank lines when a page break occurs. These lines will be printed following the footer (BTITLE) of the page just ending, and prior to the header (TTITLE) of the page just starting. If this value is zero, and only if it is zero, a formfeed character will be printed instead of any blank lines. The default value is 1. NONE Causes SQL*Plus to do nothing at all when a page break occursno blank lines, no formfeed. < previous page page_374 next page > < previous page page_375 next page > Page 375 Use SET NEWPAGE 0 if you want a formfeed printed at the start of each new page. SETNULL SET NULL allows you to change the text SQL*Plus prints in a column when the value for that column is null: SET NULL null_text where: SETNULL Is the command, which may not be abbreviated. null_text Is the text you want to print in place of a null value. The default null text setting is an empty string, which causes null values to print as blanks. The following example shows this, and also shows how the null text may be changed: SQL> SELECT employee_termination_date 2 FROM employee 3 WHERE employee_id=101; EMPLOYEE_ SQL> SET HULL *NULL* SQL> SELECT employee_termination_date 2 FROM employee 3 WHERE employee_id=101; EMPLOYEE_ *NULL* If you use the COLUMN command to format a column, the NULL clause of that command will override this setting, but only for that one column. SET NUMFORMAT SET NUMFORMAT allows you to specify the default formatting of numeric values returned from a SELECT statement. Any number format usable with the COLUMN command may also be used with SET NUMFORMAT. SET NUMF[ORMAT] format_spec < previous page page_375 next page > < previous page page_376 next page > Page 376 where: SET NUMF[ORMAT] Is the command, which may be abbreviated to SET NUMF. format_spec Is a numeric format specification, which controls the default manner in which numeric values are displayed. See Appendix B, SQL*Plus Format Elements, for a list of formats. The following example shows the effect of changing the NUMFORMAT setting: SQL> SELECT 123456.7 FROM dual; 123456.7 123456.7 SQL> SET NUMFORMAT $999,999.99 SQL> SELECT 123456.7 FROM dual; 123456.7 $123,456.70 The NUMFORMAT setting controls the default display format for numeric values. You can use the COLUMN command to specify display formats on a column-by-column basis, and those take precedence over the NUMFORMAT setting. SETNUMWIDTH SET NUMWIDTH controls the default width used when displaying numeric values: SET NUM[WIDTH] width where: SET NUM[WIDTH] Is the command, which may be abbreviated to SET NUM. width Is the default column width used when displaying a numeric value. The default NUMWIDTH setting is 10. NUMWIDTH is used only when no other settings apply. The following example shows the effect of setting NUMWIDTH to 5: SQL> SET NUMWIDTH 5 SQL> SELECT 123 FROM dual; 123 123 < previous page page_376 next page > < previous page page_377 next page > Page 377 A numeric format specified by a COLUMN command or by a SET NUMFORMAT command will override NUMWIDTH. The following example shows this: SQL> SET NUMWIDTH 5 SQL> SET NUMFORMAT 999,999.99 SQL> SELECT 123 FROM dual; 123 123.00 SQL> SHOW NUMWIDTH numwidth 5 As you can see, NUMWIDTH is still 5, but that value is ignored because the NUMFORMAT setting takes precedence. A long column title can also cause NUMWIDTH to be ignored, as the following example demonstrates: SQL> SET NUMWIDTH 5 SQL> SET NUMFORMAT SQL> COLUMN a HEADING This is a long column title SQL> SELECT 123 a FROM dual; This is a long column title 123 As you can see, the column title takes precedence over NUMWIDTH when it comes to determining the width of the column. SET PAGESIZE Use SET PAGESIZE to tell SQL*Plus the number of printed lines that will fit on one page of output. You can also use this setting to completely turn off all pagination functions. SET PAGES[IZE] lines_on_page where: SET PAGES[IZE] Is the command, which may be abbreviated to SET PAGES. lines_on_page Is the number of lines you want SQL*Plus to print on one page. This includes detail lines, header lines, and footer lines. The default value for PAGESIZE is 24. For SQL*Plus versions 2.1 and earlier, the default was 14. The PAGESIZE must be set in conjunction with NEWPAGE. The sum of PAGESIZE and NEWPAGE should equal the number of lines that will physically fit on one page. SQL*Plus will print headers, detail, and footers until PAGESIZE lines have been printed. Then it will print NEWPAGE lines to advance to the next page, < previous page page_377 next page > < previous page page_378 next page > Page 378 where the process starts over again. Your page titles will drift up or down with each new page if these settings don't match the page's physical size. The exception to this is when you use SET NEWPAGE 0. If you use SET NEWPAGE 0 to cause a formfeed to print at the beginning of each page, you should set PAGESIZE to at least one less than the physical number of lines on a page. Failure to do so may result in alternating blank pages in your printed report. You can completely turn off all pagination by issuing a SET PAGESIZE 0 command. This will eliminate page titles, page footers, column titles, and any blank lines or formfeeds from the NEWPAGE setting. SET RECSEP SET RECSEP is used to tell SQL*Plus whether or not to print a record separator between each record displayed as the result of a query. The default setting is not to print anything, except when a long record wraps to a second line. In that case, a blank line is printed as a record separator. SET RECSEP {WR[APPED] ¦ EA[CH] ¦OFF} where: SET RECSEP Is the command, which may not be abbreviated. WRAPPED] Tells SQL*Plus to print a record separator only when a line wraps. This is the default setting. EA[CH] Tells SQL*Plus to print a record separator after each record. OFF Tells SQL*Plus not to print any record separators at all. The default setting is WRAPPED, which is probably a safe choice, because it causes a separator to print only in cases where a break between records may not be obviousin other words, where each line does not necessarily start a new record. Here is an example of a record separator being printed: SQL> COLUMN view_name FORMAT A15 SQL> SELECT view_name FROM all_views; ALL_ALL_TABLES ALL_ARGUMENTS ALL_CATALOG ALL_CLUSTERS ALL_CLUSTERS_HAS < previous page page_378 next page > < previous page page_379 next page > Page 379 H_EXPRESSISONS ALL_COLL_TYPES You can see that the record separator, by default a blank line, was printed after the ALL_CLUSTER_HASH_EXPRESSIONS view was listed. This blank line removes any ambiguity about whether H_EXPRESSIONS and ALL_CLUSTER_HAS are two separate views or if a long view name has wrapped to a second line. Setting RECSEP to OFF yields the following results: SQL> SET RESCEP OFF SQL> SELECT VIEW_NAME from all_views; ALL_ALL_TABLES ALL_ARGUMENTS ALL_CATALOG ALL_CLUSTERS ALL_CLUSTER_HAS H_EXPRESSIONS ALL_COLL_TYPES Do you see six views listed or seven? How would you know? In addition to controlling whether or not the record separator prints, you can control the character used as well. See the SET RECSEPCHAR command. SET RECSEPCHAR Use SET RECSEPCHAR to change the record separator to something other than a line of space characters: SET RECSEPCHAR separator_char where: SET RECSEPCHAR Is the command, which may not be abbreviated. separator_char Is the character you want to use in the record separator line. The default value is a space. The default record separator is a blank line. The following example shows how you can change it to be a line of asterisks instead: SQL> SET RECSEPCHAR * SQL> SET RECSEP EACH SQL> SELECT view_name FROM all_views; ALL_ALL_TABLES **************************************************************************** ALL_ARGUMENTS **************************************************************************** ALL_CATALOG **************************************************************************** < previous page page_379 next page > < previous page page_380 next page > Page 380 This example uses SET RECSEP EACH to cause a separator to print after each record, so that you will have something to look at. The separator character was set to an asterisk, causing you to get a full line of asterisks between each record. The length of the separator line will match the LINESIZE setting. SET SHIFTINOUT The SHIFTINOUT setting controls whether or not shift characters are displayed as part of the output. It is usable only with IBM 3270 terminals and their equivalent, and only when SQL*Plus is displaying data in a shift-sensitive character set. SET SHIFT[INOUT] {VIS[IBLE] ¦ INV[ISIBLE]} where: SET SHIFT[INOUT] Is the command, which may be abbreviated to SHIFT. VIS[IBLE] Allows shift characters to be visible. INV[ISIBLE] Keeps shift characters from being displayed. The default setting is INVISIBLE. SET SPACE SET SPACE is an obsolete command similar to SET COLSEP. It allows you to specify the number of spaces SQL*Plus prints between columns of output. SET SPACE num_of_spaces where: SET SPACE Is the command, which may not be abbreviated. num_of_spaces Is the new setting for the number of spaces you want to print between columns. The default setting is one space. The following example shows how SET SPACE works by changing the spacing between columns from one to five spaces: SQL> SELECT A a, B FROM dual; A B - - A B SQL> SET SPACE 5 < previous page page_380 next page > < previous page page_381 next page > Page 381 SQL> SELECT A a, B FROM dual; A B - - A B Issuing SET SPACE 5 has the exact same effect as if you were to issue SET COLSEP . In fact, the two settings are kept in sync with one another. The SET SPACE command will change the COLSEP setting to match. SET TAB The TAB setting controls whether or not SQL*Plus uses tab characters when generating whitespace in terminal output. This setting is a throwback to the days when terminal connections ran at very slow data rates, such as 1200 bits per second. SET TAB {OFF¦ON} where: SET TAB Is the command, which may not be abbreviated. ON Is the default setting, and allows SQL*Plus to insert tabs into the output rather than displaying a large number of space characters. OFF Forces SQL*Plus to use space characters for all whitespace. The default setting is ON, which allows SQL*Plus to use tab characters in the output. SET TRIMOUT The TRIMOUT setting controls whether or not SQL*Plus displays any trailing spaces that may occur at the end of a line. The default setting is ON, which causes SQL*Plus to display only up to the last non-blank character on a line. SET TRIM[OUT] {ON¦OF} where: SETTRIM[OUT] Is the command, which may be abbreviated to SET TRIM. ON Causes SQL*Plus to trim any trailing spaces from each line before it is displayed. This is the default setting. OFF Causes SQL*Plus to display all characters on a line, even the trailing spaces. < previous page page_381 next page > < previous page page_382 next page > Page 382 The default setting of ON usually works well when displaying data on a terminal, so there's rarely a reason to turn this setting off. TRIMOUT has no effect on spooled output. If you are spooling output to a file, the TRIMSPOOL setting controls whether or not trailing spaces are spooled as well. SET TRIMSPOOL The TRIMSPOOL setting controls whether or not SQL*Plus writes trailing spaces when spooling data to a file. The default setting is OFF, which causes SQL*Plus to write each line to the spool file in its entirety, trailing spaces and all. SET TRIMS[POOL] {ON¦OFF} where: SET TRIMS[POOL] Is the command, which may be abbreviated to SET TRIMS. ON Causes SQL*Plus to trim any trailing spaces from each line before it is written to the spool file. OFF Causes SQL*Plus to write all characters of a line to the spool file, even the trailing spaces. This is the default setting. If you are spooling data to a file in order to load it into another program, you will want to leave TRIMSPOOL ON. Otherwise, the program reading the spool file might return errors because the records are shorter than expected. SET TRUNCATE SET TRUNCATE is an obsolete command that gives you the same choice as SET WRAP. You can choose whether or not to truncate lines that are longer than the LINESIZE setting. SET TRU[NCATE] (OFF¦ ON} where: SET TRU[NCATE] Is the command, which may be abbreviated to TRU. OFF Is the default setting, and allows long lines to be wrapped. ON Causes long lines of output to be truncated to match the current LINESIZE setting. < previous page page_382 next page > . whatsoever on SQL* Plus& apos;s behavior. SETNEWPAGE Controls the manner in which the transition from one page to the next is marked. You can have SQL* Plus print a formfeed character at the start. Forces SQL* Plus to use space characters for all whitespace. The default setting is ON, which allows SQL* Plus to use tab characters in the output. SET TRIMOUT The TRIMOUT setting controls whether. TRIMSPOOL The TRIMSPOOL setting controls whether or not SQL* Plus writes trailing spaces when spooling data to a file. The default setting is OFF, which causes SQL* Plus to write each line to the spool

Ngày đăng: 05/07/2014, 04:20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan