1. Trang chủ
  2. » Công Nghệ Thông Tin

Oracle SQL Plus The Definitive Guide- P31 doc

10 193 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 130,61 KB

Nội dung

< previous page page_365 next page > Page 365 Figure 11-5. Connecting to the PRODUCTION database NLS_ANG This parameter applies to all versions of SQL*Plus. It controls the language used for messages, the character set used, the sort order to be used, the manner in which dates are displayed, and other language-specific settings. The format for this setting is as follows: LANGUAGE_TERRITORY.CHARACTER_SET where: LANGUAGE Specifies the language to be used. This controls the language used for messages and the names of days and months, among other things. TERRITORY Specifies the territory. This controls the currency indicator, the decimal character, and the way dates are formatted. CHARACTER_SET Specifies the character set to be used. This impacts sorting and the way characters are converted between upper-and lowercase. The default value of the NLS_LANG setting for a Windows client installation is: AMERICAN_AMERICA.WE8ISO8859P1 This setting is used by other Oracle products, and is not one to toy with lightly. If you aren't sure what you are doing, it's best to leave this alone. For detailed information on Oracle's language support, see the Oracle8 Server Reference manual. < previous page page_365 next page > < previous page page_366 next page > Page 366 PRO80 The PRO80 variable specifies the location of the SQLUSMSB message file. This message file is used by a number of different Oracle products, including some versions of SQL*Plus. The 80 in the setting name refers to the specific Oracle version being used, so when Oracle 8.1 is shipped, the name of this setting will change to PRO81. The default value for this setting, under Windows 95, is: C:\ORAWIN95\PRO80 This setting applies to all operating systems. PLUS80 The PLUS80 variable points to the directory that contains the SQL*Plus message files, the glogin.sql file, and the scripts to create the SQL*Plus help. The default value for this setting, under Windows NT, is: C:\ORANT\PLUS80 The 80 corresponds to the SQL*Plus version. SQL*Plus 2.3, which shipped with Oracle 7.3, uses the PLUS23 variable. Under some operating systems, such as HP-UX, Oracle does not use this setting. RDBMS80 This variable points to the directory containing the message files that correspond to the particular language you're using. The default setting, under Windows NT, is: C:\ORANT\RDBMS80 The message files of interest to SQL*Plus are: LCDUS.MSB, ORAUS.MSB, and SOSDUS.MSB. These are the names of the American English versions of the message files; if you are using a different language, the file names may be different. As with PRO80, and PLUS80, the 80 in the setting name refers to the specific version of Oracle you are using. SQLPATH Of all the variables, SQLPATH is probably the most useful. The SQLPATH variable contains a search path that is followed by SQL*Plus when it's looking for a script file. It consists of one or more directory names, separated by semicolons. There is no default value under Unix, but under Windows, the default will be something like this: C:\ORAWIN95\DBS < previous page page_366 next page > < previous page page_367 next page > Page 367 The \DBS directory is where the default login.sql script file is installed under Windows. You can add your own directories to the search path; just be sure to separate each directory name from the next with a semicolon, as shown here: c:\jonathan\sql_scripts; C:\ORAWIN95\DBS When you invoke a SQL script without providing the full path, SQL*Plus will first look in the current directory; then it will search each directory listed in SQLPATH. The directories are searched in the order in which they are listed. The SQLPATH setting applies to SQL*Plus on all operating systems. PLUS_DFLT This is a Windows-specific setting that controls which version of SQL*Plus is executed when you invoke the sqlplus. exe executable. A Windows system will typically have at least two different SQL*Plus executables installed. One is a GUI version and the other is a DOS version. For SQL*Plus 8.0, the executables are named according to the following convention: PLUS80 the DOS executable PLUS80W the GUI executable In addition, it is possible to have two or more versions of SQL*Plus installed under Windows, and each version will still have two executables. Thus, a PC with SQL*Plus 3.3 and SQL*Plus 8.0 would have the following four executable files: PLUS80 8.0 DOS PLUS80W 8.0 GUI PLUS33 7.3 DOS PLUS33W 7.3 GUI This makes for a bit of a problem if you are writing batch files that make use of SQL*Plus. You would need to hardcode the executable name in each batch file, then edit those files whenever you upgraded to a new version. To ease your pain, Oracle supplies a generic executable named sqlplus.exe. This generic executable reads the registry, gets the value of the PLUS_DFLT variable, and invokes the executable named by that value. The default value of PLUS_DFLT will be that of the DOS executable, for example, PLUS80, in order to facilitate the writing of batch files. When you set this variable, do not include the exe extension as part of the filename. For example, PLUS80 is correct, PLUS80.EXE is not. The SET Command SQL*Plus contains a large number of internal variables that control various aspects of the way the product operates. The SET command is used to change these set- < previous page page_367 next page > < previous page page_368 next page > Page 368 tings to suit your preferences. The number of settings is quite large, so for convenience I've divided them into the following categories: Report output and format settings Feedback settings Input settings Operational settings Substitution variable settings Large object settings Tuning and timing settings Database administration settings Miscellaneous settings The following sections describe the settings available in each of these categories. Report Output and Format Settings The largest group of SQL*Plus settings exists to control the way data is formatted, displayed, and output for a report. These settings control such things as the number of lines on a page, the line length, whether or not tab characters are used to format the output, and so forth. The following list briefly describes each of these settings: COLSEP Controls the text used to separate columns of data. EMBEDDED Turns the embedded report feature on or off. HEADSEP Controls the character used to mark a line break in a column heading. HEADING Controls whether or not column headings are displayed when selecting data. LINESIZE Specifies the maximum line width. MAXDATA The maximum row length SQL*Plus can handle. NEWPAGE Controls what SQL*Plus prints when advancing to a new page. NULL Contains the text SQL*Plus displays for any null values returned by a query. < previous page page_368 next page > < previous page page_369 next page > Page 369 NUMFORMAT The default display format for numbers. NUMWIDTH The default column width used for numeric columns. PAGESIZE The number of printable lines on a page. RECSEP Controls whether or not a record separator is printed between rows of output. RECSEPCHAR The record separator character. SHIFTINOUT Controls the display of shift characters on IBM 3270 terminals. SPACE Specifies the number of spaces printed between columns. TAB Controls whether or not SQL*Plus uses tab characters to format whitespace. TRIMOUT Controls whether or not trailing spaces are displayed. TRIMSPOOL Controls whether or not trailing spaces are written to a spool file. TRUNCATE Controls whether or not SQL*Plus truncates long lines. UNDERLINE The character used to underline column headings. WRAP Controls whether or not SQL*Plus wraps or truncates long lines. The following sections provide the syntax, and usage examples, for each of these settings. SET COLSEP Use SET COLSEP to change the text that prints between columns of data. SET COLSEP column_separator where: SETCOLSEP Is the command, which may not be abbreviated. < previous page page_369 next page > < previous page page_370 next page > Page 370 column_separator Is the text you want to print between columns. You should enclose this text in quotes if it contains any spaces or punctuation. The default column separator is a single space. The following example shows how you can change it to a comma: SQL> SET COLSEP , SQL> SELECT One one, 2 Two two 3 FROM dual; ONE,TWO , One,Two Like a space, the comma in this example is a single character. You aren't limited to one character, though. You could just as easily change the column separator to a string of several characters. SET EMBEDDED The SET EMBEDDED command controls the printing of embedded reports. The default setting is OFF, which causes the results of each new query to print on a new page, and also causes page numbering to start over each time a SELECT statement is executed. SET EMB[EDDED] {ON¦OFF} SET EMB[EDDED] Is the command, which may be abbreviated to SET EMB. ON Turns the embedded report feature on. Executing a SELECT statement will not force a page break, nor will it reset the page number. OFF Turns the embedded report feature off. Executing a SELECT statement will force a page break, and the page number will be reset to 1. An embedded report is one that prints as if it were the continuation of a previous report. The following example shows the results of executing two SELECT statements with the default setting. A page title has been created in order to show the effect on page numbering: SQL> SET EMBEDDED OFF SQL> SET PAGESIZE 24 SQL> SET NEWPAGE 1 SQL> TTITLE LEFT Example of SET EMBEDDED, Page SQL.PNO SQL> SELECT * FROM dual; < previous page page_370 next page > < previous page page_371 next page > Page 371 Example of SET EMBEDED, Page 1 D - X SQL> SELECT * FROM dual; Example of SET EMBEDED, Page 1 D - X Notice that the second SELECT statement generated a page breakyou can see that the page title printed again. You can also see, by looking at the titles, that page numbering for each query began with page 1. Now take a look at the same example, but with SET EMBEDDED ON: SQL> SET EMBEDDED OFF SQL> SET PAGESIZE 24 SQL> SET NEWPAGE 1 SQL> TTITLE LEFT Example of SET EMBEDDED, Page SQl.PNO SQL> SELECT * FROM dual; Example of SET EMBEDDED, Page 1 D - X SQL> SET EMBEDDED ON SQL> SELECT * FROM dual; D - X This time, the second SELECT statement did not generate a page break. The second report began printing on the same page on which the first report ended. Be sure to execute the first query of a report with SET EMBEDDED OFF. Otherwise, you may find that SQL*Plus continues the page numbering from a query executed earlier during the session. If you have defined a page footer (BTITLE) for your report, then a page break will occur at the end of the report, regardless of the EMBEDDED setting. There are a couple of reasons for this behavior. One is that SQL*Plus processes commands one line at a time. SQL*Plus doesn't know about the second SELECT statement until after it is completely finished printing the results of the first one. If a page footer is defined, SQL*Plus must print it, because it has no way of knowing whether or not another SELECT statement is coming. In order for a page footer to print, SQL*Plus < previous page page_371 next page > < previous page page_372 next page > Page 372 must advance printing to the bottom, of the page. After the footer has printed, any new data must begin on a new page. The embedded setting, however, still controls whether or not the page number is reset. SETHEADSEP Use the SET HEADSEP command when you want to change the character used when defining a two-line column heading: SET HEADS[EP] heading_separator where: SETHEADS[EP] Is the command, which may be abbreviated to SET HEADS. beading_separator Is the new heading separator character, which may be used in subsequent COLUMN commands to mark line breaks in multiline column headings. Normally, this character is a vertical bar, and marks the place in a column's heading where you want a line break to occur. The following example shows a twoline heading being defined: SQL> COLUMN dummy FORMAT A10 HEADING Line 1¦Line 2 SQL> SELECT * FROM dual; Line 1 Line 2 X As you can see, the vertical bar in the column's heading text was replaced by a line break when the column heading was printed. If you need to use the vertical bar as part of a column heading, use SET HEADSEP to choose some other character to act as the line break marker. The line break in a heading is set when you first define that heading using the COLUMN command. Subsequently changing the heading separator character will not affect column headings you have already defined. SETHEADING Use SET HEADING to control whether or not column headings print when you SELECT or PRINT data. The default value for this setting is ON, which allows column headings to print. < previous page page_372 next page > . the SQL* Plus message files, the glogin .sql file, and the scripts to create the SQL* Plus help. The default value for this setting, under Windows NT, is: C:ORANT PLUS8 0 The 80 corresponds to the. with PRO80, and PLUS8 0, the 80 in the setting name refers to the specific version of Oracle you are using. SQLPATH Of all the variables, SQLPATH is probably the most useful. The SQLPATH variable. directory; then it will search each directory listed in SQLPATH. The directories are searched in the order in which they are listed. The SQLPATH setting applies to SQL* Plus on all operating systems. PLUS_ DFLT This

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