% Librarian T01-31٘ n  5 ~$F@ACCEPTAggregate_FunctionsnALTERArithmetic_Expressions.ATTACHQ BEGIN_DECLARE2NBuilt_In_FunctionsVCALLd6 CASE_Searchedh CASE_SimplepCLOSE^Column_Select_Expressions~Command_Recallt COMMENT_ONCOMMITj Compound_StmtLConditional_ExpressionsCONNECTp\ Context_Filesnventions_in_HelpkDatabase_Options DATATRIEVE Data_TypesHDBKEY DCL_Invoke_$tinesotesV *RENAME REPEAT_Control ~RETURN_Control ~REVOKE  REVOKE_ANSI t REVOKE_ROLES ROLLBACKtRoutinesROWID,lSample_Databases5hSample_Programs SELECTLSelect_Expressions-HSETt SET_ALIASySET_ALL_CONSTRAINTSSET_ANSI SET_CATALOGSET_CHARACTER_LENGTHSET_COMPOUND_TRANSACTIONS* SET_CONNECT SET_ControlVSET_DEFAULT_CHARACTER_SET$Stored_FunctionsStored_Procedures Context_Files DCL_Invoke_$External_RoutinesLiterals Release_NotesSET_CHARACTER_LENGTH SET_KEYWORD_RULESStored_Procedures WHILE_ControlionsY rFETCH  FOR_Control vFOR_Counted_Control fGET_DIAGNOSTICS GET_ENVIRONMENT VGlobal_Temporary_Tables 2GRANTP ^ GRANT_ANSIq GRANT_ROLESv HELPw  IF_Control} IMPORT INCLUDE INSERT INSERT_FROM_FILENAME | INTEGRATE? ITERATE_ControlB t LEAVE_ControlLiterals Local_Temporary_TablesH N LOCK_TABLE|LSE Module_language. NULL_Keyword 6 Precompiler Predicates+ Release_Notesz DECLARE Declared_Local_Temporary_TablesDefault_Database DELETE DESCRIBE D DISCONNECT DROP Dynamic_SQLb EDITg $ END_DECLAREKErrorsError_Message_Documentationt TEXECUTEl ^ Execute_@ EXECUTE_IMMEDIATE EXIT EXPORT.External_Functions nExternal_ProceduresdExternal_RoutinescContext_Structures Conventions_in_HelpCREATEkDatabase_Options DATATRIEVE Data_TypesHDBKEY DCL_Invoke_$S Local_Temporary_TablesH N LOCK_TABLELogicalsO n LOOP_Control|LSE Module_language. NULL_KeywordW 2OPENd fOperating_System_InvocationOracle_SQL_Functions/Oracle_Style_Outer_Join 6 Precompiler Predicatesf rPREPARE bPRINT :QUIT JRELEASE+ Release_NotesZStored_RoutinesVString_Concatenation_Operator6Supported_Character_Sets TRACE_Control$TRUNCATE_TABLEUNDECLARE_Variable(UPDATE]|User_Supplied_Names\Value_ExpressionsWHENEVER WHILE_ControlJSET_COMPOUND_TRANSACTIONS* SET_CONNECT SET_ControlVSET_DEFAULT_CHARACTER_SETSET_DEFAULT_CONSTRAINT_MODEdSET_DEFAULT_DATE_FORMAT SET_DIALECTZ SET_DISPLAY$SET_DISPLAY_CHARACTER_SETd SET_FLAGSdXSET_HOLD_CURSORSkSET_IDENTIFIER_CHARACTER_SETovSET_KEYWORD_RULESu<SET_LITERAL_CHARACTER_SETz& SET_NAMESSET_NATIONAL_CHARACTER_SETSET_OPTIMIZATION_LEVEL$Stored_FunctionsStored_Procedures 1 Local_Temporary_Tables See CREATE TABLE. ww1 Global_Temporary_Tables See CREATE TABLE. ww"1 Declared_Local_Temporary_Tables% See DECLARE LOCAL_TEMPORARY_TABLE. ww$1 Conventions_in_Help. The following conventions are used in HELP:@ Angle brackets in railroad diagrams indicateD where you, the user, need to supply information.<  Angle brackets in text are icons used to? identify information that is specific to an> operating system or platform. For example,@ . Double, empty angle brackets ( <>D ) indicate the end of this specific information.? vnn nn is the version number. For example, v70.; {text1 | text2} You must choose one of the two choices.B [text1 | text2] You have the option of choosing one of the two choices. ww$1 PrecompilerB Type HELP SQLPRE at the operating system prompt for OpenVMS for& information on the SQL Precompiler. ww$1 Module_languageB Type HELP SQLMOD at the operating system prompt for OpenVMS for& information on SQL Module Language. ww$1 External_ProceduresD For information on external procedures, see the External_Routines help topic.) Also see the CREATE Routine help topic ww$1 External_FunctionsC For information on external functions, see the External_Routines help topic.) Also see the CREATE Routine help topic ww$1 Stored_Procedures@ For information on stored procedures, see the Multistatement_A Variables_and_Stored_Routines help topic found under the User_> Supplied_Names help topic and Parameters_and_Variables help subtopic.) Also see the CREATE MODULE help topic. ww$1 Stored_Functions? For information on stored functions, see the Multistatement_A Variables_and_Stored_Routines help topic found under the User_> Supplied_Names help topic and Parameters_and_Variables help subtopic.) Also see the CREATE MODULE help topic. ww$1 Stored_Routines> For information on stored routines, see the Multistatement_A Variables_and_Stored_Routines help topic found under the User_> Supplied_Names help topic and Parameters_and_Variables help subtopic.) Also see the CREATE MODULE help topic. ww$1 DCL_Invoke_$- See the Operating_System_Invocation topic. ww$1 $- See the Operating_System_Invocation topic. ww$1 @ See Execute_@. ww$1 Command_RecallD Interactive SQL users can recall the 20 most recent command lines? using the up and down arrow keys or the CTRL/B key sequence:D o The up arrow key recalls lines in sequence from most recent to least recent.A o The CTRL/B key sequence also recalls lines in sequence from" most recent to least recent.D o After you have recalled prior lines, the down arrow key allows0 you to recall more recently entered lines. ww$1 Default_DatabaseC SQL allows you to specify an alias that declares the database asA the default d atabase. Specifying a default database means thatB subsequent statements during the database attachment that refer1 to the default database need not use an alias.@ In the SQL module language, the alias specified in the module= header is the one that designates the default database. In? precompiled SQL programs and in interactive SQL, the special= alias RDB$DBHANDLE designates the default database. In all: environments, omitting an explicit alias is the same as= specifying the alias that designates the default database.' Select More_Information to continue. 2 More_InformationA If you do not declare any alias or attach to any database, SQLC declares the database specified in the logical name SQL$DATABASEC or configuration parameter SQL_DATABASE as the default database,! using the FOR FILENAME clause.? If you declare a database specifying an alias other than theB one that declares the default database, you must use that aliasB  to qualify names of any database elements to which you refer inB SQL statements. If you omit the alias, SQL assumes the table orD view must be part of the default database. If there is no default; database and you omit the alias, SQL generates an error. ww$1 Dynamic_SQLA Dynamic SQL lets programs accept or generate SQL statements at? run time, in contrast to SQL statements that are part of the> source code for precompiled programs or SQL module langua ge< procedures. Unlike precompiled SQL or SQL module language? statements, such dynamically executed SQL statements are notB necessarily part of a program's source code, but can be created? while the program is running. Dynamic SQL is useful when youB cannot predict the type of SQL statement your program will need to process.@ You cannot use dynamic SQL statements in interactive SQL, butA interactive HELP includes quick reference information on these dynamic SQL state!ments:? o Dynamic DECLARE CURSOR (listed as DECLARE Dynamic_CURSOR) o DESCRIBE o EXECUTE5 o EXECUTE IMMEDIATE (listed as EXECUTE_IMMEDIATE)B o Extended Dynamic DECLARE CURSOR (listed as DECLARE Extended_ Dynamic_CURSOR) o FETCH o INCLUDE o INSERT o OPEN o PREPARE o RELEASE ww$1 LSEB DEC Language Sensitive Editor (LSE) is available on the OpenVMS platforms only.@ LSE is an a dvanced text editor that is layered on DECTPU. SQLB supports two sets of LSE templates, one for interactive SQL and? one for module language. The templates guide you in entering$ syntactically-correct statements.& NOTEA The LSE templates provided with Oracle Rdb only support SQL? syntax through V4.2. The templates do not provide support, for new and changed syntax after V4.2.= LSE templates are made up of placeholders representing SQL? syntax. You can expand a placeholder or token by positioningA the cursor anywhere on it and pressing CTRL/E. When you expandB the placeholders, LSE provides the required syntax or indicates optional elements.A For more information about LSE, see the DEC Language Sensitive Editor documentation.A For more information about other editors SQL supports, see the online help topic EDIT. 2 Invoking_LSE: You can invoke LSE in either of the following two ways:A o To use LSE within interactive SQL, define the logical names# SQL$EDIT and LSE$ENVIRONMENT: $ DEFINE SQL$EDIT LSE $ DEFINE LSE$ENVIRONMENT -6 _$ SYS$COMMON:[SYSLIB]LSE$SYSTEM_ENVIRONMENT.ENVB Then, when you enter the EDIT statement from within SQL, you2 automatically invoke LSE with SQL templates.A o To invoke LSE from DCL level, type LSE followed by the name< of the file you want to edit. The file type determines> the templates that LSE uses. To invoke the templates for> interactive SQL, use the file type of SQL; to invoke the= templates for SQL module language, use the file type of? SQLMOD. For example, you can type the following commands: $ LSE SAMPLE.SQL or $ LSE SAMPLE.SQLMOD 2 General_SQL_Terms< You can access online help for any placeholder in the LSE@ templates for SQL. To obtain this help while you are editing,B position your cursor on the placeholder, then press the PF1 and PF2 keys in succession.@ The templates include some placeholders for low-level syntax.B While these topics are essential to SQL, they are so general asC to not be applicable at top-level help. This topic, General_SQL_A Terms, serves as a location for the low-level help topics that LSE requires. 3 check_col_constraint col-constraint= ) ---+---------------------------------++) +-> CONSTRAINT -+|) +------------------------------------+% +-> PRIMARY KEY -----------------+% +-> UNIQUE ----------------------+% +-> NOT NULL --------------------+% +-> NULL ------------------------+% +-> CHECK (predicate) -----------+% +-> references-clause -----------+% +------------>-------------------+% +-------------<------------------+) +----+----------------------------+-->& +--> constraint-attributes --+C Specifies a predicate that column values inserted into the table must satisfy. 3 col_clauseD A placeholder used in LSE templates for the DECLARE TABLE syntax.? The col-clause placeholder allows the optional expansions of@ either the col-constraint or sql-and-dtr-clause placeholders.A In the following syntax diagram for col-definition, col-clauseB is represented by the right-most syntax loop that includes col-) constraint and the sql-and-dtr-clause. declare-col-definition = @ --> --> data-type -++------------------------++->> |+-> col-constraint ------+|> |+-> sql-and-dtr-clause --+|> +----------- <-------------+ B See also the Help topic on col-definition, located at this same level. 3 column_qualifier= A placeholder used in LSE templates as an expansion of the> column-name placeholder. The templates use the term column-> qualifier to describe leftmost loop in the followin g syntax& diagram for the column-name syntax. column-name = : ---+----------->-----------------+-> --># +-> -------+> . -+ +-> --------+ +-> -+ D If you expand column-qualifier in the templates, you will see the6 optional items of table-name, view-name, and alias. 3 column_name column-name = : ---+----------->-----------------+-> --># +-> -------+> . -+! +-> --------+ +-> -+ C You can name columns in CREATE TABLE and ALTER TABLE statements.@ In other SQL statements, the names you give to columns can be3 qualified by table name, view names, or aliases.? The only time you must qualify column names is when they are@ ambiguous. Joining a table with itself and joining two tables@ with common column names are two cases that require qualified column names.D You always have the o"ption of qualifying column names. In complex= statements, such qualifiers often make the statements more readable. 3 col_definition  col-definition =  --> --+ +---------------+; +---> column-type ---+--------------------------+-+--+; | +->DEFAULT value-expr | | |; | +->column-identity --------+ | |; +---> COMPUTED BY value-expr ---------------------+ |; +------------------------#-<--------------------------+. +-+--------------------+----------------+. +-> col-constraint --+ |. +--------------------------<------------+@ ++------------------------+-----+-----------------------+->> +-> comment-is-clause --+ +-> sql-and-dtr-clause -+   C The definition for a column in the table. SQL gives you two ways! to specify column definitions:C o By directly specifying a data type to associate with a column na$meA o By naming a domain that indirectly specifies a data type to" associate with a column nameB Either way also allows options of specifying column constraints and formatting clauses. 3 FILENAMEC FILENAME is a keyword used in SQL syntax that is always followed$ by a required file specification.A See the online help for file_spec, located at this same level, for more information. 3 file_specB Specifies a valid file specification. A full file s%pecification includes: o Network node name( o Device directory (on OpenVMS only) o Directory name or list o File name o File type+ o File version number (on OpenVMS only)8 For example, on OpenVMS a full file specification is:. SPEEDY::YOURDISK:[YOURDIR]APPLICANTS.RDB;81: File specifications are used throughout SQL syntax. For? example, when you first create a database, you give the file0 specifications for the database system files.& 3 integer@ An integer is a whole number. It may be positive or negative,; depending on its use, but cannot have a fractional part.D SQL uses integers in many situations. For example, you specify an0 integer to refer to columns by column number. 3 n= Specifies an integer. For the GRANT statement, the integer? specifies the earliest relative position of the entry in theA ACL. For the EDIT statement, the integer tells SQL to save the previous n statements. ' 3 parameter> Parameters are a type of value expression. Many SQL clauses> that will not accept more general value expressions require parameters.@ A parameter is a variable declared in a host language program; that is associated with an SQL statement. The meaning ofB parameter encompasses host variables named directly in embedded@ SQL statements, actual and formal parameters in programs thatB use SQL module language, and parameter markers in the statement! strin(g of a PREPARE statement. 3 path_or_file< Path-or-file is a placeholder used in LSE templates as anD expansion of the attach-clause, alter-database-clause and create- database-clause placeholders.< You can expand the path-or-file placeholder to the syntaxA FILENAME file-spec and PATHNAME path-name. See the online help> for FILENAME and path_name, located at this level, for more information on those topics. 3 path_name& A data dictionary path name can be:); o A full path name, such as CDD$TOP.MOLLY.SQL.PERSONNEL o A relative path name5 o A logical name for a full or relative path name> Unless you use the PATHNAME argument in the CREATE DATABASE@ statement, SQL does not use the data dictionary to store data definitions.? If you specify the PATHNAME argument when you first create aA database, SQL creates a path name that contains copies of data definitions for the database. 3 quoted_string= A quo*ted character string literal is a string of printableD characters enclosed in single quotation marks. The maximum lengthB of a character string is 1,024 octets. An unqualified characterA string must contain characters only from the literal character set of that session.- The printable ASCII characters consist of:& o Uppercase alphabetic characters: A-Z& o Lowercase alphabetic characters: a-z o Numerals: 0-9 o Special charac+ters:% ! @ # $ % ^ & * ( ) - _ = + ` ~# [ ] { } ; : " \ | / ? > < . ,B For a list of the printable characters for MCS, see the OpenVMSB documentation; for a list of printable characters for the other@ supported character sets, see the standard for that character set. 3 database_idB Database-id is a placeholder used in LSE templates. Database-idD expands to the placeholders ALIAS alias-name, FILENAME file-spec,? and PATHNAME path-name. See the online ,help for FILENAME andB path_name, located at this level, for more information. See theC Aliases HELP topic under the top-level topic User_Supplied_names# for more information on aliases. ww5Ⴠ1 Release_NotesD The release notes for the SQL interface to Oracle Rdb are part ofC the Oracle Rdb Release Notes, which are available online in this file:) SYS$HELP:RDBvvu.RELEASE_NOTES) where vv = version( - u = update For example:) SYS$HELP:RDB071.RELEASE_NOTES ww5Ⴠ1 Sample_Databases= To help you learn and test Oracle Rdb features, Oracle Rdb; provides online files that you can execute to create the following sample databases: o personnel7 The personnel database is a single-file database. o mf_personnel8 The mf_personnel database is a multifile database. o corporate_data@ The corpor .ate_data database is a single-file database that= demonstrates the use of the multischema feature of SQL.< The personnel and mf_personnel databases contain the same< domains, tables, and columns. The corporate_data database< contains slightly different domains, tables, and columns. 2 OpenVMS_Sample_DatabaseD To create the various forms of the sample databases, use a single% command procedure with Oracle Rdb.; By default, the command procedure builds the single-fil/eC personnel database using SQL data definitions. Use the following" command to build this database: $ @RDM$DEMO:PERSONNELC You can specify parameters when you invoke the command procedure> to create alternative versions of the sample databases. The@ following shows the format of the command you enter to create a sample database:M $ @RDM$DEMO:PERSONNEL interface-lang database-form reposit multischema dir0 The parameters specify the following choices: 1. 0Interface-lang: Enter SQL.? Specifies SQL as the data definition language. SQL is the default.A There are slight differences between the SQL definitions of! PERSONNEL and MF_PERSONNEL." 2. Database-form: Enter S or M.; Specifies the creation of either a single-file (S) orD multifile (M) database. A single-file database is the default." 3. Reposit: Enter CDD or NOCDD.? Specifies whether or not to store data definitions in theA repo 1sitory. The default is not to store data definitions in the repository.0 4. Multischema: Enter MSDB or omit parameter.B Specifies the creation of a multischema database, CORPORATE_= DATA. Note that for the first three parameters you must? specify the SQL interface, the single-file database form,D and that data definitions not be stored in the repository. TheB following example demonstrates how to create the multischema database:, $ @RDM$D 2EMO:PERSONNEL SQL S NOCDD MSDB= 5. Dir: Enter a directory specification where you want theB database created. If you do not specify this parameter, thisA procedure will prompt you for a directory specification. IfA you do not provide a directory specification at the prompt,* your default directory will be used.> If you run this procedure in batch and this parameter is1 empty, your default directory will be used.A To specify the second, third, fourth, 3 or fifth parameters, youA must include any previous parameters. You can use uppercase or' lowercase to specify the parameters.A For example, to build the the multifile version using SQL dataB definitions and storing the data definitions in the repository, enter the following command:" $ @RDM$DEMO:PERSONNEL SQL M CDDA When you build the single-file personnel database, the command? procedure builds a database called PERSONNEL.RDB, regardless? of the interface la 4nguage used. When you build the multifileA mf_personnel database, the command procedure builds a database= called MF_PERSONNEL.RDB (plus related storage area files),- regardless of the interface language used.> When you build the multischema corporate_data database, theA command procedure builds a database called CORPORATE_DATA.RDB.. You can use only SQL to build the database.& NOTEA When you create the personnel or mf_personnel data 5base, the@ log of the database definition statements used in creatingB the database is placed in a file called PERSONNEL.LOG in the% same directory as the database.A When you create the corporate_data database, the log of theB database definition statements used in creating the database? is placed in a file called CORPORATE_DATA.LOG in the same directory as the database.> The personnel command procedure consists of several smallerC command files6, executable files, and data files. These files areA located in the directory RDM$DEMO. You might want to use these. files as models in creating your databases.B For additional information about creating the sample databases,@ read the online file ABOUT_SAMPLE_DATABASES.TXT. This file is$ located in the Samples directory. ww5Ⴠ1 Sample_ProgramsC During installation, SQL installs a number of sample programs in1 a variety of languages in a Samples dir7ectory.A These programs are located in the following Samples directory: SQL$SAMPLEA A brief description of the sample programs can be found in the8 file about_sql_examples.txt in the Samples directory. ww5Ⴠ1 Supported_Character_SetsD Oracle Rdb supports multiple character sets and lets you use more@ than one character set in a database. The supported character sets are: o ARABIC o BIG5 o DEC_HANYU o DEC_HANZI48 o DEC_KANJI o DEC_KOREAN o DEC_MCS o DEC_SICGCC o DEVANAGARI o DOS_LATIN1 o DOS_LATINUS o HANYU o HANZI o HEX o ISOLATIN1 o ISOLATIN9 o ISOLATINARABIC o ISOLATINCYRILLIC o ISOLATINGREEK o ISOLATINHEBREW o KANJI o KATAKANA o KOREAN o SHIFT_JIS o TACTIS o WIN_ARABIC o WIN_CYRILLIC o WIN_GREEK o WIN_HEBREW o WIN_LA9TIN10 The various ways characters can be coded are: o Single-octetA A single-octet character set is entirely represented in oneA octet. ASCII is an example of a single-octet character set.7 Each ASCII character is represented in one octet. o Multi-octet: A multi-octet character set is, in general, entirely@ represented in one or more octets. Some character sets are@ fixed multi-octet character sets and some are mixed multi- octet ch:aracters. - Fixed multi-octet@ A fixed multi-octet character set is represented by twoA or more fixed number of octets. Kanji is an example of aA fixed multi-octet character set. Each Kanji character is# represented in two octets. - Mixed multi-octetC A mixed multi-octet character set is represented by one orD more mixed number of octets that allow the use of ASCII andC a fixed multi-octet character set in the ;same string. DEC_B KANJI is an example of a mixed multi-octet character set.C The ASCII characters are represented in one octet, and the8 Kanji characters are represented in two octets. 2 Automatic_TranslationB During operations on text data such as assignments of a literal> to a text column or the comparison of two string variables,? Oracle Rdb carries out character set compatibility checks to' ensure that the operation is viable.? Without autom <atic translation being enabled this checking isD quite restrictive in that in most cases the two text objects must@ have identical character set before the operation is allowed.A The automatic translation feature allows you to choose whether> the character set checking should be restrictive or whether= Rdb should attempt a character set translation, similar to? that provided by the TRANSLATE function prior to assignments or comparisons.> With automatic translation enab =led you may easily carry outD operations that previously required additional translations steps to be carried out explicitly.= 1. Carry out comparisons between columns that contain dataD encoded in different character sets that have common character? subsets, for example, DEC_MCS and DEC_KANJI have ASCII in common.C 2. Use the same SQL code to access database data irrespective ofA the client's environment. For example, a user on a Japanese? PC acces >sing a DEC_MCS column would have to add TRANSLATE> statements to the SQL commands to convert the DEC_MCS toB SHIFT_JIS before they could display it on their screen. With? automatic translation enabled and a Display Character set, specified, this would not be required.9 3. Enter data from a native interface without explicit; translations. For example, users using SHIFT_JIS on a> Japanenese PC may access and insert data into a DE_KANJI: column in the da?tabase without explicit translations statements., You may enabled automatic translation by:1 1. Using a SET AUTOMATIC TRANSLATION statement9 2. Defining the SQL$AUTOMATIC_TRANSLATION logical name SQL$AUTOMATIC_TRANSLATIONA The logical name SQL$AUTOMATIC_TRANSLATION allows SQL users toD specify that automatic translations should be enabled by default.= The logical SQL$AUTOMATIC_TRANSLATION may be placed in any; logical name table accessible to the client @ SQL process.@ If the logical name is set to either the string 'TRUE' or theC value 'T' prior to invoking SQL, then automatic translation will@ be enabled by default, any other value will disable automatic translation within SQL. 2 Character_Set_HEX> The character set HEX is comprised of two octet hexadecimal? characters '00' through 'FF' and has the characteristic that@ the contents of data objects with this character set will not@ be automatically translated to Athe display character set when* automatic translation has been enabled.< It may be used in conjunction with the CAST and TRANSLATEC functions to obtain the hexadecimal equivalence of text objects.B Translation to the HEX character set will translate source data, octet by octet into hexadecimal notation.= Translation from the HEX character set will translate from9 hexadecimal notation to the destination character set. For example: SQL> show character sets' B Default character set is DOS_LATINUS( National character set is DOS_LATINUS* Identifier character set is DOS_LATINUS' Literal character set is DOS_LATINUS' Display character set is DOS_LATINUS Alias RDB$DBHANDLE:' Identifier character set is DEC_MCS$ Default character set is DEC_MCS% National character set is DEC_MCS" SQL> show automatic translation Automatic translation: ON9 SQL> create tab latin (f1 char(4) char set win_latin1,* cont> f2 char(4) charC set dos_latinus);. SQL> insert into latin value ('A','A'); 1 row inserted4 SQL> select f1, cast(f1 as char(8) char set hex),9 cont> f2, cast(f2 as char(8) char set hex) from latin; F1 F2! A 41C9D620 A 41909920 1 row selected? SQL> select cast (_hex'9099' as char(2) ) from rdb$database;  1 row selected< SQL> select translate (_hex'9099' using rdb$dos_latinus ) Cont> from rdb$database;  1 row selectedA The previ Dous example also shows automatic translations between: the literals character set DOS_LATINUS and the field F2B containing WIN_LATIN1, and the subsequent automatic translation7 from the F2 field back to the display character set.? The hexadecimal display of the field contents shows that the? actual data stored in the database is different for field f1A and f2 even though the input literals and the output displayed appears identical. 2 Default_Character_SetsC T Ehe default character set is the character set that SQL uses for the following elements:? o Database columns with a character data type that does not( explicitly specify a character set: o Parameters that are not qualified by a character set? You can specify the default character set at the session andD database level. See the Oracle Rdb Introduction to SQL and OracleD Rdb Guide to Database Design and Definition for more detail about' session and database characte Fr sets.? You can specify the database default character set only whenB you create the database. You cannot change the database default5 character set after you have created the database.A SQL uses DEC_MCS as the default character set, unless you have> set the dialect to MIA or specified a default character set? at the session level. You can override any default characterB set by specifying another default character set when creating a database.A To specify the de Gfault character set, use one of the character0 set names listed in Supported Character Sets.? The default character set does not affect the setting of the currency sign.? When you compile SQL programs (either SQL module language orA precompiled SQL), SQL uses the following to derive the default character set:; o The DEFAULT CHARACTER SET clause in the DECLARE ALIAS@ statement specifies the default character set of the aliasB at compile time. At run time H, SQL uses the default character@ set of the attached database. At run time, you must ensureA that the database default character set is identical to theB default character set specified in the DECLARE ALIAS clause.B o The DEFAULT CHARACTER SET clause of the SQL module header orB the DECLARE MODULE statement specifies the character set for; parameters that are not qualified by a character set.= o In dynamic SQL, the SET DEFAULT CHARACTER SET statementC I specifies, at run time, the character set for parameters that+ are not qualified by a character set.C o The RDB$CHARACTER_SET logical name. However, the logical nameB is deprecated and will not be supported in a future release. 2 Display_Character_Set> The display character set is the character set SQL uses for@ determining the character set that text will automatically beD translated to before display in interactive SQL or for text being% returned by SQL to Ja user program.? You can specify the display character set only for a sessionB or a module by using the SET DISPLAY CHARACTER SET statement orA the DISPLAY CHARACTER SET clause of the SQL module header, the< DECLARE MODULE statement, or the DECLARE ALIAS statement.D The choice of display character set is limited to those character? sets that include ASCII characters. Identifier Character Set> identifies the subset of character sets that you can use to% specify the displ Kay character set. 2 Identifier_Character_SetA The identifier character set is the character set SQL uses for? database object names, such as table names and column names.B You can specify the identifier character set at the session andD database level. The choice of identifier character set is limitedA to those character sets that include ASCII characters. This is? necessary so that the object names for the Oracle Rdb system. metadata, which is in ASCII, can be store Ld.@ You can specify the identifier character set for the database: only when you create the database. You cannot alter the9 identifier character set of a database after creation.D Following is a list of the character sets used for the identifier character set: o ASCII o AL24UTFFSS o DEC_MCS o DOS_LATIN1 o DOS_LATINUS o DEVANAGARI o DEC_SICGCC o DEC_HANYU o DEC_HANZI o GB18030 o ISOLATINARABIC %M o ISOLATINCYRILLIC o ISOLATIN1 o ISOLATIN9 o ISOLATINGREEK o ISOLATINHEBREW o DEC_KANJI o KATAKANA o DEC_KOREAN o SHIFT_JIS o UTF8 o UNSPECIFIED o TACTIS o WIN_ARABIC o WIN_GREEK o WIN_CYRILLIC o WIN_HEBREW? When you compile SQL programs (either SQL module language orD precompiled SQL), SQL uses the following to derive the identifier character set:B o The IDENTIFIER CHA NRACTER SET clause of the SQL module headerA or the DECLARE MODULE statement specifies the character set? for parameters that are not qualified by a character set.@ o In dynamic SQL, the SET IDENTIFIER CHARACTER SET statementC specifies, at run time, the character set for parameters that+ are not qualified by a character set.C o The RDB$CHARACTER_SET logical name. However, the logical nameB is deprecated and will not be supported in a future release.D O SQL uses DEC_MCS as the identifier character set, unless you haveB set the dialect to MIA or specified an identifier character setB at the session level. You can override any identifier characterC set by specifying another identifier character set when creating a database. 2 Literal_Character_Sets> The literal character set is the character set SQL uses for) unqualified character string literals.? You can specify the literal character set only for a sessionB or Pa module by using the SET LITERAL CHARACTER SET statement orA the LITERAL CHARACTER SET clause of the SQL module header, the< DECLARE MODULE statement, or the DECLARE ALIAS statement.B When inserting data into a column, you must qualify the literalA with the same character set with which you defined the column.= For example, suppose that the literal character set of theC module is DEC_MCS. If the column ENGLISH is defined as data type? DEC_MCS, SQL returns an error when yoQu execute the following statement: SQL> INSERT INTO COLOURS cont> (ENGLISH) cont> VALUES cont> (_DEC_KANJI'Black');M %SQL-F-INCCSASS, Incompatible character set assignment between ENGLISH and  SQL> 2 National_Character_SetB The national character set is a shorthand notation that you can@ use for a character set of your choice. SQL uses the national, character set for the following elements:C o For all columns and Rdomains with the data type NCHAR or NCHARA VARYING and for the NCHAR data type in a CAST function. ForA information about these data types, see the Data_Types HELP topic.B o For all parameters in SQL module language with the data type NCHAR or NCHAR VARYING.A o For all character string literals qualified by the nationalC character set; that is, the literal is preceded by the letter? N and a single quotation mark (for example, N'). For more/ S information, see the Literals HELP topic.@ You can specify the national character set at the session andA database level. See the Oracle Rdb Introduction to SQL and the> Oracle Rdb Guide to Database Design and Definition for more4 detail about session and database character sets.A You specify the national character set for a database when youC create the database. You cannot alter the national character set of a database.B SQL uses DEC_MCS as the national characte Tr set, unless you haveB set the dialect to MIA or specified a national character set atA the session level. You can override any national character set? by specifying another national character set when creating a database.? When you compile SQL programs (either SQL module language orB precompiled SQL), SQL uses the following to derive the national character set:< o The NATIONAL CHARACTER SET clause in the DECLARE ALIASA statement specifies the national charact Uer set of the aliasA at compile time. It controls the national character set forC column and domain definitions and the NCHAR and NCHAR VARYING> data types in a CAST function. At run time, SQL uses the? national character set of the attached database for these elements.@ o The NATIONAL CHARACTER SET clause of the SQL module headerB and the DECLARE MODULE statement specifies the character setB for literals qualified by the national character set and V forC parameters defined with the data type NCHAR or NCHAR VARYING.> o In dynamic SQL, the SET NATIONAL CHARACTER SET statement@ specifies, at run time, the character set for columns withD the data type NCHAR and NCHAR VARYING and for character string7 literals qualified by the national character set.C o The RDB$CHARACTER_SET logical name. However, the logical nameB is deprecated and will not be supported in a future release.& W NOTE? Although SQL does not require that the national character: set of the database and the module match, Oracle Rdb= recommends that you define both with the same character set. 2 Character_Set_ISOLATIN9DOracle Rdb supports the ISOLATIN9 character set (as described by ISO 8859-15).= ISOLATIN9 is similar to ISOLATIN1 except for 8 codepoints.8 The following table compares ISOLATIN9 and ISOLATIN1.8 Table 1 ISOLATIN1/ISOLATIN9 Character Set DifXferences8 ISO Latin 1 ISO Latin 9( Code Unicode Unicode$ Pos Pos Pos* Hex Hex Name Hex Name/ A4 00A4 currency symbol 20AC euro signA A6 00A6 broken bar 0160 latin capital letter s with+ caron? A8 00A8 diaeresis 0161 latin small letter s with+ caronA B4 00B4 acute accent Y 017D latin capital letter z with+ caron? B8 00B8 cedilla 017E latin small letter z with+ caron? BC 00BC vulgar fraction 0152 latin capital ligature oe one quarter= BD 00BD vulgar fraction 0153 latin small ligature oe one halfA BE 00BE vulgar fraction 0178 latin capital letter y with/ three quarters diaeresis !2 OraZcle_NLS_Character_Set_NamesB Oracle Rdb supports the use of Oracle National Language SupportA (NLS) names as aliases for existing Oracle Rdb character sets,D as summarized in the following table. You can use NLS alias names- anywhere a character set name can be used.> Table 2 Oracle NLS Character Set Names Supported as Aliases US7ASCII ASCII WE8DEC DEC_MCS WE8ISO8859P1 ISOLATIN1 WE8ISO8859P1 ISOLATIN9" CL8ISO8859P5 ISOLATINCYRILLIC A[R8ISO8859P6 ISOLATINARABIC EL8ISO8859P7 ISOLATINGREEK IW8ISO8859P8 ISOLATINHEBREW TH8TISASCII TACTIS JA16VMS DEC_KANJI JA16SJIS SHIFT_JIS KO16KSC5601 KOREAN ZHS16CGB231280 HANZI ZH16BIG5 BIG5 JA16EUCFIXED KANJI 2 Character_Set_UNSPECIFIED@ Oracle Rdb supports the use of the UNSPECIFIED character set.@ You can make comparisons and assignments between text objects; (columns, literals, and so on) that have the UNSP\ECIFIED= character set, and any other text object regardless of the* character set of the other text object.> The characteristics of the UNSPECIFIED character set are as follows:$ o The character set ID is 32767.A o It can be used to specify any session or database character2 set, including the identifier character set.1 o It is a single-octet character set (fixed).? o It applies casing (uppercase and lowercase) only to ASCII characters.$ ] o It contains ASCII, as follows:A - The space character is the ASCII space character (0x20).? - The wildcard character is the ASCII underscore (0x5f).9 - The string wildcard is the ASCII percent (0x25). #2 Logical_Names_for_Character_Sets@ You can define a logical name for a character set name. Doing= so allows easy portability of applications across nationalB boundaries. You can use this logical name or parameter anywhereB you use a character set n^ame in SQL. SQL translates the logical@ name or parameter at compile time for precompiled SQL and SQLB module language, or at run time for dynamic SQL and interactive SQL.8 The logical name can begin with any of the following: o RDBVMS$ o RDB$ o SQL$C Oracle Rdb recommends that you begin logical names with RDB$. wwF 1 User_Supplied_NamesC You must supply names (identifiers) to satisfy the syntax of SQLC statements that _ require user-supplied names. In statement syntax= diagrams, user-supplied names are shown in lowercase type. User-supplied names must:3 o Be no more than 31 octets (8-bit characters)., o Conform to one of the following rules:> - If the identifier character set is MCS, the name must? contain only alphanumeric characters and begin with anC uppercase or lowercase letter. Alphanumeric characters areA uppercase or lowercase letters (A, a), incl`uding lettersC with diacritical marks (), digits, dollar signs ($), and underscores (_).= Uppercase and lowercase letters are treated equally.@ Although dollar signs are valid characters in names, toD avoid conflicts it is recommended that you do not use them.= You cannot begin a user-supplied name with a numeric character.B - If the identifier character set is other than DEC_MCS, itC can contain only a va alid sequence of characters as defined0 by the standard for that character set.< - The name can be a delimited identifier. A delimited> identifier is a user-supplied name enclosed in double< quotation marks ("). It can start with and contain= alphanumeric characters, special characters, controlB characters, and spaces. The quotation mark (") character@ can be included in a delimited identifier by typing two> quotation marks tog bether (see the following example).@ Trailing spaces are not significant. See the Oracle Rdb? SQL Reference Manual for a list of special characters.A The alphabetic characters can be uppercase or lowercase.A The following example shows many variations of delimited identifiers:& SQL> SET QUOTING RULES 'SQL99+ SQL> CREATE TABLE "This is a Test"+ cont> ("""" CHAR(5),, cont> "_NAME" CHAR(20), c, cont> " City" CHAR(20),( cont> "1st_date" DATE,, cont> "A ""B and C""" CHAR(10),' cont> "$_Amount" INT,* cont> """Test" CHAR(5) cont> );3 SQL> SHOW TABLE (COLUMN) "This is a Test";- Information for table This is a Test* Columns for table This is a Test:@ Column Name Data Type Domain@ ----------- --------- d ------0 " CHAR(5)1 _NAME CHAR(20)1 City CHAR(20)1 1st_date DATE VMS1 A "B and C" CHAR(10)0 $_Amount INTEGER0 "Test CHAR(5)= If you use a delimited identifier, SQL maintains the< case of the identifier. That is, if you enclose theC e identifier Employee_ID in quotation marks ("Employee_ID"),? SQL preserves the uppercase and lowercase letters. The@ delimited identifiers "Employee_ID", "EMPLOYEE_ID", and4 "employee_id" are distinct from each other.? You must enable ANSI/ISO SQL quoting when using delimited identifiers.A If you want to use a keyword as a user-supplied name, you mustB set the quoting rules or dialect to SQL99 and use the delimited identifier.A SQL usefs the identifier character set as the character set forC database object names. However, because SQL interprets the namesA of some database objects as file names or path names, you must> use only ASCII alphanumeric characters for the names of the following database objects: o Database file name o Database path name o Snapshot files o Storage areas o Journal files o Alias names 2 Aliases@ An alias is a name for a particular attachm gent to a database.B Explicitly specifying an alias lets your program or interactive2 SQL statements refer to more than one database.? Once you specified the alias, you must use it when referring= to the database in subsequent SQL statements (unless those? statements are within a CREATE DATABASE statement). You mustC use an alias when you declare more than one database so that SQLD knows the database to which your statements refer. When you issueD an ATTACH, CONNECT, CREAT hE DATABASE, CREATE DOMAIN, CREATE TABLE,C DECLARE ALIAS, GRANT, GRANT (ANSI-style), IMPORT, REVOKE, or SETC TRANSACTION statement, you can specify an alias in addition to a0 file specification or a repository path name.C SQL allows you to specify an alias that declares the database asA the default database. Specifying a default database means thatB subsequent statements that refer to the default database during7 the database attachment do not need to use an alias. 2 i Authorization_Identifiers@ SQL uses an authorization identifier in a stored or nonstored> module to convey to Oracle Rdb the concept of a user. These> modules can be either definer's rights or invoker's rights. 3 Stored_Modules@ A stored module resides in the database as an object. You canC store modules and their procedures and functions with the CREATE MODULE statement.7 The authorization identifier, specified by using the@ AUTHORIZATION clause, enables Oracle jRdb to identify the user" under whom the module executes.D When you specify an authorization identifier in the definition ofC a stored module, that stored module is called a definer's rights? module. This type of module enables any user who has EXECUTEB privilege on the module to execute any of the module's routinesB without privileges on any of the underlying schema objects that@ the routine references. The routines execute under the rightsA identifier of the module define kr, not the rights identifier of@ the person executing the routine. This ability to allow users> access to schema objects through a call to a stored routine@ without having direct access to those schema objects is a key benefit of stored modules.= In contrast, when you omit the AUTHORIZATION clause in the> definition of a stored module, that stored module is called@ an invoker's rights module. In this type of module, users who? have EXECUTE privilege on a particular modulel must also haveB privileges to all the underlying schema objects associated with@ any of the routines in this module that they want to execute.B The following examples relate to stored modules and procedures.? Authorization and CURRENT_USER are handled the same for both types of stored routines.B Consider the following stored module definition, Module M1 with5 Procedure P1 and Authorization Brown. For example: CREATE MODULE M1 LANGUAGE SQL AUTHORIZAmTION BROWN PROCEDURE P1 (); BEGIN TRACE CURRENT_USER; CALL P2 (); END; END MODULE;C As you can see in the preceding example, P1 calls another stored= procedure, P2. Procedure P2 is defined in Module M2 as the following example shows: CREATE MODULE M2 LANGUAGE SQL -- no authorization PROCEDURE P2 (); BEGIN TRACE CURRENT_USER; CALL P3 (); END; END MODULE;B Procedure Pn2 calls another procedure, P3, from Module M3, which% is shown in the following example: CREATE MODULE M3 LANGUAGE SQL -- no authorization PROCEDURE P3 (); BEGIN TRACE CURRENT_USER; . . . END; END MODULE;4 In each procedure you can trace the CURRENT_USER. Assume the following:B o Smith is granted the EXECUTE privilege on Module M1; but not on M2 or on M3.C o Brown is granted the EXEoCUTE privilege on Modules M1, M2, and M3.B o Jones is granted the EXECUTE privilege on Modules M1 and M2.D When P1 is executed, CURRENT_USER always returns Brown as defined> by the AUTHORIZATION clause in Module M1. When P2 or P3 are( executed, the CURRENT_USER is either:B o Inherited from the calling routines AUTHORIZATION clause, orA o The CURRENT_USER of the calling routine if no authorization was specified> When there is no AUTHORIZATION clause f por the first callingA routine, then CURRENT_USER is inherited from the SESSION_USER. 3 Nonstored_ModulesC A nonstored module resides outside the database in an SQL module file.B The AUTHORIZATION clause specifies the authorization identifier@ for the module. If you omit the authorization identifier, SQL@ selects the user name of the user compiling the module as theA default authorization. Thus, if you use the RIGHTS clause, SQLB compares the user name of the perso qn who executes a module withB the authorization identifier with which the module was compiledD and prevents any user other than the one who compiled that moduleA from invoking that module. When you use the RIGHTS clause, SQLC bases privilege checking on the default authorization identifier, in compliance with the ANSI/ISO standard. 2 Catalog_Names= If you include the MULTISCHEMA IS ON clause in your CREATE> DATABASE statement, you can store your metadata in multiple? r schemas. A database with multiple schemas must organize them> within catalogs. A catalog is a group of schemas within one database.9 You name catalogs in CREATE CATALOG or CREATE DATABASEB statements. You can also use catalog names to qualify the namesA of other database elements such as schemas, tables, and views.& NOTEB In syntax diagrams, the column-name syntax element refers to@ either the qualified or unqualified form of the sname given@ to the catalog in the CREATE statement. That is, in syntax6 diagrams, the catalog-name is always defined as: catalog-name = . -+------> --------------+->, | |, +-> " -> . ->" -+ < In each multischema database, SQL creates a catalog namedC RDB$CATALOG. SQL stores all schemas in RDB$CATALOG by default. AC multischema database must contain at least one catalog, although= t you can create more than one catalog for each database. ToB store a schema in a catalog other than RDB$CATALOG, qualify theA schema name with the other catalog's name in the CREATE SCHEMAD statement, or use the SET CATALOG statement to change the default4 catalog before issuing a CREATE SCHEMA statement. 2 Column_NamesB You name columns in CREATE TABLE and ALTER TABLE statements. InD other SQL statements, the names you give to columns in CREATE andC ALTER statements ucan be qualified by table names, view names, or correlation names.& NOTEB In syntax diagrams, the column-name syntax element refers to@ either the qualified or unqualified form of the name givenA to the column in the CREATE TABLE or ALTER TABLE statement.@ That is, in syntax diagrams, column-name is always defined as: column-name = : ---+----------->-----------------+-> --># +-> -----v--+> . -+ +-> --------+ +-> -+ ? The only time you must qualify column names is when they are@ ambiguous. Joining a table with itself and joining two tables@ with common column names are two cases that require qualifiedC column names. Also, if you have a parameter without a colon withD the same name as a column, you need to qualify references to that column. 3 Correlation_NamesB In addition to qualifying column names with w table names or view> names, you can qualify column names with correlation names.@ Correlation names are analogous to aliases, but they refer toA tables instead of databases. Just as aliases provide temporaryD names for databases to qualify ambiguous table names, correlationC names give temporary names to tables to qualify ambiguous column names.@ Specify a correlation name after a table name within the FROM> clause of a select expression or DELETE statement, or in anA x UPDATE statement. Use any valid name that has not already been? used in the FROM clause either as a correlation name or as a) table name without a correlation name.< You must use correlation names to qualify column names in@ statements that join a table with itself. As with table names@ and view names, however, you can always specify a correlation name for clarity 3 Outer_References> You may have to qualify column names in an outer reference.A An outer referenc ye is a reference within a subquery to a tableC specified in an outer query that contains the subquery. An outer3 reference is also called a correlated reference.= For example, the previous example that retrieved the names= of employees who worked in the marketing department can be* reformulated to use an outer reference.= SQL> SELECT FIRST_NAME, --= cont> LAST_NAME --= cont> FROM EMPLOYEES z --= cont> WHERE 'MKTG' IN --D cont> (SELECT DEPARTMENT_CODE -- -- OuterD cont> FROM JOB_HISTORY -- -- Query> cont> WHERE JOB_END IS NULL -- Sub- --> cont> AND -- query --( cont> EMPLOYEE_ID => cont> EMPLOYEES.EMPLOYEE_ID) -- --0 cont> -- -------{--------------, cont> -- outer reference cont> ; FIRST_NAME LAST_NAME Chris Danzig Lawrence Hall Paul Belliveau 3 rows selectedA If the outer reference to EMPLOYEE_ID in this example were not? qualified by the table name EMPLOYEES, it would refer to the? EMPLOYEE_ID column in the subquery, not the outer query. The= predicate EMPLOYEE_ID = EMPLOYEE_ID is true for all values? of EMPLOYEE_ID that are not null, so |the statement would notC generate an error, but would give unexpected results. Instead ofA the three marketing employees, it would select all rows of theB EMPLOYEES table with values in the EMPLOYEE_ID column that were not null.? Although the outer reference is contained within a subquery,> it receives its value from an outer query. Because of this,> the subquery must be evaluated once for each value that the< outer reference receives from the outer query. It is this2 } characteristic that defines an outer reference. 2 Connection_Names? When your application attaches to one or more databases, SQL; associates the databases with a set of aliases (database? handles). In CONNECT, DISCONNECT, or SET CONNECT statements,@ you refer to this association as the connection name. You canA specify the connection name as a parameter marker from dynamic@ SQL, a host language variable from a precompiled SQL program,> a parameter from an SQL module ~language module, or a string literal.A The set of databases that you can attach or detach as one unitA is called the database environment. Within an application, all@ of the databases declared in all the modules form the defaultB database environment for that application at run time. For more2 information about connections, see the CONNECT. 2 Constraint_NamesB A constraint defines a condition that restricts the values that> can be stored in a table. When you inse rt and update columnB values, the constraint checks the values against the conditionsC specified by the constraint. If a value violates the constraint,A SQL generates an error message and the statement fails (either< when the INSERT, UPDATE, or DELETE statement executes, or@ when the next COMMIT statement executes depending on when SQL evaluates the constraint).@ You specify constraints in CREATE and ALTER TABLE statements.B Optionally, you supply a name for the constraints following the CONSTRAINT keyword. 2 Cursor_Names? Cursors provide access to individual rows of a result table.? A result table is a temporary collection of columns and rowsB from one or more tables or views. For cursors, the result table> is specified by the select expression in the DECLARE CURSOR statement.< Unlike other result tables, the result table for a cursor= can exist throughout execution of more than one statement.? Host language programs requir e cursors because programs mustB perform operations one row at a time, and therefore can execute? statements more than once to process an entire result table.? You name the result table for a cursor in the DECLARE CURSORB statement and refer to that name in OPEN, CLOSE, FETCH, UPDATE,: and DELETE statements. You cannot qualify cursor names. 2 Database_Names@ A database consists of physical data storage characteristics,@ such as a root file and storage area specificat ions; metadata: definitions, such as tables and domains; and user data.C By default, a database contains a single schema and no catalogs.> If you specify the multischema attribute when creating yourB database, you can group the data definitions within one or moreC schemas within one or more catalogs. See the CREATE DATABASE for7 information on how to create a multischema database.? When you create a database, you name it by specifying a fileC name and an optional reposi tory path name in the CREATE DATABASE= statement. You can supply a complete file specification, a= partial file specification, or use system-supplied default= values. You must use ASCII alphanumeric characters for the database name.< To perform operations on a database, the database name is> referenced through an attachment to that database called an= alias. When you first refer to a database in SQL, you mustC indicate the source of data definitions for the database and theD location of database files by declaring an alias. You can declare* an alias using one of three statements: o ATTACH o CONNECT o DECLARE ALIAS? Choose a statement based on the interface that you are usingA (interactive SQL, SQL module language, or precompiled SQL) andD your purpose (declaring a new alias or overriding the association@ between an alias and a database name). More information about aliases appears in Aliases.A There are two ways to identify the source of data definitions: o With a file specificationD o With a repository path name (if the repository is installed on the system) #3 Oracle_Rdb_Attach_SpecificationsA When you first create a database, you give file specificationsA for the files that contain all database definitions (metadata); and user data stored in the database. You must use ASCII; alphanumeric characters for the file specification name.@ You can also use a file specification whenever you refer to aA database in the CONNECT and DECLARE ALIAS statements, althoughC Oracle Rdb recommends that you always use a repository path name$ when the repository is installed.& A full file specification includes: o Network node name o Device name o Directory name or list o File name o File extension o File version number? Note that if you are specifying a database name for a remote= database, all logic al names/file specifications referenced? will be evaluated on the remote node, not on the local node.B Therefore, the necessary logical names/file specifications must exist on the remote node. 3 Repository_Path_Names> Unless you use the PATHNAME argument in the CREATE DATABASE; statement, SQL does not use the repository to store data definitions.? If you specify the PATHNAME argument when you first create aA database, SQL creates a path name that contains copie s of data definitions for the database.A Because SQL treats a path name like a string literal, you mustD enclose a path name in single quotation marks. You must use ASCII8 alphanumeric characters for the repository path name.A When you issue an ATTACH or a DECLARE ALIAS statement, you canC either specify the repository path name for that database (whichB in turn points to the physical database files) or directly name, the physical database file specification.A If you do not use the PATHNAME argument in the CREATE DATABASEA statement, you cannot specify a path name in ATTACH or DECLARE? ALIAS statements for that database unless you first issue anA INTEGRATE statement. Oracle Rdb recommends that you always useA a repository path name in CREATE DATABASE, ATTACH, and DECLARE@ ALIAS statements, and that you use the DICTIONARY IS REQUIRED5 clause to ensure that the two copies are the same.# A repository path name can be a:@ o Full path name, such as CDD$TOP.ELLINGSWORTH.SQL.PERSONNEL o Relative path name> A relative path name consists of the portion of the full; path name that follows the current default repository@ node. For example, assume that you used the SET DICTIONARY8 command to set the current repository directory to< CDD$TOP.ELLINGSWORTH.SQL. Now you can use the relative8 path name PERSONNEL in place of the full path name> CDD$TOP.ELLINGSWORTH.SQL.PERSONNEL. By defau lt, SQL setsA the current repository node to the path name defined by the? CDD$DEFAULT logical name. See the SET for the description< of the SET DICTIONARY statement. See also Using Oracle: CDD/Repository on OpenVMS Systems for more detail on repository path names.3 o Logical name for a full or relative path nameC Some Oracle Rdb features are not fully supported by all versions< of the repository. If you attach by path name and attempt> to create, mo dify, or delete objects not fully supported by< the repository, you may receive an error or informationalB message. See the Oracle Rdb Release Notes for information aboutC compatibility of Oracle Rdb features with the different versions of the repository. 2 Domain_Names> A domain is the set of values that a table column can have.? A domain definition restricts the set of values that a tableA column can have by associating a data type with a domain name,C and all ows optional formatting and collating clauses. The CREATE= and ALTER TABLE statements refer to domain names in columnA definitions. The domain name must be unique among domain names in the schema.A You can use a domain when defining columns in multiple tables.@ Once you have defined a domain, use the CREATE or ALTER TABLE? statement to define a column based on the domain definition.A You can qualify the domain name with the schema name (when the? domain belongs to a multischema database) or with the alias.C In general, you should use domains when you create tables. Using domains:C o Ensures that similar columns in multiple tables comply to one@ standard. For example, if you define the columns using theD domain ID_DOM, the data type for all these columns is CHAR(5).@ o Allows you to change the data type for all columns defined@ using a domain by changing the domain itself. For example,B if you want to change the da ta type for POSTAL_CODE_DOM fromC CHAR(5) to CHAR(10), you only need to alter the data type forA POSTAL_CODE_DOM. You do not have to alter the data type forB the column POSTAL_CODE in the tables COLLEGES and EMPLOYEES.? You might not want to use domains when you create tables if:C o You are creating intermediate result tables. It takes time toC plan what the domains are in the database and to define them.? Intermediate result tables might not warrant this effort.& NOTEB In syntax diagrams, the domain-name syntax element refers to@ either the qualified or unqualified form of the name given3 to the domain in the CREATE DOMAIN statement. domain-name = 7 -+---------------------------+-> ---> +-+-> -+-> . -+ +-> -------+  2 Index_NamesB You name indexes in the CREATE INDEX statement. In CREATE INDEXA and other SQL statements, the names you give to indexes can be* qualified by authorization identifiers.& NOTEA In syntax diagrams, the index-name syntax element refers to@ either the qualified or unqualified form of the name given1 to the index in the CREATE INDEX statement. index-name = 9 ---+----------------------------+-> --->" +---> -+--> . -+ +---> -------+  2 Multischema_Databases> If yo u specify the multischema attribute for your database,< you can store data definitions in multiple schemas within? that database. To specify the multischema attribute, use theB MULTISCHEMA IS ON clause in a CREATE DATABASE or ALTER DATABASEB statement. If you want SQL behavior compliant with the ANSI/ISO8 standard, you must specify the multischema attribute.D Databases that contain multiple schemas must organize the schemasA within one or more catalogs. To refer to data definitions in aC multischema database, qualify the names of data definitions with@ the schema and catalog names and, optionally, qualify with an alias.B When you use an alias to qualify the name of a catalog, schema,' or object in a multischema database:C o Separate subordinate names from the alias and from each other) with a period (.) after each name.B o Use double quotation marks (") to delimit the leftmost name pair.> o Use only uppercase charact ers in the leftmost name pair.? The leftmost name pair in a qualified name for a multischema< object is a delimited identifier. In an object name, eachD qualifying name is considered one level, and names with more thanC three levels are not allowed. However, a delimited identifier is! interpreted as a single level. 2 Nonstored_Names@ The SQL module language provides a calling mechanism for host= language programs to execute SQL statements contained in aC separate file called an SQL module file. The module contains SQLB statements that can be called from any host language, including@ those not supported by the SQL precompiler. The file containsB module language elements, including the following user-supplied names: o Module name> You supply a module name after the MODULE keyword at the? beginning of an SQL module. If you do not supply a module, name, SQL names the module SQL_MODULE.B Module names must be uniqu e. The following error is returnedA if a nonstored module is invoked while a stored module with the same name is active:) %RDB-E-EXT_ERR, Rdb extension errorL -RDMS-E-MODEXTS, there is another module named SALARY_ROUTINES in this database o Procedure nameD Every SQL module contains one or more procedures consisting ofB a procedure name, one or more actual parameter declarations,C and a single executable SQL statement. You must supply a name5 for each procedure after the PROCEDURE keyword. o Parameter nameC Actual parameters within a procedure in an SQL module specifyA a name to be used for the parameter by the SQL statement inB the procedure. Some special-purpose procedure parameters areB SQL keywords (SQLCODE, SQLCA, SQLDA, SQLSTATE), but you must8 give names to all other parameters in SQL modules. 2 Parameters_and_VariablesC Parameters, routine parameters, and SQL variables are often usedA in value expressions (for information on value expression, see$ the Value_Expressions HELP topic.? A variable is an identifier that represents a value that can< change during the execution of a program. You can use SQL* variables in multistatement procedures.@ A routine parameter is a variable associated with a parameter? of a routine that is used in a stored routine or an externalA routine. A stored routine refers to both stored procedures andA sto red functions defined using the CREATE MODULE statement. AnC external routine refers to both external procedures and externalC functions defined using the CREATE PROCEDURE and CREATE FUNCTION statements.B When you use SQL variables in multistatement procedures or whenB you use routine parameters, you do not use indicator variables.B See the Multistatement_Variables_and_Stored_Routines HELP topic= for more information about SQL variables in multistatement> procedures and stored routine parameters. See the External_D Routine_Parameters HELP topic for more information about external routine parameters.C A parameter is an identifier declared in a host language programC that is associated with an SQL statement. A parameter represents< values that can change during the execution of a program.@ Many SQL data manipulation clauses that do not accept general@ value expressions require parameters. However, you cannot use5 parameters in data definition language statements.2 You can use parameters in the following places: o Interactive SQLC In interactive SQL, you use the DECLARE Variable statement toA declare the parameter. For more information about declaring5 parameters and variables, see DECLARE Variable. o SQL module language@ In programs that call SQL module procedures containing SQL> statements, references to host language variables by SQLC statements are indirect. The variabl e declared in the programC is specified as a parameter in a host language call statement? to a procedure in the SQL module. Parameters in such call. statements are called actual parameters.@ In nonstored procedures, the SQL module procedure contains: parameter declarations that correspond to the actualC parameters in the calling program. Module parameters in thoseB declarations are called formal parameters. The SQL statement? in the module procedur e uses the formal parameter name to@ refer indirectly to the actual parameter named in the host, language call to the module procedure. o Precompiled SQL= In precompiled programs, SQL statements embedded in theC program refer directly to the host language variable using itB in the statement. The SQL precompiler supports only a subsetB of the declaration syntax for host languages. See the OracleA Rdb SQL Reference Manual for more information. You can only? use parameter names that conform to the rules of the host language. o Dynamic SQLB In dynamic SQL, dynamically executed SQL statements refer toB parameters with parameter markers denoted by a question mark9 (?) in the statement string of PREPARE statements.< SQL statements use parameters for the following purposes:; o SQL retrieves data from the database and places it in& parameters for use by a program.B o Parameters conta in data generated by a program that SQL uses to update the database.B o Data manipulation statements can specify parameters in value expressions.< o Special-purpose parameters called indicator parametersA indicate whether or not the value stored in a correspondingC main parameter is null. (Indicator parameters are not used in stored routines.)> o SQL puts information about the success or failure of SQL= statements in a parameter called SQLCO DE that is eitherC declared explicitly or as part of the SQL Communications Area? (SQLCA) or in the SQLSTATE status parameter (ANSI/ISO SQL standard).= See SQLCA for more information on SQLCODE and SQLSTATE.@ o SQL and programs use a collection of parameters called the= SQL Descriptor Areas (SQLDA and SQLDA2) to communicateB information about dynamic SQL statements. See SQLDA for more information.D SQL statements cannot use parameters to r efer to columns, tables,@ or views. For instance, if BADVAR is a host language variableC that contains the name of a table in the database, the following statement is invalid:A EXEC SQL SELECT FIRST_NAME INTO :GOODVAR FROM :BADVAR END-EXECA When you use the precompiler, module language, or dynamic SQL,? display operations should use CAST or EXTRACT with CHAR host> variables to convert date-time data from binary format when6 passing data to and from the database. For example:. EXEC SQL SELECT CAST(TBL_INT_H3 AS CHAR(4)) INTO :string_var3 FROM ALL_DATE_TABLE;A For more information about the CAST and EXTRACT functions, see% the Built_In_Functions HELP topic. 3 Data_and_Indicator_ParametersC A data parameter contains the value that an SQL statement storesB in, retrieves from, or compares to a column in the database. AnC indicator parameter specifies whether or not its associated data@ parameter was assigne d a null value. You specify an indicatorB parameter after the data parameter. As for data parameters, the@ notation for referring to indicator parameters depends on the3 environment in which an SQL statement is issued. parameter = 9 --> : -+----------------------------+->7 ++---------------+---------+ |7 +-> INDICATOR --+ | |7 +--------------------------+ |7 +-> : -+ = o If you set the dialect to SQL99 or another dialect thatA enforces the use of parameters or if you use a clause, suchC as PARAMETER COLONS, that enforces the use of parameters, all@ parameter names must begin with a colon. This rule appliesA to declarations and references of module language procedure< parameters. If you do not use one of these dialects orA clauses, no parameter name can begin with a colon. For more # information, see SET_DIALECT.B The current default behavior is no colons are used. However,> this default is deprecated syntax. In the future, colonsB will be the default because it allows processing of ANSI/ISO standard modules.= o In SQL statements to be dynamically executed, you refer< to the data parameters and indicator parameters with aB single parameter marker (?). SQL gets information about the@ parameters in EXECUTE or OPEN statem ents. These statements< either provide an explicit list of data parameters andB indicator parameters (using the notation for precompiled SQL? or SQL modules as appropriate) or refer to the SQLDA that? has fields that provide information about data parameters2 (SQLDATA) and indicator parameters (SQLIND). '3 Host_Structures_and_Indicator_Arrays? Host structures are host language parameters that correspond? to group constructs or records in the languages that supportC such constructs. Use a host structure to refer to a list of host@ language variables with a single name. Once you define a hostA structure, you can refer to it in an embedded SQL statement orB in an SQL module language procedure instead of listing the host' language variables that comprise it.< Parameters can be qualified by group fields to any depth.@ The format of a qualified reference to a parameter in a group construct is: qualified-parameter = ? - -> : --+-+------------------------+-+--> parameter-name ---->' | +--> group-field-name. --+ |' +------------ <--------------+ < In addition, you can declare an indicator parameter for a? host structure by defining a one-dimensional array of signed> longword integers. This array provides indicator parameters> for fields in the host structure and is called an indicatorC array. (Indicator arrays are also called indicator structures orC indicator vectors.) Just as you append an indicator parameter toB a data parameter, you can append the name of an indicator array? to a host structure that represents several data parameters.D Indicator arrays are the only way to specify indicator parameters for host structures.D You can refer to a host structure anywhere that SQL allows a list of parameters:* o VALUES clause of an INSERT statement o Select lists o IN predicates9 o INTO clause of FETCH or singleton SELECT statements0 o USING clause of OPEN or EXECUTE statements: You cannot use host structures in a stored routine or a multistatement procedure.C You can also refer to a single parameter in a host structure. InC FORTRAN, C, Pascal, and Ada, you must qualify the parameter nameD with all preceding group field names. In COBOL and PL/I, you needC to qualify the parameter with group field names only if the name+ is ambiguous without such qualification. /3 Multistatement_Variables_and_Stored_RoutinesC Multistatement procedure variables and stored routine parametersB are often used in value expressions A variable is an identifierB that represents a value that can change during the execution ofA a program. You use SQL variables in multistatement procedures.? A stored routine parameter is a variable associated with theD parameters of a stored routine that you use in a stored procedure= or stored function. A stored routine refers to both storedB procedures and stored functions defined using the CREATE MODULE statement. variable = * --+-> : --------------+->( +-> : -+ < Variables in multistatement procedures and stored routine? parameters follow the rules, such as case-sensitivity rules,7 associated with the encompassing module. That means:B o In embedded SQL, the variables follow the rules for the host/ language in which the program is written.? o In SQL module language programs, the variables follow the" rules for the SQL interface.D o In stored routines, the variables follow the rules for the SQL interface.B Unlike data parameters, variables and stored routine parameters? allow null values. Because of this, you cannot use indicator; parameters with variables and stored routine parameters.C For more information about stored routine parameters, see CREATE MODULE. 3 External_Routine_Para meters: An external routine parameter is a 3GL declaration thatC corresponds to an actual parameter in the calling program. TheseC declarations are called formal parameters. 3GL or SQL statementsA in the external routine use the formal parameter name to refer8 indirectly to the calling programs actual parameters.< External routine parameters cannot represent null values. 2 Statement_NamesA Dynamic SQL lets programs accept or generate SQL statements at? run time, i n contrast to precompiled statements that must beA embedded in the program before it is compiled. Unlike embeddedD statements, such dynamically executed SQL statements are not partC of any source code but are created while the program is running.@ Dynamic SQL is useful when you cannot predict the type of SQL+ statement your program needs to process.> To handle dynamically executed SQL statements, programs useD embedded PREPARE statements to assign a name to the SQL statement D created at run time and to prepare it for execution. The EXECUTE,@ dynamic DECLARE CURSOR, and DESCRIBE statements refer to that> assigned name. You cannot qualify prepared statement names.B Because they are prepared with embedded PREPARE statements, youD can refer to dynamic statement names from programs only, not from interactive SQL. 2 Schema_NamesC A schema consists of metadata definitions such as tables, views,D domains, constraints, collating sequences, in dexes, storage maps,2 triggers, and the privileges for each of these.C You name schemas in CREATE SCHEMA or CREATE DATABASE statements.> You can also use schema names to qualify the names of other8 database elements such as tables, views, and columns.& NOTEB In syntax diagrams, the schema-name syntax element refers to@ either the qualified or unqualified form of the name given? to the schema in the CREATE statement. That is, in syntax5 diagrams, the schema-name is always defined as: schema-name = 2 --+---------------------------------------------+2 +------> --------------+->. ---+2 +-> " -> . ->" --+ |2 | +-----------------------------------------+2 | +--------------> ------+->0 +-> " -> . ->" ------+ A By default, each database that you create has only one schema.> CREATE DATABASE tells how to crea te a multischema database.> The alias RDB$DBHANDLE represents the schema when you referA to definitions in a single-schema database or definitions in a; multischema database without multischema naming enabled.D When you refer to definitions in a multischema database, you mustA follow multischema naming rules unless you disable multischema! naming. In multischema naming:D o You must qualify definition names using the name of the schema@ that contains them. You cannot refer to a table and a viewC or two objects of the same type (such as two tables) with the8 same name unless they belong to different schemas.< o You may additionally qualify the names of objects in a? multischema database with the alias and the catalog name.? Whenever you qualify the object name with a catalog name,C you must also specify the schema name, unless you want to useB the default schema. Remember that the catalog name and aliasB combin ation or the schema name and alias combination must be- enclosed within double quotation marks.D o If you prefer, you can qualify an object name in a multischemaD database with just an alias, provided you have set the defaultA catalog and schema to the ones that you want to contain theB object. Enclose the alias and object name pair within double6 quotation marks and separate them with a period.= If you omit the schema name when referring to objects in a@ multischema database, SQL uses a schema with the same name asD the user identifier of the invoker as the default schema. You can= use the SET SCHEMA statement to change the default schema. 2 Storage_Area_Names@ Storage areas are data and snapshot files that are associatedD with one or more tables in a multifile database. You name storageA areas in CREATE STORAGE AREA clauses within CREATE DATABASE or? IMPORT statements. The CREATE STORAGE MAP statements controlA which parts of which tables get stored in a particular storageC area. In syntax diagrams, the syntax element area-name specifies> that you supply the name of a storage area at that place inA the statement. In CREATE STORAGE AREA clauses and in other SQL@ statements, the names you give to storage areas in the CREATE) statement can be qualified by aliases.B You must use ASCII alphanumeric characters for the storage area name.& NOTE@ In syntax diagrams, the area-name syntax element refers to@ either the qualified or unqualified form of the name given< to the storage area in the CREATE STORAGE AREA clause. area-name = + -+---------------+-> -----> +---> . +  2 Storage_Map_NamesC Storage maps control which parts of which tables get stored in aD particular storage area in a multifile database. You name storageA maps in CREATE STORAGE MAP statements. In syntax diagrams , theB syntax element map-name specifies that you supply the name of a/ storage area at that place in the statement.@ In CREATE STORAGE MAP and other SQL statements, the names youC give to storage maps in the CREATE statement can be qualified by aliases.& NOTE? In syntax diagrams, the map-name syntax element refers to@ either the qualified or unqualified form of the name given= to the storage map in the CREATE STORAGE MAP statement. map-name = - ---+------------------+-> ---> +-> --> . -+ 2 Stored_NamesB The name that you specify for a data definition when you createD it is called the SQL name. Each data definition also has a stored* name that it is known by to Oracle Rdb.B You can give the same SQL name to two entities of the same typeC within different schemas of a multischema database. For example,@ you could create a table called EMPLOYEES in the schema DEPT1B and a second EMPLOYEES table in the schema DEPT2. For the firstA EMPLOYEES table created, SQL assigns a stored name that is the= same as the SQL name. For subsequent EMPLOYEES tables, SQL? generates a unique stored name by adding a serial number and% truncating the name, if necessary.? If you prefer to specify a stored name for a definition in aB multischema database instead of relying on SQL to generate one,? you can do so using the STORED NAME IS clause f or any CREATEB statement. You can only specify stored names for definitions in multischema databases. 2 Table_and_View_Names< You name tables and views in CREATE TABLE and CREATE VIEW? statements. In those and other SQL statements, the names youD give to tables and views in CREATE statements can be qualified by3 aliases and can themselves qualify column names.? If your database has the multischema option enabled, you canA also qualify table and view names by sc hema and catalog names,C or by the alias. You must use double quotation marks to surroundA the alias and table name pair and have set your dialect to theA ANSI/ISO SQL standard or use the ANSI/ISO SQL standard quoting@ rules. See the SET_DIALECT and the SET_QUOTING_RULES for moreB information about dialects and quoting rules. The following areA valid names for the EMPLOYEES table in the database with alias6 CORP, catalog ADMINISTRATION, and schema PERSONNEL:/ o "CORP.ADMINISTRATION".PERSONNEL.EMPLOYEES o "CORP.EMPLOYEES"& NOTE= In syntax diagrams, the table-name and view-name syntax; elements refer to either the qualified or unqualified@ form of the names given to the table or view in the CREATEB statement. That is, in syntax diagrams, table-name and view-! name are always defined as: table-name = 3 -+-------------------------+-> --> +-+-> +> . -+ +-> ------+ view-name = 3 -+-------------------------+-> ---> +-+-> +> . -+ +-> ------+ D You must qualify table names and view names with an alias if theyC are not in the default database. The following example shows theB error that SQL generates if you try to use an unqualified tableA name to refer to a database previously declared with an alias:/ SQL> ATTACH 'ALIAS PERS PATHNAME personnel';"  SQL> SET QUOTING RULES 'SQL92'; SQL> SELECT * FROM EMPLOYEES;/ %SQL-F-NODEFDB, There is no default database$ SQL> -- This statement will work:' SQL> SELECT * FROM "PERS.EMPLOYEES"; 2 Trigger_Names@ You name a trigger in the CREATE TRIGGER statement. A triggerC name must be unique within a schema of a multischema database or+ unique within a nonmultischema database.; A trigger defines the actions to occur before or after a> specified table is updated (by a wr ite operation such as anA INSERT, DELETE, or UPDATE statement). A trigger can be thoughtC of as a rule on a single table, which takes effect at a specific> time for a particular type of update and causes one or more% triggered actions to be performed.8 With triggers, you can define useful actions such as: o Cascading deletes@ Deleting a row from one table causes additional rows to beC deleted from other tables that are related to the first table by key values. o Cascading updates> Updating a row in one table causes additional rows to beA updated in other tables that are related to the first tableA by key values. These updates are usually limited to the key values themselves. o Summation updates> Updating a row from one table causes a value in a row ofB another table to be updated by being increased or decreased. o Hidden deletesA Causing rows to be deleted from a table by moving them to a6 parallel table that is not used by the database. o Audit log= Records when and by whom a row is inserted, updated, or deleted. www 1 Data_Types@ When you define new columns of a table in the CREATE TABLE or? ALTER TABLE statements, you must specify a data type for theD column. The data type of a column controls how SQL interprets andC stores values for that column. All value expressions (functions,8 parameters, and literals) have associated data types. data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+---------------+A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+ |A +-> FLOAT ----------------+ |A +-> NUMBER -+----------------------------------+-------------+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE VARYING --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT ---+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) +  |A | +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION ----------------------------------------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+  |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac --------------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+  frac = " --+---------------------------+-> +--> ( ) -+  interval-qualifier = ; --+-> YEAR ---> prec --+-------------+-----------------+->9 | +-> TO MONTH -+ |9 +-> MONTH --> prec ----------------------------------+9 +-> DAY ----> prec --+-------------------------------+9 | +-> TO -+-> HOUR ---------------+9 | +-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> HOUR ---> prec --+-------------------------------+9 | +-> TO -+-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> MINUTE -> prec --+-------------------------------+9 | +-> TO SECOND ------> frac -----+9 +-> SECOND -> seconds-prec --------------------------+  prec = " --+---------------------------+-> +--> ( ) -+  seconds-prec = . --+--------------------------------------+-->+ +-> ( ---+ |+ +-------------------------+ |+ ++--------------------------+-> ) --+# +> , --+  2 Character3 SQL supports the following character data types: o CHAR@ This data type specifies that the column is a fixed-lengthB sequence of octets or characters. It indicates the number ofA octets or characters in the column with an unsigned integer? (n). (See the Oracle Rdb SQL Reference Manual for a listA of the number of octets used by characters in the supported? character sets). T he maximum size for n is 65,271 octets.A For characters, the maximum size for n is 65,271 divided byB the maximum number of octets per character. For example, theB Kanji character set uses a maximum of 2 octets. Therefore, nD is 65,271/2 or 32,635 characters. If you omit n, SQL creates a$ 1-octet or 1-character column.C o CHAR or CHARACTER qualified by the keywords CHARACTER SET and the character set nameA This data type has the same characteristics as CHAR, exceptC that the character set is that specified in the CHARACTER SETB clause. For a list of the character set names, see Supported Character Sets.1 o NCHAR, NATIONAL CHAR, or NATIONAL CHARACTERD This national character data type has the same characteristicsA as CHAR, except that the character set is that specified as! the national character set." o VARCHAR or CHARACTER VARYINGB This data type specifies that the column is a va rying-length@ sequence of octets or characters. It indicates the maximumC number of octets or characters in the column with an unsigned@ integer (n). The maximum size for n is 65,269 octets. ForA characters, the maximum size for n is 65,269 divided by theD maximum number of octets per character. For example, the Kanji? character set uses a maximum of 2 octets. Therefore, n is$ 65,269/2 or 32,634 characters.A In addition to the VARCHAR2 synonyms, th e CHARACTER VARYINGA and CHAR VARYING data type keywords are supported by OracleB Rdb as synonyms for VARCHAR, in compliance with the ANSI/ISO SQL standard.= o VARCHAR qualified by the keywords CHARACTER SET and the character set nameD This data type has the same characteristics as VARCHAR, exceptC that the character set is that specified in the CHARACTER SETB clause. For a list of the character set names, see Supported Character Sets.A o NCHAR VARYING, NATIONAL CHAR VARYING, or NATIONAL CHARACTER VARYING8 This national character set data type has the same? characteristics as VARCHAR, except that the character set6 is that specified as the national character set. o LONG VARCHARB This data type specifies that the column is a varying-length? sequence of octets or characters with a maximum number of> 16,383 octets. For characters, the maximum size for n isC 16,383 div ided by the maximum number of octets per character.> For example, the Kanji character set uses a maximum of 2D octets. Therefore, n is 16,383/2 or 8,191 characters. The LONGD VARCHAR data type is equivalent to specifying VARCHAR (16383).= o RAW is a synonym for VARCHAR. It always has a character> set of UNSPECIFIED (that is, the CHARACTER SET clause is? not permitted) and so can be assigned data from any other> character set in the database. This allows dat a from any= character set to be assigned to a column, parameter, or? variable of this type. If you specify a length, the valueC can be 0 to 65535. Actual usage might be limited by available> space in a table row, but the full length can be used by> variable and parameter definitions (as is true for CHAR,( VARCHAR, and VARCHAR2 data types).9 o LONG is a synonym for LIST OF BYTE VARYING AS TEXT.? o LONG RAW is a synonym for LIST OF BYTE VARYING AS BINARY. 3 Maximum_LengthB All SQL data types take up a fixed amount of room in a databaseD row. Most are predetermined in size. For example, the BIGINT dataB type requires 8 octets for storage. However, the CHAR, VARCHAR,@ and the NATIONAL CHARACTER equivalent data types allow you to* specify the storage size in characters.B Oracle Rdb restricts a stored row to 65,272 octets which limitsC the number of columns and the associated data type sizes for the table.D T here is also a variable overhead for each table definition whichA is a varying number of octets to represent the NULL flags (oneA flag for each column). The larger the number of columns in theD table, the larger the NULL bit vector (which is stored as a wholeC number of octets). For each eight columns in the table, a single. octet is used to store the NULL bit vector.& NOTE= Each VARCHAR, NATIONAL CHARACTER VARYING (or equivalent? syntax) column requires two additional octets in which to save the actual length.@ The maximum length for a CHAR or VARCHAR column is controlledA by the amount of free space available to store the new column.> For example, it is possible to create a table with a single CHAR(65271) column.( SQL> CREATE TABLE T1 (A CHAR(65271));B However, if you define an additional BIGINT column, the maximumC CHAR length is reduced to 65,263 octets (65,271 minus 8 octets).2 SQL> CREATE TABLE T1 (A CHAR(65271), B BIGINT);0 %RDB-E-NO_META_UPDATE, metadata update failed? -RDMS-F-RECMAXEXC, relation T1 definition exceeds data limit2 SQL> CREATE TABLE T1 (A CHAR(65263), B BIGINT);? The maximum character length is dependent upon the types and" number of columns in the table. 2 Date-Time? SQL provides four data types for expressing dates and times,= hereafter called date-time data types. The DATE, TIME, andB TIMESTAMP data types refer to calendar date and clock time. TheC INTERVAL data type is a relative date-time data type that refers0 to the duration between two date-time values. The date-time data types are: o DATE- You can qualify DATE with two keywords:; - DATE ANSI specifies a DATE containing Year To Day.B - DATE VMS specifies a timestamp containing YEAR TO SECOND.D If you do not qualify the DATE data type, it is interpreted asB DATE VMS when creating columns in a table. When you issue an@ INSERT or SELECT statement, you must qualify the DATE data> type. The DATE VMS data type cannot be used in date-time arithmetic.@ You can change DATE to DATE ANSI with the SET DEFAULT DATEB FORMAT statement, the precompiler DEFAULT DATE FORMAT clauseA in a DECLARE MODULE statement embedded in a program, or theB module language DEFAULT DATE FORMAT clause in a module file.? You must use the SET DEFAULT DATE FORMAT statement before B creating domains or tables. You cannot use this statement toA modify the data type once you create a database definition.B For information on the format of the DATE data type, see the Literals HELP topic. o TIMEC Contains the fields HOUR, MINUTE, and SECOND. You can specifyD a fractional-seconds precision following TIME. The fractional-B seconds precision, shown in the syntax diagram in Data Types> as frac, is a number between 0 and 2 that represents the@ number of digits taken up by fractions of a second. If you= specify TIME without a fractional-seconds precision, it defaults to TIME(0). o TIMESTAMP= Contains the fields YEAR, MONTH, DAY, HOUR, MINUTE, and< SECOND. You can specify a fractional-seconds precisionB following TIMESTAMP. The fractional-seconds precision, shown> in the syntax diagram in Data Types as frac, is a number? between 0 and 2 that represent the number of digits takenC up by fractions of a second. If you specify TIMESTAMP withoutB a fractional-seconds precision, it defaults to TIMESTAMP(2), hundredths of a second. o INTERVAL@ Specifies the difference between two date-time data types.= To qualify which interval in which you want an interval; calculation expressed, SQL provides two categories of> intervals, each with its own set of interval qualifiers. 2 DECIMAL_and_NUMERICD SQL p rovides limited support for the packed decimal (DECIMAL) and' signed numeric (NUMERIC) data types:C o Conversion to integer or floating point in column definitionsC Because the databases that underlie SQL may not support theseA data types, if you specify the DECIMAL or NUMERIC data typeC for a column, SQL generates a warning message and creates theD column with a data type that depends on the precision argument specified. For example:) SQL> CREATE TABLE T (C DECIMAL(3));G %SQL-I-NO_DECIMAL, C is being converted from DECIMAL to SMALLINT.B Following is a list of the data types to which SQL converts:B - DECIMAL(1) through DECIMAL(4) are converted to SMALLINT.B NUMERIC(1) through NUMERIC(4) are converted to SMALLINT.A - DECIMAL(5) (default for DECIMAL) through DECIMAL(9) are converted to INTEGER.A NUMERIC(5) (default for NUMERIC) through NUMERIC(9) are converted to INTEGER.A - DECIMAL(10) through DECIMAL(18) are converted to BIGINT.A NUMERIC(10) through NUMERIC(18) are converted to BIGINT.7 - DECIMAL(19) and larger are converted to FLOAT.7 NUMERIC(19) and larger are converted to FLOAT.B o Conversion to packed decimal or signed numeric data types in3 formal parameters or host language parametersA You can specify DECIMAL or NUMERIC for formal parameters inC SQL modules, and declare host langua ge parameters with packedD decimal or signed numeric storage format. SQL converts betweenA the data types of values in the database and the DECIMAL orC NUMERIC representation specified for corresponding parameters# and host language parameters.A Prior to Oracle Rdb V6.0, SQL allowed you to insert a value? into a column that exceeded the precision specified. ThisB behavior is maintained for databases created prior to Oracle Rdb V6.0.C To comply with the ANSI/ISO SQL standard, Oracle Rdb V6.0 andD higher generates an error message if you attempt to exceed the' precision specified. For example:* SQL> INSERT INTO T (C) VALUE (9999);G %RDB-E-VALOUTRANGE, value outside the specified precision (3) for column "C" 2 Fixed_Point_Numeric= SQL provides four fixed-point numeric data types: TINYINT,A SMALLINT, INTEGER, and BIGINT. In all four, you can specify an@ optional unsigned integer (n). The integer is a scale factorB that indicates the number of places to the right of the decimal point.B The scale factor must be an integer in the range from 0 to 127.C If you do not specify n, the default is 0 (with no places to the right of the decimal point). o TINYINT> Specifies that the column is a signed byte. (A byte is 8? contiguous bits.) The TINYINT data type can store a range& of values from -128 through 127. o SMALLINT< Specifies that the column is a signed 16-bit word. TheA SMALLINT data type can store a range of values from -32,768 to 32,767. o INTEGER@ Specifies that the column is a signed 32-bit longword. TheB INTEGER data type can store a range of values from -2**31 to (2**31) -1. o BIGINT@ Specifies that the column is a signed 64-bit quadword. TheA BIGINT data type can store a range of values from -2**63 to (2**63) -1. 2 Floating_Po int_Numeric8 SQL provides three floating-point numeric data types: o FLOATD Specifies that the column is a 32-bit (REAL) or 64-bit (DOUBLEB PRECISION) floating-point number, depending on the precisionC indicated in the positive integer (n). If n is less than 25,C FLOAT specifies a 32-bit floating-point number. If n is 25 or> greater, FLOAT specifies a 64-bit floating-point number.D The maximum value for n is 53. If FLOAT does not include n, it/  specifies a 64-bit floating-point number. o REALA Specifies that the column is a 32-bit floating-point number) with precision to 24 binary digits. o DOUBLE PRECISIONA Specifies that the column is a 64-bit floating-point number) with precision to 53 binary digits. 2 LIST_OF_BYTE_VARYINGA The LIST OF BYTE VARYING data type is designed to handle large@ data objects with a segmented internal structure. The LIST OF- BYTE VARYING data type is equivalent to a: o Segmented stringC o Binary large object (BLOB) (certain industry implementations)4 o LIST OF VARBYTE (alternate name in SQL syntax)= An object of the LIST OF BYTE VARYING data type is usuallyC referred to as a list. A list is a linked list of data segments,/ with each segment stored on a separate page.C In a list, you can store unstructured data such as large amounts? of text, long strings of binary input from a data collecting< d evice, or graphics data. Any data type can be stored andC retrieved from a list. The data is stored in unstructured bytes.? For example, you can store character data in a list and thenA interpret it as hexadecimal data. Except for the length of the@ segments, Oracle Rdb does not know anything about the type of data contained in a list.= There is no limit on the number of segments within a list.@ Each segment stored on a page is referenced by the line indexB structure, which uses a word offset and a word length. The pageC structure imposes a segment size limit of 65,535 unsigned bytes.? Use an unsigned integer (n) to specify the number of octets? (bytes) in a column with the LIST OF BYTE VARYING data type.> If you omit n, SQL creates a 1-octet column. In the chained> list format, the maximum size for n is 65,508 for the firstA segment and 65,522 for each subsequent segment. In the indexedA list format, the maximum size for n is 65,530, leaving 5 bytesA for overhead. See the Oracle Rdb SQL Reference Manual for more< information on the chained and indexed formats for lists. ww 1 Literals> Literals, which are also called constants, specify a value.6 The following diagram shows the format of literals: literal = --+-> numeric-literal ----+---> +-> string-literal -----+ +-> date-time-literal --+ +-> interval-literal ---+ +-> dbkey-literal ------+B Literals are a type of value expression . Many SQL clauses thatB do not accept general value expressions require literal values.C Literal values can be either numeric, character string, or date.A In addition, SQL provides keywords that refer to literals, for example: o NULL o CURRENT_DATE o SYSTEM_USER 2 Numeric_LiteralsC A numeric literal is a string of digits that SQL interprets as a. decimal number. A numeric literal can be a:D o Decimal string that consists of digits and an optional decimalC point. The maximum length, not counting the decimal point, is 19 digits.= o Decimal number in scientific notation (E notation) that@ consists of a decimal string mantissa and a signed integerB exponent, separated by the letter E. You cannot embed spaces in E notation.= The following syntax shows the format of numeric literals: numeric-literal = 9 --+------+-+-+> +-+------------------------+-+-+9 +-> + -+ | +----<-----+ +-> . --+------->------+-+ | |9 +-> - -+ | +-+> +-+ | |9 | +----<-----+ | |9 +-> . -+> +-----------------------+ |9 +----<-----+ |9 +-----------------------------------------------------+$ ++---------->-----------------+-->! +-- E -+------+-+> +-+ +-> + -+ +----<-----+ +-> - -+ 2 Character_Str ing_LiteralsC SQL recognizes the following types of character string literals:A o A quoted character string to represent printable characters/ from the session's literal character set.D o A quoted character string qualified by the name of a characterD set. The string represents printable characters from the named character set.D o A national character string literal (an N followed by a quotedA character string), represents printable characters from the  national character set.? o A hexadecimal character string (an X followed by a quotedC character string) represents printable and nonprintable ASCII characters. 3 Quoted_Character_String= A quoted character string literal is a string of printableD characters enclosed in single quotation marks. The maximum lengthB of a character string is 1,024 octets. An unqualified characterA string must contain characters only from the literal character set of that session.- The printable ASCII characters consist of:& o Uppercase alphabetic characters: A-Z& o Lowercase alphabetic characters: a-z o Numerals: 0-9 o Special characters:% ! @ # $ % ^ & * ( ) - _ = + ` ~# [ ] { } ; : " \ | / ? > < . ,> For a list of the printable characters for DEC_MCS, see the; OpenVMS documentation for users; for a list of printable= characters for the other supported character sets, see the# standard for that character set.> Use a pair of single quotation marks to enclose a character8 string literal. If you use double quotation marks, an= informational message is displayed, indicating that double> quotation marks are nonstandard. Double quotation marks are? passed as delimited identifiers if the quoting rules are set to ANSI/ISO SQL. 4 Qualified= You can use a quoted character string literal qualified byA the name of a character set. The character string must contain0 characters only from the named character set.? A string literal qualified by a character set begins with anA underscore (_), followed by the name of a supported characterC set, and a quoted string. No blank spaces are allowed outside of the literal.D The following example shows how to qualify character strings with DEC_MCS and with DEC_KANJI: _DEC_MCS'Blue' _DEC_KANJI'Blue'> You can use a national character string literal, which is a< quoted character string literal qualified by the nationalC character set. The character string must contain characters only# from the national character set.? A national character string literal begins with the letter NC followed by a quoted string. No blank spaces are allowed outside of the literal.@ The following example shows how to qualify a character string# with the national character set: N'Blue' 3 Hexadecimal_Character_String: A hexadecimal character string literal begins with an XA followed by a string of up to 16 characters enclosed in singleB quotation marks. This type of string literal lets you representD nonprintable ASCII characters by specifying the hexadecimal value0 of the characters within the quotation marks.B Each ASCII character requires 2 hexadecimal digits to represent> it, so you must provide an even number of characters withinA the quotation marks. The only valid characters for hexadecimal< character string literals are 0 through 9 and A through F (uppercase or lowercase).= In the following example, the hexadecimal character stringB literal represents two delete characters; the ASCII hexadecimal& value for a delete character is FF: X'FFFF' 2 Date_Time_Literals? When you refer to a date-time data type with a literal in anA SQL statement, you must precede the literal with the data typeC name and enclose the literal in single quotatio n marks. You must? provide values for all fields, and values must be within the valid range for the field.? The following syntax shows the format of date-time literals: date-time-literal = B --+-> TIME --> ' --> time-body --> ' ------------------------+-->? +-> DATE -+---------+-> ' --> date-body --> ' -------------+? | +-> ANSI -+ |? +-> TIMESTAMP --> ' --+-> date-body time-body -+--> ' --+5 +-> date-body : time-body -+ time-body = + ---> : : ---++ +---------------------<---------------+, ++---------------------------+--------->" +-> . -+ date-body = " ---> - - --> & NOTE@ In the following syntax descriptions, y, d, h, and s standB for single digits in fields representing years, days, hours,@ and seconds, respectively. The letter m stands for 1 digitA of the month number when it follows a y, and 1 digit of the@ minutes number when it does not. Fractions of a second are4 represented by digits after the decimal point.3 The syntax for date-time literals is as follows: o DATE literals DATE 'yyyy-mm-dd' or$ DATE 'dd-mmm-yyyy hh:mm:ss.ss'& Examples: DATE ANSI '1993-05-27'2 DATE VMS '27-MAY-1993 15:25:00.00'A SQL includes leap year validation for the 29th of February. o TIME literals TIME 'h:m:s' TIME 'h:m:s.s'! Example: TIME '14:23:45.19'# TIME represents 24-hour time. o TIMESTAMP literals TIMESTAMP 'y-m-d h:m:s' or TIMESTAMP 'y-m-d:h:m:s'/ Example: TIMESTAMP '1993-1-4 14:12:01.00'/ TIMESTAMP '1993-1-4:14:12:01.00'B There are two formats allowed for the TIMESTAMP literal. TheB SQL92 format allows a separating space c haracter between theC date-body and the time-body as shown in the previous example.@ The nonstandard format allows a separating colon character; between the date-body and the time-body. For example:+ SQL> SET DEFAULT DATE FORMAT 'SQL92'; SQL> --O SQL> -- Create a table and insert several rows using the SQL92 format and? SQL> -- the nonstandard format for the TIMESTAMP literal. SQL> --4 SQL> CREATE TABLE t (a INTEGER, b TIMESTAMP(2)R cont> DEFAULT TIMESTAMP '1995-1-1 12:34:10.01');' SQL> INSERT INTO t (a) VALUE (0); 1 row inserted SQL> --I SQL> -- Insert a row using the nonstandard format for the TIMESTAMP SQL> -- literal. SQL> --K SQL> INSERT INTO t (a,b) VALUE (1, TIMESTAMP '1995-1-1:12:34:10.01'); 1 row inserted SQL> --L SQL> -- Insert a row using the SQL92 format for the TIMESTAMP literal. SQL> --K SQL> INSERT IN TO t (a,b) VALUE (2, TIMESTAMP '1995-1-1 12:34:10.01'); 1 row inserted SQL> --H SQL> -- Select the rows. SQL uses the SQL92 format to display the6 SQL> -- TIMESTAMP literal for all selected rows. SQL> --? SQL> SELECT a, b, CAST (b AS CHAR(30)) FROM t ORDER BY a; A BD 0 1995-01-01 12:34:10.01 1995-01-01 12:34:10.01D 1 1995-01-01 12:34:10.01 1995-01-01 12:34:10.01D 2 1995-01-01 12:34:10.01 1995-01-01 12:34:10.01 3 rows selected o INTERVAL literals# INTERVAL 'y-m' YEAR TO MONTH) INTERVAL 'd:h:m:s.s' DAY TO SECOND- Examples: INTERVAL '-1-2' YEAR TO MONTH3 INTERVAL '1:4:30:0.0' DAY TO SECOND+ INTERVAL '1:10' DAY TO HOUR' INTERVAL '235' MONTH(3)A The following syntax shows the format of interval literals: interval-literal = H --> INTERVAL --> ' --> --> ' --> interval-qualifier -->  interval-body = # +----++-> years -+---------------+# +> + || +> - + |J +> - ++---------------+> months -+-------------------------------------+>I +> days +--------------+ |I | +> : + | |I +------------+> hours ++-----------+ |I | +> : + |  |I +--------------------------+> min ++-----------+ |I | +> : + | |I +--------------------------------------+> sec ++-----------------+I | +> : + |I +--------------------------------------------------+> . frac-sec +  interval-qualifier = ; --+-> YEAR ---> prec --+-------------+-----------------+->9 | +-> TO MONTH -+ |9 +-> MONTH --> prec ----------------------------------+9 +-> DAY ----> prec --+-------------------------------+9 | +-> TO -+-> HOUR ---------------+9 | +-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> HOUR ---> prec --+-------------------------------+9 | +-> TO -+-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> MINUTE -> prec --+-------------------------------+9 | +-> TO SECOND ------> frac -----+9 +-> SECOND -> seconds-prec --------------------------+  frac = " --+---------------------------+-> +--> ( ) -+  prec = " --+---------------------------+-> +--> ( ) -+  seconds-prec = . --+--------------------------------------+-->+ +-> ( ---+  |+ +-------------------------+ |+ ++--------------------------+-> ) --+# +> , --+ D Because intervals can be signed quantities, a leading additionA or subtraction operator can precede the literal to indicate. positive (+) or negative (-) intervals. o DBKEY string literalsD THE DBKEY literal is used primarily by database administratorsD who have database keys which were displayed in error messages,D  or shown on an RMU/SHOW STATISTICS display and wish to display the associated row.B The dbkey string literal is prefixed by _DBKEY, or _ROWID toD identify it as a special DBKEY literal. Some examples of valid$ DBKEY literals are as follows: o _DBKEY'23:5628:0'B An Oracle Rdb table dbkey has three parts, a logical areaD (in this example 23), a page number (in this example 5628),D and a line number (in this example 0). All three parts must be specified.% o _ROWID'23:5628:0, 45:345:15'; The DBKEY string literal may include several comma= separated dbkeys if this is used to reference a viewA table. Each DBKEY references a row from the view made up( of component rows from a table.2 The ROWID keyword is a synonym for DBKEY.B Leading and trailing spaces are ignored, however, spaces may= not be embedded within the numeric values in the DBKEY.D  Errors will be reported if the DBKEY is for a different table,@ is incorrectly formatted, or does not reference a row. TheD reported errors are shown in the following example. A question> mark is placed within the string to highlight the syntax error.? SQL> select * from employees where dbkey = _dbkey'1,2,3';B %RDB-F-CONVERT_ERROR, invalid or unsupported data conversionL -RDMS-E-DBKFORMAT, database key format incorrect "1,?2,3" - unexpected characterA SQL> select * from employees where dbkey = _dbkey'-1:+2:0';B %RDB-F-CONVERT_ERROR, invalid or unsupported data conversionN -RDMS-E-DBKFORMAT, database key format incorrect "-1:+?2:0" - unexpected character@ SQL> select * from employees where dbkey = _dbkey'23:1:1';T %RDB-E-NO_RECORD, access by dbkey failed because dbkey is no longer associated with a record1 -RDMS-F-INVDBK, 23:1:1 is not a valid dbkey wwф 1 DATATRIEVE> Optional SQL and DATATRIEVE formatting clauses allow you toD modify data displays or query characteristics for interactive SQLD users, DATATRIEVE users, or both. The optional formatting clausesD (QUERY NAME and EDIT STRING) and DATATRIEVE clauses (QUERY HEADER@ and DEFAULT VALUE) can be used with the following statements: o CREATE TABLE o CREATE DOMAIN o CREATE VIEW o ALTER TABLE o ALTER DOMAIN< The following diagram shows the format for these clauses: sql-and-dtr-clause = A -+-> QUERY HEADER IS -+> +-------------------+->? | +------ / <--------+ |? +-> EDIT STRING IS -------------------------+? | |? +-> QUERY NAME FOR -+-> DTR --------+-> IS -+? | +-> DATATRIEVE -+ |? +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+* +-> DATATRIEVE -+ > o A query header specifies a string, enclosed in quotationA marks, that interactive SQL or DATATRIEVE displays in place@ of the column name when it retrieves values from a column.A Query headers allow you to specify descriptive headings for columns.C Both interactive SQL and DATATRIEVE display any query headers% you specify in SQL definitions.> o An edit string specifies a string, enclosed in quo tationD marks, that controls how interactive SQL or DATATRIEVE formats( the display of values in a column.> Both interactive SQL and DATATRIEVE use edit strings youB specify in SQL definitions to control display formatting for those definitions.A DATATRIEVE recognizes columns with null values and displays> them according to the edit string for the missing value.C o A query name specifies a string, enclosed in quotation marks,B that you can u se instead of the column name when formulatingA DATATRIEVE queries. Query names are useful for abbreviating. long column names in DATATRIEVE queries.D SQL does not recognize query names in interactive queries; theA QUERY NAME clause is useful only when you use DATATRIEVE to retrieve the data.D o If you specify a default value for a column and do not specify< that column in a DATATRIEVE STORE or MODIFY statement,> DATATRIEVE stores the default value  specified in the SQL definition.? SQL does not recognize default values in INSERT or UPDATEB statements; the DEFAULT VALUE clause is useful only when you0 use DATATRIEVE STORE or MODIFY statements. 2 QUERY_HEADER_ClauseD The QUERY HEADER clause specifies the column header that SQL uses9 in displays of result tables that contain that column.D If you include the QUERY HEADER clause, SQL uses the query headerD as the column header. If you omit the claus e, SQL uses the column name as the column header.@ The column header can include any character except a carriageC return, a line feed, or a control character. To include a doubleD quotation mark in a column header, enclose it in single quotation marks.D The following example defines a query header for one column and a, DATATRIEVE query name for another column: SQL> ALTER TABLE TEMP cont> ADD STATE CHAR (2)2 cont> QUERY NAME FOR DATATRIEVE IS 'ST'  cont> ADD SEX CHAR (1)- cont> QUERY HEADER IS 'S'/'E'/'X';@ These statements define query headers and query names for theA STATE and SEX columns. The slash character (/) specifies thatB the header is split into three lines, so the header for the SEX6 column is 1 character wide, like the column itself.@ Both SQL and DATATRIEVE display the query header used in this6 example. Only DATATRIEVE recognizes the query name. 2 EDIT_STRING_ClauseA The EDI T STRING clause specifies the output format of a columnD value. SQL uses the EDIT STRING clause as the default format when5 writing a column value to a file or output device.? To specify the format of a column value, use a string of one> or more edit characters. Specify the edit string charactersA in single quotation marks without embedded spaces. In general,A each edit character corresponds to 1 character position in theB displayed output. For example, 999999 specifies tha t the output( is 6 digits in 6 character positions.> To enter more of the same edit characters, shorten the edit@ string by placing a repeat count in parentheses following the@ edit character. For example, the edit string 9(6) is equal to 999999.C You can change the character that SQL and DATATRIEVE display forC the currency symbol ($), decimal point (.), and digit separator (,) edit string characters.C To make your output conform to other conventions for numeri c andD monetary notation, override the system defaults for these symbols- by redefining the following logical names:? o SYS$CURRENCY: Specifies the character SQL substitutes forB the dollar sign ($) edit string character. The default is a dollar sign.B o SYS$RADIX_POINT: Specifies the character SQL substitutes forD the decimal point (.) edit string character. The default is a decimal point.D o SYS$DIGIT_SEP: Specifies the character SQL substitutes for the? comma (,) edit string character. The default is a comma. wwф1 Value_Expressions> A value expression is a symbol or string of symbols used to> represent or calculate a single value. When you use a valueC expression in a statement, SQL retrieves or calculates the valueD associated with the expression and uses that value when executing the statement.: Value expressions are also called scalar expressions or expressions.: There  are several different types of value expressions:A o A literal directly specifies a value. See the Literals HELP! topic for more information.B o A parameter represents a value in a host language program orB in an SQL module. See the User_Supplied_Names HELP topic for more information.C o A column name represents a value contained in table rows. SeeB the User_Supplied_Names HELP topic for details on specifying* value expressions with column names.; o A column select expression used as a value expression@ specifies a one-value result table. See the Column_Select_2 Expressions HELP topic for more information.@ o A built-in function calculates values based on input value< expressions. See the Built_In_Functions HELP topic for details.< SQL built-in functions include functions such as CAST,= CURRENT_USER, and TRIM. For a complete list of built-in( functions, see Built In Functions.; o An aggregate function calculates a single value for a> collection of rows in a result table. See the Aggregate_' Functions HELP topic for details." SQL aggregate functions are: - AVG - COUNT - MAX - MIN( - STDDEV, STDDEV_SAMP, STDDEV_POP - SUM$ - VARIANCE, VAR_SAMP, VAR_POPB o SQL functions (CONCAT, CONCAT_WS, CONVERT, DECODE, GREATEST,? LEAST, LENGTH, LENGTHB, SIGN, SYSDATE, SYSTIMESTAMP, SYS_B  GUID, ROUND and TRUNC) have been added to the Oracle Rdb SQL? interface for convergence with Oracle SQL. See the Oracle@ Server SQL Language Reference Manual for more information.D o The DBKEY or ROWID keyword represents the value of an internal= pointer called a database key to a table row. The ROWIDC keyword is a synonym to the DBKEY keyword. See the DBKEY HELP! topic for more information.B o A character value expression represents a value that belongs > to the CHAR, CHARACTER, VARCHAR, LONG VARCHAR, NCHAR, or? NCHAR VARYING data type. You can link two character valueA expressions together using the concatenation operator (||).D o You can also combine certain value expressions with arithmetic+ operators to form a value expression.: o A substring specifies a portion of a character valueD expression that you can manipulate using arithmetic operators.@ o A conditional expression is a form of the value expression@ that allows applications to return alternative information@ within an expression. See the Conditional_Expressions HELP topic for details." Conditional expressions are: - ABS - CASE - COALESCE (or NVL) - DECODE - GREATEST - LEAST - NULLIF - NVL2 - SIGN@ The following syntax diagrams show the format of an SQL value expression: value-expr = ( ---+--> numeric-value-expr -----+----->" +--> char-value-expr --------+" +--> date-time-value-expr ---+" +--> interval-value-expr ----+" +--> date-vms-value-expr ----+" +--> DBKEY ------------------+" +--> NULL -------------------+" +--> ROWID ------------------+ numeric-value-expr = 4 --+-+------+-> numeric-value-factor --+----------->1 | +-> + -+ +-> + -+-+1 | +-> - -+ +-> - -+ |1 |  +-> * -+ |1 | +-> / -+ |1 +----------------------- <-------------------+  numeric-value-factor = C --+---> common-value-expr ------------------------------------+-->@ +---> numeric-literal --------------------------------------+@ +---> BITSTRING (numeric-value-expr FROM -----+ |@ | +---------------------------------------+ |@ | +-> -+------------------------+- ) --+@ |  +-> FOR -+ |@ +---> uid-numeric-functions --------------------------------+@ +---> length-value-functions -------------------------------+@ +---> POSITION --> ( --> char-value-expr IN ----+ |@ | +--------------------------------------------+ |@ | +-> char-value-expr --+---------------------------+-> ) -+@ | +> FROM numeric-value-expr -+ |@ +---> EXTRACT --> ( date-time-field --+  |@ +--------------------------------+ |@ +---> FROM --> date-time-value-expr ) -----------------+ common-value-expr = B -+-> -------------------------------------------+->@ +-> ---------------------------------------------+@ +-> -----------------------------------+@ +-> ----------------------------------------------+@ +-> (col-select-expr) ---------------------------------------+@ +-> CAST --> ( --> value-expr -> AS +-> data-type -----+> ) -+@ | +-> -+ |@ +-> VALUE ---------------------------------------------------+@ +-> aggregate-function --------------------------------------+@ +-> conditional-expr ----------------------------------------+@ +-> function-invocation -------------------------------------+@ +-> (value-expr) --------------------------------------------+  aggregate-function = P -+-> COUNT (*) -------------------------------------------+-+----------------+>O +-> COUNT ----+->( -+--------------+-> value-expr -> ) --+ +> filter-clause +< +-> AVG ------+ +-> ALL -------+ |< +-> MIN ------+ +-> DISTINCT --+ |< +-> MAX ------+ |< +-> SUM ------+ |< +-> STDDEV ---+ |< +-> VARIANCE -+  |< +-> STDDEV_POP --+-->( -> numeric-value-expr --> ) ------+ +-> STDDEV_SAMP -+ +-> VAR_POP ----+ +-> VAR_SAMP ---+ filter-clause =- -+---------------------------------------+->+ +-> ( --> WHERE --> predicate --> ) --+ conditional-expr = K -+-> NULLIF --> ( --> value-expr --> , --> value-expr --> ) ----------+->I +-> COALESCE -+-> ( -> value-expr -+-> , --> value-expr +-> ) --------+I +-> NVL ------+ +--------- <---------+ |I +-> GREATEST -+ |I +-> LEAST ----+ |I +-> NVL2 (value-expr, value-expr, value-expr) ------------------------+I +-> DECODE (value-expr, -+> search , result +--+--------------+--> ) -+I | +------- , <-------+ +-> , default -+ |I +-> ABS --+-> (value-expr) -------------------------------------------+I +-> SIGN -+  |I +-> simple-case-expr -------------------------------------------------+I +-> searched-case-expr -----------------------------------------------+ simple-case-expr = F -> CASE -> value-expr +> WHEN with-values ---> THEN -> value-expr -++F +---------------------- <--------------------+|F +------------------------------------- <----------------------------+F +-+-------------------------+-----> END ---------!-------------------> +-> ELSE -->value-expr ---+  searched-case-expr = ; --> CASE +-> WHEN predicate --> THEN ---> value-expr -+-+; +---------------------- <---------------------+ |; +--------------------------------------------------------+< +--+-----------------------------+--> END ----------------># +-> ELSE ---> value-expr -----+  with-values = ; --+--+--------------------------+-> value-expr --+--+---->6 | +--> partial_predicate1 ---+ " | |6 | +--> partial_predicate2 --------------------+ |6 +------------ , <---------------------------------+   partial_predicate1 = & -+---> NOT CONTAINING ----------+--># +---> NOT STARTING WITH -------+# +---> NOT MATCHING ------------+# +---> = -----------------------+# +---> <> ----------------------+# +---> ^= ----------------------+# +---> != ----------------------+# +---> < -----------------------+# +---> >= --------------#--------+# +---> > -----------------------+# +---> <= ----------------------+ partial_predicate2 = I -+---> IS NOT NULL -------------------------------------------------+->G +---> NOT BETWEEN -+----------------+- value-expr AND value-expr --+G | +-> ASYMMETRIC --+ |G | +-> SYMMETRIC ---+ |G +---> NOT LIKE --> --+-------------------------------+---+G | $ +-> ESCAPE --+ |G | +-> IGNORE CASE ----------------+ |G +---> NOT IN --+-> value-expr --------------------+----------------+6 +-> ( -++-> value-expr --++--> ) --+- |+-> select-expr -+|- +---- , <----------+ function-invocation = 7 --> --> ( -+-----------------+-> ) -->/ ++-> value-expr -++. % +-> DEFAULT ----+. +------ , <-----+ uid-numeric-functions = ( -+---> UID -----------------------+-->% +---> CURRENT_UID ---------------+% +---> SESSION_UID ---------------+% +---> SYSTEM_UID ----------------+ length-value-functions = D -+---> CHARACTER_LENGTH -+-> (char-value-expr) --------------+--->@ +---> CHAR_LENGTH ------+ |@ +---> LENGTH -----------+ & |@ +---> OCTET_LENGTH -----+-> (value-expr) -------------------+@ +---> LENGTHB ----------+ |@ +---> SIZEOF -----------+-> (value-expr) -------------------+ +---> VSIZE ------------+ char-value-expr = Q +-> common-value-expr -------------------------------------------------------+->O +-> --------------------------------------------------------+O +-> user-string-functions -----------------------------'----------------------+O +-> SYS_GUID ( ) ------------------------------------------------------------+O +-> UPPER (char-value-expr) -------------------------------------------------+O +-> LOWER (char-value-expr) -------------------------------------------------+O +-> TRANSLATE (char-value-expr -+->USING ) ----------------+O | +-> , char-value-expr , char-value-expr) -+O +-> CONCAT ----+-> (value-expr -+-> , value-expr -+-> ) ------------(--------+O +-> CONCAT_WS -+ +-------<---------+ |O +-> trim-expr ---------------------------------------------------------------+O +-> SUBSTRING ( char-value-expr FROM --+ |O | +------------------------------------+ |O | +-> +--------------------------+-- ) ---------------------+O | +-> FOR --+ |O +)-> char-value-expr --> || --> char-value-expr ------------------------------+  user-string-functions = ( -+---> USER ----------------------+-->% +---> CURRENT_USER --------------+% +---> SESSION_USER --------------+% +---> SYSTEM_USER ---------------+ trim-expr =  ---> TRIM --+ +-----------+7 +-> ( -+-------------------------------------------+-+7 ++------------++-------------------+-> FROM + |7 +-> BOTH ----++-> char-value-expr + * |7 +-> LEADING -+ |7 +-> TRAILING + |7 +----------------------------------------------------+9 +--> char-value-expr --> ) ---------------------------->  date-time-value-expr = ? -+-> date-time-value-expr -+-> + -+-> interval-value-expr -+->= | +-> - -+ |= +-> interval-value-expr --> + --> date-time-value-expr ---+= +-> date-time-value-factor ---+----------------------------+  date-time-value-factor = = --+---> common-value-expr -------------------------------+->; +---> date-time-literal -------------------------------+; +---> CURRENT_DATE ------------------------------------+; +---> SYSDATE -----------------------------------------+; +---> SYSTIMESTAMP ------+-+-------------------------+-+9 +---> LOCALTIME ---------+ +-> (seconds-precision) --+ +---> CURRENT_TIME ------+ +---> LOCALTIMESTAMP ----,+ +---> CURRENT_TIMESTAMP -+ date-time-literal = B --+-> TIME --> ' --> time-body --> ' ------------------------+-->? +-> DATE -+---------+-> ' --> date-body --> ' -------------+? | +-> ANSI -+ |? +-> TIMESTAMP --> ' --+-> date-body time-body -+--> ' --+5 +-> date-body : time-body -+ time-body = + ---> : : ---++ +---------------------<----------------+, ++---------------------------+--------->" +-> . -+ date-body = " ---> - - -->  interval-value-expr = E -++----++-> interval-value-factor -+----------------------------++->C |+> + +| +> * +-> numeric-value-expr -+|C |+> - +| +> / + ||C | +-> numeric-value-expr --> * -> interval-value-factor --+|C +-----------------------------+- + <--.+-------------------------+) +- - <--+  interval-value-factor = G -+-> interval-literal ---+------------------------------------------+>F +-> common-value-expr --+ |F +-> ( -> date-time-value-expr -> - -> date-time-value-expr -> ) -+ |F +-----------------------------------------------------------+ |F +-> interval-qualifier ---------------------------------------+  date-vms-value-expr/ = 8 --+-+-------------+-> ' --> --> ' +->6 | +-> DATE VMS -+ |6 +---> common-value-expr --------------------------+  ww1 NULL_Keyword@ The NULL keyword specifies the null value. When assigned to aA column of any data type, the NULL keyword forces the column to@ be set to null because the NULL keyword has no data type. For example:I SQL> -- List all employees in the database and all pote0ntial employees SQL> --1 SQL> SELECT employee_id, last_name, first_name cont> FROM employees cont> UNION+ cont> SELECT NULL, last_name, first_name cont> FROM candidates; . . .( 00418 Blount Peter* 00435 MacDonald Johanna( 00471 Herbener James' NULL Boswick Fred) NULL Schwartz Trixie( NULL Wilson Oscar 103 rows selected 1@ The NULL keyword is distinct from the IS NULL predicate which: tests for null values of an expression. When testing an@ expression for null, using equality with NULL (for example, aA = NULL) is not productive as it is never true. Use the IS NULLA predicate when testing an expression as shown in the following example:% SQL> SELECT e.last_name, j.job_end( cont> FROM employees e, job_history j, cont> WHERE e.employee_id = j.employee_id cont> AND j.job_end IS NULL;2 E.LAST_NAME J.JOB_END Smith NULL O'Sullivan NULL Hastings NULL . . .C In some cases, the NULL keyword may have a data type of CHAR(31)= when used in a query that requires a data type; such as in= arithmetic and character expressions. In such queries, the@ assumption of the CHAR data type may cause an incompatibilityB error. If this occurs, use the CAST function (for example, CASTD (NULL AS data-type)) 3to change NULL to a compatible data type for the query. ww1 Built_In_Functions? Built-in functions calculate values based on specified value> expressions. Built-in functions are sometimes called scalar< functions. See the Conditional_Expressions Help topic for additional information. 2 BITSTRINGC The BITSTRING function extracts selected bits from a binary dataC value. This functionality is primarily intended to query the bitB values 4stored in the RDB$FLAGS columns in the Rdb system table,& but can also be used for user data.D BITSTRING accepts numeric and date/time values and processes themB as bit arrays. The first (least significant) bit is numbered 1.5 The most significant bit depends on the data type. o TINYINT has 8 bits o SMALLINT has 16 bits o INTEGER has 32 bitsC o BIGINT, DATE, TIME, TIMESTAMP and INTERVAL types have 64 bitsD o The numeric expression after the FOR and FRO5M keywords must be unscaled numeric values.@ The following notes apply to usage of the BITSTRING function:D o If the numeric expression of the FOR clause is less than equal1 to zero then it will be assumed equal to 1.B o If the FOR clause is omitted it will default to a value that6 includes all remaining bits of the source value.@ o If the FOR clause specifies a larger value than the number? of bits remaining in the source then will only return the 6 remaining bits.( Example: Using the BITSTRING functionD Bit 1 in the RDB$FLAGS column of RDB$RELATIONS indicates that theC table is a view. This example uses this query to fetch the names7 of all user defined views in the PERSONNEL database. SQL> select rdb$relation_name cont> from rdb$relations& cont> where rdb$system_flag = 0 and4 cont> bitstring (rdb$flags from 1 for 1) = 1; RDB$RELATION_NAME CURRENT_JOB CURRENT_SALARY CURRENT_INFO7 3 rows selected SQL> 2 CAST@ The CAST function converts a value expression to another data> type. The source and target columns can be of any data type except LIST OF BYTE VARYING.> If you convert to an INTERVAL data type, you must specify aD single interval qualifier field, and the source must be a numeric@ value (fixed or floating) or a compatible INTERVAL data type.B For information on interval qualifiers, see the Data_Types HELP topic.C You can a 8lso convert from a single interval qualifier field to a$ numeric type (fixed or floating).B If you convert a TIMESTAMP literal using the CAST function, SQLB puts a separating space character (SQL92) between the date-bodyC and the time-body of the TIMESTAMP literal. For more information1 on TIMESTAMP literals, see Date Time Literals.B The CAST function allows you to convert host language variables? into date-time values. You can also use the CAST function to> express dat 9es in VMS format as ANSI format dates (using the< syntax CAST(date-vms-value-expr AS DATE ANSI)) to do date" arithmetic using DATE VMS data. 2 CHARACTER_LENGTHC The CHARACTER_LENGTH (CHAR_LENGTH or LENGTH) function calculates5 the length of a value expression of any data type.B If the result of the value expression is a character data type,C the CHARACTER_LENGTH function returns the length, in characters,D of the character string. (Remember that the length of a chara :cterD can be one or more octets.) If the result of the value expression@ is NULL, the function returns a null value. You can use CHAR_; LENGTH or LENGTH as an alternative for CHARACTER_LENGTH. 2 CONCATB The CONCAT function returns the concatenated value expressions.? The result is a VARCHAR type large enough to hold all source value expressions.> Any date/time or numeric values are implicitly converted toC VARCHAR types prior to concatenation. For dialects ORACLE; LEVEL1A and ORACLE LEVEL2, any supplied value that is NULL is ignored.C For all other dialects, in conformance with the ANSI and ISO SQLA database language standard, the resulting CONCAT expression is NULL.B CONCAT is functionally equivalent to the concatenation operator (||).% Example: Using the CONCAT functionL SQL> select distinct CONCAT (e.last_name, ' has a ', d.degree, ' degree')$ cont> from employees e, degrees d, cont> where e.employee_id = d.employe<e_id cont> limit to 5 ROWS;" Ames has a MA degree" Ames has a PhD degree" Andriola has a MA degree" Andriola has a PhD degree" Babbin has a MA degree 5 rows selected 2 CONCAT_WSC The CONCAT_WS function returns the concatenated value expressionB using the first parameter as a separator which is applied after each of the other parameters.> If the separator value expression resolves to NULL then theA result of = CONCAT_WS will be NULL. If any other parameter value@ expression resolves to NULL then it will be ignored. That is,B that column value and any separator will not be included in the output.C The function CONCAT_WS accepts all data types with the exceptionB of LIST OF BYTE VARYING, LONG, and LONG RAW. Each non-characterC string value will be implicitly converted to VARCHAR with a size! appropriate for the data type.@ The result of this function will have the type VARCHA >R with a? length long enough for the concatenated data and separators.> If dialect ORACLE LEVEL1 or ORACLE LEVEL2 is used then zeroD length strings ('') will be considered as NULL and so be excludedB from the output. If the resulting value is a zero length string- then the result of CONCAT_WS will be NULL.C Example: Using the CONCAT_WS function to simplify the formatting7 of table data in CSV (comma separated value) format. SQL> select '"' ||J cont> CONCAT_WS ('"?, "', first_name, nvl(middle_initial,''), last_name) cont> || '"' cont> from employees cont> order by employee_id;' "Alvin ", "A", "Toliver "' "Terry ", "D", "Smith "& "Rick ", "", "Dietrich "& "Janet ", "", "Kilpatrick " . . .& "Peter ", "", "Blount "' "Johanna ", "P", "MacDonald "' "James ", "Q", "Herbener " 100 rows selected SQL> 2 CONVERTD The CONVERT function @converts a character string to the specified character set.> You cannot specify the source character set as you can with@ Oracle. The destination character set must be a character set supported by Oracle Rdb.9 The CONVERT function is functionally equivalent to the TRANSLATE...USING function.& Example: Using the CONVERT function/ SQL> SELECT CONVERT (english, RDB$SHIFT_JIS) cont> FROM colours; Black White Blue Red Yellow GreeAn 6 rows selected 2 CURRENT_DATEA The CURRENT_DATE function returns a DATE data type value (ANSI@ format) containing year, month, and day for date 'today'. YouD can specify an optional fractional-seconds precision for CURRENT_ DATE.+ Example: Using the CURRENT_DATE function< The following example shows how a site with an Oracle Rdb< database might use the CURRENT_DATE function to determine? employee ages. You must use the CAST function to convert theB D BATE column BIRTHDAY from VMS to ANSI format to use it with the% ANSI format CURRENT_DATE function.) SQL> ATTACH FILENAME 'corporate_data';. SQL> SET SCHEMA 'ADMINISTRATION.PERSONNEL';> SQL> CREATE VIEW AGE (LAST_NAME, FIRST_NAME, BIRTHDAY, AGE)9 cont> AS SELECT LAST_NAME, FIRST_NAME, BIRTHDAY,J cont> (CURRENT_DATE - CAST(BIRTHDAY AS DATE ANSI)) YEAR TO MONTHE cont> FROM EMPLOYEES ORDER BY BIRTHDAY ASC LIMIT TO 10 ROWS; SQL> --@ SQL> -- A SELECT stat Cement displays the ten oldest employees. SQL> SELECT * FROM AGE;: LAST NAME FIRST_NAME BIRTHDAY AGE= O'Sullivan Rick 12-Jan-1923 68-06= Clairmont Rick 23-Dec-1924 66-07= Nash Walter 19-Jan-1925 66-06= Kinmonth Louis 7-Apr-1926 65-03= Bartlett Dean 5-Mar-1927 64-06= Johnson Bill 13-Apr-1927 D64-03= Herbener James 28-Oct-1927 63-09= Babbin Joseph 12-Dec-1927 63-07= Ziemke Al 27-Oct-1928 62-09= Reitchel Charles 13-Dec-1928 62-07 10 rows selected SQL> 2 CURRENT_TIME; The CURRENT_TIME function returns a TIME data type value9 containing hours, minutes, and seconds for time 'now'.= You can specify a fractional precision between 0 and 2 for E? the seconds returned by CURRENT_TIME. The fractional-seconds= precision is a number that designates the number of digits@ returned in the field. For example, a fractional precision ofA 2 means that seconds are returned as hundredths of a second (2D digits beyond the decimal point), while a fractional precision ofD 1 means that only tenths of a second are returned (1 digit beyond the decimal point).B You can specify a current default for a time or timestamp field0 witFh nondefault fractional-seconds precision. 2 CURRENT_TIMESTAMP? The CURRENT_TIMESTAMP function returns a TIMESTAMP data type> value containing year, month, and, day for date 'today' and. hours, minutes, and seconds for time 'now'.= As in CURRENT_TIME, you can specify a fractional precisionA between 0 and 2 for the seconds returned by CURRENT_TIMESTAMP.C The fractional-seconds precision is a number that designates the* number of digits returned in the field.A The G CURRENT_TIMESTAMP data type can be either DATE VMS or DATEA ANSI format. Date-time arithmetic is not allowed with DATE VMSB columns. A DATE VMS format CURRENT_TIMESTAMP specifies the day,B month, and year of the current date and the hours, minutes, andD seconds of the current time. A DATE ANSI format CURRENT_TIMESTAMPB specifies the year, month and day of the current date, followed: by the hours, minutes, and seconds of the current time. 2 CURRENT_UIDD The CURRENT_UID f Hunction returns a unique integer that representsA the current user. This UID value is based on the AUTHORIZATIONB user or role for the currently executing stored routine, or the5 SESSION_USER if there is no current authorization. 2 CURRENT_USERA The CURRENT_USER function returns the current active user name for a request.? If a definer's rights request is executing, the CURRENT_USERC function returns the rights identifier of the module definer. IfD a definer'sI rights request is not executing, CURRENT_USER returns? the session user name, if it exists. Otherwise, CURRENT_USERB returns the system user name. See Authorization Identifiers for more information.' The resulting data type is CHAR(31).D The CURRENT_USER function does not return the definer's user name of a trigger.+ Example: Using the CURRENT_USER functionC Example 1: To allow users access only to the rows they inserted, create a view1 SQL> CREATE VIEW JSELECTIVE_EMPLOYEES_UPDATE AS" cont> SELECT * FROM EMPLOYEES' cont> WHERE USER_ID = CURRENT_USER7 cont> WITH CHECK OPTION CONSTRAINT MUST_HAVE_USER; 2 EXTRACTB The EXTRACT function returns a single date-time field expressedB as an integer from a column of data type DATE, TIME, TIMESTAMP, or INTERVAL.4 The date-time fields that EXTRACT can return are: o YEAR o MONTH o DAY o HOUR o MINUTE o SECOND o WEEKDAY K o JULIAN o WEEK_NUMBER o YEAR_WEEKA The data type returned is a signed longword of scale 0, unlessB the date-time field is SECOND. If the SECOND field is selected, then the scale is set to 2.D If you specify WEEKDAY, you can only use the data types TIMESTAMPB and DATE as the extract source. In all other cases, the extractA source can be data type DATE, TIME, TIMESTAMP, or INTERVAL. IfD you specify WEEKDAY, then the EXTRACT function returns an integerB L representing the day of the week. (Monday is represented as day 1, Sunday as day 7.)C If the EXTRACT function is applied to a null value, it returns a null value.; The number of days since the first day of a year, called> the Julian date, can be an important integer value to whichD programmers need direct access. The SQL EXTRACT function lets youD determine the Julian date from column data defined with date-time data types.B The JULIAN keyword requires that the Mextract expression resolveB to either the DATE ANSI or TIMESTAMP date-time data type. ValueB expressions that do not resolve to one of these particular dataB types will fail. For example, trying to extract the Julian dateC from an expression defined by the CURRENT_TIME data type results& in the following SQL error message:M SQL> SELECT EXTRACT(JULIAN FROM CURRENT_TIME) FROM ACCOUNTING.DAILY_HOURS;? %RDB-F-CONVERT_ERROR, invalid or unsupported data conversionJ -RDMS-E-EXT_J NULIAN_TS, invalid type for EXTRACT JULIAN, must be DATE or TIMESTAMP SQL>A You cannot represent dates from the year 1858 using the JULIANA keyword in the EXTRACT function because JULIAN calculates from7 1-January and the first date in 1858 is 18-November.? The options WEEK_NUMBER and YEAR_WEEK return the week number? as defined by the International Standard ISO 8601:1988 "Data? elements and interchange formats - Information interchange -& Representation of dates O and times".D WEEK_NUMBER is a number between 1 and 53 representing the week ofD the year (most years only have 52 weeks). A week starts on Monday7 and has most of its days falling in a specific year.@ YEAR_WEEK is a variation of the WEEK_NUMBER that includes theB year (including the century) in which the week logically falls.A The values range from 185901 through 999952 (higher values areB possible if dates are constructed with a year beyond 9999). TheC last two digits oPf the value are identical to the value returned by the WEEK_NUMBER option. 2 LENGTHA The LENGTH function returns the length of a supplied string in6 characters. Also see the CHARACTER_LENGTH function. 2 LENGTHBB The LENGTHB function returns the length of a supplied string in- bytes. Also see the OCTET_LENGTH function. 2 LOCALTIMEA The LOCALTIME built-in function is a synonym for CURRENT_TIME,= and is defined by the SQL:1999 database language standardQ. 2 LOCALTIMESTAMPA The LOCALTIMESTAMP built-in function is a synonym for CURRENT_= TIMESTAMP and is defined by the SQL:1999 database language standard. 2 LOWERB The LOWER function converts all uppercase characters in a valueA expression to lowercase characters. This function is useful to= maintain consistency in value expressions in the database.> If the result of the value expression is NULL, the function returns a null value.< When you use the RLOWER function, SQL follows the rules of= the character set for the value expression when converting@ characters to lowercase. For example, if the character set ofA the value expression is Hanzi and ASCII, SQL converts only the? ASCII characters to lowercase. It does not convert the Hanzi characters. 2 OCTET_LENGTHC The OCTET_LENGTH (or LENGTHB) function calculates the length, in2 octets, of a value expression of any data type.> If the result of the value expres Ssion is NULL, the functionD returns a null value. Otherwise, the function returns the length,@ in octets, of the value expression. You can use LENGTHB as an alternative for OCTET_LENGTH. 2 POSITIONC The POSITION function searches for a string in a character valueB expression. The first character value expression is also calledA a search string. The second character value expression is also? called a source string. If the search string is located, the? POSITION func Ttion returns a numeric value that indicates theC position of the search string in the source string. The returnedA numeric value is the absolute position of the search string inB the source string starting with 1. The match between the search2 string and the source string is case sensitive.> If the search string is not found in the source string, the= POSITION function returns a zero (0) value. If any of the' strings is NULL, the result is NULL.B The FROM clause of thUe POSITION function is an extension to the? ANSI/ISO SQL standard and allows searching to begin from any location.( Examples: Using the POSITION function? Example 1: Using the POSITION function in a SELECT statement SQL> SELECT COLLEGE_NAME,0 cont> POSITION ('University' IN COLLEGE_NAME) cont> FROM COLLEGES1 cont> WHERE COLLEGE_NAME LIKE '_%University%'; COLLEGE_NAME+ American University 10+ Drew University 6+ V Harvard University 9+ Purdue University 8+ Stanford University 10+ Yale University 6 6 rows selectedC Example 2: Using the POSITION function with the SUBSTRING clause1 SQL> SELECT SUBSTRING (COLLEGE_NAME FROM 1 FORE cont> POSITION ('University' IN COLLEGE_NAME) -1) cont> FROM COLLEGES1 cont> WHERE COLLEGE_NAME LIKE '_%University%'; American Drew WHarvard Purdue Stanford Yale 6 rows selectedC Example 3: Using the POSITION function to find individual words.A Because this example uses the TRACE statement, you must define- the RDMS$DEBUG_FLAGS logical name to "Xt". SQL> BEGIN% cont> DECLARE :TXT VARCHAR(100);$ cont> DECLARE :RES VARCHAR(20);$ cont> DECLARE :ST, :EN INTEGER; cont> --/ cont> SET :TXT = 'Some words and phrases'; cont> --& cont> -- Start at the beginning X cont> -- cont> SET :ST = 1; cont> --C cont> -- Loop over all the text looking for space delimiters cont> --) cont> WHILE :ST <= CHAR_LENGTH(:TXT) cont> LOOP7 cont> SET :EN = POSITION (' ' IN :TXT FROM :ST); cont> IF :EN = 0 THEN cont> --H cont> -- No trailing spaces, so assume space after last character cont> --/ cont> SET :EN = CHAR_LENGTH(:TXT) + 1; cont> END IF;? cont> SET :RES = SUBSTRING(:TXT FROM Y:ST FOR :EN - :ST);2 cont> IF CHAR_LENGTH (TRIM (:RES)) > 0 THEN cont> --& cont> -- Have a word to display cont> --* cont> TRACE 'Word: "', :RES, '"'; cont> END IF; cont> --* cont> -- Advance the start position cont> -- cont> SET :ST = :EN + 1; cont> END LOOP; cont> END;$ ~Xt: Word: "Some "$ ~Xt: Word: "words "$ ~Xt: Word: "and "$ ~Xt: Word: "phrases " Z2 ROUNDD The ROUND function accepts two numeric value expressions (n,m) asC arguments. The result is the first value expression n rounded toC m places to the right of the decimal point. The value expressionC m can be negative to round off digits to the left of the decimal> point. The data type of m must be an unscaled numeric valueB (tinyint, smallint, integer, or bigint). If omitted, m defaults& to zero. See the following example." SQL> select avg (salary_amount) [ cont> from salary_history% cont> where employee_id = '00164'; 3.857350000000000E+004 1 row selectedG SQL> select round (avg (salary_amount)) as SAL edit using 'sz(9).99' cont> from salary_history% cont> where employee_id = '00164'; SAL 38574.00 1 row selected Usage NotesD o The function ROUND for numeric values is supported as a native function in Oracle Rdb.= o Fixed point values are truncated and rounded corre\ctly.? Floating values, while supported by ROUND, may not alwaysB return the expected results. Please review usage of ROUND in such contexts.? o The result type for ROUND will match the data type of the input source parameter.B o The implementation of ROUND for DATE values requires the useC of the OCI Services for Rdb library (also know as SQL*net forD Rdb). These functions will now accept DATE ANSI, TIMESTAMP and DATE VMS values.C o ]Attempts to use ROUND on a database that is not setup for OCI4 Services will receive errors similar to these:9 SQL> select TRUNC (current_date) from rdb$database;V %RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist5 -RDMS-F-BAD_SYM, unknown routine symbol - TRUN29 SQL> select ROUND (current_date) from rdb$database;V %RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist5 -RDMS-F-BAD_SYM, unknown rou ^tine symbol - ROUN2) NOTE; The special functions ROUN2 and TRUN2 are internal* routines to deal with DATE types.D o ROUND supports the data types REAL, FLOAT and DOUBLE PRECISIONC for both parameter and results. However, due to the impreciseC nature of floating point arithmetic this may cause unexpected> results. A value such as 4.185 will not round to 4.19 asD expected because the internal (and approximate) _representation= of the number is something like 4.184999942780E+000 andA therefore does not appear to require rounding to the second4 decimal place according to the rounding rules./ The following example shows this problem.H SQL> select cast(round (4.185,2) as integer(2)) from rdb$database; 4.18 1 row selectedH SQL> select cast(round (4.175,2) as integer(2)) from rdb$database; 4.18 1 row selected SQL> `) NOTEA The result of a divide operation (/) or the AVG, STDDEV,B VARIANCE statistical functions are floating point values,= so applying TRUNC or ROUND to those results, even if? performed on integer sources, will also be affected by. the intermediate floating point type.A o If you use SQL to access older versions of Rdb (such as viaB remote access) then SQL will revert to the previous behavior= a and use the SQL functions provided by the SQL_FUNCTIONS library. 2 SESSION_UID= Returns a unique integer that represents the session user. 2 SESSION_USERD The SESSION_USER function returns the current active session user name.D If the session user name is not returned, the system user name is1 returned. The resulting data type is CHAR(31). 2 SIZEOF@ The SIZEOF (or VSIZE) function calculates the maximum length,@ in octets, of a value express bion of any data type. It returnsC the length or storage width of the value expression. Like OCTET_@ LENGTH, SIZEOF returns the number of eight-bit units (octets)B rather than the number of characters if the expression yields aB text string in a multi-byte character set. You can use VSIZE as an alternative for SIZEOF. 2 SUBSTRING? Substrings return portions of character value expressions. AA substring must have the data type CHAR, VARCHAR, LONG VARCHAR, NCHAR, or N cCHAR VARYING.@ To specify a substring, you must specify the value expressionD and the FROM keyword, followed by the start position of the valueC expression. (The first character in the string occupies position@ 1.) You can optionally add a FOR clause after the FROM clause@ to specify the length of the value expression after the start position.? The start position and string length values can be a numericC value expression. By default, SQL expects the start position and dC the string length to be specified in octets. You can use the SET@ DIALECT or the SET CHARACTER LENGTH statements or the DIALECTC or CHARACTER LENGTH clause of the SQL module language header andB DECLARE MODULE statement to specify whether the length value is octets or characters.> If you specify a length longer than the string, SQL returnsB only valid characters in the string and terminates the returned, substring after the last valid character.D If either operand oef the substring is a null value, the resulting value is also null.; When you use a substring with the equal (=) conditional- operator, the operation is case sensitive. 2 SYS_GET_DIAGNOSTIC; The SYS_GET_DIAGNOSTIC function returns the same session? information available to the GET DIAGNOSTICS statement. ThisB function provides a shorthand method of fetching values without? requiring a compound statement, or an intermediate variable.8 Syntax: SYS_GET_DIAGNOSTI fC ( statement-item-name ) ->> For the list of keywords acceptable by this function please? see the statement-item-name syntax under the GET DIAGNOSTICS statement.B Each keyword used with SYS_GET_DIAGNOSTIC will cause the resultD to have a different associated data type. Please refer to the GET5 DIAGNOSTICS statement for the returned data types.A The following example shows the return of session information.< SQL> select SYS_GET_DIAGNOSTIC (CONNECTION_NAME) as CONN, gC cont> SYS_GET_DIAGNOSTIC (SERVER_IDENTIFICATION) as IDENT,? cont> SYS_GET_DIAGNOSTIC (DATABASE_HANDLE) as DBHANDLE cont> from GET_DIAG;P CONN IDENT DBHANDLEL RDB$DEFAULT_CONNECTION Oracle Rdb V7.2-501 1 1 row selected SQL> 2 SYS_GUID; The SYS_GUID function returns a 16 octet globally uniqueC identifier. Applications would use this to provide unique values? h from various applications and across databases in an OpenVMS cluster or network.@ This function uses the OpenVMS system service SYS$CREATE_UID.? Applications that call this system service create compatible values for Rdb.= The returned value from SYS_GUID() may contain octets that? are zero. If returning values to C applications, then Oracle@ recommends using the $SQL_VARCHAR pseudo type to avoid C null terminated string semantics.B The SYS_GUID() returns da ita using a special character set. ThisB special character set is used by Oracle Rdb to distinguish thisD type of string from others. Interactive SQL will format the valueA using standard OpenVMS formatting services when this characterB set is seen. Note that these services perform reordering of theD octet values during formatting, that is, the value isn't a direct+ hexadecimal representation of the value.< Database administrators can define a domain to be used by1 applicatijons which will make it easier to use.! SQL> create domain GUID_DOMAIN' cont> char(16) character set -11; SQL> SQL show domain GUID_DOMAIN;+ GUID_DOMAIN CHAR(16)* GUID 16 Characters, 16 Octets SQL>> This domain can be used for column, parameter, and variable definitions.A To support storing literal GUID values, SQL also supports GUIDB literals. The literals follow the standard literal format using@ the special prefikx _GUID, as shown in the following examples.! SQL> create domain GUID_DOMAIN' cont> char(16) character set -11; SQL> show domain GUID_DOMAIN;+ GUID_DOMAIN CHAR(16)* GUID 16 Characters, 16 Octets SQL> create table SAMPLE cont> (a intQ cont> ,b GUID_DOMAIN default _guid'00000000-0000-0000-0000-000000000000');* SQL> insert into SAMPLE default values; 1 row inserted# SQL> show table (column) SAMPLE; Informationl for table SAMPLE Columns for table SAMPLE:: Column Name Data Type Domain: ----------- --------- ------* A INTEGER? B CHAR(16) GUID_DOMAIN* GUID 16 Characters, 16 OctetsB Oracle Rdb default: GUID'00000000-0000-0000-0000-000000000000' SQL>C The literal can also be used in queries to select existing rows. SQL> select * from SAMPLEm? cont> where b = _guid'3DBB657F-8513-11DF-9B74-0008029189E7'; 2 SYSDATEB The SYSDATE function returns the current date and time. It does not require any arguments.? SYSDATE is a synonym for CURRENT_TIMESTAMP. As with CURRENT_= TIMESTAMP, the return result of SYSDATE is affected by the@ setting of the SET DEFAULT DATE FORMAT statement, as shown in the following example:' SQL> SET DEFAULT DATE FORMAT 'SQL99') SQL> SELECT SYSDATE, CURRENT_TIMESTAMP connt> FROM RDB$DATABASE;3 1995-08-21 15:21:05.29 1995-08-21 15:21:05.29 1 row selected% SQL> SET DEFAULT DATE FORMAT 'VMS') SQL> SELECT SYSDATE, CURRENT_TIMESTAMP cont> FROM RDB$DATABASE;5 21-AUG-1995 15:21:24.83 21-AUG-1995 15:21:24.83 1 row selected 2 SYSTIMESTAMPC The SYSTIMESTAMP function returns the current date and time as aC TIMESTAMP type. This function is similar to SYSDATE and CURRENT_B TIMESTAMP however, its type doesn't change wheno the SET DEFAULT DATE FORMAT command is used.< Syntax: SYSTIMESTAMP [ ( fractional-seconds-precision ) ]? The function name can be followed by an optional fractional-? seconds-precision. This value, if omitted, defaults to 2 and! accepts the values 0, 1, or 2.A The following example shows that SYSTIMESTAMP always returns a SQL standard date and time.H SQL> select systimestamp,sysdate,current_timestamp from rdb$database;N 2007-03-27 16:33:32.19 27-MAR-2007 1p6:33:32.19 27-MAR-2007 16:33:32.19 1 row selected( SQL> set default date format 'sql99';H SQL> select systimestamp,sysdate,current_timestamp from rdb$database;L 2007-03-27 16:33:41.32 2007-03-27 16:33:41.32 2007-03-27 16:33:41.32 1 row selected SQL> 2 SYSTEM_UID< Returns a unique integer that represents the system user. 2 SYSTEM_USERC The SYSTEM_USER function returns the user name of the process at# the time of the database attach.D If qyou attach to the database specifying a user name and password? in the USER and USING clauses, SQL returns the user name you specify.' The resulting data type is CHAR(31). 2 TRANSLATEC SQL provides an alterative TRANSLATE function which uses a comma separated list of arguments.9 TRANSLATE ( , , )= This format of the TRANSLATE function uses two translation: character strings to define the translation of specific@ cha rracters. Any characters in the which do not> appear in the are not replaced. Any characters? in the source string which do appear in the are> replaced with the character from the corresponding position= in the . The may be longer than the? and in this case the matched character is omitted from the result.< If any of the arguments , , and@ are NULL then the resuslt of the TRANSLATE function is NULL.D The data type of the result is a VARCHAR string with a length and: character set equivalent to that of the . Examples$ Example 1: Eliminating characters> This example removes the single quote punctuation character? from names. For example, "O'Hara" will becomes "OHara". ThisB would usually be done during sorting to avoid having the singleC quote group these names separately, and instead they are orderedB btetween names starting with "Og" (such as Ogdan) and "Oi" (such as Oiler). SQL> select last_name cont> from EMPLOYEES4 cont> order by TRANSLATE (last_name, '"''', '"');& NOTE@ In Oracle RDBMS the empty string is considered to be NULL,< so an extra '"' character was added to the translation> strings to avoid a NULL result. This is not required forB Oracle Rdb. However, if an ORACLE dialect is used then these) Oracle suemantics would be possible.# Example 2: Formatting characters@ When numeric values are displayed they are normally displayedB with leading spaces, however, some applications require leadingC zeros. This example assumes that the postal code is stored as an? INTEGER but needs to report the 5 digits with leading zeros.A SQL> select TRANSLATE (CAST(postal_code as CHAR(5)), ' ', '0') cont> from EMPLOYEES; Example 3: Masking characters@ TRANSLATE can be used to mavsk out characters which should not@ appear in the output. For instance, when displaying a licenseA number all the letters are required to be converted to 'X' and all digits to '9'.$ SQL> select TRANSLATE ('2KRW229',7 cont> '01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',7 cont> '99999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') cont> from ...; 9XXX999+ Example 4: Transforming text for sortingC Last names often contain special punctuation characters, such asC w the single quote in O'Sullivan, or D'Amico. Consider this simple' example from the PERSONNEL database. SQL> select last_name cont> from employees+ cont> where last_name starting with 'D' cont> order by last_name; LAST_NAME D'Amico Dallas Danzig Dement Dement Dietrich Dietrich 7 rows selected SQL>A You can see that the quote punctuation causes the name to sortD higher than expected by many applications (such as telexphone book listings).C This example removes the single quote punctuation character fromD names and converts the last name to lowercase so that these namesD sort within similar names without quote punctuation. However, the6 original name is displayed as stored in the column. SQL> select last_name cont> from employees+ cont> where last_name starting with 'D'( cont> order by translate (last_name,= cont> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ''',< cyont> 'abcdefghijklmnopqrstuvwxyz'); LAST_NAME Dallas D'Amico Danzig Dement Dement Dietrich Dietrich 7 rows selected SQL>A The first string argument to TRANSLATE contains the target setD of characters, if a character in the name does not match this setC it is written to the result unchanged. For example, the trailing* spaces are simply copied to the result.A The second string argument contains the translations zfor those= characters. Any upper case characters are transformed into> their lower case equivalent. If a single quote character is? matched then it is omitted from the result because there was no translation.B Applying these rules will convert "D'Amico" to "damico" so that* it sorts between "dallas" and "danzig". 2 TRANSLATE_USINGA The TRANSLATE function translates a character value expression> from one character set to another compatible character set.C The { characters in the char-value-expr are translated, character-B by-character, to the character set indicated by the translation> name. If a direct translation exists for a character, it isD replaced by the equivalent character in the translation character@ set. If there is no direct translation for a character, it isD replaced by the space character of the translation character set,8 as shown in the example using the TRANSLATE function.< For example, the Kanji character set cont |ains traditional; Kanji characters, Katakana characters, ASCII characters,> and Roman characters that are ASCII characters encoded in 2= octets. If a Kanji char-value-expr is translated using the@ RDB$KATAKANA translation name, those 2-octet Kanji characters@ that have an equivalent in the 1-octet Katakana character setD are translated. The other characters are replaced by the Katakana space character.B If a character in the source character string is not compatibleC w}ith the target character set, SQL substitutes a space character for that character. 2 TRIM? The TRIM function removes either or both leading or trailing: spaces, numbers, or characters from any character valueA expression. SQL returns the specified string minus any leading$ or trailing characters (or both).A The BOTH option is the default if none is specified. The space9 character is the default if a string is not specified.? The character value expression th~at you trim must be defined? as data type CHAR, VARCHAR, NCHAR, or NCHAR VARYING. Use theB CAST function to convert other data types before using the TRIM function.> SQL returns a run-time error when the trim character is not# exactly one character in length.$ Examples: Using the TRIM functionD Example 1: The following example, though not effective, shows the TRIM function: SQL> SELECT LAST_NAME,* cont> TRIM (LEADING 'H' FROM LAST_NAME) cont> FROM EMPLOYEES# cont> WHERE LAST_NAME LIKE 'H%'; LAST_NAME Hall all Harrington arrington Harrison arrison Hastings astings Herbener erbener 5 rows selected; Example 2: Using the TRIM function with the WHERE clause; SQL> -- The following INSERT statement helps to show the SQL> -- TRIM function. SQL> --G SQL> INSERT INTO EMPLOYEES (LAST_NAME,FIRST_NAME,EMPLOYEE_ID) VALUES% cont> (' Hillson','Ann','99999'); 1 row inserted SQL> --7 SQL> -- If you select columns without specifying theD SQL> -- TRIM function on the WHERE clause, SQL returns only thoseE SQL> -- last names that start with 'H' and have no leading spaces. SQL> --. SQL> SELECT LAST_NAME || ', ' || FIRST_NAME cont> FROM EMPLOYEES# cont> WHERE LAST_NAME LIKE 'H%'; Hall , Lawrence Harrington , Margaret Harrison , Lisa Hastings , Norman Herbener , James 5 rows selected SQL> --F SQL> -- Add the TRIM function to the WHERE clause to get a completeE SQL> -- list of last names beginning with 'H' including those with SQL> -- leading spaces. SQL> --. SQL> SELECT LAST_NAME || ', ' || FIRST_NAME cont> FROM EMPLOYEES; cont> WHERE TRIM (LEADING ' ' FROM LAST_NAME) LIKE 'H%'; Hastings , Norman Harrington , Margaret Hall , Lawrence Harrison , Lisa Hillson , Ann Herben er , James 6 rows selected@ Example 3: Using the TRIM function on the SELECT portion of a( query in addition to the WHERE clauseC SQL> -- Add the TRIM function to the SELECT portion of the queryD SQL> -- to trim the leading spaces from the display of 'Hillson'.D SQL> -- Note that the LEADING option has been changed to the BOTH> SQL> -- option to trim leading and trailing spaces from the SQL> -- LAST_NAME column. SQL> --C SQL> SELECT TRIM (BOTH ' ' FROM LAST_NAME) || ', ' || FIRST_NAME cont> FROM EMPLOYEES; cont> WHERE TRIM (LEADING ' ' FROM LAST_NAME) LIKE 'H%'; Hastings, Norman Harrington, Margaret Hall, Lawrence Harrison, Lisa Hillson, Ann Herbener, James 6 rows selected 2 TRUNCD The TRUNC function accepts two numeric value expressions (n,m) asB arguments. The result is the first value expression n truncated; to m places to the right of the decimal point. The valueA expression m can be negative to truncate digits to the left ofD the decimal point. The data type of m must be an unscaled numeric? value (tinyint, smallint, integer, or bigint). If omitted, m/ defaults to zero. See the following example." SQL> select avg (salary_amount) cont> from salary_history% cont> where employee_id = '00164'; 3.857350000000000E+004 1 row selectedG SQL> select trunc (avg (salary_amount)) as SAL edit using 'sz(9).99' cont> from salary_history% cont> where employee_id = '00164'; SAL 38574.00 1 row selected Usage NotesD o The function TRUNC for numeric values is supported as a native function in Oracle Rdb.= o Fixed point values are truncated and rounded correctly.? Floating values, while supported by TRUNC, may not alwaysB return the expected results. Please review usage of TRUNC in such contexts.? o The result type for TRUNC will match the data type of the  input source parameter.B o The implementation of TRUNC for DATE values requires the useC of the OCI Services for Rdb library (also know as SQL*net forD Rdb). These functions will now accept DATE ANSI, TIMESTAMP and DATE VMS values.C o Attempts to use TRUNC on a database that is not setup for OCI4 Services will receive errors similar to these:9 SQL> select TRUNC (current_date) from rdb$database;V %RDB-E-OBSOLETE_METADA, request references metad ata objects that no longer exist5 -RDMS-F-BAD_SYM, unknown routine symbol - TRUN29 SQL> select ROUND (current_date) from rdb$database;V %RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist5 -RDMS-F-BAD_SYM, unknown routine symbol - ROUN2) NOTE; The special functions ROUN2 and TRUN2 are internal* routines to deal with DATE types.D o TRUNC supports the data types REAL, FLOAT and DOUB LE PRECISIONC for both parameter and results. However, due to the impreciseC nature of floating point arithmetic this may cause unexpected> results. A value such as 4.185 will not round to 4.19 asD expected because the internal (and approximate) representation= of the number is something like 4.184999942780E+000 andA therefore does not appear to require rounding to the second4 decimal place according to the rounding rules./ The following example shows this problem.H SQL> select cast(round (4.185,2) as integer(2)) from rdb$database; 4.18 1 row selectedH SQL> select cast(round (4.175,2) as integer(2)) from rdb$database; 4.18 1 row selected SQL>) NOTEA The result of a divide operation (/) or the AVG, STDDEV,B VARIANCE statistical functions are floating point values,= so applying TRUNC or ROUND to those results, even if? performed on integer sources, will also be affected by. the intermediate floating point type.A o If you use SQL to access older versions of Rdb (such as viaB remote access) then SQL will revert to the previous behavior= and use the SQL functions provided by the SQL_FUNCTIONS library. 2 UPPERB The UPPER function converts all lowercase characters in a valueA expression to uppercase characters. This function is useful to= maintain consistency in value expressions in the database.> If the result of the value expression is NULL, the function returns a null value.< When you use the UPPER function, SQL follows the rules of< the character set of the value expression when converting@ characters to uppercase. For example, if the character set ofA the value expression is Hanzi and ASCII, SQL converts only the? ASCII characters to uppercase. It does not convert the Hanzi characters. 2 USER A The USER function specifies the current active user name for a@ request and is a synonym for the (CURRENT_USER) function. ForD definer's rights stored procedures, the returned user name is theA definer's user name. For all other requests, it is the currentB user name of the calling routine or, if no calling routine, theB current session user name. The resulting data type is CHAR(31). wwq1 Aggregate_FunctionsC Aggregate functions calculate a single value for a collection ofC rows in a result table. Aggregate functions are sometimes called statistical functions.A The following notes generally apply to aggregate functions. An@ aggregate function is a single value derived from one or more sets of values.B o A value expression is used to evaluate a value for each row.6 The aggregate function operates on these values.C o Null values are not included when SQL evaluates functions. IfC you specify DISTINCT , redundant values are also not included.A If you have set the dialect to SQL99, this null eliminationB causes a warning to be returned for the SQLCODE or SQLSTATE.B See the Oracle Rdb SQL Reference Manual for more information on SQLSTATE and SQLCODE.? o If a function has as its argument a value expression thatC contains a column name that is an outer reference (see Outer_D References), the value expression cannot include an arithmeticD operator. (T he only cases where an outer reference makes senseB as the argument to a function is in the subquery of a HAVING0 clause or in a subquery in a select list.)C o You cannot nest functions. This means that a value expressionB used as an argument to a function cannot include a function.B o The keyword ALL in SUM, AVG, MAX, and MIN has no effect. For? instance, specifying MAX (ALL EMPLOYEE_ID) is the same as saying MAX (EMPLOYEE_ID).? o VARIANCE and STDDE V must be passed a single numeric valueA expression and the result is returned as a DOUBLE PRECISIONA value. Use the CAST function to alter the result data type.C o VARIANCE, and hence STDDEV, assume that one degree of freedomD is used in the calculation of the mean (average) and therefore> the divisor is specified as (n-1). For a large number ofD values in the statistical sample this will not be significant.A However, for small samples it may not be desir able, so thisA default can be changed for the current session by using theC SET FLAGS option VARIANCE_DOF(0). Only the values 0 and 1 are allowed.@ o The keywords ALL and DISTINCT are not permitted when usingC the VAR_POP, VAR_SAMP, STDDEV_POP and STDDEV_SAMP statistical functions.D The FILTER clause is provided for all statistical functions. This@ clause can be used to limit the values included in the COUNT,6 MAX, MIN, SUM, AVG, STDDEV, and VARIANC E functions.< FILTER can be used to eliminate data from the statistical@ function so that the generated report can process the data inB a single pass. The following example illustrates how the FILTER clause is applied. SQL> selectA cont> max (salary_amount) filter (where salary_end is null),E cont> max (salary_amount) filter (where salary_end is not null),Q cont> min (distinct salary_amount) filter (where salary_end = salary_start),P cont> min (distinct salary_amount) filter (where salary_end > salary_start) cont> from cont> salary_history cont> where cont> employee_id = '00164' cont> group by cont> employee_id;A 51712.00 50000.00 NULL 26291.00 1 row selected SQL> 2 COUNT_Function/ There are three forms of the COUNT function:A o COUNT (*) calculates the number of rows in a result table.C It is the only function that does not allow a specific colum n@ name in its argument. The data type of the resulting value expression is an integer.D o COUNT (value-expr) calculates the number of non-NULL values ofC the value-expr in a result table. The value-expr is evaluatedD for each row and, if non-NULL, the count is incremented or theB value is counted. The data type of the resulting value is an integer.C o COUNT (DISTINCT value-expr) calculates the number of distinctA values of the specified valu e-expr in the result table. TheB COUNT DISTINCT function eliminates duplicate values from theD number it calculates. The value-expr is evaluated for each rowD and, if non-NULL and if different from previously seen values,@ the value is counted. It does not count null values in theC specified value-expr. The data type of the resulting value is an integer.@ If there are no values in the result table to which the COUNT: function is applied, the COUNT function returns a zero. 2 SUM_FunctionC The SUM function calculates the total of the values specified byD the value expression in its argument. If there are no rows in theB result table to which the SUM function is applied, it returns a null value.D The SUM function must refer to a value with a numeric or INTERVAL> data type. It returns a value of the same general data type= (fixed- or floating-point) big enough to store the result.@ If your dialect is set to an ANSI /ISO SQL standard, a warning4 message is returned if any of the values is NULL. 2 AVG_FunctionB The AVG function calculates the average of the values specifiedC by the value expression in its argument. If there are no rows inD the result table to which the AVG function is applied, it returns a null value.D The AVG function must refer to a value with a numeric or INTERVALD data type. The value it returns is a floating-point data type for1 numeric expressions, or an INTERVAL data type.A If a value is NULL, the row is treated as missing and, if yourC dialect is set to an ANSI/ISO SQL standard, a warning message is returned. 2 MAX_FunctionB The MAX function calculates the largest of the values specifiedB by the value expression in its argument. If there are no values? in the result table to which the MAX function is applied, it returns a null value.@ The MAX function returns a value of the same data type as the? value in its argument for all data types except LIST OF BYTE VARYING. 2 MIN_FunctionC The MIN function returns the smallest of the values specified byB the value expression in its argument. If there are no values inD the result table to which the MIN function is applied, it returns a null value.@ The MIN function returns a value of the same data type as the@ column in its argument for all data types except LIST OF BYTE VARYING. 2 STDDEV_FunctionsA The STDDEV (standard deviation) function calculates the squareA root of the variance and is expressed in the same units as the source expression.= Oracle Rdb provides the following statistical functions to standard deviation: o STDDEV6 This function calculates the standard deviation. o STDDEV_POPA This function calculates the standard deviation (the squareC root of the variance) for the population. It is equivalent toC STDDEV with degrees of fre edom fixed at 0, that is, SET FLAGS5 'VARIANCE_DOF(0)' which is the default setting. o STDDEV_SAMPA This function calculates the standard deviation (the square= root of the variance) for the subset of sampling of theD population. It is equivalent to STDDEV with degrees of freedomC fixed at 1, that is, SET FLAGS 'VARIANCE_DOF(1)' which is theB default setting. By convention one degree of freedom is used7 when the sampling of the population is performed. 2 VARIANCE_FunctionsD The VARIANCE function calculates the variablity from the mean (or average) value.D Oracle Rdb provides the following variance statistical functions: o VARIANCE/ Calculates the variance of the value set. o VAR_POPB This function calculates the variance for the population. It@ is equivalent to VARIANCE with degrees of freedom fixed atB 0, that is, SET FLAGS 'VARIANCE_DOF(0)' which is the default setting. o VAR_SAMPD This function calculates the variance for a subset or samplingB of the population. It is equivalent to VARIANCE with degreesB of freedom fixed at 1, that is, SET FLAGS 'VARIANCE_DOF(1)'.C By convention one degree of freedom is used when the sampling% of the population is performed. wwq1 External_RoutinesB User-defined functions allow you to execute subprograms writtenB either in 3GL host languages (such as C or SQL Module language)D or in the SQL procedural language. There are two classes of user- defined functions:@ o The external function feature consists of several discrete= pieces: the routine definition, the executable, and the: invocation. You define a function that points to theA executable form of the routine. You code, compile, and link, the routine written in a 3GL language.= See CREATE Routine and CREATE MODULE for information on! creating ext ernal routines.; o The SQL function feature consists a module definition@ containing the function definition. Such SQL functions can@ include any SQL procedural language features (except those? that change the transaction state: SET TRANSACTION, START< TRANSACTION, COMMIT and ROLLBACK) and can invoke otherA functions, call procedures (using the CALL statement) which7 in turn can activate other user-defined routines.? See CREATE MODULE for information on creating modules and functions in SQL.A The function definitions reside in the database like any other@ schema object, such as a table or view. Use the SHOW FUNCTION@ statement to display the names of user-defined functions. See* SHOW for more information and examples.@ Finally, you refer to the routine within an SQL statement for- automatic invocation by the SQL interface.; The following diagram shows how to invoke a user-defined function: function-invocation = 7 --> --> ( -+-----------------+-> ) -->/ ++-> value-expr -++. +-> DEFAULT ----+. +------ , <-----+C You invoke a user-defined function from anywhere you can specify? a value expression. Some of the locations from which you can# invoke an external function are:C o A column using a COMPUTED BY or AUTOMATIC AS value expression clauseA o A CHECK clause in a table constraint, column constraint, or domain constraintD o A select expression in a view definition or cursor declaration? o On the right-hand side of a set-assignment-statement of aD compound statement or of the SET clause of an UPDATE statement# o A select list or where clause? o A DEFAULT value expression clause for a domain, column or parameter wwq1 ROWID@ The ROWID keyword is a synonym to the DBKEY keyword. For more) information, see the DBKEY HELP topic. wwq1 DBKEYA Database keys (dbkeys) are internal pointers to specific table@ rows in a database. Application programs can use the DBKEY orC ROWID keyword in SQL statements to refer to the database key forD a table row. The ROWID keyword is a synonym to the DBKEY keyword.D Database keys are considered value expressions. As such, they can/ be specified as part of a select expression.A SQL state ments that retrieve rows by specifying their database& keys have the following advantages:@ o Fast access: Retrieval through database keys is direct and2 bypasses any indexed or sequential searches.< o Reduced locking of data: Because access is direct, the> database system locks only the row retrieved or updated.@ o Uniqueness: Within the database key scope specified in the@ CREATE DATABASE or DECLARE ALIAS statements, database keys> are guaranteed to be u nique. This means singleton SELECTC statements based on database keys will never return more thanA a single row, and that they will return the same row, or an# error if the row was deleted.> The scope of a database key refers to how long the database> system guarantees that a particular row's database key will? point only to that row and not be used again even if the rowD is deleted. In ATTACH, CREATE DATABASE, DECLARE ALIAS, and IMPORTA statements, you can speci fy that the database key scope be forB the duration of a transaction (the default) or for the duration$ of an attachment to the database.A Applications that plan to use database keys across transaction> boundaries should declare databases with the DBKEY SCOPE ISD ATTACH clause, which allows the program to use a database key forB a particular table row over the course of many transactions. IfB another user deletes the row, the database key will not be usedD again for a newly  inserted row, ensuring that the database key isD still valid. Any further reference to that DBKEY wukk generate an error.B When you use the DBKEY, some space on the page is not reclaimedD until all users are using DBKEY SCOPE IS TRANSACTION and the pageD is updated. Also, see the RMU RECLAIM command which allows online reclaiming of this space.& NOTE? Oracle Rdb recommends using DBKEY SCOPE IS TRANSACTION to= reclaim space on a database page faster than if you use DBKEY SCOPE IS ATTACH. wwq 1 String_Concatenation_OperatorA You can use the string concatenation operator (||) to link two> character value expressions. Concatenated value expressions? must belong to one of the character data types. In addition,C the character sets of the concatenated value expressions must be identical. wwq1 Arithmetic_Expressions; An arithmetic expression is  a value expression formed byB combining one or more numeric value expressions with arithmeticC operators. When you use an arithmetic expression in a statement,B SQL calculates the numeric value associated with the expression4 and uses that value when executing the statement.D You cannot use text values in arithmetic expressions whether theyB are literals, stored in parameters, or stored in table columns.A If either operand of an arithmetic expression is a null value,$ the resulting value is also null.4 The arithmetic operators and their functions are: + Addition - Subtraction * Multiplication / DivisionA You do not have to use spaces to separate arithmetic operators from value expressions.< You can use parentheses to control the order in which SQL? performs arithmetic operations. SQL follows the normal rulesA of precedence. That is, it evaluates arithmetic expressions in the following order:& 1. Value expressions in parentheses5 2. Multiplication and division, from left to right2 3. Addition and subtraction, from left to right> You can use date-time variables and constants in arithmetic expressions.< The following restrictions apply to date-time arithmetic:C o You cannot use the DATE VMS data type in date arithmetic; youC must use the CAST function (CAST(VMS_COL AS TIMESTAMP(2))) or: alter the DATE VMS domain to DATE ANSI or TIMESTAMP. B o You must use an interval qualifier with date-time data types in subtraction operations.C o Certain subtraction operations can produce an answer that canA be either a YEAR-MONTH interval or a DAY-TIME interval. ForA example, when subtracting a timestamp from a timestamp or aC timestamp from a date, you must specify the qualifier desired as follows:# SQL> CREATE TABLE ORDER_TABLE cont> (PART_NUM INT,& cont> ORDER_LOGGED TIMESTAMP (2),' cont> DELIVERY_DATE TIMESTAMP(2),M cont> TIME_TO_DELIVER COMPUTED BY (DELIVERY_DATE - ORDER_LOGGED) DAY(2)A cont> TO MINUTE, SLOW_DELIVERY COMPUTED BY EXTRACT(DAY FROM9 cont> (DELIVERY_DATE - ORDER_LOGGED) DAY(2)) - 30);C o You cannot add days to or subtract days from TIME. The resultA exceeds the allowable range for TIME. The interval day-time1 column must be a subset of HOURS to SECOND.> o You cannot add hours to or subtract hours from DATE. The1 interval day-time column must be DAYS only. ww癅1 Conditional_Expressions< A conditional expression is an advanced form of the value: expression that allows applications to return alternateC information within an expression. See Value_Expressions for more? information on the syntax. The following table describes the< conditional expressions that are supported by Oracle Rdb." Table 3 Conditional Expressions Expression Name  Description2 ABS ABS returns the absolute value of n.D CASE CASE alters the result of an expression. CASE can also. generate or convert null values.E COALESCE COALESCE returns the first non-NULL value from a series< of value expressions; otherwise, returns NULL.4 DECODE Alternate form of the Case expression.; GREATEST GREATEST returns the greatest non-null value.5 LEAST LEAST returns the least non-null value.D NULLIF  NULLIF substitutes NULL when two value expressions are8 equal; otherwise, returns the first value.C NVL NVL returns the first non-NULL value from a series ofB value expressions; otherwise, returns NULL. NVL is a# synonym for COALESCE.E NVL2 If the first value expression to NVL2 is not NULL, thenB return the second value expression; otherwise return) the third value expression.0 SIGN SIGN returns the  sign of the value 2 ABS_Function? The ABS function returns NULL if the passed value expressionC evaluates to NULL. The datatype of the result is the same as theC passed value expression and supports scaled values of these dataA types: TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE4 PRECISION, INTERVAL, DECIMAL, NUMERIC and NUMBER.> The absolute value function (ABS) returns NULL if the valueB expression evaluates to NULL. If the value expression evaluates? to a value less than zero then that value is negated so that@ a positive value is returned. Otherwise the value is returned= unchanged. For instance, ABS (-1) will return the value 1./ ABS (a) is equivalent to the CASE expression case when a < 0 then - a else a endB Example: Using the ABS function on an INTERVAL result of a date subtraction. SQL> select3 cont> ABS ((birthday - current_date) year(3)) cont> from employees cont> order by employee_id cont> limit to 10 rows; 054 047 047 064 068 062 044 069 050 074 10 rows selected3 Example: Using ABS within a statistical function> SQL> -- what is the average time in a job for each employee, SQL> -- exclude anyone on there first job SQL> select cont> employee_id,L cont> AVG (ABS (EXTRACT (MONTH FROM (job_start - job_end) month (4))))F cont> as "Average Job" edit using '--,---,--9.99" years"' cont> from JOB_HISTORY$ cont> where employee_id < '00200' cont> group by employee_id cont> having COUNT (*) > 1;% EMPLOYEE_ID Average Job% 00164 14.00 years% 00165 22.67 years% 00166 20.00 years% 00167 14.50 years% 00168 26.33 years% 00169 22.67 years ...etc...% 00197 26.33 years% 00198 37.00 years% 00199 35.00 years 30 rows selected: %RDB-I-ELIM_NULL, null value eliminated in set function 2 COALESCE_ExpressionsC The COALESCE and NVL expressions return the first non-NULL value& from a series of value expressions.; SQL evaluates each value expression in a COALESCE or NVL> expression until it can return a non-NULL value. If all theC columns specified in the COALESCE or NVL expression contain NULL!  values, then NULL is returned.B The data type of the resulting expression is a common data type? to which all value expressions in the list can be converted.A For example, COALESCE(SALARY_AMOUNT, ESTIMATED_BONUS, 1.23E+5)< results in a DOUBLE PRECISION result because at least one& argument is a floating point value.> The following example replaces the stored NULL value in the> MIDDLE_INITIAL column of the EMPLOYEES table with a hyphen:5 SQL> SELECT FIRST_NAME, LAST_ NAME, MIDDLE_INITIAL,& cont> COALESCE(MIDDLE_INITIAL, '-') cont> FROM EMPLOYEES# cont> WHERE LAST_NAME LIKE 'L%';0 FIRST_NAME LAST_NAME MIDDLE_INITIAL4 Jo Ann Lapointe C C4 Hope Lapointe NULL -4 Stan Lasch P P4 Norman Lasch NULL -4 Peter Lengyel A A4 Peter Lonergan V V 6  rows selected 2 CASE_ExpressionsD There are many situations where you might find it useful to alterC the result of an expression. For example, you might have a tableD column called WORK_STATUS containing the data 0, 1, and 2 meaning? Inactive, Full time, and Part time, respectively. The singleB character is more efficient to store than the definition of theC character in the database. However, the definition of the single% character is not always intuitive.9 There may also be times when you want to generate null@ values based on the information derived from the database or,C conversely, convert a null value into a more concrete value likeD zero (0). The CASE expressions provide an easy solution to these problems.+ There are two types of CASE expressions:7 o Simple-matches two value expressions for equality= o Searched-allows complex predicate, including subqueries4 An example of the simple case expression follows:% SQL> SELECT LAST_NAME, FIRST_NAME, cont> CASE STATUS_CODE& cont> WHEN '1' THEN 'Full time'& cont> WHEN '2' THEN 'Part time'% cont> WHEN NULL THEN 'Unknown' cont> ELSE 'Inactive' cont> END cont> FROM EMPLOYEES; LAST_NAME FIRST_NAME+ Smith Terry Part time+ O'Sullivan Rick Full time . . .+ Sarkisian Dean Part time+ Stornelli James Full tim e+ Hall Lawrence Full time+ Mistretta Kathleen Full time* James Eric Inactive+ MacDonald Johanna Full time+ Dement Alvin Full time+ Blount Peter Full time+ Herbener James Full time+ Ames Louie Full time 100 rows selected= When SQL encounters the first WHEN clause that matches theD primary value expression following the CASE keyword, it evaluatesD the THEN clause. If no matching values are found, the ELSE clauseD is evaluated. If the ELSE clause is missing, NULL is the returned value. For example: SQL> SELECT PRODUCT_NAME, cont> CASE5 cont> WHEN QUANTITY <= 0 THEN 'On back order'$ cont> WHEN QUANTITY > 0 THEN= cont> CAST(QUANTITY AS VARCHAR(10)) || ' in stock' cont> END cont> FROM INVENTORY; PRODUCT_NAME! Staples-boxes 20 in stock Staplers-each 3 in stock# Tape-rolls On back order! Calendars-each 25 in stock# Tape disp.-each On back order Desk cleaner NULL 6 rows selected6 An example of the searched case expression follows: SQL> SELECT PRODUCT_NAME, cont> CASE5 cont> WHEN QUANTITY <= 0 THEN 'On back order'$ cont> WHEN QUANTITY > 0 THEN= cont> CAST(QUANTITY AS VARCHAR(10)) || ' in stock'K cont> ELSE -- must be NULL+ cont> 'New Item - awaiting stock' cont> END cont> FROM INVENTORY; PRODUCT_NAME! Staples-boxes 20 in stock Staplers-each 3 in stock# Tape-rolls On back order! Calendars-each 25 in stock# Tape disp.-each On back order/ Desk cleaner New Item - awaiting stock 6 rows selectedD The searched case expression allows arbitrary expressions in eachA WHEN clause, as shown in the previous example. The simple  caseC expression is a shorthand method of specifying the searched case expression.B For the simple and searched case expressions, the data types ofC the value expressions of the WHEN clause must be comparable, andB the data types of the value expressions of the THEN clause must be comparable.? All subqueries in a CASE expression are evaluated. It is theC results of these subqueries that are conditionalized by the CASE, expression and not the actual evaluation.> If any subquery (which must return at most a single row and@ column) returns more than one row, the following exception is generated:L %RDB-E-MULTIPLE_MATCH, record selection criteria should identify only one% record; more than one record found= A workaround is to add one of the following clauses to the subquery: o LIMIT TO 1 ROW> This ensures that only one row is returned. For example: . . . cont> WHEN A IS NOT NULL- cont> THEN (SELECT A FROM T WHERE B = Y! cont> LIMIT TO 1 ROW) . . .= The WHEN condition ignores this row if it is not valid.; o Duplicate the WHEN clause Boolean inside the subquery predicate For example: SQL> --. SQL> -- Change the following syntax from SQL> -- . . . cont> WHEN A IS NOT NULL. cont> THEN (SELECT A FROM T WHERE B = Y) .  . . SQL> --8 SQL> -- to include the Boolean inside the subquery SQL> -- . . . cont> WHEN A IS NOT NULL@ cont> THEN (SELECT A FROM T WHERE B = Y AND A IS NOT NULL) . . .B In this example, when the WHEN clause evaluates as FALSE, so@ will the WHERE predicate from the subquery and, therefore, will return no rows.A In either of the above cases, the correct results are returned from the query. 2 DECODE> The DECODE function compares an expression to each supplied> search value until a match is found. When a match is found,B DECODE returns the result in the corresponding result field. IfD no match is found, DECODE returns the default if it is specified,# null if no default is specified.% Example: Using the DECODE function2 SQL> SELECT employee_id, last_name, first_name,/ cont> DECODE (status_code, '1', 'Full time',/ cont>  '2', 'Part time') cont> FROM employees cont> LIMIT TO 5 ROWS;, EMPLOYEE_ID LAST_NAME FIRST_NAME8 00165 Smith Terry Part time8 00190 O'Sullivan Rick Full time8 00187 Lasch Stan Full time8 00169 Gray Susan Full time8 00176 Hastings Norman Full time 5 rows selected 2 GREATEST_and_LEAST_Functions@ The GREATEST and LEAST functions accept a list of two or moreC value expressions (all of which must be of comparable types) andD return the greatest value from the list for the GREATEST function< and the least value from the list for the LEAST function.< The value expressions specified can be column references,@ subselects, function calls, literal values, and other complex value expressions.B The data type of the resulting expression is a common data typeC to which all value expression s in the list can be converted. ForB example, LEAST(10, 10.3, 123E100) results in a DOUBLE PRECISION; result because at least one literal is DOUBLE PRECISION.@ If the result data type resolves to a fixed CHARACTER string,D then GREATEST and LEAST return a CHARACTER VARYING (also known as+ VARCHAR) string with the maximum length.C The NULL keyword can appear in the list but is ignored. However,A not all value expressions can be specified as NULL. That is, aA non-NULL va lue expression must be in the list so that the data- type for the expression can be determined.A The GREATEST and LEAST functions can result in NULL only if at1 run time all value expressions result in NULL.B If DATE VMS literals are used as an argument to the GREATEST orA LEAST function, the date string must be prefixed with the typeD DATE VMS so that SQL will accept it as a DATE VMS literal and not0 a string literal. See the following examples.3 Examples: Using the  GREATEST and LEAST functions5 Example 1 Using CHARACTER Versus DATE VMS LiteralsD SQL> -- Different results are returned by the LEAST function (andB SQL> -- the GREATEST function) if the parameters are treated asA SQL> -- CHARACTER or DATE VMS literals. This is because it isF SQL> -- the data types of the source expressions that determine theF SQL> -- the result data type of the LEAST (and GREATEST) functions.3 SQL> select LEAST ('1-APR-2001', '10-JAN-2000'),< cont> LEAST (DATE VMS'1-APR-2001', DATE VMS'10-JAN-2000') cont> from rdb$database;) 1-APR-2001 10-JAN-2000 00:00:00.00 1 row selected@ Example 2 finds the least value for the birthday of employees from two employees tables.% Example 2 Using the LEAST Function= SQL> SELECT LEAST (M.BIRTHDAY, E.BIRTHDAY, :SUPPLIED_DATE)E cont> FROM EMPLOYEES E, JOB_HISTORY JH, DEPARTMENTS D, EMPLOYEES M1 cont> WHERE E.EMPLOYEE_ID = JH.EMPLOYEE_ID AND cont> ... 2 NUL LIF_ExpressionsB The NULLIF expression is used to substitute NULL when two valueC expressions are equal. For example, if the data stored in columnD ADDRESS_DATA_1 or ADDRESS_DATA_2 are space characters, the NULLIF; expression replaces the space value with the NULL value. SQL> BEGIN cont> INSERT INTO EMPLOYEES1 cont> (EMPLOYEE_ID, LAST_NAME, FIRST_NAME,- cont> ADDRESS_DATA_1, ADDRESS_DATA_2) cont> VALUES, cont> (:EMP_ID, 'Clinton', 'William'," cont> NULLIF(:ADD_1, ' '),# cont> NULLIF(:ADD_2, ' ')); cont> END; SQL>8 SQL> SELECT LAST_NAME, ADDRESS_DATA_1, ADDRESS_DATA_2 cont> FROM EMPLOYEES% cont> WHERE EMPLOYEE_ID = :EMP_ID;? LAST_NAME ADDRESS_DATA_1 ADDRESS_DATA_25 Clinton NULL NULL 1 row selectedA The following example substitutes NULL when the MIDDLE_INITIAL; column of the EMPLOYEES table contains space characters: SQL> SELECT LAST_NAME,( cont> NULLIF (MIDDLE_INITIAL, ' '), cont> FIRST_NAME cont> FROM EMPLOYEES1 cont> WHERE EMPLOYEE_ID IN ('00191', '00198');& LAST_NAME FIRST_NAME! Pfeiffer I Karen" Gehr NULL Leslie 2 rows selected 2 NVL_ExpressionsD substitutes NULL when two value expressions are equal; otherwise,A returns NULL. The NVL expression is a synonym for the COALESCE? expression. See the COALESCE_Expressions HELP topic for more information. 2 NVL2_Expressions= NVL2 lets you compute a value based on whether a specified@ expression is null or not null. If the first value expression> is not null then the second value expression is returned as@ the function result. Otherwise, the final value expression isD returned. The data type function is derived as a common data type- of the second and third value expressions.A For example, when the JOB_END date in JOB_HISTORY is NU LL thenB that indicates the current job for that employee. The following@ example uses NVL2 to annotate the output from a query on JOB_B HISTORY displaying either "current job" or "prior job" based on, the NULL attribute of the JOB_END column./ SQL> select employee_id, job_start, job_end,3 cont> NVL2 (job_end, 'prior job', 'current job') cont> from job_history$ cont> where employee_id < '00180') cont> order by employee_id, job_start;' EMPLOYEE_ID JOB_START JOB_END7 00164 5-Jul-1980 20-Sep-1981 prior job9 00164 21-Sep-1981 NULL current job7 00165 1-Jul-1975 4-Sep-1977 prior job7 00165 5-Sep-1977 7-Apr-1979 prior job7 00165 8-Apr-1979 7-Mar-1981 prior job9 00165 8-Mar-1981 NULL current job . . .C The following example shows whether the income of some employeesB is made up of SALARY plus COMMISSION, o r just SALARY, dependingD on whether the COMMISSION_PCT column of EMPLOYEES is null or not.( SQL> SELECT last_name, salary_amount,$ cont> NVL2 (commission_pct,F cont> salary_amount + (salary_amount * commission_pct),? cont> salary_amount) as Income edit using SALARY, cont> FROM employees e, salary_history sh" cont> WHERE last_name like 'B%'- cont> and e.employee_id = sh.employee_id! cont> and salary_end is null cont> ORDER BY last_n ame;3 E.LAST_NAME SH.SALARY_AMOUNT INCOME3 Babbin $20,150.00 $20,956.003 Bartlett $14,817.00 $15,261.513 Bartlett $38,223.00 $38,987.463 Belliveau $54,649.00 $55,741.983 Blount $63,080.00 $64,341.603 Boyd $30,275.00 $30,275.003 Boyd $24,166.00 $24,166.003 Brown $50,357.00 $50,357.003 Burton  $23,053.00 $23,053.00 9 rows selected SQL> 2 SIGN_FunctionD SIGN returns an INTEGER value. SIGN accepts any numeric (fixed orB floating) or interval value expression. If the value expressionA evaluates to NULL, then the SIGN function returns NULL. If theD value expression evaluates to a negative value, then SIGN returns@ -1; if the value is positive then SIGN returns 1; otherwise a zero will be returned.' Example: Using SIGN Builtin FunctionC This example computes delayed departures from the LAYOVER table. SQL> select arr_date, cont> dep_date,; cont> DECODE (SIGN ((dep_date - arr_date) day(9)),D cont> -1, 'date error - can not depart before arrival',, cont> 0, 'same day departure',! cont> 1, 'delayed') cont> from LAYOVER;% 2005-12-22 2006-01-20 delayed% 2005-12-23 2005-12-25 delayed% 2006-01-30 2006-02-01 delayed% 2006-02-06 2006-02-09 delayed% 2006-01-24 2006-01-26 delayed% 2006-02-02 2006-02-19 delayed% 2007-02-10 2007-02-16 delayed% 2007-02-20 2007-02-26 delayed% 2007-05-29 2007-06-08 delayed% 2007-06-12 2007-06-26 delayed% 2007-05-15 2007-05-21 delayed% 2007-09-10 2007-09-14 delayed% 2007-09-04 2007-09-06 delayed% 2007-09-19 2007-09-20 delayed% 2007-09-21 2007-09-24 delayed 15 rows selected ww 1 Predicates@ A predicate specifies a condition that SQL evaluates as true,< false, or unknown. Predicates are also called conditional: expressions. You can specify several different types ofA predicates with different conditional operators. The different types of predicates are: o Basic o BETWEEN o Complex o CONTAINING o EXISTS o IN o IS NULL o LIKE o MATCHING o Quantified o SINGLE o STARTING WITH o UNIQUE= When you compare character value expressions, if automaticB translation has not been enabled, character sets of those value! expressions must be identical.B Some predicates have a specific behavior when used with the DEC% Multinational Character Set (MCS).D The following list describes multinational character set behavior that applies to predicates:= o The character is always treated as different from the? character n, in keeping with the practices of the SpanishC language. In a similar manner, the character is treated theC same as the character c, in keeping with the practices of the French language.@ o The character is treated the same as the character u forB many languages, but is sorted between the characters x and zA (with the ys) for Danish, Norwegian, and Finnish languages.9 The following diagram shows the syntax for predicates: predicate = 9 -+-+--------+-+ -> basic-predicate ----------------+-+-->6 | +-> NOT -+ +-> between-predicate --------------+ |6 | +-> containing-predicate -----------+ |6 | +-> exists-predicate ---------------+ |6 | +-> in-predicate -------------------+ |6 | +-> is-null-predicate --------------+ |6 | +-> like-predicate -----------------+ |6 | +-> matching-predicate -------------+ |6 | +-> quantified-predicate -----------+ |6 |  +-> single-predicate ---------------+ |6 | +-> unique-predicate ---------------+ |6 | +-> starting-with-predicate --------+ |6 | +-> (predicate) --------------------+ |6 +-----------------+- AND <--+----------------------+ +-- OR <--+& NOTE> Except for the IS NULL, EXISTS, and SINGLE operators, if= either operand in a predicate is null, the value of the predicate is unknown.=  You cannot use a value of the LIST OF BYTE VARYING dataA type for either operand in a comparison predicate. For more; information, see the LIST_OF_BYTE_VARYING HELP topic.: When you use the DEC_MCS or ASCII character set, SQL? compares character string literals according to the ASCII; collating sequence. Therefore, it considers lowercase= letters to have a greater value than uppercase letters,B and considers the letters near the beginning of the alphabet5 to have a lesser value than those near the end. 'a' > 'A' 'a' > 'Z' 'a' < 'z' 'A' < 'z' 'A' < 'Z' 2 Basic_Predicate) A basic predicate compares two values. basic-predicate = 0 ----> value-expr --+-> = --+-> value-expr ----> +-> <> -+ +-> ^= -+ +-> != -+ +-> < --+ +-> <= -+ +-> > --+  +-> >= -+ < See the Value_Expressions HELP topic for details on value expressions. 2 BETWEEN_Predicate? A BETWEEN predicate compares a value with a range of values. between-predicate = ; --> value-expr -+--------+-> BETWEEN -+----------------+-+; +-> NOT -+ +-> ASYMMETRIC --+ |; +-> SYMMETRIC ---+ |; +-------------------------------------------------------+< +-> value-expr AND value-expr --------------------------->< See the Value_Expressions HELP topic for details on value expressions. ASYMMETRIC is the default.D The BETWEEN predicate is a simpler way of representing conditions= that can be represented using other conditional operators:# value1 BETWEEN value2 AND value3A Using the BETWEEN predicate is the same as using the following complex predicate: value1 >= value2 AND value1 <= value3 ASYMMETRICC By default, the BETWEEN predicate depends on the ordering of theA values. i.e. the first value expression needed to be less than? or equal to the second value expression and was evaluated asB equivalent to: V0 V1 and V0 V2. This is demonstrated by the following example.; SQL> select a from t where a between asymmetric 2 and 4; A 2 3 4 3 rows selected= The following query returns zero matches because the value  expressions are out of order.; SQL> select a from t where a between asymmetric 4 and 2; 0 rows selected SYMMETRICB This alternate format for BETWEEN allows simpler comparision of@ unordered value expressions, as can be seen in these examplesD which return the same results. This comparision is equivalent to:2 (V0 V1 and V0 V2) or (V0 V2 and V0 V1). For example:: SQL> select a from t where a between symmetric 2 and 4; A 2 3 4 3 rows selected: SQL> select a from t where a between symmetric 4 and 2; A 2 3 4 3 rows selectedD Note that NOT BETWEEN operation also changes when using SYMMETRICB This first query using ASYMMETRIC returns all values not in the specified range.? SQL> select a from t where a not between asymmetric 2 and 4; A 1 5 2 rows selected> In this next query the range values is out of order and theC BETWEEN predicate returns an empty set of matches, and therefore5 NOT BETWEEN returns all rows in the example table.? SQL> select a from t where a not between asymmetric 4 and 2; A 1 2 3 4 5 5 rows selectedB Contrast this to SYMMETRIC which returns the same set of values! for either ordering of values:> SQL> select a from t where a not between symmetric 2 and 4; A 1 5 2 rows selected> SQL> select a from t where a not between symmetric 4 and 2; A 1 5 2 rows selected 2 Complex_PredicateA A complex predicate combines any number of predicates with theA Boolean operators AND, OR, and NOT. Boolean operators are also called logical operators. complex-predicate = 8 -+-+--- -----+-+--> complex-predicate -+---+----------->7 | +-> NOT -+ +--> predicate ---------+ +-> AND -+-+7 | +-> OR --+ |7 +-------------------------<-------------------------+ A When nesting predicates, you must enclose them in parentheses.< SQL evaluates parts of a complex predicate in this order:( 1. Predicates enclosed in parenthesesB If there are nested predicates in parentheses, the innermost# predicate is evaluated first. 2. Predicates preceded by NOT" 3. Predicates combined with AND! 4. Predicates combined with OR> The following tables summarize how SQL evaluates predicates@ combined with Boolean operators. Such tables are often called truth tables. Table 4 Boolean Operator: AND( A B A AND B& True False False% True True True& False False False& False True  False( True Unknown Unknown& False Unknown False( Unknown True Unknown& Unknown False False( Unknown Unknown Unknown Table 5 Boolean Operator: OR' A B A OR B% True False True% True True True& False False False% False True True% True Unknown True( False  Unknown Unknown% Unknown True True( Unknown False Unknown( Unknown Unknown Unknown Table 6 Boolean Operator: NOT A NOT A True False False True Unknown Unknown& NOTE; The fact that NOT A is evaluated as unknown when A is> unknown can be confusing in queries that refer to tables< with null values. It means that a NOT predicate is not@  necessarily evaluated as true for all rows of a column forA which the same predicate without NOT is evaluated as false.? In other words, the result of a query that contains NOT AA is not necessarily the complement of the result of the same! query that contains only A. 2 CONTAINING_PredicateD A CONTAINING predicate tests whether or not the string expressionC specified in the second value expression is contained within the, string expression specified by the first. containing-predicate = ; ---> value-expr -+-------+-> CONTAINING --> value-expr --> +> NOT -+ 2 The CONTAINING predicate is not case sensitive.@ The CONTAINING predicate is sensitive to diacritical markingsC used in any Multinational Character Set. Therefore, a matches a,2 but neither matches , , , , , and so on.B In Spanish, ch and ll are treated as if they were unique single characters.< If you use a collating sequence, the CONTAINING predicate< will not be sensitive to diacritical markings used in any Multinational Character Set. 2 EXISTS_Predicate< An EXISTS predicate tests whether or not the result table4 specified in a column select expression is empty. exists-predicate = % ---> EXISTS ( select-expr ) ------->D If the result table specified in the select expression has one orD more rows, SQL evaluates the EXISTS predicate as true. Otherwise,A the predicate is false. A n EXISTS predicate cannot be unknown.> Because it only checks for the existence of rows, an EXISTSC predicate does not require that the result table from its column@ select expression be a single column wide (see Column_Select_= Expressions for details on column select expressions). ForD EXISTS predicates, an asterisk (*) wildcard in the column select0 expression can refer to a multicolumn table . 2 IN_Predicate; An IN predicate compares a value with another value or a collection of values. in-predicate = D --> value-expr +--------+-> IN +-> value-expr ------------------+->B +-> NOT -+ +-> ( -++-> value-expr --++-> ) +< |+-> select-expr --+|< +---------- , <-----+@ All forms of the IN predicates can be represented using other conditional operators. o value-expr IN value-expr is the same as value-expr IN (value-expr). which is the same as the basic predicate value-expr = value-exprA (as long as the value expression on the right is not a host8 structure that expands to more than one parameter); o value-expr IN (value-expr1, value-expr2, value-expr3)* is the same as the complex predicate value-expr = value-expr1 OR value-expr = value-expr2 OR value-expr = value-expr3B (in this case, any of the value expressions on the right canB be a host structure that expands to more than one parameter)C o value-expr IN (col-select-expr1, val-expr2, col-select-expr3)- is the same as the quantified predicate) value-expr = ANY (col-select-expr1) OR value-expr = val-expr2 OR) value-expr = ANY (col-select-expr3)B (in this case, any of the value expressions on the right canB be a host structure that expands to more than one parameter) 2 IS_NULL_PredicateC An IS NULL predicate tests for null values in value expressions. is-null-predicate = 1 ----> value-expr ---> IS -+--------+-> NULL --->% +-> NOT -+< See the Value_Expressions HELP topic for details on value expressions.D SQL never evaluates an IS NULL predicate as unknown; it is always@ true or false. If the value expression is null, SQL evaluatesB the predicate as true. If the value expression is not null, the predicate is false.@ Use  an IS NULL predicate to retrieve rows with null values in> particular columns. An IS NULL predicate is the only way toD construct a query that includes rows in a result table by testingB whether or not particular columns in the rows have null values.@ Other constructions such as NOT LIKE or <> (not equal) do not8 include rows with null values in their result tables. 2 LIKE_PredicateB A LIKE predicate searches character string literals for pattern> matches. The LIKE predi cate is case sensitive; it considers< uppercase and lowercase forms of the same character to be different characters.= Because the LIKE predicate is case sensitive, searches for> uppercase characters do not include lowercase characters inA any Multinational Character Set. The reverse is also true. ForB example, LIKE "" will retrieve a different set of records than LIKE "".? The LIKE predicate is sensitive to diacritical markings usedB in any Multinational Character Set. Therefore, a matches a, but. neither matches , , , , , and so on.A In Spanish, ch and ll are treated as if they are unique singleB letters. For example, if a domain is defined with the collatingC sequence SPANISH, then LIKE "c%" will not retrieve the word char" but will retrieve the word cat.$ The LIKE predicate has this form: like-predicate = 5 ---> value-expr -+------+-> LIKE -----> +5 +> NOT + |5 +--------------------------------------------+1 +-+-+------------------------------+-+--->- | +-> ESCAPE -+ |- | +-> IGNORE CASE ---------------+ |- +----------------<-----------------+ pattern =  ----> char-value-expr ----> escape-character = $ ----> char-value-expr ------------> ? SQL interprets the value-expr argument as a character string> and compares it to the pattern. The pattern must be a value$ expression with a text data type.A Within the pattern, the percent sign (%), underscore (_), and* escape characters have special meaning.; o The percent sign represents any string of characters,D including no characters at all. The percent sign is a wildcard character.5 o The underscore represents any single character.< o An escape character causes SQL to interpret a wildcardD character as itself to search for character strings containingD the wildcard character. The value of the escape character must be 1 character in length.B The following table explains the valid sequences allowed for escape characters.% Table 7 Escape Character Sequences+ Character in Pattern Character Matched$ % any string' _ any character escape-character % % escape-character _ _* escape-character escape-character escape-character? You can only specify the percent sign, underscore, or theD escape-character itself. Any other character is invalid and an error is returned.- All other characters represent themselves. 2 MATCHING_Predicate> A MATCHING predicate searches character string literals forD pattern matches. The pattern string accepts the following pattern characters:5 o * Matches any string of zero or more characters$ o % Matches any single character matching-predicate = 8 ---> value-expr -+------+-> MATCHING ------>  +> NOT + pattern =  ----> char-value-expr ----> Usage Notes? o If either of the expressions is null, the result is null.< o MATCHING predicate is not case sensitive; it considersA uppercase and lowercase forms of the same character to be a match.< o The MATCHING predicate is not sensitive to diacritical; markings used in the DEC Multinational Character Set.> The following example shows the use of the MATCHING clause. SQL> select last_name cont> from employees) cont> where last_name matching '%on*'; LAST_NAME Connolly Lonergan 2 rows selected SQL> 2 Quantified_Predicate? A quantified predicate compares a value with a collection ofD values. It has the same form as a basic predicate except that theC second operand must be a column select expression preceded by an) ALL, ANY, or SOME comparison operator. quantified-predicate = A --> value-expr --+-> = --+-+-> ALL --+-> ( col-select-expr ) -->' +-> <> -+ +-> ANY --+' +-> ^= -+ +-> SOME -+ +-> != -+ +-> < --+ +-> <= -+ +-> > --+ +-> >= -+A The following table describes the value of the result based on9 the comparison of values for the quantified predicate., Table 8 Quantified Predicate Result Table% Comparison of Values Result ALL Quantifier# If all comparisons are True True$ If any comparisons are False False# If no comparisons are True made& Otherwise Unknown SOME and ANY Quantifiers# If any comparisons are True True$ If all comparisons are False False# If no comparisons are True made& Otherwise Unknown 2 SINGLE_ Predicate= The SINGLE predicate tests whether or not the result tableA specified in the column select expression has exactly one row.C If it has exactly one row, SQL evaluates the SINGLE predicate asD true. If the result table has zero rows or more than one row, the predicate is false.? SQL evaluates the NOT SINGLE predicate as true if the resultA table specified in the select expression has zero rows or more than one row.: The SINGLE and NOT SINGLE predicates cannot be unknown./ The SINGLE predicate has the following form: single-predicate = ' ---> SINGLE --> ( select-expr ) ----->= Because it checks only for the existence of rows, a SINGLEC predicate does not require that the result table from its column@ select expression be a single column wide (see Column_Select_= Expressions for details on column select expressions). ForD SINGLE predicates, an asterisk (*) wildcard in the column selectC expression can refer to a multicolumn table (as in the following example). 2 STARTING_WITH_Predicate= The STARTING WITH predicate tests whether or not the firstA characters of the first value expression match those specifiedB in the second value expression. The STARTING WITH predicate has the following form: starting-with-predicate = < --> value-expr -+------+-> STARTING WITH --> value-expr --> + NOT -+ < Because the STARTING WITH predicate is case sensitive, itC  searches for uppercase characters and does not include lowercaseB characters for the DEC Multinational Character Set; the reverseB is also true. For example, STARTING WITH '' retrieves a set of? records different from those retrieved by STARTING WITH ''.C The STARTING WITH predicate is sensitive to diacritical markingsC used in any Multinational Character Set. Therefore, a matches a,2 but neither matches , , , , , and so on.; In Spanish, ch and ll are treated as if they were unique> single characters. For example, if a domain is defined withB the collating sequence SPANISH, then STARTING WITH 'c' does not6 retrieve the word char, but retrieves the word cat. 2 UNIQUE_PredicateD The UNIQUE predicate is used to determine if duplicate rows existC in the result table of a column select expression. Note that theB UNIQUE predicate (in compliance with the SQL language standard)C ignores rows with a NULL column value and ensures uniqueness forD the other column values. Contrast this with the SINGLE predicate,C which considers a single column value of NULL as a match for any' other NULL value in the same column. unique-predicate = * ---> UNIQUE ---> ( col-select-expr ) ---> B If any two rows in the expression are equal to one another, the' UNIQUE predicate evaluates to false.A The following example determines those cities in which one and7 only one employee from the EMPLOYEES database lives.3 SQL> SELECT E.LAST_NAME, E.CITY FROM EMPLOYEES E cont> WHERE UNIQUE% cont> (SELECT * FROM EMPLOYEES EMP cont> WHERE EMP.CITY=E.CITY); LAST_NAME CITY Harrison Boston Smith Bristol McElroy Cambridge Kilpatrick Marlow Sciacca Munsonville Vormelker Rochester Dement Sanbornton! Babbin Sanbornville" Keisling Twin Mountain Ziemke Winnisquam Johnston Wolfeboro 11 rows selected wwꅀ1 Select_Expressions@ Using select expressions, you can define four types of result tables: o Simple tables o Aggregate tables o Joined tables o Derived tablesA A simple table result is generated from a single table or viewB and usually includes the special DBKEY column. The rows of such. tables can be updated, if privileges allow.< An aggregate table is a virtual table formed by the GROUP= BY clause (allowing multi-row results) or an aggregate (or@ statistical) expression without allowing a GROUP BY (a single row result).? A table reference is a base table, view, derived table, or a joined table.@ A derived table is a named virtual table that represents dataD obtained through the evaluation of a select expression. A derivedD table is named by the specified correlation name. References to aC derived table and its  columns can be made within the query using@ the correlation name. A derived table is similar to a view in@ that a view is also a virtual table represented by the selectC expression used to define it. Therefore, a derived table is like? a view whose definition is specified within the FROM clause.B A joined table is a virtual table that represents data obtained@ through the joining of two table references. The type of join> between the two table references can be either CROSS, INNER? JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, or FULL OUTER JOIN.C You need to use the joined table syntax to specify an outer join operation.( There are two types of joined tables: o Qualified join o Cross join 2 EnvironmentD You can use select expressions, by themselves or as part of otherC SQL statements, in interactive SQL or in host language programs.B SQL evaluates the arguments in a select clause in the following order: 1. FROM 2. WHERE 3. GROUP BY 4. HAVING 5. Select list 6. ORDER BY 7. OFFSET 8. LIMIT TO (or FETCH FIRST)C After each of these clauses, SQL produces an intermediate resultB table that is used in evaluating the next clause. The optimizerC finds the fastest way of doing this without changing the result. 2 Format select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ select-merge-clause = > -+-> EXCEPT -+--------------+---+----+-------------------+-->; | +-> DISTINCT --+ | +-> CORRESPONDING --+; +-> INTERSECT -+-------------+-+ +-> NATURAL --------+" | +-> DISTINCT -+ |" +-> MINUS ---------------------+" +-> UNION --+-------------+----+ +-> ALL ------+ +-> DISTINCT -+ select-clause = G SELECT -+-------------+-> select-list -------------------------------+G +-> ALL ------+ |G +-> DISTINCT -+ |G +------------------<-------------------------------------------------+G +-> FROM -+--> table-ref --+-----------------------------------------+G +------ , <------+ |G +--------------------------------------------------------------------+G ++--------->-----------------------+-+------------->----------------++G +> WHERE predicate ---------------+ +> GROUP BY -+> -+|G +> value-expr ----+|G +------- ,<-------+|G  +--------------------------------------<-----------------------------+H ++---------->----------+----------------------------------------------> +-> HAVING predicate -+ select-list = H -+-+----> * ------------------------------------------------------+-+->F | +-+--> value-expr --+--------------------------------------+-+-+ |F | | +-> AS -+----------------------++ | |F | | +-> edit-using-clause -+ | |F | |   | |F | ++-> ------+-> . * ---------------------------+ |F | +-> -------+ |F | +-> + |F +---------------- , <----------------------------------------------+ edit-using-clause = ' --> EDIT USING -+-> edit-string ---+->% +-> -+ table-ref = < --+--> - -+--+-----------------------------+-->9 +--> --+ +-> correlation-name-clause --+9 +--> derived-table -+ |9 +--> joined-table -----------------------------------+  derived-table = ' ----> ( -+-> select-expr --+-> ) ----> +-> joined-table -+  joined-table = ( --+-------> qualified-join ------+----># +-------> cross-join ----------+# +-> ( --> joined-table --> ) --+  qualified-join =  9 -+-> table-ref -+-------------+--> JOIN --> table-ref -+9 | +> join-type -+ |9 | +---------------------------------------------------+C | ++-> ON predicate -------------------------------+-----------+>B | +-> USING ----> ( -+> +-> ) ------+ |B | +------ , <------+ |B +-> table-ref -> NATURAL -+-------------+-> JOIN -> table-ref -++ +> join-type -+  cross-join = 1 ---> table-ref --> CROSS JOIN --> table-ref ---> join-type = # --+-> INNER ------------------+--> +-> LEFT ---+--> OUTER -----+ +-> RIGHT --+ +-> FULL ---+  correlation-name-clause = B -> AS +------------------------------------+->@ +-> ( -+-> -+-> ) --+8 +-------- , <---------+  order-by-clause = 3 --> ORDER BY -++-> value-expr -++---------+-+-->0 |+-> ----++-> ASC --+ |0 | +-> DESC -+ |0 +------------ , <---------------+  offset-clause = - ---> OFFSET skip-expression -+-> ROW --+-->* +-> ROWS --+ limit-to-clause = P -+> LIMIT TO -+-> limit-expression -+---------------------------+++---------++>O | | +-> OFFSET skip-expression -+|+-> ROW -+|O |  | +-> SKIP skip-expression --+|+-> ROWS -+|O | +-> skip-expression , limit-expression -----------+ |O | |O +> FETCH -+> FIRST -+--+---------------------+--+----------+-> ONLY --------+> +> NEXT --+ +-> limit-expression -+ +-> ROW --+> +-> ROWS -+ optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE +  | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  2 Arguments 3 AS_name; You can, optionally, give a column a name that might not7 otherwise be named using the AS clause. For example: SQL> SELECT JOB_CODE AS JOB,1 cont> MAXIMUM_SALARY - MINIMUM_SALARY AS RANGE cont> FROM JOBS" cont> WHERE JOB_CODE LIKE 'S%';! JOB RANGE! SANL 20000.00! SCTR 15000.00! SPGM 25000.00 3 rows selected< You can use asterisks (*) as wildcards in a select list.> To use delimited identifiers, you must specify the SQL99 orD similar dialect, or use the SET QUOTING RULES statement for these dialects. 3 ASC Syntax options: ASC | DESC< Determines whether the values for sort keys are sorted in! ascending or descending order.= If you do  not specify the sort order for the sort key, the default order is ascending.D If your dialect is set to 'SQLV40' (the default dialect) then the7 sort order is inherited from the preceding sort key. 3 correlation-name-clauseB You can specify a correlation name following a table or a view,A and you must specify a correlation name for a derived table in@ the FROM clause to qualify column names in other parts of theD select expression. If you do not explicitly specify a correlationB name, SQL implicitly specifies the table name or view name as aC correlation name. The same correlation name may not be specified3 more than once, either explicitly or implicitly.C The correlation name may also rename columns when specified withD a derived table. Therefore, the number of columns in the table toD the left of the correlation name must match the number of columns2 specified to the right of the correlation name. 3 CORRESPONDINGD The U NION, EXCEPT, MINUS, and INTERSECT operators can be followedD by the keyword CORRESPONDING. This causes the two select lists ofD the select-merge-clause to be compared by name. Only those columnB names which appear in both lists are retained for the resulting query table.> The name is either the column name, or the name provided by> the AS clause. If there are no names in common, or a column@ name appears more than once in a select list then an error is reported. 3  CROSS_JOINA Combines all rows of the left-specified table reference to all? rows of the right-specified table reference in the result. AD cross join is a Cartesian product between two table references. AA cross join is similar to the basic join expression but without= the WHERE clause. This is also called a Cartesian product.A Following is an example of the basic join expression using the comma-separated syntax: SQL> SELECT * cont> FROM TABLE1, TABLE2;D  Using the CROSS JOIN clause, the previous example would appear as follows: SQL> SELECT *) cont> FROM TABLE1 CROSS JOIN TABLE2; 3 EDIT_USING Syntax options: EDIT USING edit-string EDIT USING domain-nameD Associates an edit string with a value expression. When a domain-@ name is specified, the edit string defined for that domain is> used. This clause overrides any EDIT STRING defined for the= columns or variables in the query. This clause is valid in interactive SQL only. 3 EXCEPT Syntax options: EXCEPT | EXCEPT DISTINCT@ The EXCEPT DISTINCT operator is used to create a result tableD from the first select expression except for those row values that. also occur in the second select expression.< DISTINCT is the default so EXCEPT and EXCEPT DISTINCT are< identical operations. EXCEPT conforms to the ANSI and ISO' SQL:1999 Database Language Standard.& NOTEB EXCEPT is not commutative. That is, A EXCEPT B may result in. a different set of rows from B EXCEPT A. 3 FETCH Syntax options:" FETCH FIRST limit-expression FROM NEXT limit-expressionBThe FETCH FIRST clause allows the database programmer to limit the@results returned from a query expression. The FETCH FIRST clauseBis equivalent to functionality currently supported by the LIMIT TOBclause. FETCH accepts a numeric value expression which may containDar bitrary arithmetic operators, function calls, subselect clauses orDsequence references. The subselect clauses may not reference columnsCin the outer query as it is evaluated before row processing begins.C The FETCH NEXT is identical to FETCH FIRST but allows the syntax> to be more descriptive when coupled with the OFFSET clause.D If no value expression is provided for FETCH it will default to 1 row.? The FETCH clause is not compatible with the LIMIT TO clause.@ The fol lowing example uses the FETCH FIRST to find the oldestA manager in the company. The example uses the DEPARTMENTS tableD to locate the employee id of each manager, and after sorting themC by their birthday, the oldest manager's name and employee id are displayed.) SQL> -- select the most senior manager7 SQL> select e.last_name, e.first_name, e.employee_id( cont> from departments d, employees e+ cont> where d.manager_id = e.employee_id cont> order by e.birthday cont> fetch first row only;1 E.LAST_NAME E.FIRST_NAME E.EMPLOYEE_ID) O'Sullivan Rick 00190 1 row selected SQL> 3 FROM_derived_tableD A derived table is a named virtual table containing data obtained> through the evaluation of the select expression in the FROMC clause. The derived table is named by specifying the correlation name.@ You must specify a correlation name for a derived table. This? may determine which column names th e user can specify in theD select list or subsequent clauses. The select list and subsequentA clauses can reference only the correlation name and the column? names of the derived table and cannot reference the table or/ column names that defined the derived table.A Following is an example of a derived table using the personnelC database. This example finds all departments that have less than# 3 rows in the JOB_HISTORY table. SQL> SELECT */ cont> FROM (SELECT DEPARTMENT_CODE, COUNT(*) cont> FROM JOB_HISTORY$ cont> WHERE JOB_END IS NULL( cont> GROUP BY DEPARTMENT_CODE)- cont> AS DEPT_INFO (D_CODE, D_COUNT) cont> WHERE D_COUNT < 3; D_CODE D_COUNT ENG 2 MCBS 1 MSMG 1 MTEL 2 PERS 2 SUSA 2 6 rows selected 3 FROM_joined_table@ A joined table represents a join between two table references specified in the FROM clause.( There are two types of joined tables:C o Qualified join-syntax contains either an implicit or explicit predicate4 o Cross join-syntax does not contain a predicateB A table can be joined to itself or joined to other tables. WhenA an outer join is specified in the joined-table expression, you? can use the parentheses to explicitly define the join order.A If only inner or cross joins are specified in the joined-table>   expression, the use of parentheses does not affect the join= order. SQL tries all possible join orders to find the mostA efficient order for the query. If outer joins are specified inB the joined-table expression, the join order is determined firstB by any existing parentheses and then by the left-to-right rule.? The table or correlation names specified in the joined-table? expression can be referenced by the outer select expression. 3 FROM_name Syntax options:! FROM table-name FROM view-name@ Identifies the tables and views that SQL uses to generate theC result table. If you name more than one table or view, SQL joins/ them to create an intermediate result table. 3 FULL_OUTER_JOINA Preserves all rows from the left-specified table reference andC all rows from the right-specified table reference in the result.D NULL appears in any column that does not have a matching value in) the corresponding column. For e"xample: SQL> SELECT *+ cont> FROM TABLE1 FULL OUTER JOIN TABLE2" cont> ON TABLE1.C1 = TABLE2.C1;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C40 10 15 10 AA0 NULL NULL 15 BB0 20 25 20 CC2 30 35 NULL NULL 4 rows selectedD You must specify at least one equijoin condition in the ON clauseB of a FULL OUTER JOIN clause. This restr#iction does not apply toC a FULL OUTER JOIN clause with the USING clause or to the NATURAL FULL OUTER JOIN clause.@ An equijoin matches values in columns from one table with theD corresponding values of columns in another table implicitly using an equal (=) sign. 3 GROUP_BY_value-exprC Indicates the value expressions that SQL uses for organizing theD intermediate result table from the WHERE clause, if specified, orB the FROM clause. These groups of rows contain $ing the same value" are also called control breaks.A For the first expression specified in the GROUP BY clause, SQLB orders the rows of the preceding intermediate result table into> groups whose rows all have the same value for the specified? expression. If a second expression is specified in the GROUPC BY clause, SQL then groups rows within each main group by valuesA of the second expression. SQL groups any additional columns in+ the GROUP BY clause in a similar manner.%? All null values for a column name in the GROUP BY clause are grouped together.A Each group is treated as the source for the values of a single row of the result table.@ Because all rows of a group have the same value for the valueA expression specified in the GROUP BY clause, references withinB value expressions or predicates to that column specify a single value. 3 HAVING_predicate: Specifies a predicate that SQL evaluates to generate anB inter &mediate result table. SQL evaluates the predicate for each@ group of the intermediate result table created by a precedingC clause. The groups of that table for which the predicate is trueD become another intermediate result table to which SQL applies the select list for evaluation.: If the clause preceding the HAVING clause is a GROUP BY@ clause, then the predicate is evaluated for each group in theC intermediate result table. The HAVING clause affects groups just/ as the 'WHERE clause affects individual rows.A If the HAVING clause is not preceded by a GROUP BY clause, SQL? evaluates the predicate for all the rows in the intermediate" result table as a single group.C SQL restricts which expressions you can specify in the predicate> of a HAVING clause. A column name or expression in a HAVING5 predicate must meet one of the following criteria:1 o It must also appear in the GROUP BY clause.8 o It must be specified within an aggregate ( function.@ o It must be an outer reference (possible only if the HAVING4 clause is part of a column select expression).= For instance, the following statement is invalid. It has a@ HAVING clause without a GROUP BY clause, which means that any? column names in the HAVING clause must be part of a function? (because there is no outer query, the column names cannot be outer references).3 SQL> SELECT LAST_NAME, FIRST_NAME FROM EMPLOYEES# cont> HAVING FIRST_NAME =) 'Bob';? %SQL-F-NOTGROFLD, Column FIRST_NAME cannot be referred to inL the select list or HAVING clause because it is not in the GROUP BY clause 3 INNER_JOIN= Combines all rows of the left-specified table reference to< matching rows in the right-specified table reference. For example: SQL> SELECT *& cont> FROM TABLE1 INNER JOIN TABLE2! cont> ON TABLE1.C1 = TABLE2.C1" cont> AND C2 BETWEEN 25 AND 35;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C4*0 10 15 10 AA0 20 25 20 CC 2 rows selectedD Both TABLE1 and TABLE2 are exposed in the remainder of the selectD clause and, therefore, can be used to qualify columns from either table reference. SQL> SELECT *& cont> FROM TABLE1 INNER JOIN TABLE2! cont> ON TABLE1.C1 = TABLE2.C1 cont> WHERE TABLE1.C1 = 10;9 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C49 10 15 + 10 AA 1 row selected@ If INNER JOIN is specified in the joined-table expression, itD implies any join ordering of the table references. For example, AB INNER JOIN B INNER JOIN C is equivalent to A INNER JOIN C INNER@ JOIN B. In general, any permutation of table references A, B,D and C in an inner join table expression produces the same result.D Further, SELECT * FROM A INNER JOIN B ON P1 INNER JOIN C ON P2 isB equivalent to the syntax SELECT * FROM A, B,, C WHERE P1 AND P2. 3 INTERSECT Syntax options:! INTERSECT | INTERSECT DISTINCTC The INTERSECT DISTINCT operator is used to create a result tableB from the first select expression for those row values that also) occur in the second select expression.B DISTINCT is the default so INTERSECT and INTERSECT DISTINCT are? identical operations. INTERSECT conforms to the ANSI and ISO' SQL:1999 Database Language Standard.& NOTE -A In general INTERSECT is commutative. That is, A INTERSECT BA results in the same set of rows from B INTERSECT A. This isA demonstrated by the examples below. However, care should be@ taken when using LIMIT TO within the different branches ofB the INTERSECT as this will make the result non deterministic@ because of possible different solution strategies employed by the Rdb optimizer. 3 LEFT_OUTER_JOIN? Preserves all rows in the left-specifie .d table reference and@ matches to rows in the right-specified table reference in theA result. NULL appears in columns where there is no match in the& right-specified table. For example: SQL> SELECT *+ cont> FROM TABLE1 LEFT OUTER JOIN TABLE2" cont> ON TABLE1.C1 = TABLE2.C1;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C40 10 15 10 AA0 20 25 20 CC2 30 35 NULL NU/LL 3 rows selectedD Basically, outer joins are an inner join with a union adding NULLA to all unmatched rows. Notice that the LEFT OUTER JOIN exampleB results are the same as the INNER JOIN example results plus the unmatched row.= The search condition specified in the ON clause is used to; construct the outer join result. In addition to the joinB predicates, you can specify selection predicates and subqueries! in the ON clause. For example: SQL> SELECT *+ 0 cont> FROM TABLE1 LEFT OUTER JOIN TABLE2! cont> ON TABLE1.C1 = TABLE2.C1" cont> AND C2 BETWEEN 25 AND 35;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C42 10 15 NULL NULL0 20 25 20 CC2 30 35 NULL NULL 3 rows selected= A select condition in the ON clause reduces the inner joinD result. The left outer join result contains the inner join resultC plus each row from 1TABLE1 that did not match a row in TABLE2 and was extended with NULL.C In contrast, the result from the following example uses the same1 selection condition but with the WHERE clause: SQL> SELECT *+ cont> FROM TABLE1 LEFT OUTER JOIN TABLE2! cont> ON TABLE1.C1 = TABLE2.C1$ cont> WHERE C2 BETWEEN 25 AND 35;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C40 20 25 20 CC2 30 35 NULL NULL 2 r2ows selected? In the previous example, the left outer join result is firstD constructed using the search condition in the ON clause. Then theD selection condition in the WHERE clause is applied to each row in2 the outer join result to form the final result. 3 LIMIT_TO LIMIT TO limit-expression LIMIT TO skip-expression= The LIMIT TO clause allows you to limit the number of rows> in the result table, or to skip rows returned from a query.< For example 3, the first row in the result set might be the> column headings loaded from a CSV data source loaded by theB RMU/LOAD/RECORD=FORMAT=DELIMITED command that should be ignored by queries.B If either limit-expression or skip-expression is specified as aD numeric literal, then it must be an unscaled value. These numericB expressions are converted to BIGINT before executing the query.= Neither limit-expression nor skip-expression can reference> columns from the select-expressio 4n in which they occur. You? can use only columns of a subselect specified for the limit-D expression or skip-expression. The example in this section uses a$ subselect in the LIMIT TO clause.& NOTE; Oracle recommends that the values specified for skip-; expression be kept small for performance reasons. The@ skipped rows are still fetched and processed by the query;4 they are just not returned to the application.@ If limit-ex 5pression is evaluated to a negative value or zero,< then no rows are returned from the query, and no error is reported.D If skip-expression is evaluated to a negative value or zero, thenA no rows are skipped. If the skip-expression is larger than theD rows in the result set, then no rows are returned from the query,C and no error is reported. The following examples show the use of the LIMIT TO ... SKIP syntax.B This query returns the 100th employee from the EMPLOYEES ta6ble:1 SQL> select last_name, first_name, employee_id cont> from employees cont> order by employee_id! cont> limit to 1 skip 99 rows;- LAST_NAME FIRST_NAME EMPLOYEE_ID' Herbener James 00471 1 row selectedC To retrieve the last row in the sorted list, you can replace theD literal value with a subselect that calculates the value as shownB in the following example. This query also shows the output from0 the SET FLAGS command for the7 query strategy.$ SQL> set flags 'strategy,detail';1 SQL> select last_name, first_name, employee_id cont> from employees cont> order by employee_id cont> limit to 16 cont> skip (select count(*)-1 from employees) rows; Tables: 0 = EMPLOYEES 1 = EMPLOYEES Cross block of 2 entries Cross block entry 1 Aggregate: 0:COUNT (*)3 Index only retrieval of relation 1:EMPLOYEES* Index name EMP_EMPLOYEE_ID [0:0] Cross block entry8 2 Firstn: 1 Skipn: - 19 Get Retrieval by index of relation 0:EMPLOYEES* Index name EMP_EMPLOYEE_ID [0:0]- LAST_NAME FIRST_NAME EMPLOYEE_ID' Herbener James 00471 1 row selected SQL>B An alternative to this query would be to use ORDER ... DESC and$ then to use a LIMIT 1 ROW clause.2 This query finds the statistical median salary:# SQL> -- select the median salary SQL> select salary_amount 9 cont> from salary_history! cont> where salary_end is NULL cont> order by salary_amount cont> limit to 1 cont> skip (select count(*)/2" cont> from salary_history) cont> where salary_end is NULL); SALARY_AMOUNT $24,166.00 1 row selected SQL>7 This result can be compared with the average salary:8 SQL> -- select the median salary compare with average. SQL> select salary_amount as median_salary,+ cont> (select avg (salar:y_amount)$ cont> from salary_historyJ cont> where salary_end is NULL) as avg_salary edit using SALARY cont> from salary_history! cont> where salary_end is NULL cont> order by salary_amount cont> limit to 1 cont> skip (select count(*)/2" cont> from salary_history) cont> where salary_end is NULL); MEDIAN_SALARY AVG_SALARY $24,166.00 $31,922.79 1 row selected SQL> 3 MINUSC The MINUS operator is a s;ynonym for the EXCEPT DISTINCT operatorC and is provided for language compatibility with the Oracle RDBMS SQL language. 3 NATURAL_JOINB Performs an equijoin operation on the matching named columns ofC the specified tables. An equijoin matches values in columns from@ one table with the corresponding values of columns in another- table implicitly using an equal (=) sign.> A NATURAL JOIN implicitly performs the following functions:A o Coalesces the common col <umns to condense the columns into aA single column and, therefore, you cannot qualify the common column= o Performs an equijoin using common columns between table references? You cannot specify an explicit join condition if the NATURALB keyword is specified in the query. Following is an example of aD natural join. Note the common column C1 is only shown once. OtherC types of join conditions return the common column as often as it$ occurs in the table's r=eferences. SQL> SELECT *4 cont> FROM TABLE1 NATURAL LEFT OUTER JOIN TABLE2;) C1 TABLE1.C2 TABLE2.C4) 10 15 AA) 20 25 CC) 30 35 NULL 3 rows selectedC The complexity of what the NATURAL LEFT OUTER JOIN is implicitly> executing in the previous example is shown in the following example: SQL> SELECT1 cont> COALESCE (TABLE1.C1, TABLE2.C1) AS C1, c>ont> TABLE1.C2, TABLE2.C4+ cont> FROM TABLE1 LEFT OUTER JOIN TABLE2" cont> ON TABLE1.C1 = TABLE2.C1;) C1 TABLE1.C2 TABLE2.C4) 10 15 AA) 20 25 CC) 30 35 NULL 3 rows selectedD The NATURAL keyword can be specified for INNER, LEFT OUTER, RIGHT OUTER, and FULL OUTER joins.@ A natural join between two table references that do not share9 matching named column?s results in a Cartesian product. 3 OFFSET< The OFFSET clause allows the database programmer to start@ fetching the result rows from the specified offset within theD result table. OFFSET accepts a numeric value expression which mayD contain arbitrary arithmetic operators, function calls, subselect@ clauses or sequence references. The subselect clauses may notA reference columns in the outer query as it is evaluated before row processing begins.: The OFFSET clau @se is equivalent in functionality to the> SKIP clause currently supported by the LIMIT TO clause. TheC distinction is that OFFSET can be specified without a row limit.@ This following query uses a subselect in the OFFSET clause to7 locate the median (or middle) row of the sorted set.G SQL> select e.last_name, e.first_name, employee_id, sh.salary_amountJ cont> from salary_history sh inner join employees e using (employee_id)$ cont> where sh.salary_end is null" cont> orderA by sh.salary_amount cont> offset (select count(*)$ cont> from salary_history1 cont> where salary_end is null)/2 rows cont> fetch next row only;B E.LAST_NAME E.FIRST_NAME EMPLOYEE_ID SH.SALARY_AMOUNTB Boyd Ann 00244 $24,166.00 1 row selected SQL> 3 ON_predicate? Specifies a search condition on which the join is based. TheA predicate can have columns from the two operands mentioned, or0 B have outer references if it is in a subquery. 3 OPTIMIZE_AS_query_nameC Assigns a name to the query. You can define the RDMS$DEBUG_FLAGS@ logical name or use SET FLAGS with the option STRATEGY to seeC the access methods used to produce the results of the query. The= following example shows how to use the OPTIMIZE AS clause: SQL> DELETE FROM EMPLOYEES E cont> WHERE EXISTS ( SELECT */ cont> FROM SALARY_HISTORY S< cont> WHERE SC.EMPLOYEE_ID = E.EMPLOYEE_ID7 cont> AND S.SALARY_AMOUNT > 75000)" cont> OPTIMIZE AS DEL_EMPLOYEE;' Leaf#01 FFirst RDB$RELATIONS Card=19 . . . ~Query Name : DEL_EMPLOYEE . . . 7 rows deleted 3 OPTIMIZE_FORA Specifies the preferred optimizer strategy for statements thatD specify a select expression. The following options are available: o FAST FIRSTB A query optimized for FAST FIRST ret Durns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optimization. A good candidate for FAST FIRST> optimization is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST optimizatiEon.D If the optimization level is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records inD the query, and performs updates or writes a report, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization.A The following examples illustrate the DECLARE CURSOR syntax0 for setting a preferred optimization mode:% SQL> DECLARE TEMP1 TFABLE CURSOR cont> FOR cont> SELECT * cont> FROM EMPLOYEES, cont> WHERE EMPLOYEE_ID > '00400'% cont> OPTIMIZE FOR FAST FIRST; SQL> --% SQL> DECLARE TEMP2 TABLE CURSOR cont> FOR+ cont> SELECT LAST_NAME, FIRST_NAME cont> FROM EMPLOYEES% cont> ORDER BY LAST_NAME% cont> OPTIMIZE FOR TOTAL TIME; o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly G: valuable for tables that use the strict partitioning functionality.D When the storage map of a table has the attribute PARTITIONING@ IS NOT UPDATABLE, the mapping of data to a storage area is> strictly enforced. This is known as strict partitioning.< When queries on such tables use sequential access, the? optimizer can eliminate partitions which do not match the9 WHERE restriction rather than scan every partition.D The following example sh Hows a query that deletes selected rowsA from a specific partition. This table also includes severalC indexes, which may be chosen by the optimizer. Therefore, the/ OPTIMIZE clause forces sequential access. SQL> delete from PARTS_LOG2 cont> where parts_id between 10000 and 20000+ cont> and expire_date < :purge_date+ cont> optimize for sequential access;< Note that all access performed by such queries will beA sequential. Care should be tIaken that the I/O being used isA acceptable by comparing similar queries using index access. 3 OPTIMIZE_USING_outline_name@ Explicitly names the query outline to be used with the selectB expression even if the outline ID for the select expression and! for the outline are different.? The following example is the query used to create an outline named WOMENS_DEGREES:Q SQL> SELECT E.LAST_NAME, E.EMPLOYEE_ID, D.DEGREE, D.DEGREE_FIELD, D.YEAR_GIVEN6 cont> FROM JEMPLOYEES E, DEGREES D WHERE E.SEX = 'F'* cont> AND E.EMPLOYEE_ID = D.EMPLOYEE_ID cont> ORDER BY LAST_NAME@ By using the OPTIMIZE USING clause and specifying the WOMENS_B DEGREES outline, you can ensure that Oracle Rdb attempts to useB the WOMENS_DEGREES outline to execute a query even if the query; is slightly different as shown in the following example:Q SQL> SELECT E.LAST_NAME, E.EMPLOYEE_ID, D.DEGREE, D.DEGREE_FIELD, D.YEAR_GIVEN6 cont> FROM EMPLOYEES E, DEGREES D W KHERE E.SEX = 'F'* cont> AND E.EMPLOYEE_ID = D.EMPLOYEE_ID cont> ORDER BY LAST_NAME cont> LIMIT TO 10 ROWS' cont> OPTIMIZE USING WOMENS_DEGREES;Q ~S: Outline WOMENS_DEGREES used <-- the query uses the WOMENS_DEGREES outline . . .N E.LAST_NAME E.EMPLOYEE_ID D.DEGREE D.DEGREE_FIELD D.YEAR_GIVENN Boyd 00244 MA Elect. Engrg. 1982N Boyd 00244 PhD Applied Math L 1979N Brown 00287 BA Arts 1982N Brown 00287 MA Applied Math 1979N Clarke 00188 BA Arts 1983N Clarke 00188 MA Applied Math 1976N Clarke 00196 BA Arts 1978N Clinton 00235 MA Applied Math 1975N Clinton M 00201 BA Arts 1973N Clinton 00201 MA Applied Math 1978 10 rows selectedD See the CREATE OUTLINE statement for more information on creating an outline. 3 OPTIMIZE_WITHB Selects one of three optimization controls: DEFAULT (as used by@ previous versions of Oracle Rdb), AGGRESSIVE (assumes smaller= numbers of rows will be selected), and SAMPLED (which uses= literals in the query to Nperform preliminary estimation on indices). 3 ORDER_BY Syntax options: ORDER BY integer ORDER BY value-expr> Specifies the order of rows for the result table. SQL sorts? the rows from the intermediate result table by the values ofA expressions specified in the ORDER BY clause. The intermediateB result table is the result table SQL produces when it evaluatesC the preceding clause in the select expression (HAVING, GROUP BY, WHERE, or FROM).O? You can refer to columns in the ORDER BY clause in two ways: o By a value expressionC o By column number, where the integer you specify indicates the> left-to-right position of the column in the result table? You must use an integer to identify a column in the ORDER BY= clause if that column in the select list is derived from a@ function, an arithmetic expression, or the result of a UNION,( MINUS, EXCEPT, or INTERSECT operator.A Whether you identify expr Pessions in an ORDER BY clause using a@ name or using a number, the expressions are called sort keys.C When you use multiple sort keys, SQL treats the first expression@ as the major sort key and successive keys as minor sort keys.B That is, it first sorts the rows into groups based on the firstA value expression. Then, it uses the second value expression toA sort the rows within each group, and so on. Unless you specify= a sort key for every column in the result table, rows w Qith> identical values for the last sort key specified will be in arbitrary order.C The following example illustrates using the ORDER BY clause with a value expression. SQL> SELECT * FROM EMPLOYEES/ cont> ORDER BY EXTRACT (YEAR FROM BIRTHDAY),. cont> TRIM(FIRST_NAME) || TRIM(LAST_NAME);2 00190 O'Sullivan Rick G.E 78 Mason Rd. NULL FremontF NH 03044 M 12-Jan-1923 1 R None4 00231 Clairmont Rick NULLF 92 Madiso7 Drive NULL ChocoruaF NH 03817 M 23-Dec-1924 2 None2 00183 Nash Walter V.E 197 Lantern Lane NULL FremontF NH 03044 M 19-Jan-1925 1 None4 00177 Kinmonth Louis NULLB 76 Maple St. NULL S EtnaF NH 03750 M 7-Apr-1926 1 None2 00240 Johnson Bill R.E 20 South St NULL MilfordF NH 03055 M 13-Apr-1927 2 None . . . 3 qualified-joinC Qualifies and alters the result returned from the joined tables.. There are several types of qualified joins: o INNER JOIN o LEFT OUTER JTOIN o RIGHT OUTER JOIN o FULL OUTER JOIN o NATURAL JOINC For an INNER and OUTER JOIN, the result table is the combinationD of all columns of the first table reference to all the columns inC the second table reference. For a NATURAL JOIN, the result tableA condenses common columns (that is, columns with the same name) between the table references. 3 RIGHT_OUTER_JOIN@ Preserves all rows of the right-specified table reference and? matches to roUws in the left-specified table reference in theA result. NULL appears in columns where there is no match in the/ left-specified table reference. For example: SQL> SELECT *, cont> FROM TABLE1 RIGHT OUTER JOIN TABLE2" cont> ON TABLE1.C1 = TABLE2.C1;7 TABLE1.C1 TABLE1.C2 TABLE2.C1 TABLE2.C40 10 15 10 AA0 NULL NULL 15 BB0 20 25 20 CC 3 rows selectedD Not Vice that the FULL OUTER JOIN example result is the same as theD INNER JOIN example result plus the unmatched rows from TABLE1 and unmatched rows from TABLE2. 3 SELECT_*_(wildcard_character)@ Tells SQL to use all the column results from the intermediateD result table (namely, all the columns in all the table references< referred to in the FROM clause). If the select expressionB contains a GROUP BY clause, SQL interprets the wildcard (*) as: specifying only the expressioWns in the GROUP BY clause. 3 SELECT_ALLB Specifies that duplicate rows should not be eliminated from the$ result table. ALL is the default. 3 SELECT_DISTINCT> Specifies that SQL should eliminate duplicate rows from the result table. 3 SELECT_name.*D Tells SQL to use all the columns in the table references referredA to by the table name, view name, or correlation name. The nameA must be specified in the FROM clause of the select expression.? YouX cannot mix this form of wildcard notation with SELECT *.B The number of columns you specify in the select list, either byA using wildcards or by explicitly listing value expressions, is0 the number of columns in the result table. In 3 select-listA Identifies a list of value expressions (to be derived from theB table references named in the FROM clause) for the final result table. 3 UNION Syntax options: UNION | UNION DISTINCT@ Merges the re Ysults of a select expression with another select> expression into one result table by appending the values ofC columns in one table with the values of columns in other tables.< The following example extracts the EMPLOYEE_ID of current@ employees with a salary greater than $50,000 and with a Ph.D.7 Duplicate rows are eliminated from the result table: SQL> SELECT EMPLOYEE_ID cont> FROM CURRENT_SALARY& cont> WHERE SALARY_AMOUNT > 50000 cont> UNION cont> SELECZT EMPLOYEE_ID cont> FROM DEGREES" cont> WHERE DEGREE = 'PhD'; EMPLOYEE_ID 00164 00166 00168 00169 00172 00182 . . . 00418 00435 00471 38 rows selected 3 UNION_ALLB Specifies that duplicate rows should not be eliminated from theA result table. By default, the UNION operator removes duplicate rows.? The following example returns duplicate rows from the result table:[E SQL> SELECT LAST_NAME, SEX FROM EMPLOYEES WHERE LAST_NAME = 'Nash' cont> UNION ALLK cont> SELECT LAST_NAME, SEX FROM EMPLOYEES WHERE LAST_NAME = 'Lapointe'; LAST_NAME SEX Nash M Nash M Lapointe F Lapointe F 4 rows selected 3 USINGA Specifies the columns on which the join is based. Column names< must be defined in both table references specified in theA qualified join. The USING clause implies \an equijoin conditionB between columns of the same name and creates a common column in the result. SQL> SELECT *+ cont> FROM TABLE1 LEFT OUTER JOIN TABLE2 cont> USING (C1);) C1 TABLE1.C2 TABLE2.C4) 10 15 AA) 20 25 CC) 30 35 NULL 3 rows selected? The common columns are coalesced into a single column in theD result in the previous example. Therefore, ]such columns cannot beD qualified. You can reference the coalesced column in a query. For example: SQL> SELECT *+ cont> FROM TABLE1 LEFT OUTER JOIN TABLE2 cont> USING (C1)$ cont> WHERE C1 BETWEEN 20 AND 30;) C1 TABLE1.C2 TABLE2.C4) 20 25 CC) 30 35 NULL 2 rows selected 3 WHERE_predicate: Specifies a predicate that SQL evaluates to generate anB intermediate result table. SQ^L evaluates the predicate for eachC row of the intermediate result table created by the FROM clause.@ The rows of that table for which the predicate is true becomeB another intermediate result table for later clauses in a select expression.C Column names specified in the predicate of the WHERE clause must either:B o Identify columns of the intermediate result table created by the FROM clause.A o Be an outer reference (possible only if the WHERE clause isC _ part of a column select expression). See Outer_References for+ more information on outer references.A In general, the predicate in a WHERE clause cannot refer to an? aggregate function. For instance, the following statement is invalid:; SQL> SELECT * FROM EMPLOYEES WHERE MAX(LAST_NAME) > 'X';/ %SQL-F-INVFUNREF, Invalid function reference ww7b1 Column_Select_ExpressionsC A column select expression is a select expression that specifie `s9 a one-column result table in one row and can be nested? within predicates and (if they specify a single value) valueB expressions. Column select expressions cannot specify a list ofA select items. You can only specify one value in a select list.@ Column select expressions are also called scalar expressions.? SQL accepts column select expressions as arguments to IN andB quantified predicates, and more generally as value expressions.A o As arguments to IN and quant aified predicates, column select= expressions specify a collection of values to which SQL; compares a value expression. Therefore, column selectA expressions as arguments to those predicates can return one or more values.> o As a type of value expression, column select expressionsC specify a single value. Therefore, a column select expression@ used as a value expression should not return more than one; value. If it does, SQL generates the followingb error:F %RDB-E-MULTIPLE_MATCH, record selection criteria should identifyH only one record; more than one record found> If a column select expression used as a value expressionD returns zero rows, SQL evaluates the value expression as null.A The data type of a column select expression used as a valueB expression is the same as the data type of the column select expression's select item. 2 EnvironmentA You can use colcumn select expressions in interactive SQL or in host language programs. 2 Format col-select-expr =  ---> select-expr ------->  select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-d> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ 2 Arguments 3 select-exprD A column select expression is a select expression specifying only@ one value in the select list. See Select_Expressions for more information. ww7b1 Context_StructuresB A distributed transaction groups more than one database or moreC than one database attachment together into one transaction, evenC if the databases are located on different n eodes. The Oracle Rdb7C Guide to Distributed Transactions explains how to use Oracle Rdb! with distributed transactions.< The two-phase commit protocol coordinates the activity of> participants in a transaction to ensure that every requiredA operation is completed before a transaction is made permanent,8 even if the transaction is a distributed transaction.< You can use the two-phase commit protocol when the DECdtm? transaction manager software is installed and started o fn all> nodes that are in the transaction. Use the two-phase commitC protocol when your application starts a distributed transaction.C When you declare a context structure in an application, you mustA associate it with most executable SQL statements. This is trueC whether you use SQL module language or precompiled SQL, althoughA the method you use to associate the context structure with SQL? statements differs depending upon which compiler you choose.= However, you cagnnot associate a context structure with the1 following categories of executable statements:> o Statements that you cannot execute when a transaction is already started: o Statements that do not execute within the scope of a@ transaction and are independent of any transaction context> o Statements that you cannot use in transactions that were: started by explicit calls to the transaction manager; You must use the USING CONTEXT clause to specify that an? h embedded SQL statement is part of a distributed transaction.A For more information about using embedded SQL with distributed= transactions, see the Oracle Rdb SQL Reference Manual. You@ must use the CONTEXT clause in a module language procedure toB make SQL execute your procedure in the context of a distributedD transaction. For more information about using SQL module languageB with distributed transactions, see the Oracle Rdb SQL Reference Manual.D The following restriictions apply when passing context structures:> o You cannot pass a context structure to the following SQLC statements because you cannot execute them when a transaction is already started: - ALTER DATABASE - CREATE DATABASE - DROP PATHNAME - DROP DATABASE> o You cannot pass a context structure to the following SQL@ statements because they do not execute within the scope of@ a transaction, and they are independent of any t"jransaction context: - CONNECT - DESCRIBE - DISCONNECT( - Extended Dynamic DECLARE CURSOR - RELEASE - SET CATALOG - SET CHARACTER LENGTH - SET CONNECT" - SET DEFAULT CHARACTER SET - SET DEFAULT DATE FORMAT - SET DIALECT% - SET IDENTIFIER CHARACTER SET - SET KEYWORD RULES" - SET LITERAL CHARACTER SET - SET NAMES# - SET NATIONAL CHARACTER SEkT - SET OPTIMIZATION LEVEL - SET QUOTING RULES - SET SCHEMA - SET VIEW UPDATE RULES> o You cannot pass a context structure to the following SQLA statements because they have been started by explicit calls! to the transaction manager: - COMMIT - ROLLBACKB (The DISCONNECT statement can be considered in this category( as well as the previous category.)> Remember that you cannot associate a context stru lcture with< nonexecutable SQL statements. Moreover, you cannot pass aD context structure to a multistatement procedure if that procedure= contains a SET TRANSACTION, COMMIT, or ROLLBACK statement. ww7b1 Database_Options< By default, the SQL module language processor, or the SQLB precompiler determines the type of database it attaches to fromA the type of database specified in compiling the program. If noD database is used to compile the program, the mprogram is processed@ for a database created with the most recent version of Oracle Rdb.A Specifying the database options in the DECLARE ALIAS statementA overrides the default established in the precompiler or module processor command lines.A The following table shows the database options for interactive> SQL, SQL module language processor, and SQL precompiler for OpenVMS. Table 9 Database Options SQL Module and Precompiler ExplanationB n RDBVMS Accesses a database created with the most recent( version of Oracle Rdb.< RDB030 Accesses Oracle Rdb Version 3.0 databases.< RDB031 Accesses Oracle Rdb Version 3.1 databases.< RDB040 Accesses Oracle Rdb Version 4.0 databases.< RDB041 Accesses Oracle Rdb Version 4.1 databases.< RDB042 Accesses Oracle Rdb Version 4.2 databases.< RDB050 Accesses Oracle Rdb Version 5.0 databases.< RDB051 Access oes Oracle Rdb Version 5.1 databases.C In most cases, it is not necessary to specify a database option.< For example, when you attach to an Oracle Rdb Version 7.0, database, SQL provides the V7.0 features.C However, you need to specify a database option when the databaseC you attach to during compilation or precompilation has differentB features than the database against which the program is to run.? You must specify a database option that provides the "lowestA common de pnominator" of features for all the databases that the& program intends to use at run time.@ If no database is used during compilation of the program, theC program is processed for a database created with the most recent@ version of Oracle Rdb. Therefore, if the resulting program is@ intended to run against a database other than the most recent> version of Oracle Rdb, you must specify that version of the& database option during compilation.B You can use any of the qualifieqrs listed in Database Options to( override the default database option. ww7b1 Context_FilesA You can use SQL context files with SQL module language just asB you can use them with precompiled SQL. A context file is an SQLC command procedure containing DECLARE statements that you want toD apply when your program compiles and executes. Context files help4 improve the portability of compiled source files.D The format of a context file used with SQL modu rle language is theC same as the one used for precompiled SQL, with one exception. ItB is not necessary to end the DECLARE statements with a semicolon= (;) when you use a context file with SQL module language.A However, if you include the semicolon, you can use the contextD file with both module and precompiled SQL. When you use a context> file, enter it as the second parameter on the command line.A Suppose an application contains a module that must be compiled> using dif sferent SQL dialects. Rather than having two copiesA of the module and the problem of maintaining them in parallel,< you can have one module and two context files. The moduleD contains all the code, and each context file contains the dialect> declaration statement. For example, assume that you need toB compile the module TEST using two different dialects: SQL92 and+ MIA. You might create two context files:@ o The context file TEST-SQL92 contains the following DECLARE MOtDULE statements: DECLARE MODULE DIALECT SQL92> o The context file TEST-MIA contains the following DECLARE MODULE statements: DECLARE MODULE DIALECT MIA? You can control the dialect you want to use by compiling the, module with the appropriate context file:A o For TEST to use the SQL92 semantics, compile TEST using theA TEST-SQL92 context file. The following example shows how to$ compile the module on OpenVMS: $ SQL$MOuD SQL$MOD> TEST TEST-SQL92@ o For TEST to use the MIA semantics, compile the module TESTB using the TEST-MIA context file. The following example shows+ how to compile the module on OpenVMS: $ SQL$MOD SQL$MOD> TEST TEST-MIA ww7b 1 RoutinesDAll the routines described here can be called from any host language<program that calls an SQL module or from any SQL precompiled<program. These routines cannot be called from an SQL module.&v NOTE7 SQL defines all routines in uppercase on OpenVMS.? Application programs must adhere to the rules about case-= sensitivity of the language compiler to ensure that the+ programs call the routines correctly. 2 sql_close_cursors 3 Format sql_close_cursors () 3 Returns No value returned. 3 Arguments None. 3 Description9 The sql_close_cursors routine closes all open cursors. w3 Related_Routines None. 2 sql_deregister_error_handler6 Deregisters an application's error handling routine 3 Format" sql_deregister_error_handler () 3 Returns No value returned. 3 Arguments None. 3 Description; The sql_deregister_error_handler routine deregisters the= application's currently registered error handling routine.< When you deregister a routine, SQL discontinues using theA application's currently registexred error handling routine. The; standard error handling mechanisms are always in effect. 3 Related_Routines o sql_get_error_handler o sql_register_error_handler 2 sql_get_error_handlerC Gets the address of the application's currently registered error> handling routine and the address of the user-specified data 3 Format8 sql_get_error_handler (user-error-routine, user-data) 3 Returns No value returned. 3 Arguments 4 y user-error-routine9 The address of an application's error handling routineD Value: Address of an application's error handling routine Data type: Longword Passing By reference mechanism: 4 user-data) The address of the user-specified data4 Value: Address of the user-specified data Data type: Longword Passing By reference mechanism: 3 Description< The sql_get_error_handler routine gets the address zof the@ application's currently registered error handling routine and* the address of the user-specified data.> An application can use the sql_get_error_handler routine to@ get the address of the currently registered routine and user-D specified data. The application can store the values in variables for use later in the program. 3 Related_Routines o sql_register_error_handler" o sql_deregister_error_handler 2 sql$get_error_text@ Passes error text{ with formatted ASCII output to programs for processing 3 Format( sql$get_error_text (buf [,errmsglen]) 3 Returns> The status code that results from the copy operation of the& vector's text to the user's buffer. 3 Arguments 4 buf* The buffer declared to receive the textD Value: Address of the buffer declared to receive the text" Data type: Character string Passing By descriptor mechanism: 4 errmsglenA| The number of characters allotted for the error messages to be( returned. This parameter is optional.= Value: Number of characters allotted for the error messages Data type: Word Passing By reference mechanism: 3 DescriptionA Use the sql$get_error_text routine when you want to pass error? text with formatted ASCII output (FAO) substitutions to your program for processing.C To use the sql$get_error_text routine, yo}u must include a bufferD (field) in your program declarations to receive the text SQL will@ pass to it. Declare this field as a text string with a length@ sufficient to accommodate the number of characters you expectB for the message associated with the RDB$LU_STATUS value and forC all follow-on messages. As an option, you can declare the buffer9 length as a separate field (defined as a signed word). 3 Related_Routines o sql_get_error_text 2 sql_get_error_t~ext@ Passes error text with formatted ASCII output to programs for processing. 3 Format+ sql_get_error_text (buf, len, errmsglen) 3 Returns> The status code that results from the copy operation of the& vector's text to the user's buffer. 3 Arguments 4 buf+ The buffer declared to receive the text.D Value: Address of the buffer declared to receive the text" Data type: Character string Passing By reference mechanism: 4 len9 The length of the buffer declared to receive the text.B Value: The length of the character string pointed to by% the first parameter Data type: Longword Passing By value mechanism: 4 errmsglenA The number of characters allotted for the error messages to be returned.= Value: Number of characters allotted for the error messages Data type: Longword Passing  By reference mechanism: 3 DescriptionA Use the sql_get_error_text routine when you want to pass error? text with formatted ASCII output (FAO) substitutions to your program for processing.C To use the sql_get_error_text routine, you must include a bufferD (field) in your program declarations to receive the text SQL will@ pass to it. Declare this field as a text string with a lengthD sufficient to accommodate the number of characters you expect forB the mes sage associated with the RDB$LU_STATUS value and for all follow-on messages. 3 Related_Routines o sql$get_error_text 2 sql_get_message_vectorD Retrieves information from the message vector about the status of the last SQL statement. 3 Format' sql_get_message_vector (addr, index) 3 Returns No value returned. 3 Arguments 4 addr@ Address of a variable into which the requested vector element will be written.A Value: Address of the variable declared to receive the vector element# Data type: longword (32 bit) Passing By reference mechanism: 4 index3 The index value of the vector element to return.B Value: A value greater than or equal to 1 and less than or equal to 20# Data type: Unsigned longword Passing By value mechanism:A The following table shows the index values and how they map to? vector elements and the information contained in each vector element. Index Value Information Returned* 1 Number of arguments in the vector6 2 Primary status code of the last SQL statement3 3 Number of FAO arguments to primary message5 4-20 Return status for follow-on messages, if any 3 DescriptionA Use the sql_get_message_vector routine to retrieve informationD from the RDB$MESSAGE_VECTOR array. The array provides informationD a bout the execution status of SQL statements. Index 2 of the sql_@ get_message_vector routine returns the primary status code ofB the last SQL statement. This index is comparable to the SQLCODE status parameter.B The ANSI/ISO SQL standard does not include the sql_get_message_B vector routine or the RDB$MESSAGE_VECTOR array. For application= programs that comply with the standard, use the SQLCODE or= SQLSTATE status parameters. Furthermore, the status valuesD returned for a particular condition may change in future versions of Oracle Rdb.> The status values that are stored in the message vector areD intended to be supplementary information to the status parametersB SQLCODE and SQLSTATE. Use the sql_get_message_vector routine ifC the information provided by SQLCODE or SQLSTATE is ambiguous andB your application needs a more specific error code to handle the error condition.A Relationship Between sql_message_vector and RDB$MESSAGE_VECTOR>  shows the relationship between the indexes returned by sql_7 message_vector and the fields in RDB$MESSAGE_VECTOR.8 Table 1-1 Relationship Between sql_message_vector and RDB$MESSAGE_VECTOR sql_message_vector8 Indexes RDB$MESSAGE_VECTOR Fields3 Index 1 RDB$LU_NUM_ARGUMENTS, Index 2 RDB$LU_STATUS/ Index 3 RDB$LU_ARGUMENTSD Index 4-20 Return status for follow-on messages,% if any 3 Related_Routines None. 2 sql_register_error_handlerB Registers an application's error handling routines with the SQL precompiler. 3 Format= sql_register_error_handler (user-error-routine, user-data) 3 Returns No value returned. 3 Arguments 4 user-error-routine9 The address of an application's error handling routineD Value: Address of an application's error handling routine Data type: Address Passing By value mechanism: 4 user-data) The address of the user-specified data4 Value: Address of the user-specified data Data type: Address Passing By value mechanism: 3 Description7 The sql_register_error_handler routine registers the: application's error handling routine with SQL. When SQLC determines that it will return a negative value for SQLCODE, SQLA calls  the error handling routine that is currently registered.= The standard error handling routines are always in effect,B whether special error handling routines have been registered orB not. After the error handling routine executes, control returns to SQL.C An application can contain and call more than one error handling> routine. However, only one routine can be active at a time.D An application can use the sql_get_error_handler routine to storeD the address of a registered routine for use later in the program.@ To deregister a routine, use the sql_deregister_error_handler routine.A For information about declaring the error handling routines inC the supported programming languages, see the Oracle Rdb Guide to SQL Programming. 3 Related_Routines" o sql_deregister_error_handler o sql_get_error_handler 2 sql_signal 3 Format sql_signal () 3 Returns No value returned. 3 Arguments None. 3 DescriptionC The sql_signal routine signals to your program condition handler@ an error that occurs on the execution of an SQL statement. If> your program does not contain a condition handler, the sql_@ routine prints an error message and exits the program when an error occurs.= If the host language compiler does not provide a signaling: mechanism, you must provide your own condition handler. 3 Related_Routines None. wwW 1 ACCEPTC Prompts the user for additional information. This information isC stored in an interactive SQL variable, which can subsequently be' used by DML and some SET statements. 2 Environment7 You can use the ACCEPT statement in interactive SQL. 2 FormatB ACCEPT --> -+-+------------------------------+-+->@ | +-> DEFAULT ---+ |@ | +-> HIDE ----------------------+ |@  | +-> PROMPT ---+ |@ | +-> NOPROMPT ------------------+ |@ | +-> TIMEOUT -+ |@ | +-> UPPER ---------------------+ |@ +-------------- <------------------+  variable-ref = ? --+-----+---> identifier -+--------------------------------+->= +> : -+ +-+-------------+-> : identifier +,  +> INDICATOR -+ 2 Arguments 3 DEFAULT_default-value> Provides a default value to be used if the user presses the> Return key. The default value must be a correctly formattedA character string that can be converted to the data type of the variable. 3 HIDED Disables echo of the input text. The default is to echo all input characters. 3 PROMPT_string-literal> Provides a prompt string that is displayed before accepting input. 3 NOPROMPT$ Disables prompting with a string. 3 TIMEOUT_numeric-literalA If the user does not respond within this many seconds, then anD error is returned. Negative or zero values of the numeric-literal4 are ignored. The default is to wait indefinitely. 3 UPPER= All lowercase characters are converted to uppercase before@ assignment to the variable. The default is to leave lowercase characters unchanged. 3 variable-refA An interactive SQL variable defined using the DECLARE Variable statement. 2 Examples@ Example 1: Prompting Based on the PROMPT and NOPROMPT Clauses SQL> DECLARE :x INTEGER; SQL> DECLARE :y INTEGER; SQL>5 SQL> ACCEPT :x indicator :y PROMPT 'what value? '; what value? 10 SQL> PRINT :x, :y; X Y 10 0 SQL>( SQL> ACCEPT :x INDICATOR :y NOPROMPT; 11 SQL> PRINT :x, :y; X Y 11 0 SQL> SQL> ACCEPT :x; Enter value for X: 12 SQL> PRINT :x; X 12 SQL>9 Example 2: Using ACCEPT to Prompt for SET FLAGS String/ This sequence would be included in a script.& SQL> DECLARE :debug_flags CHAR(20); SQL> ACCEPT :debug_flags;% Enter value for DEBUG_FLAGS: trace SQL> PRINT :debug_flags; DEBUG_FLAGS trace SQL> SET FLAGS :debug_flags; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:% PREFIX,TRACE,MAX_RECURSION(100) wwW1 ALTER 2 CONSTRAINT Alters a constraint. 3 Environment. You can use the ALTER CONSTRAINT statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format. ALTER CONSTRAINT ---------+. +---------------------------------------+; +--+--+--> COMMENT IS +-> '' -+--+--+-->8 | | +------- / <----------+ | |8 | +--> constraint-attributes --------------+ |8 | +--> RENAME TO ----+ |8 +-------------------- <------------------------+ constraint-attributes = B -+-> DEFERRABLE -------------+------------------------------+-+->@ |  +-> INITIALLY +-> IMMEDIATE --++ |@ | +-> DEFERRED ---+ |@ +-> NOT DEFERRABLE ---------+-------------------------+------+@ | +-> INITIALLY IMMEDIATE --+ |@ +-> INITIALLY IMMEDIATE ----+-------------------+------------+@ | +-> DEFERRABLE -----+ |@ | +-> NOT DEFERRABLE -+ |@ +-> INITIALLY DEFERRED -----+-------------------+------------+3 +-> DEFERRABLE -----+ 3 Arguments 4 COMMENT_ISD Adds a comment about the constraint. SQL displays the text of theA comment when it executes a SHOW CONSTRAINTS statement. EncloseC the comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 constraint-attributes! See the ALTER TABLE statement. 4 constraint-name= The name of the table whose definition you want to change. 4 RENAME_TO@ Changes the name of the constraint being altered. See the theB RENAME statement for further discussion. If the new name is the2 name of a synonym then an error will be raised.= The RENAME TO clause requires synonyms be enabled for this? database. Refer to the ALTER DATABASE statement SYNONYMS AREB ENABLED clause. Note that these synonyms may be deleted if they> are no longer used by database definitions or applications. 3 ExampleD This example shows how ALTER CONSTRAINT can be used to change the; constraint attributes and add a comment to a constraint. SQL> set dialect 'sql99';' SQL> attach 'file db$:mf_personnel'; SQL> SQL> create table PERSON! cont> (last_name char(20)/ cont> constraint MUST_HAVE_LAST_NAME cont> not null cont> deferrable," cont> first_name char(20), cont> birthday date+ cont> constraint MUST_BE_IN_PAST4 cont> check (birthday < current_date)$ cont> not deferrable,# cont> constraint ALL_UNIQUE9 cont> unique (last_name, first_name, birthday)/ cont> deferrable initially immediate cont> ); SQL>& SQL> show table (constraint) PERSON Information for table PERSON Table constraints for PERSON: ALL_UNIQUE Unique constraint+ Null values are considered distinct Table constraint for PERSON Evaluated on each VERB Source:, UNIQUE (last_name, first_name, birthday) MUST_BE_IN_PAST Check constraint) Column constraint for PERSON.BIRTHDAY' Evaluated on UPDATE, NOT DEFERRABLE Source:# CHECK (birthday < current_date) MUST_HAVE_LAST_NAME Not Null constraint* Column constraint for PERSON.LAST_NAME Evaluated on COMMIT Source: PERSON.LAST_NAME NOT null( Constraints referencing table PERSON: No constraints found  SQL># SQL> alter constraint ALL_UNIQUE+ cont> deferrable initially deferred; SQL>, SQL> alter constraint MUST_HAVE_LAST_NAME@ cont> comment is 'We must assume all persons have a name' cont> not deferrable; SQL>( SQL> alter constraint MUST_BE_IN_PAST, cont> deferrable initially immediate; SQL>& SQL> show table (constraint) PERSON Information for table PERSON Table constraints for PERSON: ALL_UNIQUE Unique constraint+  Null values are considered distinct Table constraint for PERSON Evaluated on COMMIT Source:, UNIQUE (last_name, first_name, birthday) MUST_BE_IN_PAST Check constraint) Column constraint for PERSON.BIRTHDAY Evaluated on each VERB Source:# CHECK (birthday < current_date) MUST_HAVE_LAST_NAME Not Null constraint* Column constraint for PERSON.LAST_NAME' Evaluated on UPDATE, NOT DEFERRABLE3 Comment: We must assume all persons have a name Source: PERSON.LAST_NAME NOT null( Constraints referencing table PERSON: No constraints found SQL> SQL> commit; 2 DATABASE2 Alters a database in any of the following ways:A o For single-file and multifile databases, the ALTER DATABASE@ statement changes the characteristics of the database root file.< The ALTER DATABASE statement lets you override certainD characteristics specified in the database root file parameters@ of the CREATE DATABASE statement, such as whether or not aA snapshot file is disabled. In addition, ALTER DATABASE letsB you control other characteristics that you cannot specify in@ the CREATE DATABASE database root file parameters, such as7 whether or not after-image journaling is enabled.A o For single-file and multifile databases, the ALTER DATABASE4 statement changes the storage area parameters.@ o For multifile databases only, the ALTER DATABASE statement- adds, alters, or deletes storage areas. 3 Environment, You can use the ALTER DATABASE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatI ALTER DATABASE -+-> FILENAME -++---------------------++I +-> PATHNAME ------++> literal-user -auth -+|I +----------------------------------------------------------------------+I +-+-+-----------------------------------------+-+---------------------->2 | +-> alter-root-file-params1 --------------+ |2 | +-> alter-root-file-params2 --------------+ |2 | +-> alter-root-file-params3 --------------+ |2 | +-> alter-journal-params -----------------+ |2 | +-> alter-storage-area-params ------------+ |2 | +-> add-row-cache-clause -----------------+ |2 | +-> add-journal-clause -------------------+ |2 | +-> add-storage-area-clause --------------+ |2 | +-> alter-row-cache-clause ---------------+ |2 | +-> alter-journal-clause -----------------+ |2 | +-> alter-storage-area-clause ------------+ |2 | +-> drop-clause --------------------------+ |2 +--------------------<------------------------+  db-attach-spec = ( --+----------------+-> ---> +-> -+ node-spec = + -+-> -+-------------------+-+->) | +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  alter-root-file-params1 = F -+-> attach-options ----------------------------------------------+->D +-> NUMBER OF USERS IS --> -----------------------+D +-> NUMBER OF BUFFERS IS --> -------------------+D +-> NUMBER OF CLUSTER NODES IS -> ---+ |D | +-----------------------------------------------+ |D | ++------------------------------------------+----------------+D | +> ( -+-> SINGLE ---+--> INSTANCE --> ) ---+ |D | +-> MULTIPLE -+ |D +-> NUMBER OF RECOVERY BUFFERS IS -> ---------- -+D +-> BUFFER SIZE IS BLOCKS -----------------------+D +-> SNAPSHOT IS -+> ENABLED -+------>------+-+-------------------+D | | +> IMMEDIATE -+ | |D | | +> DEFERRED --+ | |D | +> DISABLED ----------------+ |D +-> DICTIONARY IS ------+-> REQUIRED -------+--------------------+D | +-> NOT REQUIRED ---+ |D +-> DICTIO NARY IS ------+-> USED -----------+--------------------+D | +-> NOT USED -------+ |D +-> ADJUSTABLE LOCK GRANULARITY IS -+-> ENABLED -> alg-options -++C +-> DISABLED ---------------+ attach-options = G -+> MULTISCHEMA IS +> ON ---+--------------------------------------+->E | +> OFF --+ |E +> OPEN IS -+> MANUAL --------------------------------------------+E +> AUTOMATIC +---------------------------------------++D +> ( WAIT -> MINUTES -> FOR CLOSE ) +  alg-options = & --+------------------------------+--># +-> ( --> COUNT IS --> ) --+  alter-root-file-params2 = E -+-> global-buffer-params ---------------------------------------+->C +-> CARDINALITY COLLECTION IS ------------+-+-> ENABLED ----+---+C +-> CARRY OVER LOCKS ARE -----------------+ +-> DISABLED --- + |C +-> GALAXY SUPPORT IS --------------------+ |C +-> LOCK PARTITIONING IS -----------------+ |C +-> LOGMINER SUPPORT IS ------------------+ |C +-> METADATA CHANGES ARE -----------------+ |C +-> STATISTICS COLLECTION IS -------------+ |C +-> WORKLOAD COLLECTION IS ---------------+ |C +-> prestarted-transaction-params ------------------------------+C +-> LOCK TIMEOUT INTERVAL IS SECONDS ----------+C +-> RESERVE +-> CACHE SLOTS ----+---------------------------+C | +-> JOURNALS -------+ |C | +-> STORAGE AREAS --+ |C | +-> SEQUENCES ------+ |C +-> ROW CACHE IS -+-> ENABLED --+--+-----------------------+----+C | +-> DISABLED -+ +-> row-cache-options -+ |C +-> SET --+--> TRANSACTION MODES -+--> txn-modes -+---->) -+: +-> ALTER -+ +-----> , ----------+ global-buffer-params= 7 --> GLOBAL BUFFERS ARE -+-> ENABLED --+--------------+7 +-> DISABLED -+ |7 +----------------------------------------------------+: +---------------------------------------------------+--->6 +> ( -++-> NUMBER IS ----++> ) +1 |+-> USER LIMIT IS ---+|1 |+-> PAGE TRANSFER VIA --+-> DISK ---+--+|1 || +-> MEMORY -+ |1 |+-> LARGE MEMORY IS --+--> ENABLED --+--+1 | +--> DISABLED -+ |1 +------------------- , <----------------+ prestarted-transaction-params = Q -> PRESTARTED TRANSACTIONS ARE -++--> ENABLED -++----------------------------++>P |+--> ON -----++->(prestart-trans-options) -+|P +-+-> DISABLED --+----------------------------+3 +-> OFF -------+ prestart-trans-options = ' -+---------------------------------+->% +-> WAIT SECONDS FOR TIMEOUT -+% +-> WAIT MINUTES FOR TIMEOUT -+% +-> NO TIMEOUT -------------------+ row-cache-options = L -> ( -++-> CHECKPOINT -+-> ALL ROWS TO BACKING FILE -----------+-++-> ) -->D || +-> TIMED EVERY SECONDS ------------+ ||D || +-> UPDATED ROWS TO -+-> BACKING FILE -++ ||D || +-> DATABASE -----+ ||D |+-> LOCATION IS --> ---------------------+|D |+-> NO --+--> LOCATION --------+--------------------------+|D || +--> SWEEP INTERVAL --+ ||D |+-> NUMBER OF SWEEP ROWS IS --------------------------+|D |+-> SWEEP INTERVAL IS SECONDS ------------------------+|D +-------------------------- , <-----------------------------+ txn-modes = 1 -+-+-------+-+-> READ ONLY -----------------+-->. | +-> NO -+ +-> READ WRITE ----------------+. | +-> BATCH UPDATE --------------+. | +-> SHARED ----+--+----------+-+. | +-> PROTECTED -+ +-> READ --+ |. | +-> EXCLUSIVE -+ +-> WRITE -+ |. +-------------> ALL -----------------------+. +-------------> NONE ----------------------+  alter-root-file-params3 = D -+> ASYNC BATCH WRITES ARE -+-> ENABLED -> async-bat-wr-options ++>C | +-> DISABLED -----------------------+|C ++------------+-> ASYNC PREFETCH IS --+ |C |+> DETECTED -+ +-------------------+ |C | +-+-> ENABLED ---> async-prefetch-options +---+C | +-> DISABLED ---------------------------+ |C ++------+-> INCREMENTAL BACKUP SCAN OPTIMIZATION ---------------+C |+> NO -+  |C +> RECOVERY JOURNAL -> ( -> ruj-options -> ) -------------------+C +> SECURITY CHECKING IS ---> security-checking-options ---------+C +> SYNONYMS ARE ENABLED ----------------------------------------+C +> SHARED MEMORY IS --+-> SYSTEM -------------------+-----------+C | +-> PROCESS --+-------------+-+ |C | +-> RESIDENT -+ |C +> NOTIFY IS -+->ENABLED ---> notify-options -+---------------+3  +->DISABLED ----------------------+ asynch-bat-wr-options = C -+----------------------------->-------------------------------+->A + ( ++-> CLEAN BUFFER COUNT IS BUFFERS --++> ) +< |+-> MAXIMUM BUFFER COUNT IS BUFFERS +|< +------------------- , <-----------------------------+  async-prefetch-options = A --+-----------------------------------------------------------+>@ +-> ( -+-+-> DEPTH IS BUFFERS -----+--+> )-+; | +-> THRESHOLD IS BUFFERS -+ |; +----------------- , <--------------------------+  ruj-options = , -+-> LOCATION IS --> -+-->) +-> NO LOCATION ----------------------+) +-> BUFFER MEMORY IS -+-> LOCAL ------+) +-> GLOBAL -----+ security-checking-options = E -+-> EXTERNAL -+------------------------------------------------++->C | +-> ( -> PERSONA SUPPORT IS -+-> ENABLED --+> ) -+|C | +-> DISABLED -+ |C +-> INTERNAL -+-----------------------------------------------+-+A +-> ( -> ACCOUNT CHECK IS -+---> ENABLED --+> ) +< +---> DISABLED -+ alter-journal-params =  -> JOURNAL IS ---+ +----------------+; +-+> ENABLED +----------------------------------------++->9 | +> ( +-+-> aij-control-options-1 -+-+> ) +|9 |  | +-> aij-control-options-2 -+ | |9 | +------------- , <-------------+ |9 +> DISABLED -----------------------------------------+  aij-control-options-1 = ? --+-> ALLOCATION IS BLOCKS ----------------------------+->= +-> BACKUP SERVER IS +> AUTOMATIC +> --+= | +> MANUAL ---+ |= +-> BACKUP FILENAME ---> --+ |= | +-----------------------------------------+ |= | +-> backup-filename-options -------------------------+= +-> NO BACKUP FILENAME ----------------------------------+= +-> EXTENT IS BLOCKS --------------------------------+ backup-filename-options = < -+------------------------------------------------------+->: +-> ( -+-> NO EDIT STRING ----------------------+-> ) -+3 +-> EDIT STRING IS -+-+-> SEQUENCE --+-+-+1 | +-> YEAR ------+ |1  | +-> MONTH -----+ |1 | +-> DAY -------+ |1 | +-> HOUR ------+ |1 | +-> MINUTE ----+ |1 | +-> JULIAN ----+ |1 | +-> WEEKDAY ---+ |1 | +-> literal ---+ |1 +--------- + <-----+  aij-control-options-2 = > -+-> FAST COMMIT IS -+> ENABLED ---> fc-options --+-------+->< |  +> DISABLED -----------------+ |< +-> LOG SERVER IS -+> MANUAL ----+-----------------------+< | +> AUTOMATIC -+ |< +-> OVERWRITE IS --+> ENABLED --+------------------------+< | +> DISABLED -+ |< +-> SHUTDOWN TIME IS MINUTES ------------------------+ fc-options = I --+------------------------------------------------------------------+->G +-> ( -++> CHECKPOINT -+-> INTERVAL IS BLOCKS ------+-+-+-> ) -+@ || +-> TIMED EVERY SECONDS -----+ | |@ || +-> EVERY TRANSACTIONS ------+ | |@ |++-------+-> COMMIT TO JOURNAL OPTIMIZATION ------+ |@ ||+-> NO -+ | |@ |+-> TRANSACTION INTERVAL IS --------+ |@ +----------------- , <-------------------------------+  notify-options = = --+-----------------------------------------------------+-->: +--> ( ALERT OPERATOR -+--> operator-class -+-- ) --+2 +--------- + <---------+  operator-class = ' ---+--+------+-+--> CENTRAL -----+---># | +> NO -+ +--> DISKS -------+# | +--> CLUSTER -----+# | +--> CONSOLE -----+# | +--> SECURITY ----+# | +--> OPER1 -------+# | +--> OPER2 -------+# | +--> OPER3 -------+# | +--> OPER4 -------+# | +--> OPER5 -------+# | +--> OPER6 -------+# | +--> OPER7 -------+# | +--> OPER8 -------+# | +--> OPER9 -------+# | +--> OPER10 ------+# | +--> OPER11 ------+# | +--> OPER12 ------+# +--------------> ALL ---------+# +--------------> NONE --------+ extent-params = 6 --+-> EXTENT IS -+-> ENABLED -------------------++-->3 | +-> DISABLED ------------------+|3 | +-> --> PAGES --+|3 | +-> (extension-options) -------+|3 +---------------------<------------------------+  extension-options = ' ---> MINIMUM OF PAGES, --+' +------------------------------------+' +--> MAXIMUM OF PAGES, --+' +------------------------------------+) +--> PERCENT GROWTH IS ------->  add-journal-clause = / ---> ADD JOURNAL -----> ------+/ +--------------------------------------------+B ++---------------------------------+-+-+--------------------+-+->@ +-> FILENAME -+ | +-> add-aij-options -+ |@ +---------- <------------+  add-aij-options = 9 -+-> ALLOCATION IS --> -> BLOCKS ---------------+-->6 +-> EXTENT IS --> -> BLOCKS -------------------+6 +-> BACKUP FILENAME -> ---+ |6 | +------------------------------------------+ |6 | +--> backup-filename-options --------------------+6 +-> SAME BACKUP FILENAME AS JOURNAL ---------------+6 +-> NO BACKUP FILENAME ----------------------------+  add-storage-area-clause = & ---> ADD STORAGE AREA --+& +-----------------------------------+@ +-+-------------------------+-++-> storage-area-params-1 -+-+->> +-> FILENAME -+ |+-> storage-area-params-2 -+ |> +-------------- <-------------+  storage-area-params-1 = ; --+-> ALLOCATION IS ---> --> PAGES -----+->9 +-> CACHE USING --------------------+9 +-> NO ROW CACHE ------------------------------------+9 +-> extent-params -----------------------------------+9 +-> INTERVAL IS --> -------------+9 +-> LOCKING IS --+-> ROW --+--> LEVEL ---------------+9 | +-> PAGE -+ |9 +-> PAGE FORMAT IS +-> UNIFORM -+--------------------+9 | +-> MIXED ---+ |9 +-> PAGE SIZE IS ----> --> BLOCKS -----+  storage-area-params-2 = @ --+-> CHECKSUM CALCULATION IS -----------+--+-> ENABLED --+-+->> +-> SNAPSHOT CHECKSUM CALCULATION IS --+ +-> DISABLED -+ |> +-> SNAPSHOT ALLOCATION IS --> ----> PAGES ---+> +-> SNAPSHOT EXTENT IS -+-> ----> PAGES --++> | +-> (extension-options) ---------+|> +-> SNAPSHOT FILENAME --> --------------------+> +-> THRESHOLDS ARE ( +-----------------------+> ) -+> | +> , -+----------++ |> | +> , + |> +------------------------------<--------------------------+  add-row-cache-clause = @ ---> ADD CACHE -+-+----------------------+-+->> | +-> row-cache-params1 -+ |>  | +-> row-cache-params2 -+ |> +-------------<------------+ alter-row-cache-clause = B ---> ALTER CACHE -+-+----------------------+-+->@ | +-> row-cache-params1 -+ |@ | +-> row-cache-params2 -+ |@ +-------------<------------+ row-cache-params1 = = --+-> ALLOCATION IS -+--+-----------+----------------+->;  +-> EXTENT IS -----+ +-> BLOCK --+ |; | +-> BLOCKS -+ |; +-> CACHE SIZE IS -+----> ROW --+------------------+; | +----> ROWS -+ |; +-> CHECKPOINT -+> UPDATED ROWS TO -+> BACKING FILE -+-+; | | +> DATABASE -----+ |; | +> ALL ROWS TO BACKING FILE ---------+ |; +-> LARGE MEMORY IS ----+-+-> ENABLED --+--------------+; +-> ROW REPLACEMENT IS -+ +-> DISABLED -+ |; +-> LOCATION IS --> ------------------+; +-> NO LOCATION ---------------------------------------+  row-cache-params2 = A --+-> NUMBER OF -+-> RESERVED -+-> ROWS IS --------------+->? | +-> SWEEP ----+ |? +-> ROW LENGTH IS -+-------------+---------------------+? | +----> BYTE --+ |? | +--- -> BYTES -+ |? | |? +-> ROW SNAPSHOT IS --+-> ENABLED rs-opt -+---------------+? | +-> DISABLED --------+ |? | |? +-> SHARED MEMORY IS --+----> SYSTEM -------------------+--+? | +----> PROCESS --+-------------+-+ |? | | | |? |  +-> RESIDENT -+ |? | |? +-> WINDOW COUNT IS -----------------------------------+ rs-opt =( --+-------------------------------+--->$ +-> (CACHE SIZE IS ROWS) ---+ alter-journal-clause = - ---> ALTER JOURNAL ---+-> -++- +-> RDB$JOURNAL ----+|- +------------------------------------------+/ ++-> alter-aij-options --+-------------------> +----------<------------+  alter-aij-options = 9 -+-> JOURNAL IS --> UNSUPPRESSED ------------------+--->5 +-> BACKUP FILENAME -----> -+ |5 | +------------------------------------------+ |5 | +-> backup-filename-options ------------------+5 +-> SAME BACKUP FILENAME AS JOURNAL---------------+5 +-> NO BACKUP FILENAME ---------------------------+  alter-storage-area-clause = ' ---> ALTER STORAGE AREA -+' +------------------------------------+5 ++---> alter-storage-area-params ---------------+-->2 +----------------------------<-----------------+ alter-storage-area-params = > -+-> ALLOCATION IS --> --> PAGES ----------+->< +-> extent-params ---------------------------------------+< +-> CACHE USING ------------------------+< +-> NO ROW CACHE ----------------------------------------+< +-> LOCKING IS -+-> ROW -+-> LEVEL ---------------------+< |  +-> PAGE -+ |< +-> READ WRITE ------------------------------------------+< +-> READ ONLY -------------------------------------------+< +-> SNAPSHOT ALLOCATION IS --> --> PAGES ----+< +-> SNAPSHOT EXTENT IS +-> --> PAGES ---+-+< | +-> (extension-options) --------+ |< +-> CHECKSUM CALCULATION IS ----------+--+-> ENABLED --+-+: +-> SNAPSHOT CHECKSUM CALCULATION IS -+ +-> DISABLED -+  drop-clause = ; --+-> DROP CACHE ---+-+-------------+-+->9 +-> DROP STORAGE AREA -+ +-> CASCADE --+ |9 | +-> RESTRICT -+ |9 +-> DROP JOURNAL ---------------------+  3 Arguments 4 ADD_CACHE_row-cache-nameA Adds a new row cache. For information regarding the row-cache-B params-1 and row-cache-params-2, see the descriptions under the CREATE CACHE clause. 4 ADD_JOURNAL  Creates a new journal file. 4 ADD_STORAGE_AREAC Specifies the name and file specification for a storage area you@ want to add to the database. You can use the ADD STORAGE AREAC clause only on multifile databases. The storage area name cannot> be the same as any other storage area name in the database.@ The ADD STORAGE AREA clause creates two files: a storage area? file with an .rda file extension and a snapshot file with anC .snp file extension. If you omit the FI LENAME argument, the file- specification uses the following defaults:/ o Device-the current device for the process5 o Directory-the current directory for the process7 o File name-the name specified for the storage areaC The file specification is used for the storage area and snapshotD files that comprise the storage area (unless you use the SNAPSHOTA FILENAME argument to specify a different file for the snapshot? file, which you can only specify with a multifile database).= Because the ADD STORAGE AREA clause creates two files withB different file extensions, do not specify a file extension with the file specification.A If you use the ALTER DATABASE statement to add a storage area,< the change is journaled, however, you should back up your( database before making such a change. 4 ADJUSTABLE_LOCK_GRANULARITY Syntax options:; ADJUSTABLE LOCK GRANULARITY IS ENABLED | ADJUSTABLE LOCK GRANULARITY IS DISABLED9  Enables or disables whether or not the database system? automatically maintains as few locks as possible on databaseB resources. The default, ENABLED, results in fewer locks againstA the database. However, if contention for database resources isB high, the automatic adjustment of locks can become a CPU drain.D You can trade more restrictive locking for less CPU usage in such6 databases by disabling adjustable lock granularity. 4 ALERT_OPERATORA Specifies which o perator will be notified of the occurrence ofB a database system event. You can specify the following operator classes: Operator Class Meaning@ ALL The ALL operator class broadcasts a message toA all terminals that are enabled as operators andC that are attached to the system or cluster. TheseA terminals must be turned on and have broadcast-, message reception enabled.A NONE  The NONE operator class inhibits the display of; messages to the entire system or cluster.@ [NO] CENTRAL The CENTRAL operator class broadcasts messages= sent to the central system operator. The NO@ CENTRAL operator class inhibits the display of? messages sent to the central system operator.> [NO] DISKS The DISKS operator class broadcasts messages= pertaining to mounting and dismounting disk? volumes. The NO DISKS operator class inhibitsD the display of messages pertaining to mounting and+ dismounting disk volumes.@ [NO] CLUSTER The CLUSTER operator class broadcasts messages; from the connection manager pertaining to@ cluster state changes. The NO CLUSTER operatorA class inhibits the display of messages from the@ connection manager pertaining to cluster s tate changes.> [NO] CONSOLE The CONSOLE class broadcasts messages to the= Oracle Enterprise Manager (OEM). NO CONSOLE, inhibits broadcast to OEM.? [NO] The SECURITY operator class displays messages@ SECURITY pertaining to security events. The NO SECURITYA operator class inhibits the display of messages0 pertaining to security events.C [NO] OPER1 The OPER1 through OPER12 operator classes displayC through [NO] messages to operators identified as OPER1 throughA OPER12 OPER12. The NO OPER1 through NO OPER12 operatorA classes inhibit messages from being sent to the% specified operator. 4 ALLOCATION_blocks_for_aij Syntax option: ALLOCATION IS n BLOCKSB Specifies the number of blocks allocated for the .aij file. TheA default and minimum is 512 blocks. Even if you specify a value? less than  512 blocks, the .aij file is allocated 512 blocks.? For information on determining the allocation value, see the6 Oracle Rdb Guide to Database Design and Definition. 4 ALLOCATION_IS_n_PAGESB Specifies the number of database pages allocated to the storage= area. The initial allocation never changes and is used for= the hash algorithm. The new allocation becomes the currentB allocation. If you execute the RMU Dump/Header command, you see* the initial and the current allocation.A SQL automatically extends the allocation to handle the storageC requirements. Pages are allocated in groups of three (known as aC clump). An ALLOCATION of 25 pages actually provides for 27 pages> of data and subsequent expansion. The default is 700 pages.> The altered area is extended if the specified value exceeds@ the current area allocation. Otherwise the specified value is ignored. 4 ALTER_CACHE Alters an existing row cache.5 For more "information, see the following arguments: o ALLOCATION_blocks_for_rdc o CACHE_SIZE_IS_n_ROWS o EXTENT_blocks_for_rdc o LARGE_MEMORY o LOCATION o NO_LOCATION o NUMBER_OF_RESERVED_ROWS o SHARED_MEMORY o ROW_REPLACEMENT o ROW_LENGTH o WINDOW_COUNT 4 ALTER_JOURNALD Alters existing journal files. RDB$JOURNAL is the default journal name if no name is specified. 4 alter-root-file-params> Paramet ers that control the characteristics of the database= root file associated with the database or that control the= characteristics that apply to the entire database. You can? specify these parameters for either single-file or multifile8 databases except as noted in the individual parameter? descriptions. For more information about database parameters@ and details about how they affect performance, see the Oracle1 Rdb7 Guide to Database Performance and Tuning.D The ALTER D ATABASE statement does not let you change all databaseC root file parameters that you can specify in the CREATE DATABASE> statement. You must use the EXPORT and IMPORT statements toC change a number of storage area parameters. For more informationA on changing storage area parameters, see the IMPORT statement. 4 alter-storage-area-paramsA Parameters that change the characteristics of database storageC area files. You can specify the same storage area parameters forC  either single-file or multifile databases, but the effect of the? clauses in this part of an ALTER DATABASE statement differs.< o For single-file databases, the storage area parameters? change the characteristics for the single storage area in the database.A o For multifile databases, the storage area parameters change9 the characteristics of the RDB$SYSTEM storage area.< You can also change some of the characteristics of theB RDB$SYSTEM storage a rea using the ALTER STORAGE AREA clause.? However, you can only change the read-only and read/writeB parameters in this part of the ALTER DATABASE statement. SeeB the ALTER_STORAGE_AREA topic in this Arguments list for moreC information about the RDB$SYSTEM characteristics that you are allowed to alter.C The ALTER DATABASE statement does not let you change all storageD area parameters you can specify in the CREATE DATABASE statement.> You must use the EXPORT and IMPORT statements to change the+ following database root file parameters: o INTERVAL o PAGE FORMAT o PAGE SIZE o SNAPSHOT FILENAME o THRESHOLDS 4 ALTER_STORAGE_AREAA Specifies the name of an existing storage area in the databaseD that you want to alter. You can use the ALTER STORAGE AREA clause only on multifile databases.C You can specify RDB$SYSTEM for the area-name if you are altering the following clauses:& o ALLOCATION IS number-pages PAGES o extent-params o CACHE USING row-cache-name o NO ROW CACHE, o SNAPSHOT ALLOCATION IS snp-pages PAGES o SHAPSHOT EXTENT o CHECKSUM CALCULTION# o SNAPSHOT CHECKSUM CALCULATIONA Oracle Rdb generates an error if you specify RDB$SYSTEM or theD DEFAULT storage area as the area-name when altering the following clauses: o LOCKING IS PAGE LEVEL o READ WRITE o READ ONLYC If you want to change the read-only and read/write parameters ofB the RDB$SYSTEM storage area using the ALTER DATABASE statement,A you must specify these parameters outside of the ALTER STORAGE AREA clause. 4 ALTER_TRANSACTION_MODESA Enables or disables the modes specified leaving the previouslyA defined or default modes enabled. This is an offline operation* and requires exclusive database access.D If the current transaction modes are SHARED and READ ONLY and you? want to add the EXCLUSIVE mode, use the following statement:, SQL> ALTER DATABASE FILENAME mf_personnel/ cont> ALTER TRANSACTION MODES (EXCLUSIVE); 4 ASYNC_BATCH_WRITES Syntax options:C ASYNC BATCH WRITES ARE ENABLED | ASYNC BATCH WRITES ARE DISABLED= Specifies whether asynchronous batch-writes are enabled or disabled.@ Asynchronous batch-writes allow a process to write batches ofC modified data pages to disk asynchronously (the process does notB stall while waiting for the batch-write operation to complete).> Asynchronous batch-writes improve the performance of update3 applications without the loss of data integrity.( By default, batch-writes are enabled.D For more information about when to use asynchronous batch-writes,@ see the Oracle Rdb7 Guide to Database Performance and Tuning.C You can enable asynchronous batch-writes by defining the logical name RDM$BIND_ABW_ENABLED. 4 ASYNC_PREFETCH Syntax options: 9 ASYNC PREFETCH IS ENABLED | ASYNC PREFETCH IS DISABLEDA Specifies whether or not Oracle Rdb reduces the amount of timeB that a process waits for pages to be read from disk by fetching6 pages before a process actually requests the pages.= Prefetch can significantly improve performance, but it may@ cause excessive resource usage if it is used inappropriately.D Asynchronous prefetch is enabled by default. For more information< about asynchronous prefetch, see the Oracle Rdb7 Guide to# Database Performance and Tuning.D You can enable asynchronous prefetch by defining the logical name RDM$BIND_APF_ENABLED. 4 BACKUP_FILENAME Syntax option:# BACKUP FILENAME backup-file-specD Specifies the default file specification to be used by the backup server.@ During execution, the backup server and the RMU Backup After_A Journal command use this file specification as the name of the@ backup file. You can override this value by specifying a file? name for the journal file using the RMU Backup After_Journal command. 4 backup-filename-optionsA Specifies whether or not the backup file name includes an editD string. When the EDIT STRING clause is used, the specified backupA file name is edited by appending any or all of the edit string) options listed in the following table. Edit String Option MeaningB SEQUENCE The journal sequence number of the first journal/  file in the backup operation.B YEAR The current year expressed as a 4-digit integer.B MONTH The current month expressed as a 2-digit integer (01-12).@ DAY The current day of the month expressed as a 2-( digit integer (00-31).D HOUR The current hour of the day expressed as a 2-digit" integer (00-23).? MINUTE The current minute of the hour expressed as a*  2-digit integer (00-59).D JULIAN The current day of the year expressed as a 3-digit$ integer (001-366).D WEEKDAY The current day of the week expressed as a 1-digitD integer (1-7) where 1 is Sunday and 7 is Saturday.C literal Any string literal. This string literal is copiedA to the file specification. See Quoted CharacterD String for more information about string literals.A Use a plus sign (+) between multiple edit string options. The9 edit string should be 32 characters or less in length.@ The default is NO EDIT STRING which means the BACKUP FILENAME8 supplied is all that is used to name the backup file. 4 BACKUP_SERVER Syntax options:A BACKUP SERVER IS AUTOMATIC backup-file-spec | BACKUP SERVER IS MANUAL backup-file-spec< Specifies whether the backup server runs automatically or manually.@ If BACKUP SERVER IS MANUAL is specified, you must execute the> RMU Backup After_Journal command manually. If BACKUP SERVER? IS AUTOMATIC is specified, a special backup server runs when@ a journal file in the set is full and causes a switch over to another journal file. The default is MANUAL. 4 BUFFER_SIZE Syntax option:& BUFFER SIZE IS buffer-blocks BLOCKSB Specifies the number of blocks Oracle Rdb allocates per buffer.A You need to specify an unsigned integer greater than zero. TheC default b uffer size is 3 times the PAGE SIZE value (6 blocks for the default PAGE SIZE of 2).A The buffer size is a global parameter and the number of blocksA per page (or buffer) is constrained to 64 blocks per page. TheB page size can vary by storage area for multifile databases, andA the page size should be determined by the sizes of the records, that will be stored in each storage area.D When choosing the number of blocks per buffer, choose a number soC that a round number of pages fits in the buffer. In other words,@ the buffer size is wholly divisible by all page sizes for all@ storage areas in your multifile database. For example, if youA have three storage areas with page sizes of 2, 3, and 4 blocksA each respectively, choosing a buffer size of 12 blocks ensuresB optimal buffer utilization. In contrast, choosing a buffer sizeC of 8 wastes 2 blocks per buffer for the storage area with a pageB size of 3 pages. Oracle Rdb reads as many pages as fit into the? buffer; in this instance it reads two 3-block pages into the# buffer, leaving 2 wasted blocks.B The altered buffer size must allow for existing page sizes. YouA cannot specify a buffer size smaller than the largest existing page size. 4 CACHE_USINGA Specifies that the named row cache is the default physical rowB cache for all storage areas in the database. All rows stored inC each storage area are cached, regardless of whether they consistB  of table data, segemented string data, or are special rows such as index nodes.@ You must either add the specified cache before completing the6 ALTER DATABASE statement, or it must already exist.> Alter the database and storage area to asign a new physicalC area row cache that overrides the database default physical areaB row cache. Only one physical area row cache is allowed for each storage area.B You can have multiple row caches that contain rows for a singleB storage area by defining logical area row caches, where the row3 cache name matches the name of a table or index.C If you do not specify the CACHE USING clause or the NO ROW CACHE7 clause, then the NO ROW CACHE clause is the default. 4 CARDINALITY_COLLECTION Syntax options:@ CARDINALITY COLLECTION IS ENABLED | CARDINALITY COLLECTION IS DISABLED= Specifies whether or not the optimizer records cardinality< updates in the system tables. When enabled, the opt imizer< collects cardinalities for tables and indexes as rows areC inserted or deleted from tables. The update of the cardinalities: is performed at commit time, if sufficient changes have& accumulated, or at disconnect time.< In high update environments, it may be more convenient to@ disable cardinality updates. If you disable this feature, youC should manually maintain the cardinalities using the RMU CollectB Optimizer_Statistics command so that the optimizer is given the0 most accurate values for estimation purposes.0 Cardinality collection is enabled by default. 4 CARRY_OVER_LOCKS Syntax options:? CARRY OVER LOCKS ARE ENABLED | CARRY OVER LOCKS ARE DISABLEDD Enables or disables carry-over lock optimization. Carry-over lockA optimization holds logical area locks (table and index) across@ transactions. Carry-over locks are enabled by default and are0 available as an online database modification.@ For more information on carry-over lock optimization, see the CREATE DATABASEstatement. "4 CHECKPOINT_EVERY_n_TRANSACTIONSC A FAST COMMIT option which allows the checkpoint to be generated& after a set number of transactions. See the following example. SQL> alter database! cont> filename db$:scratch cont> cont> journal is enabled( cont> (fast commit is enabled7 cont> (checkpoint every 20 transactions,7 cont> checkpoint timed every 20 seconds cont> ) cont> )$ cont> add journal rdb$journal) cont> filename db$:scratch_aij cont> ;S %RDMS-W-DOFULLBCK, full database backup should be done to ensure future recovery 4 CHECKPOINT_INTERVAL Syntax option:" CHECKPOINT INTERVAL IS n BLOCKSD You can limit how many transactions the database recovery process> (DBR) must redo by setting a checkpoint interval. Setting aA checkpoint interval instructs Oracle Rdb to periodically write7 modified pages to disk. This shortens recovery time.@ The value you assign to the checkpoint interval specifies theB number of blocks the .aij file is allowed to increase to before= updated pages are transferred. For example, if you set theA checkpoint interval value equal to 100, all processes transfer< updated pages to the disk when 100 blocks were written to> the .aij file since the last checkpoint. Thus all processes contribute to .aij grow th.C If no checkpoint interval is established and a process completesD 1000 transactions but fails during number 1001, the DBR must redo4 transactions 1 through 1000 and undo number 1001.B When a process attaches to the database, it writes a checkpointC record to the .aij file and notes the virtual block number (VBN)A of the .aij file at which the checkpoint record is located. IfC the checkpoint is located at VBN 120 and the checkpoint interval? is 100 blocks, the proc ess checkpoints again when VBN 220 is reached.B Because all processes contribute to .aij file growth, a process? may be able to commit many transactions before checkpointingA if update activity by other processes is low. Conversely, if a? process' first transaction is long and if update activity byC other processes is high, the process may be forced to checkpoint) when it commits its first transaction.A When the database checkpoint interval value is reached, Oracle$ Rdb executes the following steps:' 1. Writes updated pages to the disk.2 2. Writes a checkpoint record to the .aij file.> 3. Updates the run-time user process block (RTUPB) for each? process to indicate where the checkpoint record is stored in the .aij file.B The RTUPB is a data structure in the database root file thatC maintains information on each process accessing the database.C The database recovery process (DBR) uses the RTUPB checkpointD entry to determine where in the .aij file recovery must start. #4 CHECKPOINT_TIMED_for_fast_commitC Assigns a value to the checkpoint interval specifying the numberB of seconds that can pass before updated pages are written. WhenC the specified number of seconds elapsed, Oracle Rdb executes the checkpoint steps.D For example, if you specify TIMED EVERY 100 SECONDS, each processD checkpoints after at least 100 seconds have passed since its last checkpoint.?  You can set both a checkpoint based on time and a checkpoint> based on .aij file growth; Oracle Rdb performs a checkpoint6 operation at whichever checkpoint it reaches first.= The following statement enables fast commit processing and? specifies checkpoint intervals of 512 blocks and 12 seconds:% SQL> ALTER DATABASE FILENAME test1 cont> JOURNAL IS ENABLED cont> (FAST COMMIT ENABLED2 cont> (CHECKPOINT INTERVAL IS 512 BLOCKS,2 cont> CHECKPOINT TIMED EVERY 12 SECONDS) cont> ); 4 Checkpoint_Rows Syntax options:* CHECKPOINT UPDATED ROWS TO BACKING FILE& CHECKPOINT UPDATED ROWS TO DATABASE& CHECKPOINT ALL ROWS TO BACKING FILE< Specifies the default source and target during checkpointD operations for all row caches. If ALL ROWS is specified, then theC source records written during each checkpoint operation are bothB the modified and the unmodified rows in a row cache. If UPDATEDD ROWS is specifi ed, then just the modified rows in a row cache are checkpointed each time.= If the target of the checkpoint operation is BACKING FILE,> then the RCS process writes the source row cache entries to@ the backing (.rdc) files. The row cache LOCATION, ALLOCATION,@ and EXTENT clauses are used to create the backing files. UponA recovery from a node failure, the database recovery process isB able to repopulate the row caches in memory from the rows found in the backing files.<  If the target is DATABASE, then updated row cache entries< are written back to the database. The row cache LOCATION,A ALLOCATION, and EXTENT clauses are ignored. Upon recovery fromC a node failure, the database recovery process has no data on theC contents of the row cache. Therefore, it does not repopulate the row caches in memory.A The CHECKPOINT clause of the CREATE CACHE, ADD CACHE, or ALTER@ CACHE clause overrides this database-level CHECKPOINT clause. 4 CHECKSUM_CALCULATION Syntax options: CHECKSUM CALCULATION# SNAPSHOT CHECKSUM CALCULATION@This option allows you to enable or disable calculations of pageDchecksums when pages are read from or written to the storage area orsnapshot files. The default is ENABLED.& NOTE; Oracle Corporation recommends that you leave checksum1 calculations enabled, which is the default.@ With current technology, it is possible that er rors may occur< that the checksum calculation can detect but that may not= be detected by either the hardware, firmware, or software.C Unexpected application results and database corruption may occurD if corrupt pages exist in memory or on disk but are not detected.B Oracle Corporation recommends performing checksum calculations,2 except in the following specific circumstances:B o Your application is stable and has run without errors on theA current hardware and softw are configuration for an extended period of time.> o You have reached maximum CPU utilization in your current; configuration. Actual CPU utilization by the checksum? calculation depends primarily on the size of the database? pages in your database. The larger the database page, theC more noticeable the CPU usage by the checksum calculation may become.& NOTE? Oracle Corporation recommends that you carefully evaluate> the trade-off between reducing CPU usage by the checksumB calculation and the potential for loss of database integrity, if checksum calculations are disabled.> Oracle Corporation allows you to disable and, subsequently,> re-enable checksum calculation without error. However, once> checksum calculations have been disabled, corrupt pages mayA not be detected even if checksum calculations are subsequently re-enabled. 4 CLEAN_BUFFER_COUNT Syntax option:- CLEAN BUFFER COUNT IS buffer-count BUFFERS; Specifies the number of buffers to be kept available for immediate reuse.= The default is five buffers. The minimum value is one; the9 maximum value can be as large as the buffer pool size.? You can override the number of clean buffers by defining theD logical name RDM$BIND_CLEAN_BUF_CNT. For information about how toD set the values, see the Oracle Rdb7 Guide to Database Performance and Tuning. !4  COMMIT_TO_JOURNAL_OPTIMIZATION Syntax options:8 COMMIT TO JOURNAL OPTIMIZATION | NO COMMIT TO JOURNAL OPTIMIZATIOND If you enable COMMIT TO JOURNAL OPTIMIZATION when you enable fastB commit processing, Oracle Rdb does not write commit information> to the database root file. This option enhances performance> in database environments that are update-intensive. Because= of the prerequisites for enabling the journal optimizationB option, general-use databases or databases that have many read-@ only transactions may not benefit from this feature. For moreA information, see the Oracle Rdb7 Guide to Database Performance and Tuning.& NOTE= If you specify COMMIT TO JOURNAL OPTIMIZATION, you must! disable or defer snapshots.A If you change snapshots to ENABLED IMMEDIATE, then you must0 specify NO COMMIT TO JOURNAL OPTIMIZATION. 4 COUNT_IS_n? Specifies the number of levels on the page lock tree used toC manage locks. For example, if you specify COUNT IS 3, the fanoutD factor is (10, 100, 1000). Oracle Rdb locks a range of 1000 pages@ and adjusts downward to 100 and then to 10 and then to 1 page when necessary.D If the COUNT IS clause is omitted, the default is 3. The value of n can range from 1 through 8. 4 DEPTH_buffers_option Syntax option:" DEPTH IS number-buffers BUFFERS= Specifies the number of buffers to prefetch for a process.C The default is one-quarter of the buffer pool, but not more thanB eight buffers. You can override the number of buffers specifiedB in the CREATE or ALTER DATABASE statements by using the logical name RDM$BIND_APF_DEPTH.D You can also specify this option with the DETECTED ASYNC PREFETCH clause. 4 DETECTED_ASYNC_PREFETCH Syntax options:B DETECTED ASYNC PREFETCH IS ENABLED | DETECTED ASYNC PREFETCH IS DISABLEDA Specifies whether or not Orac le Rdb reduces the amount of time7 that a process waits for pages to be read from disk.D By using heuristics, detected asynchronous prefetch determines ifB an I/O pattern is sequential in behavior even if sequential I/OB is not actually executing at the time. For example, when a LIST@ OF BYTE VARYING column is fetched, the heuristics detect thatD the pages being fetched are sequential and asynchronously fetchesA pages further in the sequence. This avoids wait times when the page is really needed.8 Detected asynchronous prefetch is enabled by default. 4 DICTIONARY_required_option Syntax options:6 DICTIONARY IS REQUIRED | DICTIONARY IS NOT REQUIRED@ Specifies whether or not definition statements issued for theA database must also be stored in the repository. If you specifyC the REQUIRED option, any data definition statements issued afterA an ATTACH or DECLARE ALIAS statement that does not specify the PATHNAME argument fails .> If you specify the DICTIONARY argument in an ALTER DATABASE@ statement, you cannot specify any other database root file or storage area parameters.A If you omitted the PATHNAME clause from the database root file? parameters in the CREATE DATABASE statement that created the@ database, SQL generates an error if you specify DICTIONARY ISA REQUIRED in an ALTER DATABASE statement for the same database.? This is not true if you use the INTEGRATE statement with the= CREATE PATHNAME clause to copy database definitions to theA repository before specifying the DICTIONARY IS REQUIRED clause4 in an ALTER DATABASE statement for that database. 4 DICTIONARY_used_option Syntax options:. DICTIONARY IS USED | DICTIONARY IS NOT USED: Specifies whether or not to remove the link between theD repository and the database. If you specify the DICTIONARY IS NOTC USED clause, the definitions in both the repository and databaseD are still maintained. After removing the links, you can integrate$ the database to a new repository.0 The DICTIONARY IS USED clause is the default. 4 DROP_CACHE Syntax options:@ DROP CACHE row-cache-name CASCADE | DROP CACHE row-cache-name RESTRICTD Deletes the specified row cache from the database. If the mode isD RESTRICT, then an exeption is raised if the row cache is assignedC to a storage area. If the mode is CASCADE, then the row cache is. removed from all referencing storage areas.3 The default is RESTRICT if no mode is specified. 4 DROP_JOURNAL8 Deletes the specified journal file from the database.D You can only delete an .aij file that is not current and that has been backed up. 4 DROP_STORAGE_AREA Syntax options:D DROP STORAGE AREA area-name CASCADE | DROP STORAGE AREA area-name RESTRICTC Deletes the specified storage area definition and the associated@ storage area and snapshot files. Yo u can use the DROP STORAGE+ AREA clause only on multifile databases.D If you use the RESTRICT keyword, you cannot delete a storage areaD if any database object, such as a storage map, refers to the area+ or if there is data in the storage area.B If you use the CASCADE keyword, Oracle Rdb modifies all objectsA that refer to the storage area so that they no longer refer toD it. However, Oracle Rdb does not delete objects if doing so makes the database inconsistent.>  If you use the ALTER DATABASE statement to delete a storageB area, the change is journaled, however, you should back up your( database before making such a change. 4 EXTENT_blocks_for_aij? Specifies the number of blocks of each .aij file extent. The; default and minimum extent for .aij files is 512 blocks. 4 EXTENT_clause Syntax options:# EXTENT ENABLED | EXTENT DISABLED> Enables or disables extents. Extents are ENABLED by default? and can be change d on line; however, the new extents are notB immediately effective on all nodes of a cluster. On the node onC which you have changed extents, the new storage area extents areD immediately effective for all users. The new storage area extentsC become effective as the database is attached on each node of the cluster.> You can encounter performance problems when creating hashed= indexes in storage areas with the mixed page format if theB storage area was created specifying the wrong size for the areaA and if extents are enabled. By disabling extents, this problem? can be diagnosed early and corrected to improve performance. 4 EXTENT_pages Syntax options:? EXTENT IS extent-pages PAGES | EXTENT IS (extension-options)D Changes the number of pages of each storage area file extent. See6 the description under the SNAPSHOT EXTENT argument. 4 FAST_COMMIT Syntax options:3 FAST COMMIT IS ENABLED | FAST COMMIT IS DISABLED > By default, Oracle Rdb writes updated database pages to theA disk each time a transaction executes the COMMIT statement. IfB a transaction fails before committing, Oracle Rdb only needs toC roll back (undo) the current failed transaction; it never has to) redo previous successful transactions.B You can change the commit processing method by enabling journalC fast commit processing. With journal fast commit enabled, OracleB Rdb keeps updated pages in the buffer pool (in memory) and doesB not write the pages to the disk when a transaction commits. TheD updated pages remain in the buffer pool until the process meets aD condition specified by the database administrator or applicationsC programmer. At the moment the condition is met (the checkpoint),B all the pages the process updated for multiple transactions are written to the disk.2 You can set a checkpoint for your process when:B o A fixed number of transactions are committed or aborte d. You= set this by specifying CHECKPOINT EVERY n TRANSACTIONS.C o A specified time interval elapsed. You set this by specifying2 the CHECKPOINT TIMED EVERY n SECONDS clause.B o The after-image journal (.aij) file increased by a specifiedA number of blocks. You set this by specifying the CHECKPOINT" INTERVAL IS n BLOCKS clause.C If a transaction fails, Oracle Rdb must undo the current, failed@ transaction and redo all the committed transactions since the B last checkpoint. Redoing updates involves reading the .aij file9 and reapplying the changes to the relevant data pages.> Fast commit processing applies only to data updates: erase,: modify, and store operations. Transactions that include= data definition statements, such as create logical area or@ create index operations, force a checkpoint at the end of theA transaction. If you do not specify values with the FAST COMMIT* clause, the default values are applied.&   NOTE> To enable FAST COMMIT, you must first enable after-image journaling. 4 FILENAME_file_specB Identifies the database root file associated with the database.B If you specify a repository path name, the path name indirectlyA specifies the database root file. The ALTER DATABASE statementD does not change any definitions in the repository, so there is noC difference in the effect of the PATHNAME and FILENAME arguments.C If yo u specify PATHNAME, SQL does not use the repository's fullyA qualified name. Instead, SQL uses the name stored as the user-A supplied name in the repository. In the following example, SQLD uses the name TEST as the file name, not DB$DISK:[DBDIR]TEST.RDB.> As a result, the database root file must be located in yourC present working directory or the database name must be a logical) name when you use the PATHNAME clause. $ REPOSITORY OPERATOR . . .  CDO> show database/full test Definition of database TEST& | database uses RDB database TEST | database in file TEST8 | | fully qualified file DB$DISK:[DBDIR]TEST.RDB;6 | | user-specified file DB$DISK:[DBDIR]test.rdbC If the database referred to in the PATHNAME or FILENAME argumentC has been attached, the ALTER DATABASE statement will fail with a file access conflict error. 4 FILENAME_journal_file_specA Specifies the journal file specification with the default file extension .aij. 4 GALAXY_SUPPORT Syntax options:7 GALAXY SUPPORT IS ENABLED|GALAXY SUPPORT IS DISABLED9 Allows global memory to be shared in an OpenVMS Galaxy8 configuration. Galaxy support is disabled by default.B OpenVMS Galaxy is a software architecture for the OpenVMS AlphaA operating system that enables multiple instances of OpenVMS toA execute cooperatively in a single computer. An instance refersC to a copy of the Op enVMS Alpha operating system. As an extensionD of the existing OpenVMS cluster support within Oracle Rdb, OracleB Rdb provides support for databases opened on multiple instances@ (or nodes) within a Galaxy system to share data structures inA memory. Within an Oracle Rdb Galaxy environment, all instances with an open database share:D o Database root objects (for example, TSN blocks and SEQ blocks)! o Global buffers (if enabled)@ o Row caches and Row Cache Server process (RCS) (if enabled) 4 GLOBAL_BUFFERS Syntax options:; GLOBAL BUFFERS ARE ENABLED | GLOBAL BUFFERS ARE DISABLEDB Specifies whether or not Oracle Rdb maintains one global bufferA pool per VMScluster node for each database. By default, OracleD Rdb maintains a local buffer pool for each attach (GLOBAL BUFFERS@ ARE DISABLED). For more than one attach to use the same page,@ each must read it from the disk into their local buffer pool.@ A page in the global buffer pool can be read by more than oneC attach at the same time, although only one attach reads the pageD from the disk into the global buffer pool. Global buffers improve? performance because the I/O is reduced, and memory is better utilized.& NOTE? If GALAXY SUPPORT is enabled, then a single global buffer) pool is shared by all Galaxy nodes. '4 INCREMENTAL_BACKUP_SCAN_OPTIMIZATION Syntax options:D INCREMENTAL BACKUP SCAN OPTIMIZATION | NO INCREMENTAL BACKUP SCAN OPTIMIZATION@ Specifies whether Oracle Rdb checks each area's SPAM pages or@ each database page to find changes during incremental backup.B If you specify INCREMENTAL BACKUP SCAN OPTIMIZATION, Oracle Rdb? checks each area's SPAM pages and scans the SPAM interval ofA pages only if the SPAM transaction number (TSN) is higher thanD the last full backup TSN, which indicates that a page in the SPAMB interval has been updated sin ce the last full backup operation.D Specify INCREMENTAL BACKUP SCAN OPTIMIZATION if your database hasB large SPAM intervals or infrequently occurring updates, and youD want to increase the speed of incremental backups. If you disableC the attribute (using the NO INCREMENTAL BACKUP SCAN OPTIMIZATIONA clause), you cannot enable it until immediately after the next full backup.A If you specify NO INCREMENTAL BACKUP SCAN OPTIMIZATION, OracleB Rdb checks each page to find changes during incremental backup.@ Specify the NO INCREMENTAL BACKUP SCAN OPTIMIZATION clause ifA your database has frequently occurring updates, uses bulk-loadB operations, or does not use incremental backups, or if you want# to improve run-time performance.7 The default is INCREMENTAL BACKUP SCAN OPTIMIZATION. 4 JOURNAL_clause_for_aij Syntax options:+ JOURNAL IS ENABLED | JOURNAL IS DISABLED2 Specifies whether or not journaling is enabled.@ If jour nal files already exist, the JOURNAL IS ENABLED clause* simply restarts the journaling feature.E If no journal files exist when the ALTER DATABASE . . . JOURNAL ISD ENABLED statement completes, an exception is raised. For example:& SQL> ALTER DATABASE FILENAME sample cont> JOURNAL IS ENABLED;R %RDMS-F-NOAIJENB, cannot enable after-image journaling without any AIJ journals6 Use the ADD JOURNAL clause to create journal files.C The ENABLED option can be followed by a list of database journal options.B All journal files remain unchanged but become inaccessible when@ you disable them. You cannot specify database journal options with the DISABLED option. 4 JOURNAL_IS_UNSUPPRESSED@ If a journal file becomes inaccessible, it is disabled by theD journaling system. It remains in that state until you correct the5 problem and manually unsuppress that journal file. 4 literal-user-auth@ Specifies the user name and password for access to databases, particularly remote database.B This literal lets you explicitly provide user name and password/ information in the ALTER DATABASE statement. 4 LOCATION_IS_directory-spec; Specifies the name of the default directory to which rowA cache backing file information is written. The database systemD generates a file name (row-cache-name.rdc) automatically for eachD row cache backing file it creates when the RCS process starts up.B Specify a device name and directory name enclosed within single@ quotation marks ('); do not include a file specification. TheB file name is the row-cache-name specified when creating the rowC cache. By default, the location is the directory of the database root file.? The LOCATION clause of the CREATE CACHE, ADD CACHE, or ALTERA CACHE clause overrides this location, which is the default for the database.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 LOCK_PARTITIONING Syntax options:? LOCK PARTITIONING IS ENABLED | LOCK PARTITIONING IS DISABLED< Specifies whether more than one lock tree is used for the@ database or all lock trees for a database are mastered by one database resource tree.D When partitioned lock trees are enabled for a database, locks forB storage areas are separated from the database resource tree andD all locks for each storage area are independently mastered on theB VMScluster node that has the highest traffic for that resource.C OpenVMS determines the node that is using each resource the most1 and moves the resource hierarchy to that node.A You cannot enable lock partitioning for single-file databases.C You should not enable lock partitioning for single-node systems,> because all lock requests are local on single-node systems.- By default, lock partitioning is disabled. 4 LOCK_TIMEOUT_INTERVAL Syntax option:2 LOCK TIMEOUT INTERVAL IS number-seconds SECONDSA Specifies the number of seconds for processes to wait during aC lock conflict before timing out. The number can be between 1 and 65,000 seconds.@ Specifying 0 is interpreted as no lock timeout interval being+ set. It is not interpreted as 0 seconds.< The lock timeout interval is database-wide; it is used as? the default and the upper limit when determining the timeout@ interval. For example, if the database definer specified LOCKB TIMEOUT INTERVAL IS 25 SECONDS in the ALTER DATABASE statement,C and a user of that database specified SET TRANSACTION WAIT 30 orA changed the logical name RDM$BIND_LOCK_TIMEOUT_INTERVAL to 30,B SQL still uses the interval 25. For more information on timeoutD intervals, see the Oracle Rdb7 Guide to Distributed Transactions. 4 LOCKING_level Syntax options:/ LOCKING IS ROW LEVEL | LOCKING IS PAGE LEVEL@ Specifies if locking is at the page or row level. This clau se> provides an alternative to requesting locks on records. The default is ROW LEVEL.B When many records are accessed in the same area and on the sameD page, the LOCKING IS PAGE LEVEL clause reduces the number of lockD operations perfomed to process a transaction; however, this is atB the expense of reduced concurrency because these page locks areB held until COMMIT/ROLLBACK time. Transactions that benefit most@ with page-level locking are of short duration and also access-  several database records on the same page.B Use the LOCKING IS ROW LEVEL clause if transactions are long in duration and lock many rows.9 The LOCKING IS PAGE LEVEL clause causes fewer blocking> asynchronous system traps and provides better response timeB and utilization of system resources. However, there is a higherA contention for pages and increased potential for deadlocks and- long transactions may use excessive locks.C Page-level locking is never applied to !RDB$SYSTEM or the DEFAULT= storage area, either implicitly or explicitly, because the- locking protocol can stall metadata users.B You cannot specify page-level locking on single-file databases. 4 LOG_SERVER Syntax options:1 LOG SERVER IS MANUAL | LOG SERVER IS AUTOMATICA Specifies if the AIJ log server (ALS) is activated manually or( automatically. The default is manual.> Multiple-user databases with medium to high update activity> can experience af "ter-image journal (.aij) file bottlenecks.A To alleviate these bottlenecks, you can specify the LOG SERVERD clause to transfer log data to the .aij file either automaticallyC or manually. On a single node with ALS, there is no AIJ locking.? If the log server is set to MANUAL, you must execute the RMUA Server After_Journal command with the Start qualifier to startC the log server. In this case, the database must already be open.C If the OPEN IS MANUAL clause was specified, a #n explicit RMU OpenA command needs to be executed before the log server is started.> If the OPEN IS AUTOMATIC clause was specified, at least one@ user should be attached to the database before the log server is started.D If the log server is set to AUTOMATIC, the log server starts whenA the database is opened, automatically or manually, and is shut$ down when the database is closed.C For more information on setting log servers, see the Oracle Rdb7, Guide to Database$ Performance and Tuning. 4 LOGMINER_SUPPORT Syntax options:; LOGMINER SUPPORT IS ENABLED|LOGMINER SUPPORT IS DISABLEDA Allows additional information to be written to the after-image> journal file to allow the use of the RMU Unload After_ImageA command. See the Oracle RMU Reference Manual for more details.+ Logminer support is disabled by default.= The LOGMINER SUPPORT clause allows the continuous mode for' LogMiner to be enabled and disabled.. o LO%GMINER SUPPORT IS ENABLED (CONTINUOUS)" Enables continuous LogMiner.2 o LOGMINER SUPPORT IS ENABLED (NOT CONTINUOUS)@ Disables continuous LogMiner, but leaves LogMiner enabled." o LOGMINER SUPPORT IS DISABLEDA Disables LogMiner, including disabling continuous LogMiner. 4 MAXIMUM_BUFFER_COUNT Syntax option:' MAXIMUM BUFFER COUNT IS buffer-count7 Specifies the number of buffers a process will write asynchronously.D The default is &one-fifth of the buffer pool, but not more than 10D buffers. The minimum value is 2 buffers; the maximum value can be as large as the buffer pool.7 You can override the number of buffers to be writtenB asynchronously by defining the logical name RDM$BIND_BATCH_MAX.C For information about how to set the values, see the Oracle Rdb7, Guide to Database Performance and Tuning. 4 MAXIMUM_PAGES Syntax option: MAXIMUM OF max-pages PAGESD Specifies the maximum' number of pages of each extent. The default is 9999 pages. 4 METADATA_CHANGES Syntax options:? METADATA CHANGES ARE ENABLED | METADATA CHANGES ARE DISABLED? Specifies whether or not data definition changes are allowed; to the database. This attribute becomes effective at the? next database attach and affects all ALTER, CREATE, and DROPA statements (except ALTER DATABASE which is needed for databaseD tuning) and the GRANT, REVOKE, and TRUNCATE TABLE state(ments. For example:( SQL> CREATE DATABASE FILENAME sample;# SQL> CREATE TABLE t (a INTEGER); SQL> DISCONNECT ALL;& SQL> ALTER DATABASE FILENAME sample' cont> METADATA CHANGES ARE DISABLED;! SQL> ATTACH 'FILENAME sample';# SQL> CREATE TABLE s (b INTEGER);0 %RDB-E-NO_META_UPDATE, metadata update failed7 -RDMS-E-NOMETADATA, metadata operations are disabledD The METADATA CHANGES ARE DISABLED clause prevents data definition changes to the database.A T)he METADATA CHANGES ARE ENABLED clause allows data definitionB changes to the database by users granted the DBADMIN privilege./ METADATA CHANGES ARE ENABLED is the default. 4 MINIMUM_PAGES Syntax option: MINIMUM OF min-pages PAGESD Specifies the minimum number of pages of each extent. The default is 99 pages. 4 MULTISCHEMA Syntax options:) MULTISCHEMA IS ON | MULTISCHEMA IS OFF= Specifies the multischema attribute for the database. If *aB database has the multischema attribute, you can create multiple? schemas in that database and group them within catalogs. The@ MULTISCHEMA IS ON option is the default for databases createdD with the multischema attribute. MULTISCHEMA IS OFF is the default; for databases created without the multischema attribute.B You can create a database using the CREATE DATABASE MULTISCHEMAA IS ON clause, but you cannot use ALTER DATABASE MULTISCHEMA ISB OFF to take away the multisch+ema attribute. Once a database has3 the multischema attribute, you cannot change it. 4 NO_BACKUP_FILENAME> Removes a previously established backup file specification. 4 NO_LOCATIONB This is a subclause of other clauses and has different effects,= depending upon the clause in which it is used, as follows:% o In the row-cache-options clause@ Removes the location previously specified in a LOCATION IS? clause for the row cache. If you specify NO LOCA,TION, theC row cache location becomes the directory of the database root file.B The LOCATION clause of the CREATE CACHE, ADD CACHE, or ALTERD CACHE clause overrides this location, which is the default for the database.? o In a CREATE CACHE, ADD CACHE, or ALTER CACHE clause (row- cache-params1 clause)@ Removes the location previously specified in a LOCATION IS> clause for the row cache backing file. If you specify NO? LOCATION, th-e row cache location becomes the directory of the database root file.; This clause is ignored if the row cache is defined to! checkpoint to the database. 4 NO_ROW_CACHEC Specifies that the database default is to not assign a row cacheB to all storage areas in the database. You cannot specify the NO: ROW CACHE clause if you specify the CACHE USING clause.> Alter the storage area and name a row cache to override theC database default. Only one row ca.che is allowed for each storage area.C If you do not specify the NO ROW CACHE clause or the CACHE USING7 clause, then the NO ROW CACHE clause is the default. 4 NO_SWEEP_INTERVAL4 NO SWEEP INTERVAL disables periodic timed sweeps. 4 NOTIFY Syntax options:) NOTIFY IS ENABLED | NOTIFY IS DISABLED@ Specifies whether system notification is enabled or disabled.B When the system notification is enabled, the system is notifiedD (using the OpenVMS OP/COM facility) in the event of events such as+ running out of disk space for a journal.A If you specify the NOTIFY IS ENABLED clause and do not specifyC the ALERT OPERATOR clause, the operator classes used are CENTRAL@ and CLUSTER. To specify other operator classes, use the ALERT OPERATOR clause.D The NOTIFY IS ENABLED clause replaces any operator classes set by, the RMU Set After_Journal Notify command. The default is disabled. 4 NUMBER_global_buffers 0 Syntax option: NUMBER IS number-glo-buffersC Specifies the total number of buffers in the global buffer pool.C This number appears as "global buffer count" in RMU Dump command? output. Base this value on the database users' needs and the> number of attachments. The default is the maximum number of attachments multiplied by 5.& NOTE? Do not confuse the NUMBER IS parameter with the NUMBER OF> BUFFERS IS parameter. The NUMB 1ER OF BUFFERS IS parameter9 determines the default number of buffers Oracle Rdb; allocates to each user's process that attaches to the> database. The NUMBER OF BUFFERS IS parameter applies to,? and has the same meaning for, local and global buffering.A The NUMBER IS parameter has meaning only within the context of global buffering.C You can override the default number of user-allocated buffers byC defining a value for the logical name RDM$BIND_BUFFERS.2 For moreB information on user-allocated buffers, see Oracle Rdb7 Guide to# Database Performance and Tuning.? Although you can change the NUMBER IS parameter on line, theB change does not take effect until the next time the database is opened. 4 NUMBER_OF_BUFFERS Syntax option:& NUMBER OF BUFFERS IS number-buffersB The number of buffers SQL allocates for each process using thisB database. Specify an unsigned integer with a value greater thanD or equa3l to 2 and less than or equal to 32,767. The default is 20 buffers. 4 NUMBER_OF_CLUSTER_NODES Syntax option:* NUMBER OF CLUSTER NODES IS number-nodesB Sets the upper limit on the maximum number of VMS cluster nodes@ from which users can access the shared database. Specify thisD clause only if the database named in the ALTER DATABASE statement? refers to a multifile database. The default is 16 nodes. TheB range is 1 to 96 nodes. The actual maximum limit is the 4 current; VMS cluster node limit set by your system administrator.@ The Oracle Rdb root file data structures (.rdb) are mapped toA shared memory, each such shared memory copy is known as an RdbD instance. When there is only one copy of shared memory containing> root file information, several optimizations are enabled to@ reduce locking and root file I/O. activity. Specify NUMBER OFB CLUSTER NODES is set to 1, or use the SINGLE INSTANCE clause to enable these optimizations.5= MULTIPLE INSTANCE means that the Oracle Rdb root file dataD structures are mapped on different system and are kept consistent= through disk I/O. Such systems can not benefit from single< instance optimizations. MULTIPLE INSTANCE is the default. 4 NUMBER_OF_RECOVERY_BUFFERS Syntax option:/ NUMBER OF RECOVERY BUFFERS IS number-buffers= Specifies the number of buffers allocated to the automatic? recovery process that Oracle Rdb initiates after a system or 6@ process failure. This recovery process uses the recovery-unit& journal file (.ruj file extension).A You can specify any number greater than or equal to 2 and less? than or equal to 32,767. The default value for the NUMBER OFC RECOVERY BUFFERS parameter is 20. If you have a large, multifileC database and you work on a system with a large amount of memory,C specify a large number of buffers. The result is faster recovery@ time. However, make sure your buffer pool does no 7t exceed the2 amount of memory you can allocate for the pool.C Use the NUMBER OF RECOVERY BUFFERS option to increase the number0 of buffers allocated to the recovery process.) SQL> ALTER DATABASE FILENAME personnel, cont> NUMBER OF RECOVERY BUFFERS IS 150;C This option is used only if the NUMBER OF RECOVERY BUFFERS valueC is larger than the NUMBER OF BUFFERS value. For more information> on allocating recovery buffers, see the Oracle Rdb Guide to Database Maintena8nce. 4 NUMBER_OF_SWEEP_ROWS Syntax option: NUMBER OF SWEEP ROWS IS nB Specifies the number of modified rows that will be written fromC the row cache back to the database by the row cache server (RCS)B process during a sweep operation. When the RCS is notified that@ a cache is "full" of modified data, the RCS starts a sweep to@ make space available in the cache for subsequent transactions? to be able to insert rows into the cache. Oracle CorporationA recom9mends that you initially specify the number of sweep rows? to be approximately 5 percent of the total number of rows in? the cache. Then monitor performance and adjust the number ofD sweep rows, if necessary. Allowable values must be in the range 2? through 524288. If not specified, the default is 3,000 rows. 4 NUMBER_OF_USERS Syntax option:" NUMBER OF USERS IS number-usersD Limits the maximum number of users allowed to access the databaseA at one time. Spec :ify this clause only if the database named in? the ALTER DATABASE statement refers to a multifile database.B The default is 50 users. After the maximum is reached, the nextB user who tries to invoke the database receives an error message@ and must wait. The maximum number of users you can specify is# 16368 and the minimum is 1 user.? Note that number of users is defined as the number of active> attachments to the database. Therefore, if a single process= is running one ;program but that program performs 12 attach> operations, the process is responsible for 12 active users.@ If you use the ALTER DATABASE statement to change the currentC number of users, the change is not journaled. Therefore, back up- your database before making such a change. 4 OPEN Syntax options:% OPEN IS AUTOMATIC | OPEN IS MANUALB Specifies whether or not the database must be explicitly openedA before users can attach to it. The default, OPEN IS AUTOM<ATIC,A means that any user can open a previously unopened or a closed= database by attaching to it and executing a statement. The@ OPEN IS MANUAL option means that a privileged user must issue< an explicit OPEN statement through Oracle RMU, the Oracle? Rdb management utility, before other users can attach to the database.< To issue the RMU Open command, you must have the RMU$OPEN privilege for the database.8 The OPEN IS MANUAL option limits access to databases.@= You will receive an error message if you specify both OPEN IS( AUTOMATIC and OPEN IS MANUAL options. 4 OVERWRITE Syntax options:/ OVERWRITE IS ENABLED | OVERWRITE IS DISABLEDA Specifies whether the overwrite option is enabled or disabled.C After-image journal files are used for database recovery in case? of media failure and for transaction recovery as part of theB fast commit feature. In some environments, only the fast commitA feature is of interest an >d a small set of journal files can beD used as a circular fast commit log with no backup of the contentsD required. The OVERWRITE option instructs Oracle Rdb to write overB journal records that would normally be used for media recovery.A The resulting set of journal files is unable to be used by the* RMU Recover command for media recovery.D The OVERWRITE option is ignored when only one after-image journalD (.aij) file exists. Adding subsequent journal files activates the O?VERWRITE option. The default is DISABLED. 4 PAGE_TRANSFER Syntax options:4 PAGE TRANSFER VIA DISK | PAGE TRANSFER VIA MEMORYD Specifies whether Oracle Rdb transfers (flushes) pages to disk or to memory.C When you specify PAGE TRANSFER VIA MEMORY, processes on a single= node can share and update database pages in memory withoutD transferring the pages to disk. It is not necessary for a processC to write a modified page to disk before another process a@ccesses the page.C The default is to DISK. If you specify PAGE TRANSFER VIA MEMORY,8 the database must have the following characteristics:A o The NUMBER OF NODES must be one, or SINGLE INSTANCE must be6 specified in the NUMBER OF CLUSTER NODES clause.% o GLOBAL BUFFERS must be enabled.- o After-image journaling must be enabled." o FAST COMMIT must be enabled.B If the database does not have these characteristics, Oracle Rdb( will perform page trans Afers via disk.A For more information about page transfers, see the Oracle Rdb7, Guide to Database Performance and Tuning. 4 PATHNAME_path_nameB Identifies the database root file associated with the database.B If you specify a repository path name, the path name indirectlyA specifies the database root file. The ALTER DATABASE statementD does not change any definitions in the repository, so there is noC difference in the effect of the PATHNAME and FILENAME arguments.BC If the database referred to in the PATHNAME or FILENAME argumentC has been attached, the ALTER DATABASE statement will fail with a file access conflict error. 4 PERCENT_GROWTH Syntax option: PERCENT GROWTH IS growthA Specifies the percent growth of each extent. The default is 20 percent growth. 4 PRESTARTED_TRANSACTIONS Syntax options:B PRESTARTED TRANSACTIONS ARE ENABLED (prestart-trans-options)* PRESTARTED TRANSACTIONS ARE CDISABLED7 Enables or disables the prestarting of transactions.@ Note that the keyword OFF, available in previous versions, is synonymous with DISABLED. 4 READ_WRITE,READ_ONLYB The READ options of the alter-storage-area-params clause permit9 you to change existing storage area access as follows:@ o Select the READ WRITE option to change any storage area to read/write access.? o Select the READ ONLY option to change any storage area to read-onlDy access.C If you want to change the read-only and read/write parameters ofD the RDB$SYSTEM storage area, you must specify these parameters atC this point of your ALTER DATABASE statement and not in the ALTER$ STORAGE AREA clause. For example:A SQL> -- You can change the RDB$SYSTEM storage area by altering SQL> -- the database. SQL> --, SQL> ALTER DATABASE FILENAME mf_personnel cont> READ ONLY; SQL> --K SQL> -- An error is returned if you try to change theE RDB$SYSTEM storageA SQL> -- area to read-only using the ALTER STORAGE AREA clause. SQL> --, SQL> ALTER DATABASE FILENAME mf_personnel& cont> ALTER STORAGE AREA RDB$SYSTEM cont> READ ONLY;F %RDB-E-BAD_DPB_CONTENT, invalid database parameters in the database parameter block (DPB)H -RDMS-E-NOCHGRDBSYS, cannot change RDB$SYSTEM storage area explicitlyB SQL provides support for read-only databases and databases with' one or more read-only storage areas.< You canF take advantage of read-only support if you have aB stable body of data that is never (or rarely) updated. When theB RDB$SYSTEM storage area is changed to read-only, lock conflictsA occur less frequently, and the automatic updating of index and" table cardinality is inhibited." Read-only databases consist of:% o A read/write database root fileC o One or more read-only storage areas and no read/write storage areasB Read-only databases can be published and diGstributed on CD-ROM. Read-only storage areas:C o Have snapshot files but do not use them. (Data in a read-onlyA storage area is not updated; specify a small number for the? initial snapshot file size for a read-only storage area.)@ o Eliminate page and record locking in the read-only storage areas.C o Are backed up by the RMU Backup command by default unless you@ explicitly state the Noread_Only qualifier, which excludes* read-only areas withHout naming them.: o Are restored by the RMU Restore command if they were previously backed up.C o Are recovered by the RMU Recover command. However, unless theC read-only attribute was modified, the read-only area does not change.B o Are not recovered by the RMU Recover command with the Area=*A qualifier, in which you are not explicitly naming the areas5 needing recovery, unless they are inconsistent.= You use the READ ONLY option to change Ia storage area from> read/write to read-only access. If you wanted to facilitateD batch-update transactions to infrequently changed data, you wouldD use the READ WRITE option to change a read-only storage area back to read/write.C If you change a read/write storage area to read-only, you cannot? specify the EXTENT, SNAPSHOT ALLOCATION, and SNAPSHOT EXTENT clauses.B A database with both read/write and read-only storage areas can@ be fully recovered after a system f Jailure only if after-image> journaling is enabled on the database. If your database has@ both read/write and read-only storage areas but does not haveA after-image journaling enabled, perform full backup operations> (including read-only areas) at all times. Doing full backup? operations enables you to recover the entire database to its: condition at the time of the previous backup operation.B For a complete description of read-only databases and read-onlyC storage areas, seKe the Oracle Rdb7 Guide to Database Performance and Tuning. #4 RECOVERY_JOURNAL_(BUFFER_MEMORY) Syntax options: BUFFER MEMORY IS LOCAL BUFFER MEMORY IS GLOBAL? Specifies whether RUJ buffers will be allocated in global or local memory.A The RUJ buffers used by each process are normally allocated inD local virtual memory. With the introduction of row caching, theseA buffers now can be assigned to a shared global section (globalD memory) on OpenVMLS, so that the recovery process can process this5 in-memory buffer and possibly avoid a disk access.@ You can define this buffer memory to be global to improve row@ caching performance for recovery. If row caching is disabled,& then buffer memory is always local. 4 RECOVERY_JOURNAL_(LOCATION) Syntax options:0 RECOVERY JOURNAL (LOCATION IS directory-spec)C Specifies the location, including device and directory, in whichC the recovery-unit journal (.ruj) file iMs written. Do not include> network node names, file names or process-concealed logical9 names. The default is the current user's login device.< See the Oracle Rdb Guide to Database Maintenance for more. information on recovery-unit journal files.- Following is an example using this clause:& SQL> ALTER DATABASE FILENAME SAMPLED cont> RECOVERY JOURNAL (LOCATION IS 'SQL_USER1:[DBDIR.RECOVER]'); !4 RECOVERY_JOURNAL_(NO_LOCATION)> Removes a location previously defNined by a RECOVERY JOURNALA LOCATION IS clause. This causes the recovery journal to revert to the default location. 4 RESERVE_n_CACHE_SLOTSB Specifies the number of row caches for which slots are reserved in the database.A You can use the RESERVE CACHE SLOTS clause to reserve slots inB the database root file for furture use by the ADD CACHE clause.@ You can only add row caches if row cache slots are available.B Slots become available after you issue a DROP CACOHE clause or a RESERVE CACHE SLOTS clause.B You cannot reduce the number of reserved slots for row caching.C If you reserve 10 slots and later reserve 5 slots, a total of 15% slots are reserved for row caches. 4 RESERVE_n_JOURNALS? Specifies the number of journal files for which slots are toA reserve in the database. The number of slots for journal files/ must be a positive number greater than zero.A This feature is additive in nature. In other words, the n Pumber? of reserved slots for journal files cannot be decreased onceB the RESERVE clause has been issued. If you reserve 10 slots andC later reserve 5 slots, you have a total of 15 reserved slots forA journal files plus 1 slot (totaling 16 reserved slots) because) you initially get 1 pre-reserved slot.C You must reserve slots or delete an existing journal file before1 you can add new journal files to the database.? You cannot reserve journal files for a single-file da Qtabase. 4 RESERVE_n_SEQUENCESD Specifies the number of sequences for which slots are reserved inD the database. Sequences are reserved in multiples of 32. Thus, ifD you specify a value less than 32 for n, 32 slots are reserved. If? you specify a value of 33, 64 slots are reserved, and so on.? You can use the RESERVE SEQUENCES clause to reserve slots in? the database root file for future use by the CREATE SEQUENCEA statement. Sequences can be created only if sequencRe slots areD available. Slots become available after a DROP SEQUENCE statementC or a RESERVE SEQUENCES clause of the ALTER DATABASE statement is executed. 4 RESERVE_n_STORAGE_AREAS? Specifies the number of storage areas for which slots are toA reserve in the database. The number of slots for storage areas/ must be a positive number greater than zero.? You can use the RESERVE STORAGE AREA clause to reserve slots> in the database root file for future use by the S ADD STORAGEA AREA clause of the ALTER DATABASE statement. Storage areas canA be added only if there are storage area slots available. SlotsA become available after a DROP STORAGE AREA clause or a RESERVE! STORAGE AREA clause is issued.A This feature is additive in nature. In other words, the number? of reserved slots for storage areas cannot be decreased onceB the RESERVE clause is issued. If you reserve 10 slots and later= reserve 5 slots, you have a total of 15 reserTved slots for storage areas.C You must reserve slots or delete an existing storage area before1 you can add new storage areas to the database.= If you do not specify the RESERVE STORAGE AREA clause, the4 default number of reserved storage areas is zero. 4 ROW_CACHE Syntax options:/ ROW CACHE IS ENABLED | ROW CACHE IS DISABLED? Specifies whether or not the row caching feature is enabled.C Enabling row caching does not affect database operations unUtil a> cache is created and assigned to one or more storage areas.D When row caching is disabled, all previously created and assigned@ caches remain and will be available if row caching is enabled again.D The following conditions must be true in order to use row caches:( o The number of cluster nodes is one' o After-image journaling is enabled o Fast commit is enabled* o One or more cache slots are reserved o Row caching is enabled? Use the RVMU Dump Header command to check if you have met theB requirements for using row caches. The following command output< displays a warning for every requirement that is not met: . . . Row Caches... - Active row cache count is 0" - Reserved row cache count is 1 - Sweep interval is 1 second' - Default cache file directory is ""3 - WARNING: Maximum node count is 16 instead of 10 - WARNING: After-image journaling is disabled% - WARWNING: Fast commit is disabled . . "4 SAME_BACKUP_FILENAME_AS_JOURNALC During execution, the backup server assigns the same name to theC backup file as it does to the journal file. This is a quick form& of backup as a new file is created.& NOTEA Oracle Corporation recommends that you save the old journalB file on tape or other media to prevent accidental purging of these files. 4 SECURITY_CHECKINGXA Traditionally Oracle Rdb has performed security checking using@ the operating system security layer (for example, the UIC and7 rights identifiers of the OpenVMS operating system).C The access control list (ACL) information stored in the databaseC contains a granted privilege mask and a set of users represented, by a unique integer (for example, a UIC)., There are two modes of security checking:# 1. SECURITY CHECKING IS EXTERNAL@ This is the default. Externa Yl security checking recognizesB database users as operating system user identification codes? (UICs) and roles as special rights identifiers or groups.8 PERSONA support is enabled or disabled as follows:C o SECURITY CHECKING IS EXTERNAL (PERSONA SUPPORT IS ENABLED)@ Enables the full impersonation of an OpenVMS user. ThisD means the UIC and the granted right identifiers are used to/ check access control list permissions.D o SECURITY CH ZECKING IS EXTERNAL (PERSONA SUPPORT IS DISABLED)A Disables the full impersonation of an OpenVMS user. OnlyB the UIC is used to check access control list permissions.B This is the default for a new database, or for a database6 converted from a prior version of Oracle Rdb.# 2. SECURITY CHECKING IS INTERNALC In this mode, Oracle Rdb records users (username and UIC) andA roles (rights identifiers) in the database. The CREATE USERD and CREA [TE ROLE statements perform this action explicitly, andC GRANT will perform this implicitly. This type of database canA now be moved to another system and is only dependent on the# names of the users and roles.A o SECURITY CHECKING IS INTERNAL (ACCOUNT CHECK IS ENABLED)C The ACCOUNT CHECK clause ensures that Oracle Rdb validates> the current database user with the user name (such as< defined with a CREATE USER statement) stored in theC \ database. This prevents different users with the same nameB from accessing the database. Therefore, this clause might& prevent a breach in security.B The ACCOUNT CHECK IS ENABLED clause on OpenVMS forces theD user session to have the same user name and UIC as recorded in the database.B o SECURITY CHECKING IS INTERNAL (ACCOUNT CHECK IS DISABLED)B If you specify the ACCOUNT CHECK IS DISABLED clause, thenA a user with a mat ]ching UIC (also called a profile-id) is@ considered the same as the user even if his or her userD name is different. This allows support for multiple OpenVMS! users with the same UIC. 4 SET_TRANSACTION_MODESC Enables only the modes specified, disabling all other previously; defined modes. This is an offline operation and requiresD exclusive database access. For example, if a database is used forA read-only access and you want to disable all other tr^ansaction* modes, specify the following statement:, SQL> ALTER DATABASE FILENAME mf_personnel- cont> SET TRANSACTION MODES (READ ONLY);@ Specifying a negated txn-mode or specifying NONE disables all> transaction usage. Disabling all transaction usage would beD useful when, for example, you want to perform major restructuringD of the physical database. Execute the ALTER DATABASE statement to re-enable transaction modes. 4 SHARED_MEMORY Syntax options:_ SHARED MEMORY IS SYSTEM SHARED MEMORY IS PROCESS' SHARED MEMORY IS PROCESS RESIDENTBDetermines whether database root global sections (including globalCbuffers when enabled) are created in system space or process space.The default is PROCESS.A When you use global sections created in the process space, youB and other users share physical memory and the OpenVMS operatingD system maps a row cache to a private address space for each user.A As a result, all us `ers are limited by the free virtual addressA range and each use a percentage of memory in overhead. If many> users are accessing the database, the overhead can be high.D When many users are accessing the database, consider using SHAREDB MEMORY IS SYSTEM. This gives users more physical memory becauseA they share the system space of memory and there is none of the8 overhead associated with the process space of memory.+ The default is SHARED MEMORY IS PROCESS.= When you ause this clause as a cache attribute, it controlsC whether Oracle Rdb creates cache global sections in system space, or process space. The default is PROCESS.C The SHARED MEMORY clause determines whether database root globalB sections (including global buffers when enabled) or whether the? cache global sections are created in system space or processB space. The RESIDENT option extends the PROCESS option by making& the global section memory resident.> To enable or disablbe SHARED MEMORY IS PROCESS RESIDENT, the= process executing the command must be granted the VMS$MEM_A RESIDENT_USER rights identifier. When this feature is enabled,? the process that opens the database must also be granted the> VMS$MEM_RESIDENT_USER rights identifier. Oracle Corporation< recommends using the RMU Open command when utilizing this feature. 4 SHUTDOWN_TIME Syntax option: SHUTDOWN TIME IS n MINUTES@ Specifies the number of minutes the datab case system will wait@ after a catastrophic event before it shuts down the database.A The shutdown time is the period, in minutes, between the point@ when the after-image journaling subsystem becomes unavailableB and the point when the database is shut down. During the after-D image journaling shutdown period, all database update activity is stalled.A If notification is enabled with the NOTIFY IS clause, operator> messages will be broadcast to all enabled operator classes. d@ To recover from the after-image journaling shutdown state andC to resume normal database operations, you must make an .aij file? available for use. You can do this by backing up an existingD modified journal file, or, if you have a journal file reservation= available, by adding a new journal file to the after-imageD journaling subsystem. If you do not make a journal file available< before the after-image journal shutdown time expires, theA database will be shut down and eall active database attachments will be terminated.D The after-image journaling shutdown period is only in effect when@ a fixed-size .aij file is used. When a single extensible .aij@ file is used, the default action is to shut down all database5 operations when the .aij file becomes unavailable.@ The default is 60 minutes. The minimum value is 1 minute; the* maximum value is 4320 minutes (3 days). 4 SNAPSHOT_ALLOCATION Syntax option:) SNAPSHOT ALLOCATIONf IS snp-pages PAGESC Changes the number of pages allocated for the snapshot file. TheD default is 100 pages. If you have disabled the snapshot file, you. can set the snapshot allocation to 0 pages. 4 SNAPSHOT_EXTENT Syntax options:= SNAPSHOT EXTENT IS extent-pages PAGES | SNAPSHOT EXTENT IS (extension-options)D Changes the number of pages of each snapshot or storage area fileB extent. The default extent for storage area files is 100 pages.= Specify a ngumber of pages for simple control over the file@ extent. For greater control, and particularly for multivolumeD databases, use the MINIMUM, MAXIMUM, and PERCENT GROWTH extension options instead.B If you use the MINIMUM, MAXIMUM, and PERCENT GROWTH parameters,( you must enclose them in parentheses. 4 SNAPSHOT_IS_ENABLED Syntax options:/ SNAPSHOT IS IMMEDIATE | SNAPSHOT IS DEFERREDC Specifies when read/write transactions write database changes to4 the sna hpshot file used by read-only transactions.D The ENABLED IMMEDIATE option is the default and causes read/writeC transactions to write copies of rows they modify to the snapshot@ file, regardless of whether or not a read-only transaction is@ active. Although ENABLED IMMEDIATE is the default, if you set@ snapshots ENABLED DEFERRED, you must specify both ENABLED andC IMMEDIATE options to return the database to the default setting.; The ENABLED DEFERRED option lets read/write tra insactions@ avoid writing copies of rows they modify to the snapshot file@ (unless a read-only transaction is already active). Deferring? snapshot writing in this manner improves the performance forC the read/write transaction. However, read-only transactions thatD start after an active read/write transaction starts must wait for> all active read/write users to complete their transactions. 4 SNAPSHOT_IS_DISABLEDC Specifies that snapshot writing be disabled. Snapshot wjriting is enabled by default.C In this mode any READ ONLY transaction will be converted to READ WRITE mode automatically. 4 STATISTICS_COLLECTION Syntax options:> STATISTICS COLLECTION IS ENABLED | STATISTICS COLLECTION IS DISABLEDB Specifies whether the collection of statistics for the database> is enabled or disabled. When you disable statistics for theB database, statistics are not displayed for any of the processesC attached to the database. Sta ktistics are displayed using the RMU Show Statistics command.C The default is STATISTICS COLLECTION IS ENABLED. You can disable= statistics using the ALTER DATABASE and IMPORT statements.C For more information on the RMU Show Statistics command, see the Oracle RMU Reference Manual.? You can enable statistics collection by defining the logicalB name RDM$BIND_STATS_ENABLED. For more information about when toC use statistics collection, see the Oracle Rdb7 Guide to Dlatabase Performance and Tuning. 4 storage-area-paramsC Parameters that control the characteristics of the storage area.B For more information on the parameters, see the CREATE STORAGE_ AREA statement. 4 SWEEP_INTERVAL Syntax option: SWEEP INTERVAL IS n SECONDS@ Specifies the interval, in seconds, between each Record CacheC Server (RCS) sweep. Allowable values must be in the range from 15 second to 3600 seconds (1 hour). The default is 1.=m The Record Cache Server (RCS) is a detached server processC automatically invoked by the monitor when row caching is active.A A sweep is one full pass through all active row cache areas to: write modified rows back to the database storage areas. 4 SYNONYMS_ARE_ENABLED= Adds the optional system table RDB$OBJECT_SYNONYMS that is@ used for the CREATE SYNONYM, ALTER . . . RENAME TO and RENAME2 statements. The default if omitted is disabled. 4 THRESHOLD_buffersn_option Syntax option:$ THRESHOLD IS number-buffers PAGESB This number represents the number of sequential buffer accessesC that must be detected before prefetching is started. The default is four buffers.D If you specify the THRESHOLD option, you must have also specifiedB the DETECTED ASYNC PREFETCH clause. You receive an error if youB attempt to specify the THRESHOLD option with the ASYNC PREFETCH clause. 4 TRANSACTION_INTERVAL Syntax option: o& TRANSACTION INTERVAL IS number-txns? The TRANSACTION INTERVAL IS clause specifies the size of theC transaction sequence number (TSN) range where number-txns equalsC the number of TSNs. Oracle Rdb uses transaction sequence numbers> to ensure database integrity. When you specify NO COMMIT TO@ JOURNAL OPTIMIZATION, Oracle Rdb assigns TSNs to users one atB a time. When you enable the journal optimization option, OracleA Rdb preassigns a range of TSNs to each user. Assignin pg a range? of TSNs means that commit information need not be written to@ the database root for each transaction. Oracle Rdb writes allB transaction information to the .aij file except for each user's9 allocated TSN range, which it writes to the root file.B The transaction interval value (the TSN range) must be a number0 between 8 and 1024. The default value is 256.< In general, if your database has few users or if all userB sessions are long, select a large transaction iqnterval. If yourB database has many users or if user sessions are short, select a smaller transaction interval. 4 txn-modes4 Specifies the transaction modes for the database. Mode Description, Transaction Types@ [NO]READ Allows read-only transactions on the database. ONLYA [NO]READ Allows read/write transactions on the database. WRITEC [NO] BATCH Allows batch-update transactions on the database.= r UPDATE This mode executes without the overhead, or< security, or a recovery-unit journal file.> The batch-update transaction is intended for? the initial loading of a database. Oracle Rdb8 recommends that this mode be disabled.+ Reserving ModesD [NO] SHARED Allows tables to be reserved for shared mode. That= [READ | is, other users can work with those tables. WRI sTE]B [NO] Allows tables to be reserved for protected mode.B PROTECTED That is, other users can read from those tables. [READ | WRITE]D [NO] Allows tables to be reserved for exclusive access.D EXCLUSIVE That is, other users are prevented access to those9 [READ | tables, even in READ ONLY transactions. WRITE]= ALL Allows other users to work with all tables.- NONE Allows no access to tables.= For detailetd information about the txn-modes, see the SET_ TRANSACTION. 4 USER_LIMIT Syntax option: USER LIMIT IS max-glo-buffers; Specifies the maximum number of global buffers each userB allocates. Because global buffer pools are shared by all users,> you must define an upper limit on how many global buffers a< single user can allocate. This limit prevents a user fromA defining RDM$BIND_BUFFERS to use all the buffers in the global? buffer pool. The user limit c uannot be greater than the total= number of global buffers. The default is 5 global buffers.B Decide the maximum number of global buffers a user can allocate> by dividing the total number of global buffers by the total? number of users for whom you want to guarantee access to theB database. For example, if the total number of global buffers isD 200 and you want to guarantee access to the database for at leastA 10 users, set the maximum number of global buffers per user to v 20.? For maximum performance on a VMScluster system, tune the twoA global buffer parameters on each node in the cluster using the6 RMU Open command with the Global_Buffers qualifier.C Although you can change the USER LIMIT IS parameter on line, theB change does not take effect until the next time the database is opened.> The NUMBER IS and USER LIMIT IS parameters are the only twoC buffer parameters specific to global buffers. They are in effect7 on a per node baswis rather than a per process basis. 4 USER_username Syntax options: USER 'username'A A character string literal that specifies the operating systemB user name that the database system uses for privilege checking.; This clause also sets the value of the SYSTEM_USER value expression. 4 USING_password Syntax options: USING 'password'D A character string literal that specifies the user's password for. the user name specified in the USER cxlause. 4 WAIT_option Syntax option: WAIT n MINUTES FOR CLOSE< Specifies the amount of time that Oracle Rdb waits beforeC automatically closing a database. If anyone attaches during that) wait time, the database is not closed.= The default value for n is zero (0) if the WAIT clause is= not specified. The value for n can range from zero (0) toA 35,791,394. However, Oracle Rdb does not recommend using large values. 4 WORKLOAD_COLLECTION y Syntax options:C WORKLOAD COLLECTION IS ENABLED | WORKLOAD COLLECTION IS DISABLED: Specifies whether or not the optimizer records workload= information in the system table RDB$WORKLOAD. The WORKLOAD< COLLECTION IS ENABLED clause creates this system table if? it does not exist. If you later disable workload collection,@ the RDB$WORKLOAD system table is not deleted, nor is the data deleted.? A workload profile is a description of the interesting tableA and column zreferences used by queries in a database work load.> When workload collection is enabled, the optimizer collectsA and records these references in the RDB$WORKLOAD system table.A This work load is then processed by the RMU Collect Optimizer-D Statistics command which records useful statistics about the workC load. These workload statistics are used by the optimizer at run3 time to deliver more accurate access strategies.. Workload collection is disabled by default. 3 { Examples? Example 1: Changing a read/write storage area to a read-only storage area> This example changes the SALARY_HISTORY storage area from a7 read/write storage area to a read-only storage area., SQL> ALTER DATABASE FILENAME mf_personnel* cont> ALTER STORAGE AREA salary_history cont> READ ONLY;7 Example 2: Adding multiple, fixed-size journal files? This example demonstrates reserving slots for journal files,C enabling the journaling feature, and addi|ng multiple, fixed-size journal files.% SQL> CREATE DATABASE FILENAME test cont> RESERVE 5 JOURNALS& cont> CREATE STORAGE AREA sa_one& cont> ALLOCATION IS 10 PAGES; SQL> DISCONNECT ALL; SQL>$ SQL> ALTER DATABASE FILENAME test cont> JOURNAL IS ENABLED cont> ADD JOURNAL AIJ_ONE cont> FILENAME aij_one& cont> BACKUP FILENAME aij_one cont> ADD JOURNAL AIJ_TWO cont> FILENAME aij_two& cont> BACKUP FI}LENAME aij_two cont> ;A You should place journal files and backup files on disks other( than those that contain the database.9 Example 3: Reserving and using slots for storage areas> This example demonstrates reserving slots for storage areas? and adding storage areas to the database that utilizes thoseD slots. Use the SHOW DATABASE statement to see changes made to the database.' SQL> CREATE DATABASE FILENAME sample# cont> RESERVE 5 STORAGE AREAS* con~t> CREATE STORAGE AREA RDB$SYSTEM% cont> FILENAME sample_system cont> --I cont> -- Storage areas created when the database is created do not useK cont> -- the reserved storage area slots because this operation is being cont> -- executed off line. cont> -- cont> ;J %RDMS-W-DOFULLBCK, full database backup should be done to ensure future recovery SQL> --D SQL> -- Reserving storage area slots is not a journaled activity. SQL> --E SQL> -- To use the reserved slots, you must alter the database and SQL> -- add storage areas. SQL> -- SQL> DISCONNECT ALL;& SQL> ALTER DATABASE FILENAME sample% cont> ADD STORAGE AREA SAMPLE_1 cont> FILENAME sample_1% cont> ADD STORAGE AREA SAMPLE_2! cont> FILENAME sample_2;+ Example 4: Reserving Slots for SequencesD This example shows that reserving extra sequences in the database@ adds to the existing 32 that are provided by default, and the= cou nt rounded up to the next multiple of 32 (that is, 64).D $ SQL$ ALTER DATABASE FILENAME MF_PERSONNEL RESERVE 10 SEQUENCES;S %RDMS-W-DOFULLBCK, full database backup should be done to ensure future recovery* $ RMU/DUMP/HEADER=SEQUENCE MF_PERSONNELR *------------------------------------------------------------------------------R * Oracle Rdb V7.1-200 15-AUG-2003 14:54:26.55 * * Dump of Database header6 * Database: USER2:[DOCS.WORK]MF_PERSONNEL.RDB;1 *R *------------------------------------------------------------------------------ Database Parameters:= Root filename is "USER2:[DOCS.WORK]MF_PERSONNEL.RDB;1" Sequence Numbers... . . . Client sequences...2 - 64 client sequences have been allocated$ - 0 client sequences in use8 Example 5: Adding and Enabling a Row Cache on OpenVMSD The MF_PERSONNEL database is altered to add a row cache, apply it?  to several storage areas and enable row caching. The example> further assumes that after image journals have already beenA defined for the database, they are required for the JOURNAL IS ENABLED clause to succeed. SQL> /*9 ***> Prepare the database for ROW CACHE, include extra$ ***> capacity for later additions ***> */ SQL> alter database" cont> filename MF_PERSONNEL) cont> number of cluster nodes is 18 cont> journal is ENABLED (fast commit is enabled)# cont> reserve 20 cache slots! cont> row cache is ENABLED cont> cont> /*9 ***> Create a physical cache for all the employee rows ***> */! cont> add cache EMPIDS_RCACHE$ cont> shared memory is SYSTEM$ cont> row length is 126 bytes# cont> cache size is 204 rows0 cont> checkpoint updated rows to database cont> cont> /*= ***> Apply the cache to each of the relevant storage areas ***> */' cont> alter storage area EMPIDS_LOW& cont> cache using EMPIDS_RCACHE' cont> alter storage area EMPIDS_MID& cont> cache using EMPIDS_RCACHE( cont> alter storage area EMPIDS_OVER& cont> cache using EMPIDS_RCACHE cont> ;S %RDMS-W-DOFULLBCK, full database backup should be done to ensure future recovery9 Example 6: Establishing a Timeout Value for Prestarted Transactions SQL> ALTER DATABASE cont> FILENAME SAMPLE. cont> PRESTARTED TRANSACTIONS ARE ENABLED+ cont> (WAIT 90 SECONDS FOR TIMEOUT) cont> ; @ Example 7: Altering a Database Specifying the SINGLE INSTANCE Option@ This example prepares a database to be run in a 4 node GALAXY@ cluster. The SINGLE INSTANCE clause is used to enable special@ optimizations that are available because of the galaxy shared memory. SQL> alter database cont> filename MF_PERSONNEL" cont> galaxy support is ENABLED8 cont> number of cluster nodes is 4 (single instance);0 Example 8: Disabling storage if snapshot rowsB The following example demonstrates using SQL to modify the "C1"C cache to disable storage of snapshot rows in cache and to modifyA the "C5" cache to enable storage of snapshot rows in the cache, with a snapshot cache size of 12345 rows:& SQL> ALTER DATABASE FILE EXAMPLE_DB cont> ALTER CACHE C1# cont> ROW SNAPSHOT IS DISABLED; cont> ALTER CACHE C5= cont> ROW SNAPSHOT IS ENABLED (CACHE SIZE IS 12345 ROWS);- Example 9: Using the SWEEP INTERVAL clause9 Here is an example of using the SWEEP INTERVAL clause.- SQL> ALTER DATABASE FILENAME MF_PERSONNELA cont> ROW CACHE IS ENABLED (SWEEP INTERVAL IS 100 seconds) cont> ;' SQL> attach 'filename MF_PERSONNEL';" SQL> show database rdb$dbhandle Default alias:/ Oracle Rdb database in file MF_PERSONNEL . . . Row Cache is Enabled3 Row cache: sweep interval is 100 seconds! Row cache: No Location= Row cache: checkpoint updated rows to backing file . . . 2 DOMAIN Alters a domain definition.@ The ALTER DOMAIN statement lets you change the character set,B data type, optional default value, optional collating sequence,D or optional formatting clauses associated with a domain name. AnyB table or view definitions that refer to that domain reflect the changes. 3 Environment* You can use the ALTER DOMAIN statement:  o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format8 ALTER DOMAIN --> +------------------+---+8 +-> IS data-type --+ |8 +----------------------------------------------------+8 +-+-------------------------------+------------------+8 +-> SET DEFAULT value-expr -----+  |8 +-> DROP DEFAULT ---------------+ |8 +----------------------------------------------------+5 +-+---------------------------------------------+-+5 +---> COLLATING SEQUENCE IS -+ |5 +---> NO COLLATING SEQUENCE ------------------+ |5 +-------------------------------------------------+; +--+-----------------------+-+------------------------+->9 +-> domain-constraint --+ ++> sql-and-dtr-clause -++8 +----------<-----------+ data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+---------------+A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+ |A +-> FLOAT ----------------+ |A +-> NUMBER -+-------------------------------- --+-------------+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE VARYING --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT ---+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) + |A |  +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION ----------------------------------------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+  |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATION AL CHARACTER -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac --------------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+ literal = --+-> numeric-literal ----+---> +-> string-literal -----+ +-> date-time-literal --+ +-> interval-literal ---+  domain-constraint = 4 --+---------------------------------------------+->2 +-> ADD CHECK ( predicate ) NOT DEFERRABLE --+2 +-> DROP ALL CONSTRAINTS ---------------------+  sql-and-dtr-clause = @ -+-> QUERY HEADER IS -+> +------------------+->> | +------ / <--------+ |> +-> EDIT STRING IS ------------------------+> | |> +-> QUERY NAME FOR -+-> DTR --------+-> IS +> |  +-> DATATRIEVE -+ |> +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS ---+> | +-> DATATRIEVE -+ |> +-> NO QUERY HEADER ---------------------------------------+> +-> NO EDIT STRING ----------------------------------------+> +-> NO QUERY NAME ----+--> FOR -+-> DTR --------+----------+> +-> NO DEFAULT VALUE -+ +-> DATATRIEVE -+ |> +-> COMMENT IS -+-> -+---------------------+> |  +------ / <----------+ |> +-> RENAME TO ----------------------------------+  3 Arguments 4 char-data-types; A valid SQL character data type. For more information on7 character data types, see the Data_Types HELP topic. 4 character-set-nameD A valid character set name. For a list of allowable character set6 names, see the Supported_Character_Sets HELP topic. 4 COLLATING_SEQUENCE; Specifies a new collating  sequence for the named domain.> The OpenVMS National Character Set (NCS) utility provides aA set of predefined collating sequences and also lets you defineA collating sequences of your own. The COLLATING SEQUENCE clauseD accepts both predefined and user-defined NCS collating sequences.B Before you use the COLLATING SEQUENCE clause in an ALTER DOMAINC statement, you must first specify the NCS collating sequence forB SQL using the CREATE COLLATING SEQUENCE statement. The sequenceB name argument in the COLLATING SEQUENCE clause must be the sameC as the sequence name in the CREATE COLLATING SEQUENCE statement. 4 COMMENT_IS@ Adds a comment about the domain. SQL displays the text of the@ comment when it executes a SHOW DOMAIN statement. Enclose the? comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 date-time-data-typesA A data type that specifies a date, time, or interval. For more? information on date-time data types, see the Data_Types HELP topic. 4 DEFAULT_value-expr) Provides a default value for a domain.9 You can use any value expression including subqueries,@ conditional, character, date/time, and numeric expressions asC default values. See Value Expressions for more information about value expressions.D For more information about NULL, see the NULL_Keyword HELP topic.? The value expressions described in Value Expressions include@ DBKEY and aggregate functions. However, the DEFAULT clause is? not a valid location for referencing a DBKEY or an aggregate> function. If you attempt to reference either, you receive a compile-time error.@ If you do not specify a DEFAULT for a column, it inherits the? DEFAULT from the domain. If you do not specify a default for? either the column or domain, SQL assigns NULL as the default value. 4 domain-constraint? Adds or modifies a co nstraint for the existing named domain.> Domain constraints specify that columns based on the domain> contain only certain data values or that data values can or cannot be null.@ Use the CHECK clause to specify that a value must be within a@ specified range or that it matches a list of values. When youB specify a CHECK clause for a domain constraint, you ensure that? all values stored in columns based on the domain are checked consistently.D To refer to the values of all columns of a domain constraint, use" the VALUE keyword. For example:" SQL> CREATE DOMAIN dom1 CHAR(1)# cont> CHECK (VALUE IN ('F','M')) cont> NOT DEFERRABLE;= For any dialect other than SQL99, SQL92, ORACLE LEVEL 1 or? ORACLE LEVEL 2, you must specify that domain constraints are NOT DEFERRABLE.? When you add (or modify) a domain constraint, SQL propagatesB the new constraint definition to all the columns that are basedA on the domain. If columns that are based on the domain contain@ data that does not conform to the constraint, SQL returns the following error:J %RDB-E-NOT_VALID, validation on field DATE_COL caused operation to fail 4 domain-nameB The name of a domain you want to alter. The domain name must be- unique among domain names in the database. 4 DROP_DEFAULT1 Deletes (drops) the default value of a domain. 4 IS_datatypeA A valid SQL data type. For more information on data types, see the Data_Types HELP topic. 4 NO_COLLATING_SEQUENCE< Specifies that the named domain uses the standard defaultD collating sequence, that is, ASCII. Use the NO COLLATING SEQUENCEC clause to override the collating sequence defined for the schemaC in the CREATE SCHEMA or ALTER SCHEMA statement, or the domain in the CREATE DOMAIN statement. 4 RENAME_TOC Changes the name of the domain being altered. See the RENAME forD further discussion. If the new name is the name of a synonym then an error will be raised.= The RENAME TO clause requires synonyms be enabled for this? database. Refer to the ALTER DATABASE statement SYNONYMS AREB ENABLED clause. Note that these synonyms may be deleted if they> are no longer used by database definitions or applications. 4 SET_DEFAULTD Provides a default value for a column if the row that is inserted= does not include a value for that column. A column default@ value overrides a domain default value. If you do not specifyC a default value, SQL assigns NULL as the default value. For more; information about NULL, see the NULL_Keyword HELP topic. 4 sql-and-dtr-clause: Optional SQL and DATATRIEVE formatting clause. For moreA information on the formatting clauses, see the DATATRIEVE HELP topic. 4 value-expr+ Specifies the default value of a domain. 3 Examples1 Example 1: Altering the domain POSTAL_CODE_DOM< This example alters the domain POSTAL_CODE_DOM so that it$ accommodates longer postal codes: SQL> --J SQL> -- The data type of the current domain POSTAL_CODE_DOM is CHAR(5): SQL> --# SQL> SHOW DOMAIN POSTAL_CODE_DOM* POSTAL_CODE_DOM CHAR(5)- Comment: standard definition of ZIP Rdb default: SQL> --D SQL> -- Now, alter the domain to accommodate larger postal codes: SQL> --1 SQL> ALTER DOMAIN POSTAL_CODE_DOM IS CHAR(10); SQL> --; SQL> -- The SHOW TABLES statement shows how changing the1 SQL> -- domain POSTAL_CODE_DOM changes all the6 SQL> -- columns that were created using the domain: SQL> -- SQL> SHOW TABLE COLLEGES! Information for table COLLEGES Comment on table COLLEGES:8 names and addresses of colleges attended by employees Columns for table COLLEGES:: Column Name Data Type Domain: ----------- --------- ------ . . .C POSTAL_CODE CHAR(10) POSTAL_CODE_DOM . . . SQL> SHOW TABLE EMPLOYEES" Information for table EMPLOYEES Comment on table EMPLOYEES:+ personal information about each employee Columns for table EMPLOYEES:: Column Name Data Type Domain: ----------- --------- ------ . . .C POSTAL_CODE CHAR(10) POSTAL_CODE_DOM( Example 2: Altering the domain ID_DOMD The following example alters the data type for the domain ID_DOM,@ which is a standard definition of the employee identification field.B In Example 1, there were no indexes based on the domain POSTAL_C CODE_DOM. In this example, several indexes that refer to columnsD were created based on ID_DOM. As the following example shows, you< must first delete the indexes before altering the domain:: SQL> -- The data type for the domain ID_DOM is CHAR(5): SQL> --  SQL> SHOW DOMAIN ID_DOM* ID_DOM CHAR(5)5 Comment: standard definition of employee id SQL> --> SQL> -- The first attempt to alter the domain ID_DOM fails.= SQL> -- You must first delete all constraints that use the SQL> -- field EMPLOYEE_ID. SQL> --$ SQL> ALTER DOMAIN ID_DOM CHAR(6);0 %RDB-E-NO_META_UPDATE, metadata update failedB -RDMS-F-FLDINCON, field EMPLOYEE_ID is referenced in constraint RESUMES_FOREIGN1< -RDMS-F-FLDNOTCHG, field EMPLOYEE_ID has not been changed= SQL> ALTER TABLE RESUMES DROP CONSTRAINT RESUMES_FOREIGN1; SQL> --' SQL> ALTER DOMAIN ID_DOM IS CHAR(6);0 %RDB-E-NO_META_UPDATE, metadata update failedB -RDMS-F-FLDINCON, field EMPLOYEE_ID is referenced in constraint DEGREES_FOREIGN1< -RDMS-F-FLDNOTCHG, field EMPLOYEE_ID has not been changed SQL> --= SQL> ALTER TABLE DEGREES DROP CONSTRAINT DEGREES_FOREIGN1; . . ., SQL> -- You must then delete al l indexes. SQL> --' SQL> ALTER DOMAIN ID_DOM IS CHAR(6);0 %RDB-E-NO_META_UPDATE, metadata update failedM -RDMS-F-FLDINUSE, field EMPLOYEE_ID is referenced in index EMP_EMPLOYEE_ID< -RDMS-F-FLDNOTCHG, field EMPLOYEE_ID has not been changed SQL> --# SQL> DROP INDEX EMP_EMPLOYEE_ID; SQL> --' SQL> ALTER DOMAIN ID_DOM IS CHAR(6);0 %RDB-E-NO_META_UPDATE, metadata update failedL -RDMS-F-FLDINUSE, field EMPLOYEE_ID is referenced in index JH_EMPLOYEE_ID< -RDMS-F-FLDNOTCHG, field EMPLOYEE_ID has not been changed SQL> --" SQL> DROP INDEX JH_EMPLOYEE_ID; SQL> -- . . . SQL> --( SQL> -- You can now alter the domain. SQL> --' SQL> ALTER DOMAIN ID_DOM IS CHAR(6); SQL> SHOW DOMAIN ID_DOM;* ID_DOM CHAR(6)5 Comment: standard definition of employee id= Example 3: Specifying default values with the ALTER DOMAIN statementB The following example alters domains, specifying default values for those domains:7 SQL> -- If no date is entered, use the NULL default. SQL> -- SQL> ALTER DOMAIN DATE_DOM cont> SET DEFAULT NULL; SQL> --5 SQL> -- If the street address takes only one line,: SQL> -- use "NONE" for the default for the second line. SQL> --' SQL> ALTER DOMAIN ADDRESS_DATA_2_DOM cont> SET DEFAULT 'NONE'; SQL> --: SQL> -- If most employees work full-time, make the code5 SQL> -- for full-time, 1, the default work status. SQL> --$ SQL> ALTER DOMAIN STATUS_CODE_DOM cont> SET DEFAULT '1';= Example 4: Specifying an edit string with the ALTER DOMAIN statement= The following example specifies an EDIT STRING clause that@ controls how SQL displays columns based on the domain MIDDLE_> INITIAL_DOM. The edit string in the example, "X.?'No middle< initial'", specifies that columns based on the domain are? displayed as one character followed by a period. If there isA no value for the column, SQL displays the string following the& question mark, 'No middle initial'.' SQL> ALTER DOMAIN MIDDLE_INITIAL_DOM0 cont> EDIT STRING 'X.?''No middle initial';- SQL> SELECT MIDDLE_INITIAL FROM EMPLOYEES; MIDDLE_INITIAL A. D. No middle initial No middle initial . . .@ Example 5: Specifying a new collating sequence with the ALTER DOMAIN statementA The following example creates a domain with the pre defined NCS? collating sequence FRENCH. You must first execute the CREATE= COLLATING SEQUENCE statement. The example then changes theD collating sequence to Finnish, and then specifies that the domain has no collating sequence.0 SQL> CREATE COLLATING SEQUENCE FRENCH FRENCH;5 SQL> CREATE DOMAIN LAST_NAME_ALTER_TEST CHAR (10)-& cont> COLLATING SEQUENCE IS FRENCH; SQL> --( SQL> SHOW DOMAIN LAST_NAME_ALTER_TEST+ LAST_NAME_ALTER_TEST CHAR(10) Collating sequence: FRENCH SQL> --I SQL> -- Now, change the collating sequence to Finnish. You must first; SQL> -- execute the CREATE COLLATING SEQUENCE statement. SQL> --2 SQL> CREATE COLLATING SEQUENCE FINNISH FINNISH;4 SQL> ALTER DOMAIN LAST_NAME_ALTER_TEST CHAR (10)-' cont> COLLATING SEQUENCE IS FINNISH; SQL> --( SQL> SHOW DOMAIN LAST_NAME_ALTER_TEST+ LAST_NAME_ALTER_TEST CHAR(10) Collating sequence: FINNISH SQL> --C SQL> -- Now, alter the domain so there is no collating sequence. SQL> --4 SQL> ALTER DOMAIN LAST_NAME_ALTER_TEST CHAR (10)- cont> NO COLLATING SEQUENCE; SQL>( SQL> SHOW DOMAIN LAST_NAME_ALTER_TEST+ LAST_NAME_ALTER_TEST CHAR(10)- Assume the following for Examples 6 and 7:> o The database was created specifying the database default? character set as DEC_KANJI and the national character set as KANJI.B o The domain DEC_KANJI_DOM was created specifying the database default character set.? o The table COLOURS was created assigning the DEC_KANJI_DOM" domain to the column ROMAJI./ Example 6: Altering the domain DEC_KANJI_DOM* SQL> SET CHARACTER LENGTH 'CHARACTERS';" SQL> SHOW DOMAIN DEC_KANJI_DOM;* DEC_KANJI_DOM CHAR(8), SQL> ALTER DOMAIN DEC_KANJI_DOM NCHAR(8);" SQL> SHOW DOMAIN DEC_KANJI_DOM;* DEC_KANJI_DOM CHAR(8)* KANJI 8 Characters, 16 Octets SQL>@ Example  7: Error altering a domain used in a table containing data> In the following example, the column ROMAJI is based on theB domain DEC_KANJI_DOM. If the column ROMAJI contains data before> you alter the character set of the domain, SQL displays the? following error when you try to retrieve data after altering the domain.# SQL> SELECT ROMAJI FROM COLOURS;? %RDB-F-CONVERT_ERROR, invalid or unsupported data conversionM -RDMS-E-CSETBADASSIGN, incompatible character sets prohibits the requested assignment SQL> --O SQL> -- To recover, use the ROLLBACK statement or reset the character set to SQL> -- its original value. SQL> -- SQL>ROLLBACK;# SQL> SELECT ROMAJI FROM COLOURS; ROMAJI kuro shiro ao aka ki midori 6 rows selected SQL> + Example 8: Modifying a domain constraintC The following example shows how to modify an existing constraint on a domain: SQL> SHOW DOMAIN TEST_DOM, TEST_DOM DATE ANSI Rdb default: NULL+ VALID IF: (VALUE > DATE'1900-01-01' OR. VALUE IS NULL) SQL> --4 SQL> -- Add the new domain constraint definition. SQL> -- SQL> ALTER DOMAIN TEST_DOM/ cont> ADD CHECK (VALUE > DATE'1985-01-01') cont> NOT DEFERRABLE;; Example 9: Creating stored procedure domain dependenciesB The following code fragment from a stored module shows a domain@ in a parameter list and a domain in a stored procedure block: SQL> create module SAMPLE! cont> procedure FIRST_NAME cont> (in :id id_dom, cont> ,out :first_name char(40)); cont> begin( cont> declare :fn first_name_dom;' cont> select first_name into :fn cont> from employees) cont> where employee_id = :id;- cont> -- return capitalized first name cont> set :first_name =8 cont> UPPER (substring (:fn from 1 for 1)) ||0 cont> LOWER (substring (:fn from 2)); cont> end; cont> end module; SQL>+ SQL> declare :first_name first_name_dom;/ SQL> call FIRST_NAME ('00164', :first_name); FIRST_NAME Alvin SQL> SQL> alter domain id_dom cont> char(10);0 %RDB-E-NO_META_UPDATE, metadata update failedA -RDMS-F-RTNEXI, field "ID_DOM" is used in routine "FIRST_NAME"7 -RDMS-F-FLDNOTCHG, field ID_DOM has not been changed SQL># SQL> alter do main first_name_dom cont> char(60);* o Domain specified in a parameter list? When you specify a domain in a parameter list (id_number)@ of a stored routine and you subsequently try to alter thatD domain, the ALTER DOMAIN statement fails because SQL sets up aC dependency between the domain and the stored routine in whichA the domain resides. Because the statement fails, Oracle RdbC does not invalidate the stored routine. Oracle Rdb keeps this9  domain parameter list dependency in RDB$PARAMETERS.0 o Domain specified in a stored routine blockC When you specify a domain (last_name) within a stored routineD block and you subsequently try to alter that domain, the ALTERC DOMAIN statement succeeds. Future calls to the stored routine0 will use the new definition of the domain.; Example 10: Altering a Domain to Provide a Default ValueA This examples demonstrates that the default value added to the8  domain is propagated to the tables using that domain.1 SQL> -- Display the current domain definition.# SQL> SHOW DOMAIN DEPARTMENT_NAME+ DEPARTMENT_NAME CHAR(30)# Comment: Department name Missing Value: None6 SQL> -- Alter the domain to provide a default value SQL> -- for DEPARTMENT_NAME.$ SQL> ALTER DOMAIN DEPARTMENT_NAME$ cont> SET DEFAULT 'Not Recorded';1 SQL> -- Display the altered domain definition.$ SQL> SHOW DOMAIN DEPARTMENT_NAME;+ DEPARTMENT_NAME CHAR(30)# Comment: Department name$ Oracle Rdb default: Not Recorded Missing Value: NoneB SQL> -- Insert a record and omit the value for DEPARTMENT_NAME.1 SQL> INSERT INTO DEPARTMENTS (DEPARTMENT_CODE) cont> VALUES cont> ('GOGO'); 1 row inserted SQL> COMMIT;< SQL> -- Select the newly inserted record to show that the? SQL> -- default for the DEPARTMENT_NAME domain was inserted.? SQL> SELECT * FROM DEPARTMENTS WHERE DEPARTMENT_CODE='GOGO';A DEPARTMENT_CODE DEPARTMENT_NAME MANAGER_ID& BUDGET_PROJECTED BUDGET_ACTUAL; GOGO Not Recorded NULL& NULL NULL 1 row selected 2 FUNCTIONB Allows attributes to be changed for a function that was created; using the CREATE MODULE statement or the CREATE FUNCTION statement. It can be used to:C o Force a stored (SQL) function to be compiled (COMPILE option)- o Modify attributes of external functions& o Change the comment on a function 3 Environment, You can use the ALTER FUNCTION statement: o In interactive SQL( o Embedded in host language programs- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatM ALTER FUNCTION ++-> COMMENT IS +-> '' -------+++-+->K  || +------- / <----------+|| |K |+-> COMPILE --------------------------+| |K |+-> NAME ---------+ |K |+-> external-location-clause ----------+ |K |+-> LANGUAGE language-name ------------+ |K |+-> notify-clause ---------------------+ |K |+-> RETURNS NULL ON NULL INPUT --------+ |K |+-> CALLED ON NULL INPUT --------------+ |K |+-> bind-site-clause ------------------+ |K |+-> bind-scope-clause -----------------+ |K |+-+--------+--+-------------------+----+ |K || +-> NOT -+ +-> VARIANT --------+ | |K || +-> DETERMINISTIC --+ | |K  |+> RENAME TO ------+ |K +--------------<--------------------------+ external-location-clause = A ---+--> DEFAULT LOCATION ------------+-------------------------+A +--> LOCATION '' -+ |A +-------------------------------<-----------------------------+A +-+----------------------------->--------------------------+-->> +--> WITH --+-> ALL -----+--> LOGICAL_NAME TRANSLATION --+ +-> SYSTEM --+ notify-clause = > -> NOTIFY notify-entry-name --> ON -+-+-> BIND ---------+-+->< | +-> CONNECT ------+ |< | +-> TRANSACTION --+ |< +--------- , <--------+ bind-site-clause = + --> BIND ON --+--> CLIENT --+--> SITE ---> +--> SERVER --+ bind-scope-clause = ) ---> BIND SCOPE --+-> CONNECT ------+-->&  +-> TRANSACTION --+  3 Arguments 4 bind-site-clause Syntax options:, BIND ON CLIENT SITE | BIND ON SERVER SITEC Selects the execution model and environment for external routine execution.B CLIENT site binding causes the external routine to be activated< and executed in the OpenVMS database client (application)< process. This is the default binding. This binding offers? the most efficient execution characteristics, allows sharingB r esources such as I/O devices, and allows debugging of externalD routines as if they were part of the client application. However,B this binding may suffer from address space limitations. BecauseC it shares virtual memory with the database buffers, this bindingC is restricted to the client process system user environment, andB prohibits external routine execution in cases of an application$ running with elevated privileges.B SERVER site binding causes the external routine to be  activatedA in a separate process from the database client and server. The? process is started on the same node at the database process.> This binding offers reasonable execution characteristics, aA larger address space, a true session user environment, and has@ no restrictions regarding client process elevated privileges.? However, this binding does not permit sharing resources such= as I/O devices with the client (in particular, there is no@ connection to the client interactive terminal), and debugging) of routines is generally not possible. 4 bind-scope-clause Syntax options:. BIND SCOPE CONNECT | BIND SCOPE TRANSACTIONB Defines the scope during which an external routine is activated= and at what point the external routine is deactivated. The default scope is CONNECT. o CONNECT? An active routine is deactivated when you detach from the+ database (or exit without detaching). o TRANSACTION< An  active routine is deactivated when a transaction is: terminated (COMMIT or ROLLBACK). In the event that a= transaction never occurs, the scope reverts to CONNECT. 4 COMMENT_IS_stringB Adds a comment about the function. SQL displays the text of theC comment when it executes a SHOW FUNCTIONS statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/).B This clause is equivalent to the COMMENT ON FUNCTION statement. 4 COMPILEC The COMPILE option forces the Oracle Rdb server to recompile the> stored (SQL) function. External functions are not affected.; Use COMPILE when a function has been made invalid by theA execution of a DROP . . . CASCADE operation. This mechanism isC preferred over the SET FLAGS 'VALIDATE_ROUTINE' method available in previous versions. 4 DETERMINISTIC Syntax options:$ DETERMINISTIC | NOT DETERMINISTIC= These clauses are synonyms for the VARIANT and NOT VARIANT3 clauses for conformance to the SQL/PSM standard.A The DETERMINISTIC clause indicates that the same inputs to theD function will generate the same output. It is the same as the NOT VARIANT clause.@ The NOT DETERMINISTIC clause indicates that the output of the@ function does not depend on the inputs. It is the same as the VARIANT clause. 4 external-body-clauseA Identifies key characteristics of the routine: its name, whereB the executable image of the routine is located, the language in, which the routine is coded, and so forth. 4 external-body-nameB The name of the external routine. If you do not specify a name,= SQL uses the name you specify in the external-routine-name clause.A This name defines the routine entry address that is called forD each invocation of the routine body. The named routine must existA in the external routine image selected by the location clause.8 Unquoted names are converted to uppercase characters. 4 external-location-clause Syntax options: DEFAULT LOCATION LOCATION 'image-location'A A default or specific location for the external routine image.? The resulting file specification must include the type .exe.D This can be an image file specification or merely a logical name.; SQL selects a routine based on a combination of factors: o Image stringA The location defaults to DEFAULT LOCATION, which represents1 the file specification string RDB$ROUTINES. o Logical name translation? The WITH ALL LOGICAL_NAME TRANSLATION and the WITH SYSTEMC LOGICAL_NAME TRANSLATION clauses specify how logical names in/ the location string are to be translated.D If no translation option is specified, or if WITH ALL LOGICAL_D NAME TRANSLATION is specified, logical names are translated in the default manner.? If WITH SYSTEM LOGICAL_NAME TRANSLATION is specified, anyB logical names in the location string are expanded using only? EXECUTIVE_MODE logical names from the SYSTEM logical name table. 4 LANGUAGE_language-name> The name of the host language in which the external routine@ was coded. You can specify ADA, C, COBOL, FORTRAN, PASCAL, orC GENERAL. The GENERAL keyword allows you to call routines written in any language. 4 notify-clauseD Specifies the name of  a second external routine called (notified)B when certain external routine or database-related events occur.B This name defines the routine entry address that is called, for@ each invocation of the notify routine. The named routine must? exist in the external routine image selected by the location clause.? The events of interest to the notify routine are ON BIND, ONA CONNECT, and ON TRANSACTION. Multiple events can be specified.> The following describes the events and scope of each event:> BIND Routine activation to routine deactivation: CONNECT Database attach to database disconnect< TRANSACTION Start transaction to commit or roll back transaction 4 RENAME_TOA Changes the name of the function being altered. See the RENAMEC for further discussion. If the new name is the name of a synonym then an error will be raised. 4 ON_NULL_INPUT Syntax options:4 RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUTA These clauses control how an external function is invoked when? one or more of the function arguments is NULL. The CALLED ONC NULL INPUT clause specifies that the function should be executed@ normally. A normal execution when the PARAMETER STYLE GENERALD clause is specified means that SQL should return a run-time error# when the NULL value is detected.@ The RETURNS NULL ON NULL INPUT clause instructs Oracle Rdb to> avoid the function call and just return a NULL result. This= option is valuable for library functions such as SIN, COS,? CHECKSUM, SOUNDEX, and so on, that usually return an UNKNOWN! result if an argument is NULL.2 The CALLED ON NULL INPUT clause is the default. 4 VARIANT Syntax options: VARIANT | NOT VARIANT; These clauses are synonyms for the DETERMINISTIC and NOTA DETERMINISTIC clauses for conformance to the SQL/PSM standard.A The DETERMINISTIC clause indicates that the same inputs to theD function will generate the same output. It is the same as the NOTB VARIANT clause. The NOT DETERMINISTIC clause indicates that theB output of the function does not depend on the inputs. It is the same as the VARIANT clause. 3 Examples9 Example 1: Changing a function to be NOT DETERMINISTIC@ When a function is created it is assumed to be DETERMINISTIC.A That is, given the same input values it should return the sameA result. When a ro utine has no parameters, such as the GET_TIMEA function shown below, then there is never any variation in theC input. In this case the function should have been defined as NOTC DETERMINISTIC to ensure that the Rdb optimizer calls it for eachA row processed, instead of using the previously returned result for each row.B Although DROP FUNCTION and CREATE FUNCTION could have performedD the same function, ALTER FUNCTION preserves the dependencies that exist in the database. SQL> alter function GET_TIME cont> not deterministic, cont> comment 'Fetch time from clock'C cont> / 'Every call must be executed, so change to be') cont> / 'NOT DETERMINISTIC'; SQL> SQL> show function GET_TIME;$ Information for function GET_TIME+ Function is Not Deterministic (variant) Function ID is: 2620 External Location is: SYS$SHARE:CLOCKSHR.EXE Entry Point is: GET_TIME( Comment: Fetch time from clock? Every call must be executed, so change to be$ NOT DETERMINISTIC Language is: COBOL( GENERAL parameter passing style used Number of parameters is: 0B Parameter Name Data Type Domain or TypeB -------------- --------- --------------* TIME(2)# Function result datatype* Return value is passed by value 2 INDEX= Changes an index. The ALTER INDEX statement allows you to:? o Change the characteristics of index nodes (sorted indexes only)B o Change the names of the storage areas that contain the index: o Enable or disable logging to the .aij and .ruj files o Alter index partitions o Change a partition name+ o Change the description of a partition0 o Specify whether or not the index is UNIQUE You cannot change:( o The columns that comprise an index& o A hashed index to a sorted index& o A sorted index to a hashed index9 o A sorted, nonranked index to a sorted, ranked index9 o A sorted, ranked index to a sorted, nonranked index: o The duplicates compression of a sorted, ranked index 3 Environment) You can use the ALTER INDEX statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to b e dynamically executed 3 Format" ALTER INDEX -------+" +-------------------------------+F +---+-> add-partition-clause -------------------------------------+->D +-> BUILD PARTITION -------------------------+D +-> BUILD ALL PARTITIONS -------------------------------------+D +-> DROP PARTITION --------------------------+D +-> MOVE PARTITION TO area-spec -----------+D +-> REBUILD PARTITION -----------------------+D +-> REBUILD ALL PARTITIONS -----------------------------------+D +-> RENAME PARTITION TO +D +-> TRUNCATE PARTITION ----------------------+D +-> TRUNCATE ALL PARTITIONS ----------------------------------+D +-> alter-index-attributes -+------------------------+--------+; +-> index-store-clause --+  add-partition-clause = ' -> ADD PARTITION ---+' +------------------------------------+, +-> USING -> ( -+-> -+-> ) -+, +------- , <-------+ |, +-----------------------------------------+, +-> IN area-spec -------------------------+, +-----------------------------------------+6 +--+----------------------------------------------+->4 +-> WITH LIMIT OF -> ( -+-> -+-> ) --+, +------ , <----+ area-spec = I --> -+---------------------------------------------------+->G +-> ( -++-> threshold-clause ---------------++-> ) -+@ |+-> LOGGING ------------------------+|@ |+-> NOLOGGING ----------------------+|@ |+-> PARTITION ---------------+|@ |+-> COMMENT IS -+--> 'string' ---+--+|@ | +------- / <-----+ |@ +---------------- , -------------- ---+ alter-index-attributes= C -+-+---------------------------------------------------------+-+->A | +-> threshold-clause -------------------------------------+ |A | +-> DUPLICATES ARE ALLOWED -------------------------------+ |A | +-> LOGGING ----------------------------------------------+ |A | +-> NOLOGGING --------------------------------------------+ |A | +-> NODE SIZE -----------------------------+ |A | +-> PERCENT FILL -------------------- --------+ |A | +-> PREFIX CARDINALITY COLLECTION IS -+-> ENABLED ------+-+ |A | | +-> ENABLED FULL -+ | |A | | +-> DISABLED -----+ | |A | +-> USAGE -+-> UPDATE -+----------------------------------+ |A | | +-> QUERY --+ | |A | +-> COMMENT IS -+-> '' --+------------------------+ |A | | +----- / --------+ | |A | +-> MAINTENA NCE IS -+-> DISABLED -----------------+-------+ |A | +-> ENABLED -+--------------+-+ |A | +-> DEFERRED --+ |A | +-> IMMEDIATE -+ |A +---------------------------- <-------------------------------+ threshold-clause = = --+-> THRESHOLD -+-> IS -+-> ( --> --> ) ---------+->; | +-> OF -+ |; |  |; +-> THRESHOLDS -+-> ARE -+-----------+ |; +-> OF -+ | |; +----------------------------------+ |; +-> ( --> -+---------------------------+-> ) -+4 +-> , -+-------------+4 +-> , -+  index-store-clause =  STORE ----------------------+ +---------------------------+B ++-> IN area-spec ---------------------------------------------+>A +-> USING -> ( -+--> -+-> ) ----------+ |A +------- , <--------+ | |A +---------------------------------------------------+ |A ++> IN area-spec -------------------------------------+ |A | +--------------------------------------------------+ |A | +-> WITH LIMIT OF -> ( -+--> -+-> ) ---+---+ |A | +------ , <-----+ | | |A +-----------------------<--------------------------+ | |A +--------------------------------------------------------+ |A ++------------------------------------------------------------++@ +-> OTHERWISE IN area-spec ----------------------------------+ 3 Arguments 4 ADD_PARTITION< Adds the named partition to an existing hashed index. The@ partition name must be unique within the index being altered.A No other clauses may appear in the same ALTER INDEX statement. 4 BUILD_ALL_PARTITIONSC This clause operates on an index in build-pending state (createdC using MAINTENANCE IS ENABLED DEFERRED) and builds all incompleteB partitions. If the index is not in build-pending state then the3 statement completes successfully with a warning.A No other clauses may appear in the same ALTER INDEX statement. !4 BUILD_PARTITION_partition-nameC This clause operates on an index in build-pending state (created> using MAINTENANCE IS ENABLED DEFERRED) and builds the namedA partition. If the index is not in build-pending state then the3 statement completes successfully with a warning.A No other clauses may appear in the same ALTER INDEX statement. 4 COMMENT_IS? Adds a comment about the index. SQL displays the text of the? comment when it executes a SHOW INDEX statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/). 4 DROP_PARTITION@ Specifies that the data in the named partition be migrated toD the next partition in the map and the named partition be dropped.D The last partition in the index cannot be dropped. The referencedB storage area is not dropped, only the index partition stored in that area. 4 DUPLICATES_ARE_ALLOWEDB Converts a UNIQUE index to a non-unique index. An index alteredB in this manner allows duplicate key values into the index. Note? that there is no way for you to reverse this change once you? commit the ALTER INDEX statement, other than by dropping and redefining the index. 4 INB When specified as part of an ADD PARTITION clause, the IN area-C spec inserts a new partition in the index. If you do not specify? a WITH LIMIT OF clause or OTHERWISE clause, the IN area-spec( clause creates a new final partition.D When specified as part of an index STORE clause, the IN area-specC  clause associates the index directly with a single storage area,C and all entries in the index are stored in the area you specify. 4 index-name The name of the index. 4 index-store-clauseB A storage map definition for the index. You can specify a storeD clause for indexes in a multifile database only. The STORE clauseB lets you specify which storage area files are used to store the index entries.B If you omit the storage map definition, the default is to store9 all entries for the index in the default storage area.B See the the CREATE INDEX statement for details of the arguments in an index store clause. 4 LOGGING Syntax options: LOGGING | NOLOGGINGD The LOGGING clause specifies that updates to new index partitions@ should be logged in the recovery-unit journal file (.ruj) and# after-image journal file (.aij).; The NOLOGGING clause specifies that updates to new index? partitions should not be logged in the recovery-unit journal3 file (.ruj) and after-image journal file (.aij).@ If no store clause is used, then these attributes provide the) setting for the ALTER INDEX statement.D The LOGGING and NOLOGGING clauses are mutually exclusive; specify/ only one. The LOGGING clause is the default. 4 MAINTENANCE_IS_DISABLED6 Disables, but does not delete, the specified index.C When managing a very large database, an index can become corruptB or unsuit able for query optimization. If the table on which theC index has been defined is very large, it may take a considerable@ amount of time to execute the DROP INDEX statement. Using the> MAINTENANCE IS DISABLED clause of the ALTER INDEX statementC disables the index so that it is no longer used by the optimizer< nor is it maintained. You can then execute the DROP INDEX; statement at a later time even when the table is in use.A Once an index has been disabled, it may be enabled again using the REBUILD PARTITION clause.B To disable an index, you must have DROP privileges to the tableD on which the index is defined, and there can be no active queries on the table. "4 MAINTENANCE_IS_ENABLED_DEFERREDA An index created using this clause does not contain index keys? for the current rows in the table. Until this index is builtC (using ALTER INDEX . . . BUILD), the index is placed in a build-A pending state. Any table with a build-pending index can not be: updated using the INSERT, DELETE, or UPDATE statements. #4 MAINTENANCE_IS_ENABLED_IMMEDIATE= This is the default behavior for CREATE INDEX. This clause? on ALTER INDEX allows a build-pending index to be made fully operational. 4 MOVE_PARTITION= Specifies that the data in the named partition be moved to@ the partition identified in the area-spec clause and that theA current partition is to be dropped after the data is migrated.B For example, this clause allows a single hashed index partition@ to be moved to a larger storage area when too many mixed area extends are observed.A No other clauses may appear in the same ALTER INDEX statement. 4 NODE_SIZE@ The size, in bytes, of each index node in a sorted index. You@ cannot specify this argument in an ALTER INDEX statement that? refers to a hashed index. See the CREATE INDEX statement for# details of the NODE SIZE clause.; This new node size is n ot applied to the existing index.@ However, it will be used in subsequent rebuild operations and, by EXPORT/IMPORT to rebuild the database. 4 PARTITIONA Names the partition. The name can be a delimited identifier ifA the dialect is set to SQL99 or quoting rules are set to SQL99.A Partition names must be unique within the index. If you do not? specify this clause, Oracle Rdb generates a default name forB the partition. The partition name is stored in the database and validated. 4 PERCENT_FILL; Specifies how much each index node should be filled as aA percentage of its size. You cannot specify this argument in anA ALTER INDEX statement that refers to a hashed index. The valid@ range is 1 percent to 100 percent. The default is 70 percent.D Both the PERCENT FILL and USAGE clauses specify how full an indexB node should be initially. You should specify either the PERCENT% FILL or USAGE clause but not both. ,4 PREFIX_CA RDINALITY_COLLECTION_IS_DISABLEDA This setting disables the cardinality collection and, instead,? uses a fixed scaling algorithm which assumes a well balancedC index tree. The action of this clause will also set the existing& index column cardinalities to zero. +4 PREFIX_CARDINALITY_COLLECTION_IS_ENABLED@ This is the default behavior for CREATE INDEX. The Oracle RdbB optimizer collects approximate cardinality values for the indexC columns to help in future query opt imization. Note that no extraC I/O is incurred to collect these values and, therefore, adjacentD key values from other index nodes can not be checked. Hence, some@ inaccuracy may be seen for these indexes. In most cases, thisA is adequate for query optimizations. If this clause is used onB an index that is currently set to PREFIX CARDINALITY COLLECTIONB DISABLED, the RMU Collect Optimizer_Statistics command needs to> be executed as soon as possible to load the correct values. 04 PREFIX_CARDINALITY_COLLECTION_IS_ENABLED_FULLB This setting requests that extra I/O be performed, if required,> to ensure that the cardinality values reflect the key value@ changes of adjacent index nodes. If this clause is used on an@ index which is currently set to PREFIX CARDINALITY COLLECTIOND DISABLED or ENABLED, the RMU Collect Optimizer_Statistics command? needs to be executed as soon as possible to load the correct values. 4 REBUILD_ALL_PARTITIONSD This clause combines the TRUNCATE and BUILD actions into a single@ function. No other clauses may appear in the same ALTER INDEX statement. #4 REBUILD_PARTITION_partition-nameD This clause combines the TRUNCATE and BUILD actions into a singleC function for the named partition. No other clauses may appear in" the same ALTER INDEX statement. 4 RENAME_PARTITIONA Changes the name of a partition. This clause can be applied toA all types of indexes. It is par ticularly useful for specifyingA a more meaningful name for the default partition. Use the SHOWB INDEX (PARTITION) statement to display the default names of the5 partitions. See Example 4 in the Examples section.A No other clauses may appear in the same ALTER INDEX statement. 4 threshold-clauseD Specifies one, two, or three default threshold values for logical= areas that contain the index in storage areas with uniform? page formats. By setting threshold values, you can make sureA that Oracle Rdb does not overlook a page with sufficient space> to store compressed data. The threshold values (val1, val2,? and val3) represent a fullness percentage on a data page andB establish three possible ranges of guaranteed free space on the data pages.; If you use data compression, you should use logical area4 thresholds to obtain optimum storage performance.B You cannot specify the thresholds for the storage map attribute@ for any area that is a mixed page format. If you have a mixedA page format, set the thresholds for the storage area using the> ADD STORAGE AREA or CREATE STORAGE AREA clause of the ALTER2 DATABASE, CREATE DATABASE, or IMPORT statement.B For more information about SPAM pages, see the Oracle Rdb Guide% to Database Design and Definition. 4 TRUNCATE_ALL_PARTITIONSD This clause operates in a similar way to TRUNCATE TABLE, but justA on one index. The index is automatically set to MAINT ENANCE ISB ENABLED DEFERRED (i.e. build-pending state) if it was currently= ENABLED IMMEDIATE. Otherwise is stays in a disabled state.A No other clauses may appear in the same ALTER INDEX statement. $4 TRUNCATE_PARTITION_partition-nameD This clause operates on just the named index partition. The index@ is automatically set to MAINTENANCE IS ENABLED DEFERRED (thatB is, build-pending state) if it was currently ENABLED IMMEDIATE.* Otherwise is stays in a disabled state.A No other clauses may appear in the same ALTER INDEX statement. 4 USAGE Syntax options: USAGE UPDATE | USAGE QUERYB Specifies a PERCENT FILL value appropriate for update-intensiveD or query-intensive applications. You cannot specify this argumentA in an ALTER INDEX statement that refers to a hashed index. TheC USAGE UPDATE argument sets the PERCENT FILL value at 70 percent.> The USAGE QUERY argument sets the PERCENT FILL value at 100 percent.B You should specify either the PERCENT FILL or USAGE clause, but not both. 4 USING8 Specifies columns whose values are used as limits forC partitioning the index across multiple storage areas. You cannot4 name columns not specified as index key segments.B If the index key is multisegmented, you can include some or allA of the columns that are joined to form the index key. You must@ specify the columns in the order in which they were specifiedB when the index key wa s defined. If you include only a subset ofB the columns from the multisegmented index, you must include the$ leading columns of the index key. 4 WITH_LIMIT_OFB Specifies the highest value for the index key that resides in aA particular storage area if ASCENDING is defined. If DESCENDING> is defined, the lowest value is specified for the index keyC that resides in a particular storage area. For multicolumn indexD keys, specify a literal value for each column listed in the USING clause.C The WITH LIMIT OF clause must specify a new unique set of values@ for the partition. The number of literals in the list must beB the same as the number of columns in the USING clause. The dataD type of the literals must agree with the data type of the column.B For character columns, enclose the literals in single quotation marks. 3 Examples Example 1: Disabling an indexB The following example shows how to disable an index that can beC deleted at a later time when the database table can be taken off line:% SQL> alter index COLL_COLLEGE_CODE! cont> maintenance is disabled;$ SQL> show index COLL_COLLEGE_CODE Indexes on table COLLEGES:; COLL_COLLEGE_CODE with column COLLEGE_CODE No Duplicates allowed Type is Sorted' Key suffix compression is DISABLED" Index is no longer maintained Node size 4303 Example 2: Changing a Unique Index to Non-Unique& SQL> show table (index) DEPARTMENTS$ Information for table DEPARTMENTS Indexes on table DEPARTMENTS:> DEPARTMENTS_INDEX with column DEPARTMENT_CODE No Duplicates allowed Type is Sorted' Key suffix compression is DISABLED Node size 430B SQL> insert into DEPARTMENTS (DEPARTMENT_CODE) values ('SUSO');3 %RDB-E-NO_DUP, index field value already exists;/ duplicates not allowed for DEPARTMENTS_INDEX= SQL> alter index DEPARTMENTS_INDEX duplicates are allowed;B SQL> insert into DEPARTMENTS (DEPARTMENT_CODE) values ('SUSO'); 1 row inserted& SQL> show table (index) DEPARTMENTS$ Information for table DEPARTMENTS Indexes on table DEPARTMENTS:> DEPARTMENTS_INDEX with column DEPARTMENT_CODE Duplicates are allowed Type is Sorted' Key suffix compression is DISABLED Node size 430 B Example 3: Adding an Index Partition Before and After the Final Partition+ SQL> CREATE UNIQUE INDEX EMPLOYEES_INDEX' cont> ON EMPLOYEES (EMPLOYEE_ID) cont> TYPE IS HASHED& cont> STORE USING (EMPLOYEE_ID)1 cont> IN JOBS WITH LIMIT OF ('00999'); SQL> COMMIT;A SQL> -- To add a partition before the final partition requiresI SQL> -- that the final partition (which now follows the new partition)C SQL> -- be scanned and matching keys moved to the new partition." SQL> SET TRANSACTION READ WRITE3 cont> RESERVING EMPLOYEES for EXCLUSIVE WRITE ; SQL> SET FLAGS INDEX_STATS;# SQL> ALTER INDEX EMPLOYEES_INDEX' cont> ADD PARTITION NEW_EMPS_200" cont> USING (EMPLOYEE_ID)3 cont> IN EMP_INFO WITH LIMIT OF ('00200');: ~Ai alter index "EMPLOYEES_INDEX" (hashed=1, ordered=0)5 ~Ai add partition "NEW_EMPS_200" : area "EMP_INFO"' ~Ai storage area "EMP_INFO" larea=85 ~Ai splitting partition #18 ~Ai split complete: total 100 keys, moved 37 (dups 0): ~Ai reads: async 136 synch 30, writes: async 57 s ynch 0 SQL> COMMIT;; SQL> -- Now add a partition after the final partition ofC SQL> -- the index. This requires no I/O to the partition because@ SQL> -- there is no following partition and therefore no keys SQL> -- to be moved." SQL> SET TRANSACTION READ WRITE3 cont> RESERVING EMPLOYEES FOR EXCLUSIVE WRITE;# SQL> ALTER INDEX EMPLOYEES_INDEX( cont> ADD PARTITION NEW_EMPS_1400" cont> USING (EMPLOYEE_ID)6 cont> IN EMPIDS_OVER WITH LIMIT OF ('0140 0');: ~Ai alter index "EMPLOYEES_INDEX" (hashed=1, ordered=0)9 ~Ai add partition "NEW_EMPS_1400" : area "EMPIDS_OVER"+ ~Ai storage area "EMPIDS_OVER" larea=122# ~Ai adding new final partition 3 SQL> COMMIT;F SQL> -- Show the index. It shows the ADD PARTITION syntax appended/ SQL> -- to the original source of the index." SQL> SHOW INDEX EMPLOYEES_INDEX Indexes on table EMPLOYEES:; EMPLOYEES_INDEX with column EMPLOYEE_ID No Duplicates allowed  Type is Hashed Scattered' Key Suffix Compression is DISABLED4 Store clause: STORE using (EMPLOYEE_ID)? in JOBS with limit of ('00999')? Add Partition partition NEW_EMPS_200. using (EMPLOYEE_ID)> in EMP_INFO with limit of ('00200')@ Add Partition partition NEW_EMPS_1400. using (EMPLOYEE_ID)A  in EMPIDS_OVER with limit of ('01400')" Example 4: Renaming a Partition. $ rmu /extract /item=index mf_personnel.rdb . . .% create unique index EMPLOYEES_HASH on EMPLOYEES ( EMPLOYEE_ID) type is HASHED store using (EMPLOYEE_ID) in EMPIDS_LOW() partition "SYS_P00076" )* with limit of ('00200') in EMPIDS_MID() partition "SYS_P00077" )* with limit of ('00400')( otherwise in EMPIDS_OVER() partition "SYS_P00078" ); commit work; $SQL$) SQL> ATTACH FILENAME MF_PERSONNEL.RDB;" SQL> ALTER INDEX EMPLOYEES_HASH0 cont> RENAME PARTITION SYS_P00076 TO IDS_LOW;" SQL> ALTER INDEX EMPLOYEES_HASH0 cont> RENAME PARTITION SYS_P00077 TO IDS_MID;" SQL> ALTER INDEX EMPLOYEES_HASH1 cont> RENAME PARTITION SYS_P00078 TO IDS_HIGH; SQL> COMMIT;" SQL> SHOW INDEX EMPLOYEES_HASH; Indexes on table EMPLOYEES:: EMPLOYEES_HASH with column EMPLOYEE_ID No Duplicates allowed Type is Hashed Scattered' Key Suffix Compression is DISABLED4 Store clause: STORE USING (EMPLOYEE_ID)E IN EMPIDS_LOW WITH LIMIT OF ('00200')E IN EMPIDS_MID WITH LIMIT OF ('00400')8 OTHERWISE IN EMPIDS_OVERA Rename PARTITION SYS_P00076 TO IDS_LOWA Rename PARTITION SYS_P00077 TO IDS_MIDB Rename PARTITION SYS_P00078 TO IDS_HIGH D Example 5: Creating a Large Index Partitioned Across Many Storage Areas) First, create the database definition:= SQL> CREATE INDEX ... MAINTENANCE IS ENABLED DEFERRED ...;B Next submit batch jobs to build each partition in parallel. For@ example , each batch job would execute a script similar to the following:" ATTACH 'filename testdatabase'; SET FLAGS 'index_stats';9 ALTER INDEX TRANSACTIONS_INDEX BUILD PARTITION PART_1; COMMIT;= Finally, after the batch jobs have completed, the database> administrator must make the index active for query usage by> changing the maintenance mode to ENABLED IMMEDIATE. A BUILD? ALL PARTITIONS clause could be added in case any step failed; (possibly due to resource limitations or a failed node). SQL> SET FLAGS 'index_stats';D SQL> SET TRANSLATION READ WRITE RESERVING...FOR EXCLUSIVE WRITES;- SQL> ALTER INDEX ... BUILD ALL PARTITIONS;9 SQL> ALTER INDEX ... MAINTENANCE IS ENABLED IMMEDIATE; SQL> COMMIT;A This scheme has several advantages over issuing a CREATE INDEX statement directly:< o The build actions can be run in parallel, which allowsC better resource usage (read and sort fewer rows), and reduced, execution ti me for the index creation.> o The partitions being processed are relatively small whenC compared to the full index and, therefore, smaller quantitiesA of data will be processed. This will result in smaller .ruj; files and less AIJ file space for these transactions.> o Each build partition runs in a separate transaction, can> easily be repeated if a step fails, and does not require2 repeating the entire CREATE INDEX statement.A o If any steps have failed, they will also be repeated by the9 BUILD ALL PARTITIONS clause included in the script.D Example 6: Deleting a Large Index Partitioned Across Many Storage Areas First, disable the index:? SQL> ALTER INDEX TRANSACTIONS_INDEX MAINTENANCE IS DISABLED;B Next, submit batch jobs to truncate the partitions in parallel:A SQL> ALTER INDEX TRANSACTIONS_INDEX TRUNCATE PARTITION PART_1; SQL> COMMIT;C Finally, after the batch jobs are complete, remove the metadata:& SQL> DROP INDEX TRANSACTIONS_INDEX;A This scheme has several advantages over a issuing a DROP INDEX statement directly:? o The truncate actions can be run in parallel, which allowsD better resource usage and reduced execution time for the index deletion.> o The partitions being processed are relatively small whenC compared to the full index and, therefore, smaller quantitiesA of data will be processed. This will result in smaller .ruj;  files and less AIJ file space for these transactions.A o Each truncate partition runs in a separate transaction, can> easily be repeated if a step fails, and does not require" repeating the entire action.D o If any steps have failed, they will also be repeated by a DROP INDEX statement.4 Example 7: Using the TRUNCATE PARTITION statementA The following example illustrates using the TRUNCATE PARTITION+ statement for the MF_PERSONNEL database.- SQL> show index (partition) EMPLOYEES_HASH Indexes on table EMPLOYEES:: EMPLOYEES_HASH with column EMPLOYEE_ID No Duplicates allowed Type is Hashed Scattered' Key suffix compression is DISABLED$ Partition information for index: Partition: (1) SYS_P00076 Storage Area: EMPIDS_LOW Partition: (2) SYS_P00077 Storage Area: EMPIDS_MID Partition: (3) SYS_P00078 Storage Area: EMPIDS_OVERA SQL> alter index employees_hash t runcate partition SYS_P00077;L %RDB-W-META_WARN, metadata successfully updated with the reported warningM -RDMS-W-IDXBLDPEND, index in build pending state - maintenance is disabled- SQL> insert into employees default values;Q %RDB-E-READ_ONLY_REL, relation EMPLOYEES was reserved for read access; updates not allowedO -RDMS-F-BUILDPENDING, index in build pending state - operation not permittedD Until the index is made complete it will not be used by the queryB optimizer, nor can the table on which it is defined be updated.- The SHOW INDEX command reports this state.! SQL> show index employees_hash Indexes on table EMPLOYEES:: EMPLOYEES_HASH with column EMPLOYEE_ID No Duplicates allowed Type is Hashed Scattered' Key suffix compression is DISABLED, Maintenance is Deferred - build pending 2 MODULE@ Alters a module to add or drop routines, change a comment, or compile stored routines. 3 Env ironment* You can use the ALTER MODULE statement: o In interactive SQL( o Embedded in host language programs- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatO ALTER MODULE -+-> alter-module-clauses -+-+----------------+--->K +-----------<-------------+ +-> END MODULE --+ alter-module-clauses = + -+-> ADD routine-clause ---------------+->)  +-> COMMENT IS +-> '' -++) | +------- / <----------+|) +-> COMPILE --------------------------+) +-> drop-routine-clause --------------+) +-> RENAME TO ------+ drop-routine-clause =@ DROP -+-> FUNCTION --+> -+-+---------------+-+->> +-> PROCEDURE -+ | +-> CASCADE ----+ |> | +-> RESTRICT --+ |> | +-> IF EXISTS --+ |>  +----------<--------+ 3 Arguments 4 ADD_routine-clauseA Allows new functions and procedures to be added to the module.D Refer to the CREATE MODULE for details on the routine-clause. TheC END MODULE clause must be used to end the ALTER MODULE clause to0 provide an unambiguous statement termination. 4 COMMENT_IS> Adds a comment about the module. Enclose the comment within? single quotation marks (') and separat e multiple lines in aC comment with a slash mark (/). This clause is equivalent to the COMMENT ON MODULE statement. 4 COMPILE: Recompiles stored routines in the module. Any that were@ marked invalid will have this flag cleared if the compile was successful. 4 drop-routine-clauseC The DROP FUNCTION and DROP PROCEDURE clauses will drop the namedD routines from this module. All DROP clauses are executed prior to7 the COMPILE and ADD clauses in this ALTER  statement. 4 END_MODULEA This terminating clause is required when using ADD FUNCTION orA ADD PROCEDURE since there is no way to distinguish between the> end of a compound statement and the end of the ALTER MODULE statement. 4 RENAME_TOC Changes the name of the module being altered. See the RENAME forD further discussion. If the new name is the name of a synonym then an error will be raised.= The RENAME TO clause requires synonyms be enabled for this= database. Refer to the ALTER DATABASE SYNONYMS ARE ENABLEDA clause. Note that these synonyms may be deleted if they are no7 longer used by database definitions or applications.D The old name will be used to create a synonym for the new name ofD this module. This synonym can be dropped if the name is no longer used by applications. 3 Examples. Example 1: Changing the comment on a moduleB A comment can be added or changed on a module using the COMMENT&  IS clause as shown in this example.* SQL> alter module EMPLOYEES_MAINTENANCE cont> comment is= cont> 'routines to add and remove employee rows'= cont> / 'Fix: also record the employees birthday'; SQL>* SQL> show module EMPLOYEES_MAINTENANCE;/ Information for module EMPLOYEES_MAINTENANCE Header: EMPLOYEES_MAINTENANCE; Comment: routines to add and remove employee rows: Fix: also record the employees birthday Module ID is: 7- Routines in module EMPLOYEES_MAINTENANCE: ADD_EMPLOYEE IS_CURRENT_EMPLOYEE REMOVE_EMPLOYEE3 Example 2: Revalidating all routines in a moduleC The COMPILE clause can be used to check each stored procedure orC function to ensure that it can be executed. If the compile failsD it will report the first reason, in this example a missing table.3 SQL> alter module EMPLOYEES_MAINTENANCE compile;0 %RDB-E-NO_META_UPDATE, metadata update failedS -RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist? -RDMS-F-BAD_SYM, unknown relation symbol - ARCHIVE_EMPLOYEES- Example 3: Replacing a routine in a module> The following example creates a simple module and shows theE effect of DROP TABLE . . . CASCADE. That is, the procedure REMOVE_? EMPLOYEE is marked as invalid. The COMPILE clause is used toD attempt to re-validate the procedure, however, a referenced tableD no longer exists. After replacing the table the COMPILE completes successfully. SQL> set dialect 'sql99';! SQL> attach 'file PERSONNEL1'; SQL> SQL> create table EMPLOYEES) cont> (employee_id integer,* cont> last_name char(40),* cont> first_name char(40),& cont> birthday date,< cont> start_date date default current_date); SQL>& SQL> create table ARCHIVE_EMPLOYEES) cont> (employee_id  integer,* cont> last_name char(40),* cont> first_name char(40),< cont> archive_date date default current_date); SQL>+ SQL> create module EMPLOYEES_MAINTENANCE cont>A cont> procedure REMOVE_EMPLOYEE (in :employee_id integer); cont> begin( cont> -- take copy of the old row* cont> insert into ARCHIVE_EMPLOYEES5 cont> (employee_id, last_name, first_name): cont> select employee_id, last_name, first_name cont> from EMPLOYEES2 cont> where employee_id = :employee_id;" cont> -- remove the old row" cont> delete from EMPLOYEES2 cont> where employee_id = :employee_id; cont> end; cont># cont> procedure ADD_EMPLOYEE* cont> (in :employee_id integer,) cont> in :last_name char(40),* cont> in :first_name char(40),% cont> in :birthday date);" cont> insert into EMPLOYEES? cont> (employee_id, last_name, first_name, birthday)K cont> values (:employee_id, :last_name, :first_name, :birthday); cont> cont> end module; SQL>) SQL> show module EMPLOYEES_MAINTENANCE/ Information for module EMPLOYEES_MAINTENANCE Header: EMPLOYEES_MAINTENANCE Module ID is: 7- Routines in module EMPLOYEES_MAINTENANCE: ADD_EMPLOYEE REMOVE_EMPLOYEE SQL>- SQL> drop table ARCHIVE_EMPLOYEES cascade; SQL>' SQL> show procedure REMOVE_EMPLOYEE;, Information for procedure REMOVE_EMPLOYEE Current state is INVALID Can be revalidated Procedure ID is: 8 Source:. REMOVE_EMPLOYEE (in :employee_id integer); begin" -- take copy of the old row$ insert into ARCHIVE_EMPLOYEES/ (employee_id, last_name, first_name)4 select employee_id, last_name, first_name from EMPLOYEES, where employee_id = :employee_id; -- remove the old row delete from EMPLOYEES, where employee_id = :employee_id; end No description found) Module name is: EMPLOYEES_MAINTENANCE Module ID is: 7 Number of parameters is: 1B Parameter Name Data Type Domain or TypeB -------------- --------- --------------* EMPLOYEE_ID INTEGER" Parameter position is 1! Parameter is IN (read)+  Parameter is passed by reference SQL>, SQL> -- COMPILE reports the missing table3 SQL> alter module EMPLOYEES_MAINTENANCE compile;0 %RDB-E-NO_META_UPDATE, metadata update failedS -RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist? -RDMS-F-BAD_SYM, unknown relation symbol - ARCHIVE_EMPLOYEES SQL>& SQL> create table ARCHIVE_EMPLOYEES) cont> (employee_id integer,* cont> last_name char(40),* cont> firs t_name char(40),& cont> birthday date,< cont> archive_date date default current_date); SQL>- SQL> -- new table definition is compatible3 SQL> alter module EMPLOYEES_MAINTENANCE compile; SQL>* SQL> alter module EMPLOYEES_MAINTENANCE cont> comment is= cont> 'routines to add and remove employee rows'< cont> / 'Fix: also record the employees birthday' cont>5 cont> drop procedure REMOVE_EMPLOYEE if exi sts cont>E cont> add procedure REMOVE_EMPLOYEE (in :employee_id integer); cont> begin( cont> -- take copy of the old row* cont> insert into ARCHIVE_EMPLOYEES? cont> (employee_id, last_name, first_name, birthday)D cont> select employee_id, last_name, first_name, birthday cont> from EMPLOYEES2 cont> where employee_id = :employee_id;" cont> -- remove the old row" cont> delete from EMPLOYEES2 cont> where employee_id = :employee_id; cont> end; cont> end module; SQL>* SQL> show module EMPLOYEES_MAINTENANCE;/ Information for module EMPLOYEES_MAINTENANCE Header: EMPLOYEES_MAINTENANCE; Comment: routines to add and remove employee rows: Fix: also record the employees birthday Module ID is: 7- Routines in module EMPLOYEES_MAINTENANCE: ADD_EMPLOYEE REMOVE_EMPLOYEE / Example 4: Adding a new function to a module? In the following example the ADD clause is used to add a new" function to an existing module.* SQL> alter module EMPLOYEES_MAINTENANCEG cont> add function IS_CURRENT_EMPLOYEE (in :employee_id integer)! cont> returns integer; cont> return (case* cont> when exists (select *0 cont> from EMPLOYEESC cont> where employee_id = :employee_id) cont> then 1 cont> else 0 cont> end); cont> end module; SQL>* SQL> show module EMPLOYEES_MAINTENANCE;/ Information for module EMPLOYEES_MAINTENANCE Header: EMPLOYEES_MAINTENANCE; Comment: routines to add and remove employee rows: Fix: also record the employees birthday Module ID is: 7- Routines in module EMPLOYEES_MAINTENANCE: ADD_EMPLOYEE IS_CURRENT_EMPLOYEE REMOVE_EMPLOYEE 2 OUTLINE Alters an outline definition. 3 Environment+ You can use the ALTER OUTLINE statement: o In interactive SQL( o Embedded in host language programs- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format% ALTER OUTLINE ----+% +--------------------------------+? +-+-+-> COMMENT IS --+-------> '' ---------+--+-+->= | | +------------ / <--------------+ | |= | +-> COMPILE ---------------------------------------+ |= | +-> MOVE TO -----------------+ |= | +-> RENAME TO -----------------+ |= +-------------------------- <--------------------------+ 3 Arguments 4 COMMENT_IS_stringA The COMMENT IS clause can be used to modify the comment storedC with the query outline. The COMMENT ON statement is identical in9 function to the ALTER OUTLINE . . . COM MENT IS clause.9 This clause is equivalent to the COMMENT ON procedure. 4 COMPILE@ The COMPILE option can be applied to query outlines that haveC been made invalid by DROP TABLE or DROP INDEX. If the tables andB indices have been recreated then the query outline will be madeA valid again. For example, once re-validated the optimizer will! try to use that query outline.& NOTE< There is a possibility that the query outline al!though= marked valid will not be used because of changes in the> index definition. There is too little information stored> with the query outline to perform a complete consistencyB check. If possible, queries using this outline should be run. to verify correct index and table usage.> If the query outline is currently valid then this clause is ignored by Oracle Rdb. 4 MOVE_TO? MOVE TO is valid only for multischema databases. You must be? attache"d explicitly or implicitly with the MULTISCHEMA IS ONC clause. The MOVE TO clause can be used to move the query outline@ to a different catalog and schema. An error will be raised if= this clause is specified in a non-multischema environment.= The target catalog and schema must exist in this database. 4 RENAME_TO= The RENAME TO clause can be used to change the name of the@ outline. The new name must not already exist in the database.@ If RENAME TO is used in a m #ultischema database, attached with@ MULTISCHEMA IS ON, then only the multischema name is modifiedB not the STORED NAME of the object. To change the STORED NAME ofD the query outline you must attach to the database explicitly with@ the MULTISCHEMA IS OFF clause (see the example below). Please@ note that the STORED NAME for the query outline may have been generated by Oracle Rdb.& NOTE@ Any queries using the OPTIMIZE USING clause will also $need7 to be changed to reference this new outline name. 3 Examples5 Example 1: Changing the comment on a query outline! SQL> alter outline show_tables0 cont> comment is 'show the tables query'; cont> / 'derived from a stored procedure'; SQL> show outline show_tables SHOW_TABLES( Comment: show the tables query2 derived from a stored procedure Source:/ -- Rdb Generated Outline : 8-FEB-2002 16:1%7 create outline SHOW_TABLES( id '4D5B5CC5B46C6DD21B0E1999C0EB8BF3' mode 0 as ( query ( -- For loop subquery (M RDB$RELATIONS 0 access path index RDB$REL_REL_NAME_NDX ) ) ) compliance optional ; A Example 2: Using the alternate COMMENT ON syntax to change the comment& SQL> comment on outline show_tables( cont> is 'show the tables query'4 cont> / 'derived from the stored pr&ocedure' cont> / 'SHOW_TABLES';2 Example 3: Changing the name of a query outline! SQL> alter outline show_tables' cont> rename to show_the_tables;$ SQL> show outline show_the_tables SHOW_THE_TABLES( Comment: show the tables query4 derived from the stored procedure1 testing new COMMENT ON OUTLINE Source:/ -- Rdb Generated Outline : 8-FEB-2002 16:17! create outline SHOW_THE_TABLES( id '4D5B5CC'5B46C6DD21B0E1999C0EB8BF3' mode 0 as ( query ( -- For loop subquery (M RDB$RELATIONS 0 access path index RDB$REL_REL_NAME_NDX ) ) ) compliance optional ;D Example 4: This example shows setting a query outline valid after a DROP INDEXA First, our stored procedure is executed with the STRATEGY flagC defined so we can see that it is using a query outline named MY_ OUTLINE. SQL> set flag(s 'strategy'; SQL> call my_procedure(); ~S: Outline "MY_OUTLINE" usedL Aggregate Conjunct Index only retrieval of relation MY_TABLE Index name MY_INDEX [1:1]B Now the index that was used by the query (and referenced by theA query outline) is dropped. This causes the query outline to beC set invalid (as shown by using the WARN_INVALID flag). The queryC now uses sequential access strategy when the stored procedure is executed.! SQL> set flags )'warn_invalid'; SQL> drop index my_index;F ~Xw: Outline "MY_OUTLINE" marked invalid (index "MY_INDEX" dropped) SQL> SQL> set flags 'strategy'; SQL> call my_procedure();: ~S: Outline "MY_OUTLINE" is invalid and can not be used& Aggregate Conjunct Get. Retrieval sequentially of relation MY_TABLE SQL> show outline my_outline MY_OUTLINE& Outline has been marked invalid . . .? The ALTER OUTLINE ... COMPILE clause *is now used to make the= outline valid. The first attempt reports that the index is> missing. After the index is recreated the COMPILE succeeds.< Calling the stored procedure now uses this query outline.) SQL> alter outline my_outline compile;0 %RDB-E-NO_META_UPDATE, metadata update failedD -RDMS-F-INDNOTEXI, index MY_INDEX does not exist in this database" SQL> -- must redefine the index3 SQL> create index my_index on my_table (b desc);) SQL> alter outline my_outline c+ompile; SQL> call my_procedure(); ~S: Outline "MY_OUTLINE" usedL Aggregate Conjunct Index only retrieval of relation MY_TABLE Index name MY_INDEX [1:1] SQL> > Example 5: Changing the STORED NAME of a query outline in a multischema databaseD This example shows how to change the STORED NAME of a multischema@ outline. Here we explicitly provide the STORED NAME, however,D the same technique can be used when SQL generates a unique STORED NAM,E for the outline." SQL> attach 'filename mschema';! SQL> create outline SHOW_TABLE$ cont> stored name SHOW_TABLE_01) cont> on procedure name SHOW_TABLES; SQL> commit; SQL> disconnect all;5 SQL> attach 'filename mschema MULTISCHEMA IS OFF';# SQL> alter outline SHOW_TABLE_01& cont> rename to SHOW_THE_TABLES; SQL> commit; 2 PROCEDUREC Allows attributes to be changed for a procedure that was created< using the CREATE MODULE statement or the -CREATE PROCEDURE statement. It can be used to:D o Force a stored (SQL) procedure to be compiled (COMPILE option)0 o Modify attributes of an external procedure' o Change the comment on a procedure 3 Environment- You can use the ALTER PROCEDURE statement: o In interactive SQL( o Embedded in host language programs- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatK. ALTER PROCEDURE ---++-> COMMENT IS +-> '' -------+++->I || +------- / <----------+||I |+-> COMPILE --------------------------+|I |+-> NAME --------+|I |+-> external-location-clause ---------+|I |+-> LANGUAGE language-name -----------+|I |+-> notify-clau/se --------------------+|I |+-> bind-site-clause -----------------+|I |+-> bind-scope-clause ----------------+|I |+-> RENAME TO ---+|I +--------------<------------------------+     external-location-clause = A ---+--> DEFAULT LOCATION ------------+-------------------------+A +--> LOCATION '' -+ 0 |A +-------------------------------<-----------------------------+A +-+----------------------------->--------------------------+-->> +--> WITH --+-> ALL -----+--> LOGICAL_NAME TRANSLATION --+ +-> SYSTEM --+ notify-clause = > -> NOTIFY notify-entry-name --> ON -+-+-> BIND ---------+-+->< | +-> CONNECT ------+ |< | +-> TRANSACTION --+ |< +-- 1------- , <--------+ bind-site-clause = + --> BIND ON --+--> CLIENT --+--> SITE ---> +--> SERVER --+ bind-scope-clause = ) ---> BIND SCOPE --+-> CONNECT ------+-->& +-> TRANSACTION --+  3 Arguments 4 bind-site-clause Syntax options:, BIND ON CLIENT SITE | BIND ON SERVER SITEC Selects the execution model and environment for external routine execution.B CLIENT site binding causes the external r 2outine to be activated< and executed in the OpenVMS database client (application)< process. This is the default binding. This binding offers? the most efficient execution characteristics, allows sharingB resources such as I/O devices, and allows debugging of externalD routines as if they were part of the client application. However,B this binding may suffer from address space limitations. BecauseC it shares virtual memory with the database buffers, this bindingC is restricted 3 to the client process system user environment, andB prohibits external routine execution in cases of an application$ running with elevated privileges.B SERVER site binding causes the external routine to be activatedA in a separate process from the database client and server. The? process is started on the same node at the database process.> This binding offers reasonable execution characteristics, aA larger address space, a true session user environment, and has@ no rest4rictions regarding client process elevated privileges.? However, this binding does not permit sharing resources such= as I/O devices with the client (in particular, there is no@ connection to the client interactive terminal), and debugging) of routines is generally not possible. 4 bind-scope-clause Syntax options:. BIND SCOPE CONNECT | BIND SCOPE TRANSACTIONB Defines the scope during which an external routine is activated= and at what point the external routin5e is deactivated. The default scope is CONNECT. o CONNECT? An active routine is deactivated when you detach from the+ database (or exit without detaching). o TRANSACTION< An active routine is deactivated when a transaction is: terminated (COMMIT or ROLLBACK). In the event that a= transaction never occurs, the scope reverts to CONNECT. 4 COMMENT_IS_stringC Adds a comment about the procedure. SQL displays the text of theD comment6 when it executes a SHOW PROCEDURES statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/).C This clause is equivalent to the COMMENT ON PROCEDURE statement. 4 COMPILEC The COMPILE option forces the Oracle Rdb server to recompile the@ stored (SQL) procedure. External procedures are not affected.< Use COMPILE when a procedure has been made invalid by theA execution of a DROP . . . CASCADE operati7on. This mechanism isC preferred over the SET FLAGS 'VALIDATE_ROUTINE' method available in previous versions. 4 external-body-clauseA Identifies key characteristics of the routine: its name, whereB the executable image of the routine is located, the language in, which the routine is coded, and so forth. 4 external-body-nameB The name of the external routine. If you do not specify a name,= SQL uses the name you specify in the external-routine-name cla8use.A This name defines the routine entry address that is called forD each invocation of the routine body. The named routine must existA in the external routine image selected by the location clause.8 Unquoted names are converted to uppercase characters. 4 external-location-clause Syntax options: DEFAULT LOCATION LOCATION 'image-location'A A default or specific location for the external routine image.? The resulting file specification must inc9lude the type .exe.D This can be an image file specification or merely a logical name.; SQL selects a routine based on a combination of factors: o Image stringA The location defaults to DEFAULT LOCATION, which represents1 the file specification string RDB$ROUTINES. o Logical name translation? The WITH ALL LOGICAL_NAME TRANSLATION and the WITH SYSTEMC LOGICAL_NAME TRANSLATION clauses specify how logical names in/ the location string are to: be translated.D If no translation option is specified, or if WITH ALL LOGICAL_D NAME TRANSLATION is specified, logical names are translated in the default manner.? If WITH SYSTEM LOGICAL_NAME TRANSLATION is specified, anyB logical names in the location string are expanded using only? EXECUTIVE_MODE logical names from the SYSTEM logical name table. 4 LANGUAGE_language-name> The name of the host language in which the external routine@ ; was coded. You can specify ADA, C, COBOL, FORTRAN, PASCAL, orC GENERAL. The GENERAL keyword allows you to call routines written in any language. 4 notify-clauseD Specifies the name of a second external routine called (notified)B when certain external routine or database-related events occur.B This name defines the routine entry address that is called, for@ each invocation of the notify routine. The named routine must? exist in the external routine image selected by t<he location clause.? The events of interest to the notify routine are ON BIND, ONA CONNECT, and ON TRANSACTION. Multiple events can be specified.> The following describes the events and scope of each event:> BIND Routine activation to routine deactivation: CONNECT Database attach to database disconnect< TRANSACTION Start transaction to commit or roll back transaction 4 RENAME_TOB Changes the name of the procedu=re being altered. See the RENAMEC for further discussion. If the new name is the name of a synonym then an error will be raised. 3 Examples? Example 1: Using ALTER PROCEDURE to target a new routine and sharable imageD This example shows ALTER PROCEDURE updating the location, routine/ name and language for an external procedure. SQL> show procedure SEND_MAIL& Information for procedure SEND_MAIL Procedure ID is: 2613 External Location is: SYS$SHAR>E:SENDMAILSHR.EXE Entry Point is: SEND_MAIL Language is: COBOL( GENERAL parameter passing style used Number of parameters is: 2B Parameter Name Data Type Domain or TypeB -------------- --------- --------------+ USR CHAR(30)" Parameter position is 1! Parameter is IN (read)+ Parameter is passed by reference0 TXT VARCHAR(1000)" ? Parameter position is 2! Parameter is IN (read)+ Parameter is passed by reference SQL> /*< ***> The routine has been rewritten. Use ALTER PROCEDURE7 ***> to retarget the external routine to use the new4 ***> implementation, instead of using DROP/CREATE ***> */ SQL>" SQL> set quoting rules 'SQL99'; SQL>! SQL> alter procedure SEND_MAIL! cont> name "send_mail_ext"3 cont> location 'SYS$SHARE:SENDMAILSHR30.EXE' cont>@ language C6 cont> comment 'Use new V3.0 interface routine'; SQL> 2 PROFILE Alters a profile definition. 3 Environment+ You can use the ALTER PROFILE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 FormatO ALTER -+-> PROFILE --> --------------+--+->A profile-options -+->M +-> DEFAULT PROFILE -+---------------------++ +--------<-----------+4 +-> ALIAS aliasname --+ profile-options = = --+-> COMMENT IS -+-> char-literal --+--------------------+>< | +------- / <-------+ |< +-> RENAME TO -----------------------+< +-> DEFAULT TRANSACTION --> txn-options ----------------+< +-> TRANSACTION MODES --> (txn-modes) ------------------+< +-> B LIMIT -+-+-> ROWS limit-value --------------------+++< | | +-> TIME limit-value -----+-+-----------++||< | | +-> CPU TIME limit-value -+ +-> SECONDS + ||< | | +-> MINUTES + ||< | +-------------------- <---------------------+|< +-> NO -+> DEFAULT TRANSACTION --+----------------------+% +> TRANSACTION MODES -+-+# +> LIMIT-+-> CPU TIME -+# +-> ROWS ---+# +-> CTIME ----+ 3 Arguments 4 ALIAS_aliasnameD When attached to multiple databases, the aliasname is required to8 direct the ALTER command to the appropriate database. 4 COMMENT_ISA Adds a comment about the profile. SQL displays the text of theB comment when it executes a SHOW PROFILES statement. Enclose the? comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 DEFAULT_PROFILE? Alters the Dspecial profile RDB$DEFAULT_PROFILE. This profileC will be used by any user who is not assigned a profile using the- PROFILE clause of CREATE or ALTER PROFILE. 4 DEFAULT_TRANSACTIONC DEFAULT TRANSACTION provides a default transaction for the user.D By default, Oracle Rdb starts a READ WRITE transaction if none isC explicitly started. Use the DECLARE TRANSACTION or START DEFAULT@ TRANSACTION statement to make use of this definition. You canD override this clause withE a DECLARE or SET TRANSACTION statement.& NOTE< Oracle Rdb does not permit the RESERVING or EVALUATING3 clauses to appear in the default transaction. 4 LIMIT_CPU_TIME Syntax options:% LIMIT CPU TIME | NO LIMIT CPU TIMEC LIMIT CPU TIME sets the maximum CPU time that can be used by theA query compiler. The keyword DEFAULT indicates that no value isB defined by this profile and is equivalent to NO LIMIT CPU TIME.@ IFf a numeric value or the keyword UNLIMITED is specified thenA this value will be used even when the SET QUERY LIMIT CPU TIME@ statement is present in the session, or when the logical name' RDMS$BIND_QG_CPU_TIMEOUT is defined.> NO LIMIT CPU TIME is the default. Units can be specified as seconds or minutes. 4 LIMIT_ROWS Syntax options: LIMIT ROWS | NO LIMIT ROWSB LIMIT ROWS sets the maximum number of rows that can be returned@ by a query started by the uGser. The keyword DEFAULT indicatesC that no value is defined by this profile and is equivalent to NO LIMIT ROWS.@ If a numeric value or the keyword UNLIMITED is specified then= this value will be used even when the SET QUERY LIMIT ROWS@ statement is present in the session, or when the logical name% RDMS$BIND_QG_REC_LIMIT is defined. NO LIMIT ROWS is the default. 4 LIMIT_TIME Syntax options: LIMIT TIME | NO LIMIT TIMEC LIMIT TIME sets the maximumH elapsed time that can be used by theA query compiler. The keyword DEFAULT indicates that no value is> defined by this profile and is equivalent to NO LIMIT TIME.@ If a numeric value or the keyword UNLIMITED is specified then= this value will be used even when the SET QUERY LIMIT TIME@ statement is present in the session, or when the logical name# RDMS$BIND_QG_TIMEOUT is defined.B NO LIMIT TIME is the default. Units can be specified as seconds or minutes. 4 negIated-attributes Syntax options: NO DEFAULT TRANSACTION NO TRANSACTION MODES NO LIMIT CPU TIME NO LIMIT ROWS N NO LIMIT TIMEA These options explicitly record the negated attribute setting.D These clauses will remove the current setting of any clause being negated. 4 RENAME_TO@ Changes the name of the profile being altered. See the RENAME$ statement for further discussion. 4 TRANSACTION_MODES Syntax option Js:+ TRANSACTION MODES | NO TRANSACTION MODES@ TRANSACTION MODES provides the list of allowable transactionsD for this user. Please see the SET TRANSACTION MODES clause of theD CREATE DATABASE and ALTER DATABASE statements for more details of txn-modes.= The transaction modes specified may include modes disabled> for all database users by CREATE, IMPORT, or ALTER DATABASEC statements. However, only the subset allowed by both profile and@ database settings will be uKsed. For instance, if the database= specifies (READ ONLY, SHARED READ, PROTECTED READ) and the= profile specifies (READ ONLY, SHARED), the session will be/ allowed the subset (READ ONLY, SHARED READ).D See the description in the CREATE PROFILE statement for all other) attributes supported by ALTER PROFILE. 3 Examples= The following example changes a default transaction for an existing profile.& SQL> ALTER PROFILE DECISION_SUPPORT) cont> DEFAULT TRANSACLTION READ ONLY; 2 ROLEA Allows you to change the role name or add a comment to a role. 3 Environment( You can use the ALTER ROLE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format? ALTER ROLE ----> --+----------------------+------>8 +--> alter-role-Mopts --+ alter-role-opts = 1 --+--> IDENTIFIED EXTERNALLY -------------+---->, +--> NOT IDENTIFIED --------------------+, +--> RENAME TO ---------+, +--> COMMENT IS --+--> 'string' --+-----+& +--<--- / ------+ 3 Arguments 4 COMMENT_IS> Adds a comment about the role. SQL displays the text of the? comment when it executes a SHOW ROLES statement. Enclose the? comment in single quotation marks ( ') and separate multiNple, lines in a comment with a slash mark (/). 4 IDENTIFIED_EXTERNALLY@ Specifies whether SQL should inherit roles from the operating@ system. If you specify one of these clauses, you must specify> the same clause as was specified when the role was created.? You cannot use the ALTER ROLE statement to change roles fromD IDENTIFIED EXTERNALLY to NOT IDENTIFIED or from NOT IDENTIFIED to IDENTIFIED EXTERNALLY.B The IDENTIFIED EXERNALLY clause indicates that SQL inheOrits theC roles defined by the facilities of the operating system, such as OpenVMS rights identifiers.D The NOT IDENTIFIED clause indicates that SQL does not inherit anyD roles defined by the facilities of the operating system; instead,' the role is private to the database. 4 NOT_IDENTIFIED@ Specifies whether SQL should inherit roles from the operating@ system. If you specify one of these clauses, you must specify> the same clause as was specified when the role Pwas created.? You cannot use the ALTER ROLE statement to change roles fromD IDENTIFIED EXTERNALLY to NOT IDENTIFIED or from NOT IDENTIFIED to IDENTIFIED EXTERNALLY.B The IDENTIFIED EXERNALLY clause indicates that SQL inherits theC roles defined by the facilities of the operating system, such as OpenVMS rights identifiers.D The NOT IDENTIFIED clause indicates that SQL does not inherit anyD roles defined by the facilities of the operating system; instead,< the role is Q private to the database. This is the default. 4 RENAME_TO; Changes an existing role name to a new role name without@ changing the privileges granted to the role. You might changeD the name of a role that corresponds to a department name when theB department is renamed. For example, if the personnel department@ is renamed human resources, you might change the role used byB that department from PERSONNEL to HUMAN_RESOURCES. The new roleD name must not already exist in thRe database. The old role name isC removed from the database when the transaction is committed. TheA old role name can be re-created and reused, if desired. If theC new role name is identified externally, then it must exist as an/ operating system group or rights identifier.3 See the RENAME statement for further discussion. 4 role-nameD The name of an existing role (such as one created with the CREATE ROLE statement). 3 Example Example 1: Renaming a RSoleD SQL> -- Change the name of the role from WRITER to DOCUMENTATION.P SQL> -- Any privileges granted to the role WRITER are transferred to the roleG SQL> -- DOCUMENTATION. The role WRITER is deleted from the database. SQL> ALTER ROLE WRITER! cont> RENAME TO DOCUMENTATION; SQL> SHOW ROLES;3 Roles in database with filename mf_personnel.rdb DOCUMENTATION 2 SEQUENCE@ Alters a sequence. A sequence is a database object from which; multiple users can Tgenerate unique integers. You can use: sequences to automatically generate primary key values. 3 Environment, You can use the ALTER SEQUENCE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatJ ALTER SEQUENCE -++--> --------++->H |+-U-> RENAME TO -+|H +--------------<----------------------+ sequence-attributes = 2 --+--> INCREMENT BY ---------+->0 +--> sequence-range -----------------------+0 +--> CYCLE --------------------------------+0 +--> NOCYCLE ------------------------------+0 +--> CACHE ----------------+0 +--> NOCACHE ------------------------------+0 +--> ORDER --------------------------------+0 +-->V NOORDER ------------------------------+0 +--> RANDOMIZE ----------------------------+0 +--> NORANDOMIZE --------------------------+0 +--> RESTART WITH -------------------------+0 +--> WAIT ---------------------------------+0 +--> NOWAIT -------------------------------+0 +--> DEFAULT WAIT -------------------------+0 +--> COMMENT -+-------+--+-> '' -+-+. +-> IS -+ +------ / <-----+ sequence-range = / -+-> MINVALUE -+-+--> -+--+-->, +-> MAXVALUE -+ +--> TINYINT ----+ |, | +--> SMALLINT ---+ |, | +--> INTEGER ----+ |, | +--> BIGINT -----+ |, +-> NOMINVALUE --------------------------+, +-> NOMAXVALUE --------------------------+ 3 Arguments 4 CACHE_numeric-valueSyntax options: CACHE numeric-value| NOCACHED The CACHE clause specifies how many values of the sequence Oracle? Rdb should preallocate and keep X in memory for faster access.> The mumeric value must be a value between 2 and 2147483647.A You cannot cache more values than will fit in a given cycle ofB sequence numbers; thus, the maximum value allowed for the CACHEB clause must be less than the value resulting from the following formula:% (MAXVALUE-MINVALUE)/ABS(INCREMENT)@ You can alter the CACHE value if it is currently a value of 2C or higher. When you alter the CACHE value, existing users of theA sequence Ycontinue to use the original setting. You can use theA SET FLAGS 'SEQ_CACHE' statement to adjust the cache size for aC single process. See the See the SET_FLAGS statement for details.C If NOCACHE is currently enabled or the CACHE value is 1, you can@ alter the CACHE value, but may have to wait until other usersC of the sequence have released locks on it. (Note that CACHE 1 is equivalent to NOCACHE.)A A cache for a given sequence is populated at the first request; for Z a number from that sequence, and whenever a value isA requested when the cache is empty. If a system failure occurs,= or when the cache is released any unfetched values will be? discarded. The maximum number of lost values is equal to theB current cache size. This may be the value specified by CACHE or% by the SET FLAGS SEQ_CACHE option.A The NOCACHE clause specifies that values will be allocated oneB at a time. This will require more I/O to the Rdb root file than usi[ng a CACHE value.< Note that even after you alter the CACHE value, users whoA were using the sequence at the time you altered the CACHE will( continue to use the original setting. 4 COMMENT_ISB Adds a comment about the sequence. SQL displays the text of theB comment when it executes a SHOW SEQUENCE statement. Enclose the? comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 CYCLE Syntax options: \ CYCLE | NOCYCLE> The CYCLE clause specifies that the sequence is to continueD generating values after reaching either the MINVALUE or MAXVALUE.A After an ascending sequence reaches the MAXVALUE, the sequence> starts again from its MINVALUE. After a descending sequenceC reaches its MINVALUE, the sequence starts again at its MAXVALUE.< The NOCYCLE clause specifies that the sequence should not? continue generating values after reaching either its minimumC or maximum value. ] An error is generated if an attempt is made to, increment the sequence beyond its limits.= Note that even after you alter the CYCLE clause, those whoA were using the sequence at the time you altered the CYCLE will( continue to use the original setting. 4 INCREMENT_BY_numeric-valueC Specifies the size of the increment and the direction (ascendingD or descending) of the sequence. This numeric value must be in theB range -2147483648 through 2147483647, excluding 0. ^The absolute> value must be less than the difference between MAXVALUE and@ MINVALUE. A negative value specifies a descending sequence; aB positive value specifies an ascending sequence. If the existing? value is positive, then the new value must also be positive.B Likewise, if the existing value is negative, then the new valueD must also be negative. That is, you cannot change a sequence from; ascending to descending or from descending to ascending. 4 MAXVALUE Syn _tax options:& MAXVALUE numeric-value | NOMAXVALUEB The MAXVALUE clause specifies the maximum BIGINT value that theD sequence can generate. For an ascending sequence, the new maximum@ value must be greater than or equal to the existing RDB$NEXT_= SEQUENCE_VALUE. For a descending sequence, the new maximum@ value must be greater than or equal to the existing MAXVALUE.@ This ensures that the MAXVALUE is not less than any currently@ issued values. In addition, the numeric value` must be betweenB -9223372036854775808 and 9223372036854775808. The MAXVALUE must@ be greater than the value specified with the MINVALUE clause.@ The NOMAXVALUE clause specifies that the maximum value for anD ascending sequence is 9223372036854775808 (minus the cache size),A and -1 for a descending sequence. The NOMAXVALUE clause is the default. 4 MAXVALUE_integer-option Syntax options: MAXVALUE TINYINT MAXVALUE SMALLINT MAXVALUE INTEGERa MAXVALUE BIGINT? SQL allows the keyword TINYINT, SMALLINT, INTEGER and BIGINTB to follow MAXVALUE instead of a numeric value. This allows easyD range setting for sequences used with these data types. The valueC supplied will be the largest positive value that can be assigned to this data type. 4 MINVALUE Syntax options:& MINVALUE numeric-value | NOMINVALUE< The MINVALUE clause specifies the minimum signed quadwordB (BIGINT) value that the sequenc be can generate. For an ascending= sequence, the new minimum value must be less than or equal; to the existing MINVALUE. For a descending sequence, the? new minimum value must be less than or equal to the existing; RDB$NEXT_SEQUENCE_VALUE. This prevents the minimum value: from being greater than any currently issued values. InA addition, the numeric value must be equal to or greater than -@ 9223372036854775808. The MINVALUE must be less than the value< specified with the MAcXVALUE clause. The NOMINVALUE clauseC specifies that the minimum value for an ascending sequence is 1,B and -9223372036854775808 (plus the cache size) for a descending sequence.( The NOMINVALUE clause is the default. 4 MINVALUE_integer-option Syntax options: MINVALUE TINYINT MINVALUE SMALLINT MINVALUE INTEGER MINVALUE BIGINT? SQL allows the keyword TINYINT, SMALLINT, INTEGER and BIGINTB to follow MINVALUE instead of a numeric vdalue. This allows easyD range setting for sequences used with these data types. The valueD supplied will be the smallest negative value that can be assigned to this data type. 4 ORDER Syntax options: ORDER | NOORDERB The ORDER clause specifies that sequence numbers are guaranteed< to be assigned in order for each requesting process, thus? maintaining a strict history of requests. The NOORDER clause; specifies that sequence numbers are not guaranteed to bee! generated in order of request. 4 RANDOMIZE Syntax options: RANDOMIZE | NORANDOMIZEB The RANDOMIZE clause specifies that the sequence numbers are to@ be returned with a random value in the most significant bytesA of the BIGINT value. This allows unique values to be generatedD that have a random distribution. When you specify the NORANDOMIZEC clause, sequence numbers are close in value to others created at the same time.C The advantage of the RANDOMfIZE clause is that updates to columns? of a stored index to which these values are written occur in@ different locations in the index structure and so may improveA concurrent access for large indexes as leaf nodes in different@ parts of the index can be updated independently. In contrast,B the sequence numbers generated when you specify the NORANDOMIZEC clause are likely to be close in numeric value to other sequenceB values generated at the same time. This may cause index upd gates@ to occur in the same or nearby index nodes, which may lead to. contention in one part of the sorted index.@ The full range of values in the BIGINT value returned for the> sequence are used; therefore, the NOMAXVALUE and NOMINVALUE? clauses must be specified (or defaulted to) for the sequence< definition. The most significant bits of the BIGINT value> are set to a randomly generated positive value. A generatedA distinct value is returned in the least significant 32 bits h so? that uniqueness is guaranteed. If you also specify the CYCLEC clause, then only the least significant 32 bits are cycled. When@ a query is performed on the column RDB$NEXT_SEQUENCE_VALUE inA the RDB$SEQUENCES table, only the generated value of the leastB significant bits is returned, because the most significant bitsA are not assigned until the NEXTVAL pseudocolumn is referenced.; If you specify RANDOMIZE, you cannot also specify ORDER, MAXVALUE, or MINVALUE. i 4 RENAME_TOA Changes the name of the sequence being altered. See the RENAMEC statement for further discussion. If the new name is the name of* a synonym then an error will be raised.C The new name must not exist as the name of an existing sequence,@ synonym, table or view. You may not rename a system sequence.= The RENAME TO clause requires synonyms be enabled for this= database. Refer to the ALTER DATABASE SYNONYMS ARE ENABLEDA clause. Note that these synonyms jmay be deleted if they are no7 longer used by database definitions or applications. 4 RESTART_WITH? The RESTART WITH clause allows the database administrator to= reset the sequence to a specified value. The value must beC within the range of MINVALUE and MAXVALUE. This command requires< exclusive access to the sequence. Once the ALTER SEQUENCEA statement is successfully committed, applications that use theA sequence will start with a value based on the restarted vkalue.& NOTE: The TRUNCATE TABLE statement issued for a table with5 an IDENTITY column implicitly executes an ALTER? SEQUENCE...RESTART WITH process on the sequence, applyingA the MINVALUE if it is an ascending sequence, or MAXVALUE if" it is a descending sequence. 4 sequence-name@ The name of the sequence whose definition you want to change. 4 WAIT Syntax options: WAIT | NOWAIT | DEFAULT WAITA l Specifies which wait state is used when a reference to NEXTVAL= is used. A reference to NEXTVAL for a sequence may require= synchronization with other users of the sequence. When you> specify DEFAULT WAIT the wait state (WAIT or NOWAIT) of the@ current transaction is used. This may mean that no waiting is) performed during a NOWAIT transaction.; If you specify WAIT (the default) for the sequence, thenD regardless of the wait state set for the current transaction, allD m synchronization waits for the next value. This is the recommendedC setting if the application uses NOWAIT transactions. The currentC WAIT timeout interval defined for the transaction or database is used.A If you specify NOWAIT for the sequence, then regardless of theA current transaction setting, all synchronization will not wait for the next value.@ Note that even after you alter the WAIT value, users who wereC using the sequence at the time you altered WAIT will conntinue to use the original setting. 3 Examples! Example 1: Altering a sequence, SQL> -- Show current sequence definition: SQL> -- SQL> SHOW SEQUENCE EMPIDS EMPIDS Sequence Id: 1 Initial Value: 1 Minimum Value: 1& Maximum Value: 9223372036854775787 Next Sequence Value: 1 Increment by: 1 Cache Size: 20 No Order No Cycle No Randomize SQL> -- SQL> -- Alter the sequence. SQL> -- SQL> ALTER SEQUENCE EoMPIDS cont> MINVALUE 0 cont> MAXVALUE 2000 cont> CACHE 30 cont> ORDER cont> CYCLE; SQL> -- SQL> -- Show new definition. SQL> -- SQL> SHOW SEQUENCE EMPIDS EMPIDS Sequence Id: 1 Initial Value: 1 Minimum Value: (none) Maximum Value: 2000 Next Sequence Value: 1 Increment by: 1 Cache Size: 30 Order Cycle No Randomize5 Example 2: Reset the sequence to a specified value% SQL> show sequence NEW_pEMPLOYEE_ID NEW_EMPLOYEE_ID Sequence Id: 1 Initial Value: 472 . . . SQL>& SQL> alter sequence NEW_EMPLOYEE_ID cont> restart with 500; SQL>% SQL> show sequence NEW_EMPLOYEE_ID NEW_EMPLOYEE_ID Sequence Id: 1 Initial Value: 500 . . . SQL> 2 STORAGE_MAP@ Changes an existing storage map. A storage map controls whichC rows of a table are stored in which storage areas in a multifilqe database.> In addition to changing storage maps, the ALTER STORAGE MAP3 statement has options that change the following:A o Which index the database system uses when inserting rows in the table: o Whether or not the rows of the table are stored in a compressed format, o Whether or not the data is reorganized/ o Whether partitioning keys can be modifiedD o Whether logging the transaction containing the ALTER statement, is journaled tro the RUJ and AIJ files. 3 Environment/ You can use the ALTER STORAGE MAP statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format ALTER STORAGE MAP -+ +-----------------------------+L ++-+-++-> ENABLE --+-> COMPRESSION ---------------------------------+-+-+->J | | |+-> DISABLE -+ s | | |J | | +-> COMPILE ---------------------------------------------------+ | |J | | +-> NO PLACEMENT VIA INDEX ------------------------------------+ | |J | | +-> PLACEMENT VIA INDEX --------------------------+ | |J | | +-> RENAME PARTITION TO -+ | |J | | +-> REORGANIZE ---+-----------+--------------------------------+ | |J | | | +-> AREAS --+ | | |J | | | t +-> PAGES --+ | | |J | | +-> NO REORGANIZE ---------------------------------------------+ | |J | | +-> store-clause ----------------------------------------------+ | |J | | +-> PARTITIONING IS UPDATABLE ---------------------------------+ | |J | | +-> PARTITIONING IS NOT UPDATABLE -----------------------------+ | |J | | +-> threshold-clause ------------------------------------------+ | |J | | +-> LOGGING ------------------------------------------u---------+ | |J | | +-> NOLOGGING -------------------------------------------------+ | |J | | +-> COMMENT IS -+-> 'string' --+-------------------------------+ | |J | | +---- / <-----+ | |J | +------------------- <---------------------------------------------+ |J +-----------> store-list-clause ---------------------------------------+ store-clause = ( --> STORE ---+-> IN area-spec ------+->& +-> across-clause -----+& v +-> using-clause ------+ area-spec = I --> -+---------------------------------------------------+->G +-> ( -++-> threshold-clause ---------------++-> ) -+@ |+-> LOGGING ------------------------+|@ |+-> NOLOGGING ----------------------+|@ |+-> PARTITION ---------------+|@ |+-> COMMENT IS -+--> 'string' ---+--+|@ | w +------- / <-----+ |@ +---------------- , -----------------+ across-clause =  ---> RANDOMLY ACROSS ---+ +----------------------+" +-> ( -+> area-spec --+--> ) --> +----- , <-----+ using-clause = A ---> USING ---> ( -+-> -+-> ) ------------------+A +-------- , <------+ |A +--------------------------------------------------------------+A ++-> IN area-spec -> xWITH LIMIT OF --> ( +-> -+> ) +-+A | +------ , <----+ | |A +--------------------------<--------------------------------+ |A +--------------------------<----------------------------------+C ++------------------------------------------------+------------->5 +> OTHERWISE IN area-spec -----------------------+ threshold-clause = = --+-> THRESHOLD -+-> IS -+-> ( --> --> ) ---------+->; | +-> OF -+ y |; | |; +-> THRESHOLDS -+-> ARE -+-----------+ |; +-> OF -+ | |; +----------------------------------+ |; +-> ( --> -+---------------------------+-> ) -+4 +-> , -+-------------+4 +-> , -+  store-lists-clause =  ---> STORE LISTS --- z+ +------------------+< +-+-> IN -+-> area-spec ---------------+---+----------->0 | +-> ( +> area-spec -> ) ----++ |0 | +------ , <-----------+ |0 | +---------------------------------------+; | +-+------------------------>-----------------------+; | +-> FOR -> ( -+-> ---------+-> ) -+ |; | +-> + | |; | +-------- , <-------------+ | |; | { +--------------------------------------+ |; | +---+------------>----------+------------+; | +-> FILL RANDOMLY -----+ |; | +-> FILL SEQUENTIALLY --+ |; +----------------------------<-----------------------+  3 Arguments 4 AREASB Specifies that the target of the data reorganization is storage@ areas. All rows are checked to see if they are in the correct@ storage area and if some are no|t, they are moved. This is the default. 4 COMMENT_IS? Adds or alters a comment about the storage map. SQL displays? the text of the comment when it executes a SHOW STORAGE MAPSC statement. Enclose the comment in single quotation marks (') and> separate multiple lines in a comment with a slash mark (/). 4 COMPILE? Creates a SQL mapping routine that matches the WITH LIMIT OFC clause for the storage map. The routine is automatically createdD in the syst }em module RDB$STORAGE_MAPS (use SHOW SYSTEM MODULES toB view). The storage map name is used to name the mapping routine' (use SHOW SYSTEM FUNCTIONS to view).& NOTE; If a routine already exists with the same name as the@ storage map, then the mapping routine will not be created.B If the storage map includes a STORE COLUMNS clause, that is,A a vertically partitioned map, then several routines will beA created and uniquely nam ~ed by adding the vertical partition number as a suffix.4 The mapping routine returns the following values:@ o Zero (0) if the storage map is defined as RANDOMLY ACROSS.6 This routine is just a descriptive place holder.= o Positive value representing the storage map number (the@ same value as stored in RDB$ORDINAL_POSITION column of theA RDB$STORAGE_MAP_AREAS table). These values can be used withD the PARTITION clause of the SET TRANSACTION...RESERVING clauseA to reserve a specific partition prior to inserting the row.D o A value of -1 if the storage map has no OTHERWISE clause. ThisC indicates that the row cannot be inserted because it does not- match any of the WITH LIMIT OF clauses. 4 COMPRESSION Syntax options:+ ENABLE COMPRESSION | DISABLE COMPRESSION; Changes whether the rows for the table are compressed or@ uncompressed when stored. Enabling compression conserves diskA space, but it incurs additional CPU overhead for inserting and retrieving compressed rows.= Changing the COMPRESSION clause causes the database system? to read all the rows in the table and write them back to theA table in the changed format. If compression is enabled and youA subsequently disable it, records may become fragmented because> the space allowed for the record is no longer large enough. 4 FILL Syntax options:$ FILL RANDOMLY | FILL SEQUENTIALLYC Specifi es whether to fill the area set randomly or sequentially.? Specifying FILL RANDOMLY or FILL SEQUENTIALLY requires a FOR@ clause. When a storage area is filled, it is removed from the@ list of available areas. Oracle Rdb does not attempt to storeB any more lists in that area during the current database attach.> Instead, Oracle Rdb starts filling the next specified area.@ When a set of areas is filled sequentially, Oracle Rdb stores? lists in the first specified area until that area is filled.B If the set of areas is filled randomly, lists are stored acrossD multiple areas. This is the default. Random filling benefits from1 the I/O distribution across the storage areas.? The keywords FILL RANDOMLY and FILL SEQUENTIALLY can only be2 applied to areas contained within an area list. 4 FOR_(table_name)C Specifies the table or tables to which this storage map applies.@ The named table must already be defined. If you want to storeA lists o f more than one table in the storage area, separate theB names of the tables with commas. For each area, you can specifyD one FOR clause and a , do not use this statement unless all areas! specified list of table names. 4 FOR_(table_name.col_name)A Specifies the name of the table and column containing the listA to which this storage map applies. Separate the table name andA the column name with a period (.). The named table and column? must already be defined. If you want to store multiple lists? in the storage area, separate the table name and column nameC combinations with commas. For each area, you can specify one FOR% clause and a list of column names. 4 LOGGINGD The LOGGING clause specifies that the ALTER STORAGE MAP statement@ should be logged in the recovery-unit journal file (.ruj) and= after-image journal file (.aij). The LOGGING clause is the default. 4 NOLOGGING< The NOLOGGING clause specifies that t he ALTER STORAGE MAPC statement should not be logged in the recovery-unit journal file. (.ruj) and after-image journal file (.aij). 4 NO_PLACEMENT_VIA_INDEX< Negates the PLACEMENT VIA INDEX clause so that subsequent? records stored are not stored by means of the index named inC the PLACEMENT VIA INDEX clause. If you specify the ALTER STORAGE@ MAP statement without the PLACEMENT VIA INDEX argument or the@ NO PLACEMENT VIA INDEX argument, the statement executes as ifC the clause specified on the CREATE STORAGE MAP statement or last( ALTER STORAGE MAP statement was used. 4 NO_REORGANIZED Disables the reorganize action for PARTITIONING IS NOT UPDATABLE. 4 PAGESC Specifies that the target of the data reorganization is databaseC pages. All rows are checked to determine whether they are in theB correct storage area and if some are not, they are moved. Then,B all rows are checked if any should be moved within each storageC area, and these rows are moved if there is space on or closer to the new target page. 4 PARTITION_name> Names the partition. The name can be a delimited identifierA if the dialect is set to SQL99. Partition names must be uniqueD within the storage map. If you do not specify this clause, Oracle2 Rdb generates a default name for the partition. 4 PARTITIONING_IS_UPDATABLE; Specifies that the partitioning key can be modified. TheA partitioning key is the column or list of columns specified in the STORE USING clause.A See the Oracle Rdb Guide to Database Design and Definition for+ more information regarding partitioning. 4 PLACEMENT_VIA_INDEXD See the CREATE STORAGE_MAP statement for details of the PLACEMENT VIA INDEX argument. 4 RENAME_PARTITIONSyntax options:8 RENAME PARTITION partition-name TO new-partition-name> Specifies a new name for an existing storage map partition. 4 REORGANIZEA  Causes new rows and rows previously stored in specified tablesA to be moved according to the partitions specified in the STOREC clause of the ALTER STORAGE MAP statement. The REORGANIZE clause3 works for one or more areas in the storage maps.? For details of how rows are moved or not moved among storage? areas depending on whether or not the REORGANIZE argument is= specified, see the Oracle Rdb Guide to Database Design and Definition. 4 STORAGE_MAP_map_name; Specifies the name of the storage map you want to alter. 4 store-clauseB A new storage map definition that replaces the existing storageA map. The store-clause allows you to specify which storage area> files will be used to store rows from the table. Note that:A o All rows of a table can be associated with a single storage area.> o Rows of a table can be distributed among several storage areas.7 o Rows of a table can be systematically distri buted? (horizontally partitioned) among several storage areas by= specifying upper limits on the values for a column in a particular storage area.A The store-clause specifies only how you want to associate rowsD with areas and not the manner in which rows are assigned to pages within an area.@ See the CREATE STORAGE_MAP statement for a description of theA syntax for the store-clause. However, the effect of the clauseC in the ALTER STORAGE MAP statement depends on how you change the existing storage map. 4 STORE_LISTS_IN_area_nameB Directs the database system to store the lists from tables in aD specified storage area. You can store lists from different tablesB in the same area. You can create only one storage map for lists within each database.C You must specify the default storage area for lists. This should? be the LIST STORAGE AREA specified on CREATE DATABASE, or if> none, the DEFAULT STORAGE AREA, or if none, then it will be RDB$SYSTEM.> For more information, see the CREATE STORAGE_MAP statement. 4 threshold-clauseB Specifies SPAM thresholds for logical areas with uniform format pages.@ When you specify the THRESHOLD clause without enclosing it in? parentheses, you are specifying the default threshold values> for all areas specified in the ALTER STORAGE MAP statement.B You cannot alter the thresholds for any storage areas which are@ part of the storage map . Only specify this clause for storageA areas being added to the storage area by the ALTER STORAGE MAP statement.= To specify threshold values for a particular storage area,A specify the clause as part of the STORE clause and enclose theB THRESHOLD clause in parentheses. You can only specify threshold+ values for new areas, not existing ones.B For examples of specifying the THRESHOLD clause, see the Oracle> Rdb Guide to Database Design and Definition. See the CREATED  STORAGE_MAP statement for a description of the THRESHOLDS clause. 3 ExamplesD Example 1: Reorganizing storage area data using the ALTER STORAGE MAP statementD The following example defines a new storage area, EMPIDS_MID2, toC handle the employee ID numbers from 601 to 900 and to reorganizeC the data from an existing storage area, EMPIDS_OVER. The currentB data that is stored for employees with employee ID numbers fromC 601 to 900 is moved according to the new limi ts. Because no AREAD or PAGE option is specified, the default method of reorganization is by storage areas.= SQL> ALTER DATABASE FILENAME mf_personnel ADD STORAGE AREA* cont> EMPIDS_MID2 PAGE FORMAT IS MIXED;' SQL> ATTACH 'FILENAME mf_personneL';' SQL> ALTER STORAGE MAP EMPLOYEES_MAP# cont> STORE USING (EMPLOYEE_ID)5 cont> IN EMPIDS_LOW WITH LIMIT OF ('00300')6 cont> IN EMPIDS_MID WITH LIMIT OF ('00600')6 cont> IN EMPIDS_MID2 WITH LIMIT OF ('00900')+ cont> OTHERWISE IN EMPIDS_OVER cont> REORGANIZE;< Example 2: Enabling compression with an ALTER STORAGE MAP statementA The following example defines a new storage map, UNIFORM1_MAP,@ and specifies thresholds for the logical area in the UNIFORM1B storage area. The ALTER STORAGE MAP statement is used to enable row compression., SQL> ALTER DATABASE FILENAME mf_personnel$ cont> ADD STORAGE AREA UNIFORM1;' SQL> ATTACH 'FILENAME mf_personnel';& SQL> CREATE TABLE TEST (COL1 REAL);0 SQL> CREATE STORAGE MAP UNIFORM1_MAP FOR TEST cont> STORE IN UNIFORM1( cont> (THRESHOLDS ARE (80,90,95));& SQL> ALTER STORAGE MAP UNIFORM1_MAP cont> STORE IN UNIFORM1 cont> ENABLE COMPRESSION;? Example 3: Changing an overflow partition to a WITH LIMIT OF partitionC To change the overflow partition to a partition defined with theB WITH LIMIT OF clause, you must use the REORGANIZE clause if youD w ant existing data that is stored in the overflow partition movedA to the appropriate storage area. For example, suppose the JOB_D HISTORY table contains a row with an EMPLOYEE_ID of 10001 and theD JH_MAP storage map is defined, as shown in the following example: SQL> SHOW STORAGE MAP JH_MAP JH_MAP& For Table: JOB_HISTORY" Compression is: ENABLED4 Store clause: STORE USING (EMPLOYEE_ID)G IN PERSONNEL_1 WI TH LIMIT OF ('00399')G IN PERSONNEL_2 WITH LIMIT OF ('00699')3 OTHERWISE IN PERSONNEL_3 SQL>= If you want to change the PERSONNEL_3 storage area from an? overflow partition to a partition with a limit of 10,000 andD add the partition PERSONNEL_4, you must use the REORGANIZE clauseC to ensure that Oracle Rdb moves existing rows to the new storageD area. The following example shows the ALTER STORAGE MAP statement!  that accomplishes this change: SQL> ALTER STORAGE MAP JH_MAP' cont> STORE USING (EMPLOYEE_ID): cont> IN PERSONNEL_1 WITH LIMIT OF ('00399'): cont> IN PERSONNEL_2 WITH LIMIT OF ('00699'): cont> IN PERSONNEL_3 WITH LIMIT OF ('10000'): cont> IN PERSONNEL_4 WITH LIMIT OF ('10399') cont> REORGANIZE; SQL>8 Example 4: Disabling Logging to the RUJ and AIJ files* SQL> ATTACH'FILENAME MF_PERSONNEL.RDB';' SQL> ALTER STORAGE MAP EMPLOYEES_MAP cont> STORE" cont> USING (EMPLOYEE_ID) cont> IN EMPIDS_LOW. cont> WITH LIMIT OF ('00200') cont> IN JOBS" cont> (NOLOGGING). cont> WITH LIMIT OF ('00400'), cont> OTHERWISE IN EMPIDS_OVER;L %RDB-W-META_WARN, metadata successfully updated with the reported warningN -RDMS-W-DATACMIT, unjournaled changes made; database may not be recoverable B Example 5: Di sabled Area Scan for PARTITIONING IS NOT UPDATABLEA When a storage map is altered to be NOT UPDATABLE a REORGANIZE@ scan is implicitly executed to check that all rows are in theA correct storage area according to the WITH LIMIT OF clauses inD the storage map. This scan can be time consuming, and an informedA database administrator may know that the data already conforms= fully to the storage map. The NO REORGANIZE clause is used@ in the following example to avoid the extra I/O. The databaseC administrator must understand that use of this clause might leadC to incorrect query results (for sequential scans) if the storage0 map does not reflect the correct row mapping.! SQL> SET FLAGS 'stomap_stats';' SQL> ALTER STORAGE MAP EMPLOYEES_MAP* cont> PARTITIONING IS NOT UPDATABLE cont> NO REORGANIZE cont> STORE$ cont> USING (EMPLOYEE_ID)" cont> IN EMPIDS_LOW0 cont> WITH LIMIT OF ('00200')"  cont> IN EMPIDS_MID0 cont> WITH LIMIT OF ('00400'). cont> OTHERWISE IN EMPIDS_OVER;# ~As: starting map restructure...9 ~As: REORGANIZE needed to preserve strict partitioning/ ~As: NO REORGANIZE was used to override scan8 ~As: reads: async 0 synch 21, writes: async 7 synch 3 SQL>' SQL> SHOW STORAGE MAPS EMPLOYEES_MAP EMPLOYEES_MAP$ For Table: EMPLOYEES) Placement Via Index: EMPLOYEES_HASH( Partitioning is: NOT UPDATABLE8 Strict partitioning was not validated for this table< Comment: employees partitioned by "00200" "00400" Store clause: STORE# using (EMPLOYEE_ID)! in EMPIDS_LOW/ with limit of ('00200')! in EMPIDS_MID/ with limit of ('00400'), otherwise in EMPIDS_OVER" Compression is: ENABLED SQL>A A subsequent ALTER STORAGE MAP . . . REORGANIZE statement will@ validate the partitioning, as shown in the following example:' SQL> ALTER STORAGE MAP EMPLOYEES_MAP* cont> PARTITIONING IS NOT UPDATABLE cont> REORGANIZE;# ~As: starting map restructure... ~As: starting REORGANIZE... ~As: reorganize AREAS...$ ~As: processing rows from area 69$ ~As: processing rows from area 70$ ~As: processing rows from area 71: ~As: reads: async 408 synch 22, writes: async 3 synch 0 SQL>B Example 6: Redefining a SQL routine that matches the WITH LIMIT OF clause for the storage map@ The ALTER STORAGE MAP command removes any old mapping routineC and redefines it when either the STORE clause is used, or if the COMPILE option is used.' SQL> alter storage map EMPLOYEES_MAP cont> store$ cont> using (EMPLOYEE_ID)" cont> in EMPIDS_LOW0 cont> with limit of ('00200')" cont> in EMPIDS_MID0  cont> with limit of ('00400')# cont> in EMPIDS_OVER1 cont> with limit of ('00800'); SQL>4 SQL> show system function (source) EMPLOYEES_MAP;) Information for function EMPLOYEES_MAP Source: return case0 when (:EMPLOYEE_ID <= '00200') then 10 when (:EMPLOYEE_ID <= '00400') then 20 when (:EMPLOYEE_ID <= '00800') then 3 else -1 end case; 2 SYNONYM Alters a synonym definition. 3 Environment+ You can use the ALTER SYNONYM statement: o In interactive SQL( o Embedded in host language programs- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format9 ALTER SYNONYM -+----------------------+-+9 +-> FOR -+ |9 +------------------------------------------------------+9 ++-------------------------------+---------------------># +-> COMMENT IS -+-> 'string' -+-+! +----- / <----+ 3 Arguments 4 COMMENT_IS_stringA This clause can be used to add several lines of comment to theC synonym object. The SHOW SYNONYM statement displays the comment.A This clause is equivalent to the COMMENT ON SYNONYM statement. 4 FOR_object-name? You may change the synonym to reference a different databaseC object; however, it must be of the same type. Oracle Rdb assumes= that the object has the same or similar characteristics asA the referenced object. The referenced object must exist in the database. 4 synonym-name5 The name of an existing synonym you want to alter. 3 Examples Example 1: Adding a Comment SQL> ALTER SYNONYM CASHD cont> COMMENT IS 'use a different name to avoid confusion with') cont> / 'the domain MONEY';A Example 2: Using Multiple Synonyms and Changing the  Referenced Table Using ALTERC The following example uses a synonym to reference a table. Later? an empty version of the table can be created and the synonymC altered to reference this new table. Although similar to using aB view definition, the use of synonyms avoid the usage locking ofB a view. That is, to drop and create a new view requires that noC other user references that view, however, the alter synonym does- not require exclusive access to the table., SQL> CREATE TABLE t_employees_0001 (...);6 SQL> CREATE SYNONYM employees FOR t_employees_0001;* SQL> CREATE SYNONYM emps FOR employees;< SQL> CREATE TABLE t_employees_0002 LIKE t_employees_0001;5 SQL> ALTER SYNONYM employees FOR t_employees_0002; 2 TABLE1 Changes an existing table definition. You can: o Add columns* o Add constraints to tables or columns o Modify columns o Modify character sets o Modify data types o Delete columns  o Delete constraintsB The ALTER TABLE statement can also add or delete table-specific= constraints. You can display the names for all constraints< currently associated with a table by using the SHOW TABLE: statement. Any number of constraints can be deleted andC declared at both the table and column levels. See also the ALTER; CONSTRAINT statement and the DROP CONSTRAINT. statement.A When you execute this statement, SQL modifies the named column? definitions in the ta ble. All of the columns that you do not@ mention remain unchanged. SQL defines new versions of columns? before defining constraints. Then, SQL defines and evaluates= constraints before storing them. Therefore, if columns andD constraints are defined in the same table definition, constraints2 always apply to the latest version of a column.B When you change a table definition, other users see the revised> definition only when they connect to the database after you commit the changes. 3 Environment) You can use the ALTER TABLE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format ALTER TABLE --> -+ +-----------------------------+= +-+-+-> ADD -+-> COLUMN col-definition ----------------+-+->; | | +-> CONSTRAINT table-constraint ----------+ |; | |  +-> ( -+-> col-definition -+-> ) ---------+ |; | | +------- , <--------+ | |; | +-> ALTER COLUMN --> alter-col-definition ---------+ |; | +-> MODIFY -> ( -+-> alter-col-definition --+-> ) -+ |; | | +------------ , <----------+ | |; | +-> DROP -+-> COLUMN ----------------+ |; | | +-> CONSTRAINT --------+ |; | +-> enable-clause ---------------------------------+ |; | +-> disable-clause --------------------------------+ |; | +-> RENAME TO --------------------+ |; | +-> COMMENT IS -+> '' -+------------+ |; | +----- / -------------+ |; +-------------------------- <--------------------------+ col-definition =  --> --+ +---------------+; +-> add-column-type -+---------------------------+-+-+; | +-> DEFAULT value-expr ----+ | |; |  +-> column-identity ------+ | |; +---> COMPUTED BY value-expr ----------------------+ |; +----------------------------<-----------------------+; +--+-------------------++--------------------+-------+; +-> col-constraint -++-> position-clause -+ |; +----------------------------<-----------------------+= +--+------------------------+-------------------------->" +-> sql-and-dtr-clause --+ add-column-type = 8 --+-> data-type -----------------------------------+-->5 +-> -------------------------------+5 +-> -------------------------+5 +-> AUTOMATIC --+-----------+--> AS value-expr --+ +-> INSERT -+ +-> UPDATE -+ column-identity = G --> IDENTITY --+--------------------------------------------------+-->D +- ( --+----------------------+-> ) --+< +-> , --+ data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+---------------+A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+ |A +-> FLOAT ----------------+ |A +-> NUMBER -+----------------------------------+--------- ----+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE VARYING --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT ---+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) + |A |  +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION ----------------------------------------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+  |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER  -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac --------------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+ literal = --+-> numeric-literal ----+---> +-> string-literal -----+ +-> date-time-literal --+ +-> interval-literal ---+  col-constraint= ) ----+--------------------------------+-+)  +> CONSTRAINT -+ |) +---------------<--------------------+% +-> PRIMARY KEY -----------------+% +-> UNIQUE ----------------------+% +-> NOT NULL --------------------+% +-> NULL ------------------------+% +-> CHECK (predicate) -----------+% +-> references-clause -----------+% +--------------->----------------+% +---------------<----------------+) +----+----------------------------+-->& +--> constraint-attributes --+ references-clause = * --> REFERENCES -+* +----------------------------------+5 +-+-----------------------------------------+->3 +-> ( -+> +-> ) -+, +----------- , <------------+ constraint-attributes = B -+-> DEFERRABLE -------------+------------------------------+-+->@ | +-> INITIALLY +-> IMMEDIATE --++ |@ | +-> DEFERRED ---+ |@ +-> NOT DE FERRABLE ---------+-------------------------+------+@ | +-> INITIALLY IMMEDIATE --+ |@ +-> INITIALLY IMMEDIATE ----+-------------------+------------+@ | +-> DEFERRABLE -----+ |@ | +-> NOT DEFERRABLE -+ |@ +-> INITIALLY DEFERRED -----+-------------------+------------+3 +-> DEFERRABLE -----+ position-clause = - -+-> AFTER --+--> COLUMN ----> +-> BEFORE -+ sql-and-dtr-clause = A -+-> QUERY HEADER IS -+> +-------------------+->? | +------ / <--------+ |? +-> EDIT STRING IS -------------------------+? | |? +-> QUERY NAME FOR -+-> DTR --------+-> IS -+? | +-> DATATRIEVE -+ |? +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+* +-> DATATRIEVE -+  table-constraint = . ---+-----------------------------------+----+. +-> CONSTRAINT ---+ |. +------------------------------------------+. +--> table-constraint-clause --------------+. +------------------------------------------+1 +---+---------------------------+-------------># +-> constraint-attributes --+  table-constraint-clause = 5 -+----------------------------------------------+-->2 +-> PRIMARY KEY -> ( -+> +-> ) --+2 | +------- , <-----+ |2 +-> UNIQUE -> ( -+> +-> ) -------+2 | +------- , <-----+ |2 +-> CHECK (predicate) -------------------------+2 +-> FOREIGN KEY -> ( -+> +-> ) + |2 +------- , <-----+ | |2 +--------------------<---------------------+ |2 +-> references-clause ---------->------------+  alter -col-definition = D -> +----------------++-----------------------------++D +-> alt-col-type ++-> SET DEFAULT value-expr ---+|D +-> DEFAULT value-expr -------+|D +-> DROP DEFAULT value-expr --+|D +--------------------------- <------------------------------------+C +-+----------------------+---------+--------------------+--------+C ++-> col-constraint -+-+ +-> position-clause -+  |C +-------- <---------+ |C +-------------------- <------------------------------------------+E +-+-+-----------------------------> ------------------+-+---------->: | +--> sql-and-dtr-clause --------------------------+ |: | +--> NO QUERY HEADER -----------------------------+ |: | +--> NO EDIT STRING ------------------------------+ |: | +--> NO QUERY NAME ----+-> FOR --+-> DTR --------++ |: | +--> NO DEFAULT VALUE -+ +-> DATATRIEVE -+ |: +------------------------- <--------------------------+ alt-col-type = A -+-> data-type -------------------+-+---------------------+-+-->> +-> --------------+ +-> column-identity --+ |> +-> COMPUTED BY value-expr --------------------------------+> +-> AUTOMATIC -+------------+----> AS value-expr ----------+ +-> INSERT --+ +-> UPDATE --+ enable-clause =  --> ENABLE ---+ +-------<-----+F +-+-> ALL TRIGGERS -----------------------------------------------+->D +-> TRIGGER ------------------------------------++C +-+---------------+-+-> ALL CONSTRAINTS ----------------------++B +-> VALIDATE ---+ +-> CONSTRAINT ---------+B +-> NOVALIDATE -+ +-> PRIMARY KEY --------------------------+B +-> UNIQUE ->( -+-> -+-> ) -+; +------- , <-------+  disable-clause = > --> DISABLE ---+-> ALL TRIGGERS -------------------------+-->; +-> TRIGGER ---------------+; +-> ALL CONSTRAINTS ----------------------+; +-> CONSTRAINT ---------+; +-> PRIMARY KEY --------------------------+; +-> UNIQUE ->( -+-> -+-> ) -+4 +------- , <-------+ 3 Arguments 4 ADD_(...)__? This alternate syntax is added for compatibility with Oracle RDBMS. 4 ADD_COLUMNA Creates an additional column in the table. SQL adds the column? after all existing columns in the table unless the position-C clause relocates the new column. The column definition specifies? a data type or domain name, optional default value, optional7 column constraints, and optional formatting clauses." The COLUMN keyword is optional. 4 ADD_CONSTRAINT> Adds a table constraint definition. The four types of table? constraints are PRIMARY KEY, UNIQUE, CHECK, and FOREIGN KEY. 4 AFTER_COLUMN; Changes the normal field ordering of columns to make the? displayed column ordering more readable. Note that this doesA not change the on-disk layout of the columns. By default, whenC neither of these clauses is specified, columns are positioned atA the end of the table specified with the ALTER TABLE statement. $4 ALTER_COLUMN_alter_col_definition? Modifies the column specified by the column name. The COLUMN keyword is optional.> You can modify some elements of a column definition but not others.D You cannot change an existing column constraint. However, you canA delete the existing constraint and add a new column constraintD using the alter-col-definition clause to achieve the same result. 4 AUTOMATIC Syntax options:= AUTOMATIC AS value-expr | AUTOMATIC INSERT AS value-expr |! AUTOMATIC UPDATE AS value-expr < These AUTOMATIC column clauses allow you to store specialD information when data is inserted into a row or a row is updated.? For example, you can log application-specific information toB audit activity or provide essential values, such as time stamps& or unique identifiers for the data.C The assignment of values to these types of columns is managed byA Oracle Rdb. The AUTOMATIC INSERT clause can be used to provide@ a complex default for the column when the row is insert ed; itA cannot be changed by an UPDATE statement. The AUTOMATIC UPDATEB clause can be used to provide an updated value during an UPDATED statement. The AUTOMATIC clause is the default and specifies that@ the value expression should be applied during both INSERT andC UPDATE statements. The column type is derived from the AS value-@ expr; using CAST allows a specific data type to be specified.9 However, this is not required and is rarely necessary.= You can define an AUTOMAT IC INSERT column to automaticallyC receive data during an insert operation. The data is stored likeC any other column, but the column is read-only. Because AUTOMATICB columns are treated as read-only columns, they cannot appear in@ the column list for an insert operation nor be modified by anD update operation. AUTOMATIC UPDATE columns can have an associated< default value that will be used when the row is inserted.= Suppose that you want to store the current time stamp of a= transaction and supply a unique numeric value for an order= number. In addition, when the row is updated (the order isA altered), you want a new time stamp to be written to the LAST_@ UPDATED column. You could write an application to supply thisA information, but you could not guarantee the desired behavior.= For instance, a user with access to the table might update@ the table with interactive SQL and forget to enter a new timeC stamp to the LAST_UPDATED column. If you use an AUTOMATIC columnC instead, it can be defined so that columns automatically receive? data during an insert operation. The data is stored like any- other column, but the column is read-only. 4 BEFORE_COLUMN; Changes the normal field ordering of columns to make the? displayed column ordering more readable. Note that this doesA not change the on-disk layout of the columns. By default, whenC neither of these clauses is specified, columns are positioned atA the end of the table specified with the ALTER TABLE statement. 4 char-data-typesA A valid SQL character data type. See the Data_Types HELP topic0 for more information on character data types. 4 CHECK_(predicate)= Specifies a predicate that column values inserted into the? table must satisfy. See Predicates for details on specifying predicates.D Predicates in CHECK column constraints can only refer directly to- the column with which they are associated. 4 col-constraintD Specifies a constraint that column values inserted into the tableA must satisfy. You can specify more than one column constraint. For example: SQL> ALTER TABLE EMPLOYEE- cont> ADD ID_NUMBER INT NOT NULL UNIQUE;- You can name each constraint. For example: SQL> ALTER TABLE EMPLOYEE cont> ADD ID_NUMBER INT cont> CONSTRAINT A NOT NULL cont> CONSTRAINT B UNIQUE; 4 column-name2 The name of the column being added or modified. 4 COMPUTED_BYD Specifies that the value of this column is calculated from valuesB in other columns and constant expressions. See the CREATE TABLE" statement for more information. 4 constraint-attributesD Although the constraint attribute syntax provides 11 permutationsB as required by the SQL99 standard, they equate to the following three options:( o INITIALLY IMMEDIATE NOT DEFERRABLEA Specifies that evaluation of the constraint must t ake place? when the INSERT, DELETE, or UPDATE statement executes. IfB you are using the SQL92, SQL99, MIA, ORACLE LEVEL1 or ORACLE* LEVEL2 dialect, this is the default.C This clause is the same as the NOT DEFERRABLE option provided) in previous releases of Oracle Rdb.# o INITIALLY DEFERRED DEFERRABLE@ Specifies that evaluation of the constraint can take placeB at any later time. Unless otherwise specified, evaluation ofB the constraint tak es place as the COMMIT statement executes.? You can use the SET ALL CONSTRAINTS statement to have all@ constraints evaluated earlier. See the SET_ALL_CONSTRAINTSC Help topic for more information. If you are using the default? SQLV40 dialect, this is the default constraint attribute.< When using this default dialect, Oracle Rdb displays aD deprecated feature message for all constraints defined without8 specification of one of the constraint attributes.B  This clause is the same as the DEFERRABLE option provided in& previous releases of Oracle Rdb.$ o INITIALLY IMMEDIATE DEFERRABLED Specifies that evaluation of the constraint be deferred (using= the SET CONSTRAINT ALL statement or the SET TRANSACTION= statement with the EVALUATING clause) but by default it@ is evaluated after the INSERT, DELETE, or UPDATE statement executes. 4 CONSTRAINT_constraint_nameC The CONSTRAINT clause specifies a  name for the table constraint.. The name is used for a variety of purposes:= o The INTEG_FAIL error message specifies the name when anB INSERT, UPDATE, or DELETE statement violates the constraint.@ o The ALTER CONSTRAINT, DROP CONSTRAINT and ALTER TABLE DROP8 CONSTRAINT statements specify the constraint name.A o The SHOW TABLE statements display the names of constraints.B o The EVALUATING clause of the SET and the DECLARE TRANSACTION, statements specifies constraint names.@ The CONSTRAINT clause is optional. If you omit the constraint@ name, SQL creates a name. However, Oracle Rdb recommends that? you always name column and table constraints. The constraintD names generated by SQL may be obscure. If you supply a constraintB name with the CONSTRAINT clause, the name must be unique in the schema. 4 data-type= A valid SQL data type. Specifying an explicit data type toC associate with a column is an alternative to specifying a domain name.D See the Data_Types HELP topic for more information on data types.= Using the ALTER clause to change the data type of a columnD (directly or indirectly by specifying a domain) requires caution:C o If you change a column to a character data type with a largerD capacity, or increase the scale factor for a column, or changeD the character set, you may have to modify source programs that4 refer to the column and precompile them again. ? o If you change a column to a smaller capacity numeric dataD type then overflow errors may result at run time as Oracle Rdb> attemps to convert the large value to the new data type.D o If you change a column to a data type with a smaller capacity,> SQL truncates values already stored in the database that@ exceed the capacity of the new data type, but only when it> retrieves those values. (The values are not truncated in@ the database, however, until the y are updated. If you only= retrieve data, you can change the data type back to theC original, and SQL again retrieves the entire original value.)@ o You can change a DATE column only to a character data type? (CHAR, VARCHAR, LONG VARCHAR, NCHAR, NATIONAL CHAR, NCHARA VARYING, or NATIONAL CHAR VARYING, or date/time (DATE ANSI,A TIMESTAMP, TIME). If you attempt to change a DATE column to2 anything else, SQL returns an error message. 4 date-time-data-typesA A valid SQL date-time data type. See the Data_Types HELP topic0 for more information on date-time data types. 4 disable-clauseD Allows you to enable or disable all triggers, specified triggers,> all constraints, specified constraints, a primary key, or a< unique constraint, as described in the following list. ByD default, table and column constraints added during an alter table operation are enabled. o DISABLE ALL TRIGGERSC All triggers defined for the table are disabled. (No error is8 raised if no triggers are defined for this table.) o ENABLE ALL TRIGGERSB All triggers defined for the table are enabled. (No error is8 raised if no triggers are defined for this table.)" o DISABLE TRIGGER trigger-name= The named trigger for this table is disabled. The named+ trigger must be defined on the table.! o ENABLE TRIGGER trigger-nameD The named trigger for this table is enabled. The named trigger# must be defined on the table. o DISABLE ALL CONSTRAINTSC All table and column constraints for this table are disabled.> (No error is raised if no constraints are defined on the table.) o ENABLE ALL CONSTRAINTSB All table and column constraints for this table are enabled.> (No error is raised if no constraints are defined on the table.)( o DISABLE CONSTRAINT constraint-nameD The named constraint is disabled. The named constraint must be1 a table or column constraint for the table.' o ENABLE CONSTRAINT constraint-nameC The named constraint is enabled. The named constraint must be1 a table or column constraint for the table. o DISABLE PRIMARY KEY0 The primary key for the table is disabled. o ENABLE PRIMARY KEY/ The primary key for the table is enabled." o DISABLE UNIQUE (column-name)D The matching UNIQUE constraint is disabled. The columns listed# must be columns in the table.! o ENABLE UNIQUE (column-name)C The matching UNIQUE constraint is enabled. The columns listed# must be columns in the table. o VALIDATE and NOVALIDATE? These options are available only on the enable-clause. ByA default, table and column constraints are enabled during anB ALTER TABLE statement. When a constraint is added or enabled@ with the ALTER TABLE statement, the default is to valida te? the table contents. The ENABLE NOVALIDATE option allows aD knowledgeable database administrator to avoid the time and I/OD resources required to revalidate the data when he or she knows the data is valid.) NOTEB Oracle Corporation recommends that you use the RMU Verify> command with the Constraint qualifier periodically to@ verify that your assumptions are correct if you use the" ENABLE NOVALIDATE option. 4 DEFAULT_value-exprD Provides a default value for a column if the row that is inserted, does not include a value for that column.9 You can use any value expression including subqueries,@ conditional, character, date/time, and numeric expressions asC default values. See Value Expressions for more information about value expressions.D For more information about NULL, see the NULL_Keyword HELP topic.= You can add a default value to an existing colu mn or alter@ the existing default value of a column by altering the table.C However, doing so has no effect on the values stored in existing rows.? The value expressions described in Value Expressions include@ DBKEY and aggregate functions. However, the DEFAULT clause is? not a valid location for referencing a DBKEY or an aggregate> function. If you attempt to reference either, you receive a compile-time error.? If you do not specify a default value, a column inher its theA default value from the domain. If you do not specify a defaultA value for either the column or domain, SQL assigns NULL as the default value.A If you specify a default value for either the column or domainD when a column is added, SQL propagates the default value from theB column or domain to all previously stored rows. Therefore, whenB you add a column to a table and specify a default value for theA column, SQL stores the default value in the newly added colum nB of all the previously stored rows. Likewise, if the newly addedD column is based upon a domain that specifies a default value, SQLB stores the default value in the column of all previously stored rows.@ Because SQL updates data when you add a column with a defaultA value other than NULL, the ALTER TABLE statement can take some> time to complete when the table contains many rows. (If you@ specify a default value of NULL, SQL does not modify the dataB because SQL autom atically returns a null value for columns that@ have no actual value stored in them.) If you want to add moreB than one column with default values, add them in a single ALTERA TABLE statement. When you do so, SQL scans the table data once instead of many times.D Because data is added to the rows, adding a column with a default@ value may result in fragmented records. For information aboutD locating and correcting record fragmentation, see the Oracle Rdb7, Guide to Database Performance and Tuning. 4 domain-nameA The name of a domain created in a CREATE DOMAIN statement. SQLC gives the column the data type specified in the domain. For more< information on domains, see the CREATE DOMAIN. statement.B For most purposes, specify a domain instead of an explicit data type.C o Domains ensure that columns in multiple tables that serve theD same purpose all have the same data type. For example, severalA tables in the sample personn el database refer to the domain ID_DOM.@ o A domain lets you change the data type for all the columns> that refer to it in one operation by changing the domain@ itself with an ALTER DOMAIN statement. For example, if youB want to change the data type for the column EMPLOYEE_ID fromC CHAR(5) to CHAR(6), you need only alter the data type for ID_@ DOM. You do not have to alter the data type for the columnD EMPLOYEE_ID in the tables DEGREES, EMPLOYEES, JOB_HISTORY, andD SALARY_HISTORY, nor do you have to alter the column MANAGER_ID in the DEPARTMENTS table.D However, you might not want to use domains when you create tables if:? o Your application must be compatible with the Oracle RDBMS language.@ o You are creating tables that do not need the advantages of domains. 4 DROP_COLUMN@ Deletes the specified column. The COLUMN keyword is optional. 4 DROP_CONSTRAINTC Deletes the specified column constraint or table constraint from the table definition. 4 DROP_DEFAULT< Deletes (drops) the default value of a column in a table. 4 enable-clauseD Allows you to enable or disable all triggers, specified triggers,> all constraints, specified constraints, a primary key, or a< unique constraint, as described in the following list. ByD default, table and column constraints added during an alter table operation are enabled. o DISABLE ALL TRIGGERSC All triggers defined for the table are disabled. (No error is8 raised if no triggers are defined for this table.) o ENABLE ALL TRIGGERSB All triggers defined for the table are enabled. (No error is8 raised if no triggers are defined for this table.)" o DISABLE TRIGGER trigger-name= The named trigger for this table is disabled. The named+ trigger must be defined on the table.! o ENABLE TRIGGER trigger-nameD The named trigger for this table is enabled. The named trigger# must be defined on the table. o DISABLE ALL CONSTRAINTSC All table and column constraints for this table are disabled.> (No error is raised if no constraints are defined on the table.) o ENABLE ALL CONSTRAINTSB All table and column constraints for this table are enabled.> (No error is raised if no constraints are defined on the table.)( o DISABLE CONSTRAINT constraint-nameD  The named constraint is disabled. The named constraint must be1 a table or column constraint for the table.' o ENABLE CONSTRAINT constraint-nameC The named constraint is enabled. The named constraint must be1 a table or column constraint for the table. o DISABLE PRIMARY KEY0 The primary key for the table is disabled. o ENABLE PRIMARY KEY/ The primary key for the table is enabled." o DISABLE UNIQUE (column-name)D The matchi ng UNIQUE constraint is disabled. The columns listed; must be columns in a unique constraint for the table.! o ENABLE UNIQUE (column-name)C The matching UNIQUE constraint is enabled. The columns listed; must be columns in a unique constraint for the table. o VALIDATE and NOVALIDATE@ When a constraint is added or enabled with the ALTER TABLE? statement, the default is to validate the table contents.B The ENABLE NOVALIDATE option allows a knowledgeable databaseC administrator to avoid the time and I/O resources required to; revalidate the data when they know the data is valid.) NOTEB Oracle Corporation recommends that you use the RMU Verify> command with the Constraint qualifier periodically to@ verify that your assumptions are correct if you use the" ENABLE NOVALIDATE option. 4 FOREIGN_KEY> The name of a column or columns that you want to declare as? a foreign key in the table you are altering (the referencing table). 4 IDENTITYB Specifies that the column is to be a special read-only identityD column. INSERT will evaluate this column and store a unique valueA for each row inserted. Only one column of a table may have theB IDENTITY attribute. Oracle Rdb creates a sequence with the same name as the current table.; See the ALTER SEQUENCE statement and the CREATE SEQUENCE" statement for more information. 4 increment-by@ An integer literal value that specifies the increment for the= sequence created for the IDENTITY column. A negative valueA creates a descending sequence, and a positive value creates anC ascending sequence. A value of zero is not permitted. If omitted4 the default is 1, that is, an ascending sequence. 4 MODIFY_(...)__? This alternate syntax is added for compatibility with Oracle RDBMS. 4 NOT_NULL> Restricts values in the column to values that are not null. 4 NULL? Specifies that NULL is permitted for the column. This is the@ default behavior. A column with a NULL constraint cannot alsoD have a NOT NULL constraint within the same ALTER TABLE statement.D However, no checks are performed for CHECK constraints, which may' limit the column to non-null values.D The NULL constraint is not stored in the database and is provided/ only as a syntactic alternative to NOT NULL.D  When used on ALTER TABLE . . . ALTER COLUMN this clause drops any/ NOT NULL constraints defined for the column. 4 PRIMARY_KEYD A primary key constraint defines one or more columns whose values@ make a row in a table different from all others. SQL requires> that values in a primary key column be unique and not null;A therefore, you need not specify the UNIQUE and NOT NULL column' constraints for primary key columns.? You cannot specify the primary key constraint for a computed column.B When used as a table constraint this clause must be followed by@ a list of column names. When used as a column constraint this3 clause applies to the named column of the table. 4 referenced-column-name< For a column constraint, the name of the column that is aC unique key or a primary key in the referenced table. For a tableC constraint, the referenced column name is the name of the columnD or columns that are a unique key or primary key in the referencedD table. If you omit the referenced-column-name clause, the primary key is selected by default. 4 references-clause@ Specifies the name of the column or columns that are a unique: key or primary key or in the referenced table. When theD REFERENCES clause is used as a table constraint, the column namesC specified in the FOREIGN KEY clause become a foreign key for the referencing table.? When used as the column type clause, specifies that the typeB of the column be inherited from the PRIMARY KEY or UNIQUE index; referenced. Both the data type and domain are inherited. 4 RENAME_TO> Changes the name of the table being altered. See the RENAME@ statement for further discussion. If the new name is the name- of a synonym then an error will be raised.@ The new name must not exist as the name of an existing table,@ synonym, sequence or view. You may not rename a system table.= The RENAME TO clause requires synonyms be enabled for this= database. Refer to the ALTER DATABASE SYNONYMS ARE ENABLEDA clause. Note that these synonyms may be deleted if they are no7 longer used by database definitions or applications. 4 SET_DEFAULT, Specifies a default value for the column. 4 sql-and-dtr-clauseD Optional SQL and DATATRIEVE formatting clause. See the DATATRIEVE# HELP topic for more information.C If you specify a formatting clause for a column that is based onC a domain that also specifies a formatting clause, the formattingA clause in the table definition overrides the one in the domain definition. 4 start-withA An integer literal value that specifies the starting value for? the sequence created for the IDENTITY column. If omitted the default is 1. 4 table-name= The name of the table whose definition you want to change. 4 UNIQUEA Specifies that values in the associated column must be unique. 3  Examples4 Example 1: Adding a column to the EMPLOYEES table4 SQL> ALTER TABLE EMPLOYEES ADD SALARY INTEGER(2);C Example 2: Adding a column and altering a column in the COLLEGES tableC The following example adds two columns, one with a query name toD the COLLEGES table. ALTER DOMAIN is also used to implicitly alter> the POSTAL_CODE column to accept 9 characters instead of 5. SQL> SHOW TABLE COLLEGES;! Information for table COLLEGES Comment on table COLLEG ES:8 names and addresses of colleges attended by employees Columns for table COLLEGES:: Column Name Data Type Domain: ----------- --------- ------D COLLEGE_CODE CHAR(4) COLLEGE_CODE_DOM8 Primary Key constraint COLLEGES_PRIMARY_COLLEGE_CODED COLLEGE_NAME CHAR(25) COLLEGE_NAME_DOM< CITY CHAR(20) CITY_DOM= STATE  CHAR(2) STATE_DOMC POSTAL_CODE CHAR(5) POSTAL_CODE_DOM . . . SQL> ALTER TABLE COLLEGES cont> ADD RANKING INTEGER# cont> ADD NUMBER_ALUMS INTEGER) cont> QUERY_NAME IS 'ALUMS';- SQL> ALTER DOMAIN POSTAL_CODE_DOM CHAR(9); SQL> SHOW TABLE COLLEGES;! Information for table COLLEGES Comment on table COLLEGES:8 names and addresses of colleges attended by employees Columns for t able COLLEGES:: Column Name Data Type Domain: ----------- --------- ------D COLLEGE_CODE CHAR(4) COLLEGE_CODE_DOM8 Primary Key constraint COLLEGES_PRIMARY_COLLEGE_CODED COLLEGE_NAME CHAR(25) COLLEGE_NAME_DOM< CITY CHAR(20) CITY_DOM= STATE CHAR(2) STATE_DOMC POSTAL_CODE CHAR(9)  POSTAL_CODE_DOM* RANKING INTEGER* NUMBER_ALUMS INTEGER Query Name: ALUMS . . . 1 Example 3: Adding and modifying default values; SQL> /* Add a default value to the column HOURS_OVERTIME ***> */ SQL> create table DAILY_SALES$ cont> (hours_overtime int. cont> ,hours_worked int default 0$ cont> ,gross_sales int) cont> ,salesperson char(20)  cont> ); SQL>A SQL> /* Change the default value for the column HOURS_OVERTIME ***> */ SQL> alter table DAILY_SALES( cont> alter column HOURS_OVERTIME cont> set default 0; SQL>8 SQL> /* Insert the days sales figures into the table,= ***> accepting the default values for HOURS_WORKED, and ***> HOURS_OVERTIME ***> */: SQL> insert into DAILY_SALES (gross_sales, salesperson)' cont> values (2567, 'Bartlett'); 1 row inserted  SQL> SQL> table DAILY_SALES;= HOURS_OVERTIME HOURS_WORKED GROSS_SALES SALESPERSON: 0 0 2567 Bartlett 1 row selected SQL>< Example 4: Deleting a constraint from the EMPLOYEES table< To find out the name of a constraint, use the SHOW TABLESB statement. The SHOW TABLES statement shows all constraints thatB refer to a table, not just those defined as part of the table'sB definition. For that reason it is good practice to always use aA prefix to identify the table associated with a constraint when: you assign constraint names with the CONSTRAINT clause.D The constraint DEGREES_FOREIGN1 in this SHOW display follows that@ convention to indicate that the constraint is associated withA the DEGREES, not the EMPLOYEES, table despite the constraint's% presence in the EMPLOYEES display. SQL> SHOW TABLE EMPLOYEES" Information for table EMPLOYEES Comment on table EMPLOYEES:+ personal in formation about each employee Columns for table EMPLOYEES:: Column Name Data Type Domain: ----------- --------- ------: EMPLOYEE_ID CHAR(5) ID_DOM8 Primary Key constraint EMPLOYEES_PRIMARY_EMPLOYEE_IDA LAST_NAME CHAR(14) LAST_NAME_DOMB FIRST_NAME CHAR(10) FIRST_NAME_DOMF MIDDLE_INITIAL CHAR(1) MIDDLE_INITI AL_DOMF ADDRESS_DATA_1 CHAR(25) ADDRESS_DATA_1_DOMF ADDRESS_DATA_2 CHAR(20) ADDRESS_DATA_2_DOM< CITY CHAR(20) CITY_DOM= STATE CHAR(2) STATE_DOMC POSTAL_CODE CHAR(5) POSTAL_CODE_DOM; SEX CHAR(1) SEX_DOM< BIRTHDAY DATE DATE_DOMC STATUS_CODE  CHAR(1) STATUS_CODE_DOM# Table constraints for EMPLOYEES: EMPLOYEES_PRIMARY_EMPLOYEE_ID Primary Key constraint/ Column constraint for EMPLOYEES.EMPLOYEE_ID Evaluated on COMMIT Source:, EMPLOYEES.EMPLOYEE_ID PRIMARY KEY EMP_SEX_VALUES Check constraint" Table constraint for EMPLOYEES Evaluated on COMMIT Source: CHECK (2 SEX IN ('M', 'F', '?') ) EMP_STATUS_CODE_VALUES Check constraint" Table constraint for EMPLOYEES Evaluated on COMMIT Source: CHECK (? STATUS_CODE IN ('0', '1', '2', 'N') )+ Constraints referencing table EMPLOYEES: DEGREES_FOREIGN1 Foreign Key constraint- Column constraint for DEGREES.EMPLOYEE_ID Evaluated on COMMIT Source:A DEGREES.EMPLOYEE_ID REFERENCES EMPLOYEES (EMPLOYEE_ID) JOB_HISTORY_FOREIGN1 Foreign Key constraint1 Column constraint for JOB_HISTORY.EMPLOYEE_ID Evaluated on COMMIT Source:E JOB_HISTORY.EMPLOYEE_ID REFERENCES EMPLOYEES (EMPLOYEE_ID) RESUMES_FOREIGN1 Foreign Key constraint- Column constraint for RESUMES.EMPLOYEE_ID Evaluated on COMMIT Source:A RESUMES.EMPLOYEE_ID REFERENCES EMPLOYEES (EMPLOYEE_ID) SALARY_HISTORY_FOREIGN1 Foreign Key constraint4 Column constraint for SALARY_HISTORY.EMPLOYEE_ID Evaluated on COMMIT Source:H SALARY_HISTORY.EMPLOYEE_ID REFERENCES EMPLOYEES (EMPLOYEE_ID) . . .= SQL> ALTER TABLE EMPLOYEES DROP CONSTRAINT EMP_SEX_VALUES;A Example 5: Adding a NOT NULL constraint to the EMPLOYEES table SQL> ALTER TABLE EMPLOYEES cont> ALTER BIRTHDAY) cont> CONSTRAINT E_BIRTHDAY_NOT_NULL cont> NOT NULL;B If any rows in the EMPLOYEES table have a null BIRTHDAY column,D the ALTER statement fails and none of the changes described in it will be made.: Example 6: Altering the character set of a table columnB Assume the database was created specifying the database defaultB character set and identifier character set as DEC_KANJI and theA national character set as KANJI. Also assume the ROMAJI column= was created in the table COLOURS specifying the identifier character set.* SQL> SET CHARACTER LENGTH 'CHARACTERS';% SQL> SH OW TABLE (COLUMNS) COLOURS; Information for table COLOURS Columns for table COLOURS:: Column Name Data Type Domain: ----------- --------- ------; ENGLISH CHAR(8) MCS_DOM+ DEC_MCS 8 Characters, 8 Octets; FRENCH CHAR(8) MCS_DOM+ DEC_MCS 8 Characters, 8 Octets= JAPANESE CHAR(4) KANJI_DOM)  KANJI 4 Characters, 8 OctetsA ROMAJI CHAR(8) DEC_KANJI_DOM@ KATAKANA CHAR(8) KATAKANA_DOM, KATAKANA 8 Characters, 8 Octets= HINDI CHAR(8) HINDI_DOM. DEVANAGARI 8 Characters, 8 Octets= GREEK CHAR(8) GREEK_DOM1 ISOLATINGREEK 8 Characters, 8 Octets> ARABIC CHAR(8) ARABIC_DOM 2 ISOLATINARABIC 8 Characters, 8 Octets? RUSSIAN CHAR(8) RUSSIAN_DOM4 ISOLATINCYRILLIC 8 Characters, 8 Octets2 SQL> ALTER TABLE COLOURS ALTER ROMAJI NCHAR(8);% SQL> SHOW TABLE (COLUMNS) COLOURS; Information for table COLOURS Columns for table COLOURS:: Column Name Data Type Domain: ----------- --------- ------; ENGLISH CHAR(8)  MCS_DOM+ DEC_MCS 8 Characters, 8 Octets; FRENCH CHAR(8) MCS_DOM+ DEC_MCS 8 Characters, 8 Octets= JAPANESE CHAR(4) KANJI_DOM) KANJI 4 Characters, 8 Octets* ROMAJI CHAR(8)* KANJI 8 Characters, 16 Octets@ KATAKANA CHAR(8) KATAKANA_DOM, KATAKANA 8 Characters, 8 Octets= HINDI  CHAR(8) HINDI_DOM. DEVANAGARI 8 Characters, 8 Octets= GREEK CHAR(8) GREEK_DOM1 ISOLATINGREEK 8 Characters, 8 Octets> ARABIC CHAR(8) ARABIC_DOM2 ISOLATINARABIC 8 Characters, 8 Octets? RUSSIAN CHAR(8) RUSSIAN_DOM4 ISOLATINCYRILLIC 8 Characters, 8 Octets SQL> < Example 7: Error displayed if table COLOURS contains dataB In the following example, the column ROMAJI is defined with the> DEC_KANJI character set. If the column ROMAJI contains dataA before you alter the character set of the column, SQL displaysC the following error when you try to retrieve data after altering the table.# SQL> SELECT ROMAJI FROM COLOURS;? %RDB-F-CONVERT_ERROR, invalid or unsupported data conversionM -RDMS-E-CSETBADASSIGN, incompatible character sets prohibits the requested assignment SQL> --M SQL> -- To recover, use the ROLLBACK statement or return the column to its" SQL> -- original character set. SQL> -- SQL> ROLLBACK;# SQL> SELECT ROMAJI FROM COLOURS; ROMAJI kuro shiro ao aka ki midori 6 rows selected SQL> ' Example 8: Using the Position Clause" SQL> SHOW TABLE (COL) EMPLOYEES" Information for table EMPLOYEES Columns for table EMPLOYEES:: Column Name Data Type Domain:  ----------- --------- ------= EMPLOYEE_ID CHAR(5) ID_NUMBER Missing Value:= LAST_NAME CHAR(14) LAST_NAME> FIRST_NAME CHAR(10) FIRST_NAMEB MIDDLE_INITIAL CHAR(1) MIDDLE_INITIAL Missing Value:B ADDRESS_DATA_1 CHAR(25) ADDRESS_DATA_1 Missing Value:B ADDRESS_DATA_2 CHAR(25) ADDRES S_DATA_2 Missing Value:8 CITY CHAR(20) CITY Missing Value:9 STATE CHAR(2) STATE Missing Value:? POSTAL_CODE CHAR(5) POSTAL_CODE Missing Value:7 SEX CHAR(1) SEX Missing Value: ?A BIRTHDAY DATE VMS STANDARD_DATE* Missing Value: 17-NOV-1858 00:00:00.00? STATUS_CODE CHAR( 1) STATUS_CODE Missing Value: NB SQL> -- Alter the table to rearrange the order in which columns SQL> -- are displayed. SQL> ALTER TABLE EMPLOYEES1 cont> ALTER COLUMN SEX BEFORE COLUMN LAST_NAME6 cont> ALTER COLUMN BIRTHDAY BEFORE COLUMN LAST_NAME: cont> ALTER COLUMN STATUS_CODE BEFORE COLUMN LAST_NAME; SQL> COMMIT;@ SQL> -- Show the table to demonstrate that the order in which- SQL> -- columns are displayed has changed.# SQL> SHOW TABLE (COL) EMPLO YEES;" Information for table EMPLOYEES Columns for table EMPLOYEES:: Column Name Data Type Domain: ----------- --------- ------= EMPLOYEE_ID CHAR(5) ID_NUMBER Missing Value:7 SEX CHAR(1) SEX Missing Value: ?A BIRTHDAY DATE VMS STANDARD_DATE* Missing Value: 17-NOV-1858 00:00:00.00? STATUS_CODE  CHAR(1) STATUS_CODE Missing Value: N= LAST_NAME CHAR(14) LAST_NAME> FIRST_NAME CHAR(10) FIRST_NAMEB MIDDLE_INITIAL CHAR(1) MIDDLE_INITIAL Missing Value:B ADDRESS_DATA_1 CHAR(25) ADDRESS_DATA_1 Missing Value:B ADDRESS_DATA_2 CHAR(25) ADDRESS_DATA_2 Missing Value:8 CITY CHAR(20) CITY Missing Value:9 STATE CHAR(2) STATE Missing Value:? POSTAL_CODE CHAR(5) POSTAL_CODE Missing Value: ! Example 9: Disabling a Trigger< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';H EMPLOYEE_ID JOB_CODE JOB_START JOB_END DEPARTMENT_CODE SUPERVISOR_ID= 00164 DMGR 21-Sep-1981 NULL MBMN 00228= 00164 SPGM 5-Jul-1980  20-Sep-1981 MCBM 00164 2 rows selected9 SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164'; 1 row deletedB SQL> -- Show that the EMPLOYEE_ID_CASCADE_DELETE trigger causedA SQL> -- records in the JOB_HISTORY table to be deleted for the. SQL> -- employee with EMPLOYEE_ID of 00164.< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164'; 0 rows selectedG SQL> -- Roll back the delete operation and alter the EMPLOYEES table= SQL> -- to disable the EMPL OYEE_ID_CASCADE_DELETE trigger. SQL> ROLLBACK; SQL> ALTER TABLE EMPLOYEES4 cont> DISABLE TRIGGER EMPLOYEE_ID_CASCADE_DELETE;C SQL> -- Commit the alter operation and disconnect to ensure that> SQL> -- the next connection will have the trigger disabled. SQL> COMMIT; SQL> DISCONNECT DEFAULT;+ SQL> ATTACH 'FILENAME MF_PERSONNEL.RDB';9 SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164'; 1 row deleted= SQL> -- Show that with the trigger disabled, a deletion o f; SQL> -- employee 00164 from the EMPLOYEES table does not8 SQL> -- trigger a deletion for that employee from the SQL> -- JOB_HISTORY table.< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';G EMPLOYEE_ID JOB_CODE JOB_START JOB_END DEPARTMENT_CODE SUPERVISOR_ID= 00164 DMGR 21-Sep-1981 NULL MBMN 00228= 00164 SPGM 5-Jul-1980 20-Sep-1981 MCBM 00164 2 rows selected - Example  10: NOT NULL constraint is dropped> The following example shows that the NOT NULL constraint is dropped by ALTER TABLE.3 SQL> create table MY_TABLE (a integer not null); SQL>( SQL> show table (constraint) MY_TABLE! Information for table MY_TABLE" Table constraints for MY_TABLE: MY_TABLE_A_NOT_NULL Not Null constraint$ Column constraint for MY_TABLE.A' Evaluated on UPDATE, NOT DEFERRABLE Source: MY_TABLE.A NOT null* Constraints  referencing table MY_TABLE: No constraints found SQL> SQL> alter table MY_TABLE! cont> alter column A NULL; SQL>( SQL> show table (constraint) MY_TABLE! Information for table MY_TABLE" Table constraints for MY_TABLE: No constraints found* Constraints referencing table MY_TABLE: No constraints found SQL>= Example 11: Adding an identity column to an existing table SQL> alter table EMPLOYEES= cont> add column SEQUENCE_ID in teger identity (1000, 10)F cont> comment is 'Add unique sequence number for every employee'; SQL>% SQL> show table (column) EMPLOYEES" Information for table EMPLOYEES Columns for table EMPLOYEES:: Column Name Data Type Domain: ----------- --------- ------= EMPLOYEE_ID CHAR(5) ID_NUMBER . . .* SEQUENCE_ID INTEGER Computed: IDENTITY@ Comm ent: Add unique sequence number for every employee7 SQL> select EMPLOYEE_ID, SEQUENCE_ID from employees; EMPLOYEE_ID SEQUENCE_ID 00164 1000 00165 1010 . . . 00418 1970 00435 1980 00471 1990 100 rows selected SQL> SQL> show sequence EMPLOYEES EMPLOYEES Sequence Id: 2 Initial Value: 1000 Minimum Value: 1000 Maximum Value: (none) Next Sequence Value: 2000 Increment by: 10 Cache Size: 20 No Order No Cycle No Randomize Wait+ Comment: column IDENTITY sequence SQL>, Example 12: Revising a COMPUTED BY columnA SQL> create table ttt (a integer, c computed by CURRENT_USER);( SQL> insert into ttt (a) values (10); 1 row inserted SQL> select * from ttt; A C 10 SMITH 1 row selected SQL> SQL> show table (column) ttt Information for table TTT Columns for table TTT:: Column Name Data Type Domain: ----------- --------- ------* A INTEGER+ C CHAR(31)1 UNSPECIFIED 31 Characters, 31 Octets# Computed: by CURRENT_USER SQL> SQL> alter table ttt cont> alter cF cont> computed by upper (substring (current_user from 1 for 1))> con t> || lower (substring (current_user from 2)); SQL> SQL> show table (column) ttt Information for table TTT Columns for table TTT:: Column Name Data Type Domain: ----------- --------- ------* A INTEGER. C VARCHAR(31)1 UNSPECIFIED 31 Characters, 31 OctetsD Computed: by upper (substring (current_user from 1 for 1))=  || lower (substring (current_user from 2)) SQL> SQL> select * from ttt; A C 10 Smith 1 row selected SQL> 2 TRIGGER= Enables, disables, or renames an existing trigger. Changes@ take place after the transaction containing the ALTER TRIGGER statement is committed. 3 Environment+ You can use the ALTER TRIGGER statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatH ALTER TRIGGER --+--> DISABLE --+----------------+----+->F +--> ENABLE ---+ | |F +--> COMMENT IS -+-> 'string' -++ |F | +---- / ------+ |F +--> RENAME TO ---+F  +-------------------<----------------+ 3 Arguments 4 COMMENT_ISA Adds a comment about the trigger. SQL displays the text of theA comment when it executes a SHOW statement. Enclose the commentB in single quotation marks ( ') and separate multiple lines in a! comment with a slash mark (/). 4 DISABLE) Disables a previously enabled trigger. 4 ENABLE) Enables a previously disabled trigger. 4 RENAME_TOD Changes the name of the trigger being altered. See the RENAME forD further discussion. If the new name is the name of a synonym then an error will be raised.= The RENAME TO clause requires synonyms be enabled for this? database. Refer to the ALTER DATABASE statement SYNONYMS AREB ENABLED clause. Note that these synonyms may be deleted if they> are no longer used by database definitions or applications. 4 trigger-name# The name of an existing trigger. 3 Examp les! Example 1: Disabling a TriggerB The following example shows that while the EMPLOYEE_ID_CASCADE_> DELETE trigger is enabled, deleting a record from EMPLOYEES@ causes the corresponding record in JOB_HISTORY to be deleted.D After the trigger is disabled, a deletion from EMPLOYEES does not1 trigger a deletion from the JOB_HISTORY table.< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';H EMPLOYEE_ID JOB_CODE JOB_START JOB_END DEPARTMENT_CODE  SUPERVISOR_ID= 00164 DMGR 21-Sep-1981 NULL MBMN 00228= 00164 SPGM 5-Jul-1980 20-Sep-1981 MCBM 00164 2 rows selected9 SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164'; 1 row deleted< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164'; 0 rows selected SQL> ROLLBACK;9 SQL> ALTER TRIGGER EMPLOYEE_ID_CASCADE_DELETE DISABLE; SQL> COMMIT; SQL> DISCONNECT DEFAULT; . . .9 SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164'; 1 row deleted< SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';G EMPLOYEE_ID JOB_CODE JOB_START JOB_END DEPARTMENT_CODE SUPERVISOR_ID= 00164 DMGR 21-Sep-1981 NULL MBMN 00228= 00164 SPGM 5-Jul-1980 20-Sep-1981 MCBM 00164 2 rows selected 2 USERC Modifies an entry for the specified user name. The modificationsC take effect on the next database connection after the ALTER USER statement is committed. 3 Environment( You can use the ALTER USER statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format? ALTER USER --+--> --++------------------------+--->; +--> PUBLIC ------+++-> alter-user-opts --+-+9  +----------<----------+ alter-user-opts = G -+-> ACCOUNT -----+--> LOCK ----+----------------------------------+->E | +--> UNLOCK --+ |E +-> IDENTIFIED EXTERNALLY ----------------------------------------+E +-> RENAME TO ------> -----------------------------+E +-> COMMENT IS --+--> '' ---------+-----------------------+E | +-------- / <------------+  |E +-> NO PROFILE ---------------------------------------------------+E +-> PROFILE ---------------------------------------+ 3 Arguments 4 ACCOUNT Syntax options: ACCOUNT LOCK | ACCOUNT UNLOCKA The ACCOUNT LOCK clause disables access to the database by the? user for whom the ALTER USER statement is being applied. The@ ACCOUNT UNLOCK clause allows the user access to the database. 4 COMMENT_IS> Adds a comment about the user. SQL displays the text of the? comment when it executes a SHOW USERS statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/). 4 IDENTIFIED_EXTERNALLY< Indicates that the user will be authenticated through the operating system. 4 PROFILE Syntax options: PROFILE | NOPROFILEC Identifies a new profile for assignment to the user and replacesC any previously assigned profile. The specified profile name must& be the name of an existing profile.D NOPROFILE removes any assigned profile from the user. No error is3 returned if a profile is not currently assigned. 4 PUBLIC@ The PUBLIC user in the database. This entry gives you control0 over anonymous users who access the database. 4 RENAME_TOC Changes the user name and, if a security profile exists, assignsD the security profile associated with the old user name to the newC  user name. This might be used, for example, when a person's nameD changes (as through marriage), and, therefore, his or her accountC on the operating system is changed accordingly. The new-username, must not currently exist in the database.C When the ALTER USER command is issued, the existing user name isC removed from the database and replaced with the new-username. IfA SECURITY CHECKING is INTERNAL, then subsequent SHOW PROTECTIONC statements will display the new name for the user, and all GRANT@ and REVOKE statements will require the new-username. The new-B username is not visible to other sessions until the transaction2 containing the ALTER USER command is committed.) See the RENAME for further discussion. 4 username) An existing user name in the database. 3 Examples Example 1: Renaming a User SQL> create user KELLYN cont> identified externally1 cont> comment is 'User: Edward "Ned" Kelly'; SQL>G  SQL> -- The alternate name must exists at the operating system level, SQL> alter user KELLYN rename to N_KELLY;0 %RDB-E-NO_META_UPDATE, metadata update failed2 -RDMS-E-NOSUCHPRF, unknown profile user or role SQL>6 SQL> -- Use the new corporate user-id naming scheme SQL> alter user KELLYN cont> rename to NKELLY;( Example 2: Adding a profile to a user> This example creates a new profile that defines the DEFAULTD transaction and then assigns a profile to the use r. The next timeC the user attaches to the database, the START DEFAULT TRANSACTIONA statement will use the defined profile instead of the standard READ ONLY default.% SQL> create profile READ_COMMITTEDO cont> default transaction read write isolation level read committed wait 30;# SQL> show profile READ_COMMITTED READ_COMMITTED/ Default transaction read write wait 30) Isolation level read committed/ SQL> alter user JAIN profile READ_COMMITT!ED; SQL> show user JAIN; JAIN Identified externally Account is unlocked Profile: READ_COMMITTED0 No roles have been granted to this user 2 VIEW7 This statement allows the named view to be modified. 3 Environment( You can use the ALTER VIEW statement: o In interactive SQL( o Embedded in host language programs, o As part of a procedure in a SQL module> o In dynamic SQL as a statement to be dynamicall "y executed 3 Format H ALTER VIEW -+-+--> AS -----------------+-+->F | +--> ------------+ |F | +--> COMMENT IS -+-> 'text-literal'--+-+ |F | | +--------- / <------+ | |F | +--> RENAME TO -------+ |F | +--> WITH NO CHECK OPTION ------------+ |F +----------#--------- <---------------------+       select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ check-option-clause$ = < WITH CHECK OPTION --+----------------------------------+-->9 +-> CONSTRAINT +  3 Arguments 4 ASA Replaces the view select expression and the definitions of theC columns. The number of expressions in the select list must match( the original CREATE VIEW column list. 4 COMMENT_IS@ Replaces the comment currently defined for the view (if any).> The comment will be displayed by the SHOW VIEW statement in% Interactive SQL. 4 CONSTRAINT@ Specifies a name for the WITH CHECK OPTION constraint. If youD omit the name, SQL creates a name. However, Oracle Rdb recommendsA that you always name constraints. If you supply a name for the? WITH CHECK OPTION constraint, the name must be unique in the schema.? The name for the WITH CHECK OPTION constraint is used by the> INTEG_FAIL error message when an INSERT or UPDATE statement violates the constraint. 4 RENAME_&TOD Renames the current view. The new view name must not exist as the9 name of an existing view, table, sequence, or synonym. 4 WITH_CHECK_OPTIONB A constraint that places restrictions on update operations madeD to a view. The check option clause ensures that any rows that areA inserted or updated in a view conform to the definition of theD view. Do not specify the WITH CHECK OPTION clause with views that are read-only. 4 WITH_NO_CHECK_OPTION@ Removes' any check option constraint currently defined for the view. 3 Examples, Example 1: Changing the comment on a viewC A comment can be added or changed on a view using the COMMENT IS# clause as shown in this example.' SQL> show view (comment) current_job$ Information for table CURRENT_JOB SQL> alter view CURRENT_JOBD cont> comment is 'Select the most recent job for the employee';' SQL> show view (comment) current_job$ Information for table CURRENT_JOB( Comment on table CURRENT_JOB:. Select the most recent job for the employee SQL>@ Example 2: Changing the column's results of a view definition> The following view uses a derived table and join to collectA the count of employees in each department. The view is used in@ several reporting programs used by the department and company managers.' SQL> create view DEPARTMENTS_SUMMARY cont> as3 cont> select department_code, d.department_name,/ cont> ) d.manager_id, jh.employee_count& cont> from departments d inner join0 cont> (select department_code, count (*)! cont> from job_history& cont> where job_end is null* cont> group by department_code): cont> as jh (department_code, employee_count)& cont> using (department_code); SQL>& SQL> show view DEPARTMENTS_SUMMARY;, Information for table DEPARTMENTS_SUMMARY( Columns for view DEPARTMENTS_SUMMARY:: Column Name * Data Type Domain: ----------- --------- ------* DEPARTMENT_CODE CHAR(4)+ DEPARTMENT_NAME CHAR(30) Missing Value: None* MANAGER_ID CHAR(5) Missing Value:* EMPLOYEE_COUNT INTEGER Source:- select department_code, d.department_name,) d.manager_id, jh.employee_count from departments d inner join* (select department_code, count (*) + from job_history where job_end is nullL group by department_code) as jh (department_code, employee_count) using (department_code) SQL>? The database administrator decides to create a column in the@ DEPARTMENTS table to hold the count of employees (rather than? using a query to gather the total) and to maintain the valueB through triggers on EMPLOYEES and JOB_HISTORY (not shown here).= Now the view can be simplified without resort,ing to a DROP? VIEW and CREATE VIEW. The ALTER VIEW statement preserves theD dependencies on the view from other views, triggers, and routinesA and so minimizes the work required to implement such a change. SQL> alter table DEPARTMENTS/ cont> add column EMPLOYEE_COUNT integer; SQL>& SQL> alter view DEPARTMENTS_SUMMARY cont> as3 cont> select department_code, d.department_name,. cont> d.manager_id, d.employee_count cont> from departments d; S-QL>& SQL> show view DEPARTMENTS_SUMMARY;, Information for table DEPARTMENTS_SUMMARY( Columns for view DEPARTMENTS_SUMMARY:: Column Name Data Type Domain: ----------- --------- ------* DEPARTMENT_CODE CHAR(4) Missing Value: None+ DEPARTMENT_NAME CHAR(30) Missing Value: None* MANAGER_ID CHAR(5) Missing Value:* EMPLOYEE_COUNT INTEGER . Source:- select department_code, d.department_name,( d.manager_id, d.employee_count from departments d SQL>A Example 3: Changing the WITH CHECK OPTION constraint of a view definitionC This example shows that a WITH CHECK OPTION constraint restrictsD the inserted data to the view's WHERE clause. Once the constraint3 is removed, the INSERT is no longer constrained.$ SQL> create view TOLIVER_EMPLOYEE? cont> as select * from EMPLOYEES where em/ployee_id = '00164' cont> with check option;C SQL> insert into TOLIVER_EMPLOYEE (employee_id) value ('00000');a %RDB-E-INTEG_FAIL, violation of constraint TOLIVER_EMPLOYEE_CHECKOPT1 caused operation to fail@ -RDB-F-ON_DB, on database DISK1:[DATABASES]MF_PERSONNEL.RDB;1 SQL>9 SQL> alter view TOLIVER_EMPLOYEE with no check option; SQL>C SQL> insert into TOLIVER_EMPLOYEE (employee_id) value ('00000'); 1 row inserted SQL> ww 1 ATTAC 0H> Specifies the name of a database and the source of the data@ definitions to be accessed by interactive SQL or by a program@ at run time. Makes the specified database part of the currentC database environment. The database environment is the set of all; databases with unique aliases in the current connection.B The ATTACH statement lets you add new databases at run time; it@ has no effect on the compile-time environment. To specify the= compile-time environment, use the D1ECLARE ALIAS statement.B You can name either a file or a repository path name to be used for the data definitions.7 If a transaction is currently active, SQL returns anC informational message and does not attach the specified database! environment to the connection.@ If a database is currently attached and you attach to another< database without using an alias, SQL detaches the current@ database environment and attaches to the specified one in its place. 22 Environment$ You can use the ATTACH statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format, ATTACH ---+-> attach-string-literal ----+->* +-> -------+* +-> +  attach-string-literal = & --> ' --> attach-expression --> ' -->  a 3ttach-expression = : -+------------------++-> FILENAME -> '' -+-+: +-> ALIAS -++-> PATHNAME -> ----+ |: +------------------------------------------------------+: ++------------------------+----------------------------+: +--> literal-user-auth --+ |: +------------------------------------------------------+; ++-----------------------------+------------------------>" +-+-+-> database-options --+-++! | +-> attach-option!4s ----+ |! +----------- <-------------+  literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  attach-spec = * --+----------------+-> -----> +-> -+ node-spec = + -+-> -+-------------------+-+->) | +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  database-options = % --+--> ELN ---------------------+-->" +--> NSDS --------------------+" +--> rdb-options -------------+" +--> VIDA --------------------+" +--> VIDA V1 -----------------+" +--> VIDA V2 -----------------+" +--> VIDA V2N ----------------+" +--> NOVIDA ------------------+" +--> DBIV1 -------------------+" +--> DBIV31 ------------------+" +--> DBIV70 ------------------+  rdb-6options =  -+-> RDBVMS --+--> +-> RDB030 --+ +-> RDB031 --+ +-> RDB040 --+ +-> RDB041 --+ +-> RDB042 --+ +-> RDB050 --+ +-> RDB051 --+ +-> RDB060 --+ +-> RDB061 --+ +-> RDB070 --+ +-> RDB071 --+ attach-options = H -+-> DBKEY -+-> SCOPE IS -+-> ATTACH -------+-----------------------+->F +-> ROWID -+ +-> TRANSACTION --+ |F +-> MULTISCHEMA IS -+-> ON --+-------------------------------------+F7 | +-> OFF -+ |F +-> PRESTARTED TRANSACTIONS ARE -+-> ON --+------------------------+F | +-> OFF -+ |F +-+-------+-> RESTRICTED ACCESS -----------------------------------+ +-> NO -+ 2 Arguments 3 ALIAS_alias@ A part of the attach expression that specifies a name for theC attach to the database. Specifying an alias lets your program or> interactive SQL s 8tatements refer to more than one database.? You do not have to specify an alias in the ATTACH statement.C The default alias in interactive SQL and in precompiled programsB is RDB$DBHANDLE. In the SQL module language, the default is the@ alias specified in the module header. Using the default aliasA (either by specifying it explicitly in the ATTACH statement or@ by omitting any alias) makes the database part of the defaultC environment. Specifying a default database means that 9 statements; that refer to that database do not need to use an alias.? If a default alias was already declared, and you specify the? default alias in the alias clause (or specify any alias thatA was already declared), interactive SQL issues an informational message.B In the following example, TESTDB is the first database attachedA and uses the default alias. When no alias is specified for the? second database attached, SQL tries to assign it the default> alias b :ut finds that the default alias is already declared.! SQL> ATTACH 'FILENAME testdb';" SQL> ATTACH 'FILENAME otherdb';( This alias has already been declared.6 Would you like to override this declaration (No)? NN SQL-F-DEFDBDEC, A database has already been declared with the default alias SQL> SHOW DATABASES; Default alias:) Oracle Rdb database in file testdb" SQL> ATTACH 'FILENAME otherdb';( This alias has already been declared.6 Would you like to override th;is declaration (No)? Y SQL> SHOW DATABASES; Default alias:* Oracle Rdb database in file otherdb 3 attach-expression7 Specifies a database to be added to the environment. 3 attach-parameterD A host language variable in precompiled SQL or a formal parameterB in an SQL module language procedure that specifies the databaseD environment for the connection. The attach parameter must contain an attach expression. 3 attach-parameter-markerC A< parameter marker, denoted by question marks (?), in a dynamicC SQL statement. The attach parameter marker refers to a parameterB that specifies the database environment for the connection. TheD attach parameter marker must specify a parameter that contains an attach expression. 3 attach-optionsC Specifies characteristics of the particular database attach. You. can specify more than one of these clauses. 3 attach-string-literal9 A character string litera=l that specifies the databaseA environment for the connection. The attach string literal mustC contain an attach expression enclosed in single quotation marks. 3 database-optionsB By default, the SQL precompiler determines the type of databaseB it attaches to from the type of database specified in compiling the program.> For more information on database options, see the Database_ Options HELP topic. 3 DBKEY_SCOPE Syntax options:5 DBKEY SCO >PE IS ATTACH | DBKEY SCOPE IS TRANSACTIOND Controls when the database key of a deleted row can be used again by SQL.? o The default DBKEY SCOPE IS TRANSACTION means that SQL canB reuse the database key of a deleted table row (to refer to aA newly inserted row) as soon as the transaction that deletedA the original row completes with a COMMIT statement. (If theD user who deleted the original row enters a ROLLBACK statement,@ then the database key for that ? row cannot be used again by SQL.)> During the connection of the user who entered the ATTACH@ statement, the DBKEY SCOPE IS TRANSACTION clause specifies@ that a database key is guaranteed to refer to the same row+ only within a particular transaction.D o The DBKEY SCOPE IS ATTACH clause means that SQL cannot use theA database key again (to refer to a newly inserted row) untilA all users who have attached with DBKEY SCOPE IS ATTACH have! deta @ched from the database.= It only requires one process to attach with DBKEY SCOPE: IS ATTACH to force all database users to assume this characteristic.D o Oracle Corporation recommends using DBKEY SCOPE IS TRANSACTION? to prevent excessive consumption of storage area space byD overhead space needed to support DBKEY SCOPE IS ATTACH, and to9 prevent performance problems when storing new rows.> During the connection of the user who entered the ATTAACH@ statement, the DBKEY SCOPE IS ATTACH clause specifies thatA a database key is guaranteed to refer to the same row until* the user detaches from the database.2 For more information, see the DBKEY HELP topic. )3 DISPLAY_CHARACTER_SET_support-char-setD Specifies the character set encoding and characteristics expected8 of text strings returned back to SQL from Oracle Rdb. 3 FILENAMEC A quoted string containing full or partial information needed to B access a database.C For an Oracle Rdb database, an attach specification contains the' file specification of the .rdb file.> When you use the FILENAME argument, any changes you make to? database definitions are entered only to the database system= file, not to the repository. If you specify FILENAME, yourB application attaches to the database with that file name at run time.D For information regarding node-spec and file-spec, see Oracle Rdb Attach SpecificatCions. 3 literal-user-auth; Specifies the user name and password to enable access to+ databases, particularly remote databasesB This literal lets you explicitly provide user name and password( information in the attach expression.A When you use Oracle Rdb for OpenVMS to attach to a database inC the same cluster, you do not have to explicitly specify the userB name and password. Oracle Rdb implicitly authenticates the user, whenever the user attaches to a databDase.> However, when you use Oracle Rdb for OpenVMS to attach to a= database on a remote node, you must use one of the methods1 provided by Oracle Rdb to access the database.C You can use one of the following methods to attach to a database on a remote OpenVMS node.A o Explicitly provide the user name and password in the ATTACH statement.: o Explicitly provide the user name and password in the? configuration file RDB$CLIENT_DEFAULTS.DAT. The following9E example shows how to include the information in the configuration file:/ ! User name to be used for authentication SQL_USERNAME HELENG. ! Password to be used for authentication SQL_PASSWORD MYPASSWORD= o Use a DECnet proxy account on the remote system system.A o Embed the user name and password in the file specification.) o Use the RDB$REMOTE default account.@ For information on proxy accounts, embedding the user name inB tFhe file specification or using the RDB$REMOTE account, see the' Oracle Rdb Guide to SQL Programming. 3 MULTISCHEMA_IS Syntax options:) MULTISCHEMA IS ON | MULTISCHEMA IS OFFB The MULTISCHEMA IS ON clause enables multischema naming for theA duration of the database attach. The MULTISCHEMA IS OFF clause? disables multischema naming for the duration of the database@ attach. On attach, multischema naming defaults to the setting( specified during database definitGion.B You can use multischema naming only when attached to a databaseB that was created with the multischema attribute. If you specifyD the MULTISCHEMA IS ON clause with a database that was not createdC with the multischema attribute, SQL returns an error message, as" shown in the following example:G SQL> ATTACH 'ALIAS PERS_ALIAS FILENAME personnel MULTISCHEMA IS ON';P %SQL-F-NOPHYSMULSCH, The physical multischema attribute was not specified for the database 3 P HATHNAME= A full or relative repository path name that specifies the@ source of the database definitions. When you use the PATHNAME= argument, any changes you make to database definitions are? entered in both the repository and the database system file.D Oracle Rdb recommends using the PATHNAME argument if you have theD repository on your system and you plan to use any data definition statements.< If you specify PATHNAME, your application attaches to the4 database fiIle name extracted from the repository. 3 PRESTARTED_TRANSACTIONS_ARE Syntax options:C PRESTARTED TRANSACTIONS ARE ON | PRESTARTED TRANSACTIONS ARE OFF> Specifies whether Oracle Rdb enables or disables prestarted transactions.> Use the PRESTARTED TRANSACTIONS ARE OFF clause only if your< application uses a server process that is attached to theA database for long periods of time and causes the snapshot file> to grow excessively. If you use the PRESTARTED TRAN JSACTIONSB ARE OFF clause, Oracle Rdb uses additional I/O because each SETC TRANSACTION statement must reserve a transaction sequence number (TSN).? For most applications, Oracle Rdb recommends that you enableB prestarted transactions. The default is PRESTARTED TRANSACTIONSB ARE ON. If you use the PRESTARTED TRANSACTIONS ARE ON clause or@ do not specify the PRESTARTED TRANSACTIONS clause, the COMMIT@ or ROLLBACK statement for the previous read/write transaction> automat Kically reserves the TSN for the next transaction and reduces I/O.C You can define the RDMS$BIND_PRESTART_TXN logical name to define@ the default setting for prestarted transactions outside of an@ application. The PRESTARTED TRANSACTION clause overrides thisC logical name. For more information, see the Oracle Rdb7 Guide toA Database Performance and Tuning. See also the ALTER and CREATE? DATABASE clause PRESTARTED TRANSACTIONS ARE ENABLED for more details. 3 RESLTRICTED_ACCESSB Restricts access to the database. This allows you to access theC database but locks out all other users until you disconnect fromC the database. Setting restricted access to the database requires DBADM privileges.8 The default is NO RESTRICTED ACCESS if not specified. 3 ROWID_SCOPE Syntax options:5 ROWID SCOPE IS ATTACH | ROWID SCOPE IS TRANSACTION@ The ROWID keyword is a synonym for the DBKEY keyword. See the- DBKEY_SCOPE argument for Mmore information. 3 USER_usernameA A character string literal that specifies the operating systemB user name that the database system uses for privilege checking.= Because the user name literal is within the quoted attach-C string, you must enclose the user name within two sets of single& quotation marks in interactive SQL.; This clause also sets the value of the SYSTEM_USER value expression. 3 USING_passwordD A character string literal that specifi Nes the user's password forC the user name specified in the USER clause. Because the password? literal is within the quoted attach-string, you must encloseB surround the password within two sets of single quotation marks in interactive SQL. 2 ExamplesB Example 1: Attaching a database by file name in interactive SQL# and specifying restricted accessB This interactive SQL statement attaches the database defined byA the file specification mf_personnel to the current Oconnection,D and declares the alias pers_alias for that database. Use the SHOW3 DATABASE statement to see the database settings.8 SQL> ATTACH 'ALIAS pers_alias FILENAME mf_personnel - cont> RESTRICTED ACCESS';B Example 2: Attaching a database by path name in interactive SQLD This interactive SQL statement attaches to the database file nameD extracted from the repository. Use the SHOW DATABASE statement to see the database settings. SQL> ATTACHA cont> 'ALIAS PPERS PATHNAME DISK3:[REPOSITORY.DEPT2]PERSONNEL'; 4 Example 3: Using an attach parameter in a programC This excerpt from an SQL module language procedure shows how youC might declare a parameter to contain an attach string. You wouldA need to compile the module with the PARAMETER COLONS clause in. order to prefix the parameter with a colon. PROCEDURE attach_db SQLCODE attach_string char(155); ATTACH :attach_string;B You could then write Qa C program that calls this procedure. TheA line that passes the attach string would need a format such as the following: main () { long sqlcode;? attach_db( &sqlcode, "ALIAS CORP FILENAME corporate_data" );C /* Now dynamic statements can refer to alias CORP */ }D Example 4: Explicitly providing the user name and password in the ATTACH statementA The following example shows how to explicitly provide the user- name and password iRn the ATTACH statement.D SQL> ATTACH 'FILENAME FARSID::USER1:[GREMBOWSKI.DB]MF_PERSONNEL -: cont> USER ''grembowski'' USING ''mypassword'''; wwӉ1 BEGIN_DECLAREA Delimits the beginning of a host language variable declaration$ section in a precompiled program. 2 EnvironmentD You can use the BEGIN DECLARE statement embedded in host language programs to be precompiled. 2 Format. EXEC SQL --> BEGIN DECLARE SECTION --> ; ---+. +S-------------------------------------------+0 +-+-> -+-+0 +---------<-------------------------------+ |0 +---------------------------------------------++ +-> EXEC SQL --> END DECLARE SECTION --> ;  2 Arguments 3 BEGIN_DECLARE_SECTIONA Delimits the beginning of host language variable declarations. 3 END_DECLARE_SECTION; Delimits the end of host language variable declarations. 3 ;_(semicolon); Terminates thTe BEGIN DECLARE and END DECLARE statements.C Which terminator you should use depends on the language in whichD you are embedding the host language variable. The following table! shows which terminator to use./ Required SQL Terminator* END. BEGIN DECLARE DECLARE0 Host Language Statement Statement/ COBOL END-EXEC END-EXEC+ FORTRAN None requirUed None/ required/ Ada, C, Pascal, or ; (semicolon) ; (semi-- PL/I colon) %3 host_language_variable_declaration0 A variable declaration embedded in a program.B See the Parameters HELP topic for full details on host language variable definitions. 2 ExampleC Example 1: Declaring a host language variable within BEGIN . . . END DECLARE statements@ The following example shows por Vtions of a Pascal program. The@ first part of the example declares the host language variableA LNAME within the BEGIN DECLARE and END DECLARE statements. TheA semicolon is necessary as a terminator because the language is Pascal.D The second part of the example shows a singleton SELECT statement? that specifies a one-row result table. The statement assigns@ the value in the row to the previously declared host language variable LNAME." EXEC SQL BEGIN DECLARE SECTION;W) LNAME: packed array [1..20] of char; EXEC SQL END DECLARE SECTION; . . . EXEC SQL SELECT FIRST_NAME INTO :LNAME FROM EMPLOYEES" WHERE EMPLOYEE_ID = "00164"; wwӉ1 CALL 2 Compound_StatementA Invokes an external or stored procedure from within a compoundC statement. That is, invocation must occur with a BEGIN . . . END block.C The OUT and INOUT arguments cannot be general value expressions.A X They must be variables or parameters. The IN argument can be a general value expression.; When you register a procedure definition with the CREATE= PROCEDURE statement, you store information in the databaseB about an external procedure written in a 3GL language. External? procedures reside outside the database. The CREATE PROCEDUREC statement is documented under the CREATE Routine. See the CREATE@ Routine for more information on creating external procedures.B For oYptional information on invoking stored procedures, see the CALL Simple_Statement. 3 Environment+ You can use the compound statement CALL: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format? CALL --> --> ( -+-------------------+-> ) -->7 +-+-> value-expr -+-+5Z +-> DEFAULT ----+5 +------ , <-----+ 3 Arguments 4 DEFAULTB Requests that Oracle Rdb use the DEFAULT expression defined for@ the parameter. The DEFAULT can be defined for an IN parameterE during the CREATE MODULE . . . PROCEDURE or ALTER MODULE . . . ADDB PROCEDURE statements. If no DEFAULT clause exists then the NULL expression is assumed. 4 procedure-name> The name of the ext[ernal or stored procedure being invoked. 4 value-expr< Any value expression except DBKEY or aggregate functions.< See the Value_Expressions HELP topic for details on value expressions. 3 Examples; Example 1: Calling an external routine within a compound statement BEGIN DECLARE :param1 INTEGER;' CALL extern_routine (:param1, 3); END; ? Example 2: Calling a stored procedure from a stored function' SQL> CREATE MODULE utility_\functions cont> LANGUAGE SQL cont> --+ cont> PROCEDURE trace_date (:dt DATE); cont> BEGIN cont> TRACE :dt; cont> END; cont> --6 cont> FUNCTION mdy (IN :dt DATE) RETURNS CHAR(10)? cont> COMMENT 'Returns the date in month/day/year format'; cont> BEGIN$ cont> IF :dt IS NULL THEN( cont> RETURN '**/**/****'; cont> ELSE* cont> CALL trace_date (:dt);P cont> RETURN CAS]T(EXTRACT(MONTH FROM :dt) AS VARCHAR(2)) || '/' ||N cont> CAST(EXTRACT(DAY FROM :dt) AS VARCHAR(2)) || '/' ||F cont> CAST(EXTRACT(YEAR FROM :dt) AS VARCHAR(4)); cont> END IF; cont> END; cont> END MODULE; 2 Simple_Statement Invokes a stored procedure.A When you define a module with the CREATE MODULE statement, SQLD stores the module as an object in an Oracle Rdb database. It alsoC stores each of the module's pro^cedures and functions. The module> procedures that reside in an Oracle Rdb database are called@ stored procedures. In contrast, nonstored procedures refer toC module procedures that reside outside the database in SQL module@ files. See the CREATE MODULE for more information on creating stored procedures.B For optional information on invoking stored procedures, see the CALL Compound_Statement. 3 Environment) You can use the simple statement CALL: o In int_eractive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL moduleA o In dynamic SQL as a statement that are dynamically executed 3 Format< CALL --> --> call-argument-list -->  call-argument-list = 0 ---> ( --+-+------------------------+-+-> ) -->( | +--> ----------+ |( | +--> --------+ |( | +--> ---------+ |( +---`-------- , <-------------+  3 Arguments 4 call-argument-listD Passes a list of literal, parameter values (parameter markers forC dynamic execution), or variables to the called stored procedure.= You can pass a literal only to an IN parameter of a stored: procedure. You cannot pass a literal to an OUT or INOUT parameter.B In SQL statements to be dynamically executed, you refer to bothC the main and indicator parameters with a single parameter markera? (?). See the Parameters HELP topic for details about how to? use parameters in programs for static as well as dynamic SQL statement execution. 4 procedure-name" The name of a stored procedure. 3 Examples( Example 1: Calling a stored procedureD The following examples show the definition of a stored procedure,A NEW_SALARY_PROC, and the nonstored procedure, CALL_NEW_SALARY,2 that invokes it with the simple statement CALL.E SQL> ! The following sh bows the definition of the stored procedure: SQL> !% SQL> CREATE MODULE NEW_SALARY_PROC cont> LANGUAGE SQL) cont> PROCEDURE NEW_SALARY_PROC( cont> (:ID CHAR (5),4 cont> :NEW_SALARY INTEGER (2)); cont> BEGIN+ cont> UPDATE SALARY_HISTORY? cont> SET SALARY_END = CURRENT_TIMESTAMP5 cont> WHERE EMPLOYEE_ID = :ID;0 cont> INSERT INTO SALARY_HISTOcRYE cont> (EMPLOYEE_ID, SALARY_AMOUNT,C cont> SALARY_START, SALARY_END); cont> VALUES (:ID, :NEW_SALARY,C cont> CURRENT_TIMESTAMP, NULL); cont> END; cont> END MODULE; SQL>? The following example shows an excerpt of an SQL module thatD contains the nonstored procedure that calls the stored procedure. . . . d PROCEDURE CALL_NEW_SALARY :ID CHAR(5), :ID_IND SMALLINT, :NEW_SALARY INTEGER (2), :NEW_SALARY_IND SMALLINT, SQLCODE;0 CALL NEW_SALARY_PROC (:ID, :NEW_SALARY ); . . .4 Example 2: Calling a procedure in interactive SQL> The following example shows that you use interactive SQL to< invoke a stored procedure with the simple statement CALL: SQL> DECLARE :X INTEGER; SQL> BEGIN cont> SET :X = 0; conet> END; SQL> CALL P2 (10, :X); ww1 CASE_Searched> Executes one of a sequence of alternate statement blocks in= a compound statement of a multistatement procedure. Unlike? the simple CASE control statement, the searched CASE controlC statement supports arbitrary predicates for the WHEN clause that1 can contain variable and parameter references. 2 Environment@ You can use the searched CASE control statement in a compound+ statement of fa multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format case-searched-statement = 0 CASE -----+--> WHEN -> predicate -> THEN -----+0 | +--------------------------------+0 | +-+-> compound-use-statement -+-++0 | +------------ <-------------+ ||0 +------g----------- <---------------+|0 +-------------------------------------------+= +-+--------------------------------------+--> END CASE -->- +-> ELSE -+-> compound-use-statement -++, +------------- <------------+ 2 Arguments 3 ELSEC Specifies the set of SQL statements to be executed when the WHEN( clause evaluates to FALSE or UNKNOWN. 3 THENC Specifies the set of SQL statements to be executed when the WHEN clause evaluates to TRUhE. 3 WHEND Determines whether the compound use statements in the THEN clause@ are to be executed or the compound use statements in the ELSEA clause are to be executed. If the predicate evaluates to TRUE,D then the compound use statements in the THEN clause are executed.D If the predicate evaluates to FALSE or UNKNOWN, then the compound2 use statements in the ELSE clause are executed. 2 Examples< Example 1: Specifying Predicates with Variable References SiQL> CREATE TABLE T (C INT); SQL> BEGIN! cont> DECLARE :V INTEGER = 10; cont> DECLARE :X INTEGER = 0; cont> CASE= cont> WHEN :V = 1 THEN INSERT INTO T(C) VALUES (:X + 1);= cont> WHEN :V = 2 THEN INSERT INTO T(C) VALUES (:X + 2);9 cont> WHEN :V > 3 THEN INSERT INTO T(C) VALUES (:X);- cont> ELSE INSERT INTO T(C) VALUES (-1); cont> END CASE; cont> END; ww1 CASE_Simple@ Executes one of a sequence of alternate statement blojcks in a4 compound statement of a multistatement procedure. 2 Environment> You can use the simple CASE control statement in a compound+ statement of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format case-statement =  CASE value-expr --------+ +-----------------------+I ++-k> WHEN -+-+> -+-+-> THEN -+-> compound-use-statement -+-+-+I | | +> NULL ------+ | +------------<--------------+ | |I | +----- , <--------+ | |I +---------------------------------<---------------------------------+ |I +--------------------------------<-----------------------------------+? ++----------------------------------------+--> END CASE --->. +--> ELSE -+-> compound-use-statement -+-+, +l------------<--------------+ 2 Arguments 3 CASEC An expression that evaluates to a single value. SQL compares theC CASE clause value expression with each WHEN clause literal value. in the WHEN clauses until it finds a match.B The value expression cannot contain a column specification that- is not part of a column select expression.B See the Value_Expressions HELP topic for a complete description9 of the variety of value expressions that SQL provides.m 3 ELSE? Executes a set of SQL statements when SQL cannot find a WHEN? clause that matches the value expression in the CASE clause.A See the Compound_Statement HELP topic for a description of the9 SQL statements that are valid in a compound statement. 3 THEN? Executes the set of SQL statements associated with the firstA WHEN clause in which its argument value matches the CASE value expression. 3 WHEN Syntax options: WHEN literal | nWHEN NULLA The literal or NULL value of the WHEN clause that SQL comparesB with the value expression of the CASE clause. Most CASE control, statements include a set of WHEN clauses.C When the values of the WHEN and CASE clauses match, SQL executesD the SQL statements associated with that WHEN clause. Control thenB drops out of the CASE control statement and returns to the next+ SQL statement after the END CASE clause. 2 Examples. Example 1: Using the CASE controol statement char x[11]; long x_ind; EXEC SQL/ DECLARE ALIAS FOR FILENAME personnel ; EXEC SQL BEGIN% CASE :x INDICATOR :x_ind! WHEN 'Abrams' THEN5 DELETE FROM employees WHERE . . . ; WHEN NULL THEN5 DELETE FROM employees WHERE . . . ; ELSE5 DELETE FROM employees WHERE . . . ; END CASE ; END ;D Example 2: Usinpg a List of Literal Values with the Case Statement SQL> DECLARE :CODE CHAR(4); SQL> BEGIN cont> JOB_LOOP: cont> FOR :JOBFOR cont> AS EACH ROW OF( cont> SELECT * FROM JOBS JOB cont> DO/ cont> SET :CODE = :jobfor.JOB_CODE; cont> CASE :CODE& cont> WHEN 'ASCK' THEN$ cont> UPDATE JOBS1 cont> SET MINIMUM_SALARY=100000 cont> WHERE JOB_CODE q= :code;6 cont> WHEN 'ADMN', 'JNTR', 'SCTR' THEN$ cont> UPDATE JOBS1 cont> SET MINIMUM_SALARY=150000 cont> WHERE JOB_CODE = :code; cont> ELSE$ cont> UPDATE JOBSF cont> SET MINIMUM_SALARY=:jobfor.MINIMUM_SALARY*1.1. cont> WHERE JOB_CODE=:code; cont> END CASE; cont> END FOR; cont> END; SQL> ww r1 CLOSE Closes an open cursor. 2 Environment# You can use the CLOSE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format( CLOSE -+-> -----------+->& +-> -+ 2 Arguments 3 cursor-name, The name of the cursor you want to close. 3 cursor-name-parameter? Use a parameter if the cursor referresd to by the cursor nameC was declared at run time with an extended dynamic DECLARE CURSOR@ statement. Specify the same cursor name parameter used in the$ dynamic DECLARE CURSOR statement.D You can use a parameter to refer to the cursor name only when the1 CLOSE statement is accessing a dynamic cursor. 2 Examples9 Example 1: Closing a cursor declared in a PL/I program@ This program fragment uses embedded DECLARE CURSOR, OPEN, andD FETCH statements to retrieve tand print the name and department ofB managers. The CLOSE statement closes the cursor after the FETCHB statement fails to find any more rows in the result table (when SQLCODE is set to 100). /* Declare the cursor: */& EXEC SQL DECLARE MANAGER CURSOR FOR> SELECT E.FIRST_NAME, E.LAST_NAME, D.DEPARTMENT_NAME2 FROM EMPLOYEES E, DEPARTMENTS D7 WHERE E.EMPLOYEE_ID = D.MANAGER_ID ; /* Open the cursor: */ EXEC SQL OPEN MANAGER;u8 /* Start a loop to process the rows of the cursor: */ DO WHILE (SQLCODE = 0);- /* Retrieve the rows of the cursor; and put the value in host language variables: */> EXEC SQL FETCH MANAGER INTO :FNAME, :LNAME, :DNAME;3 /* Print the values in the variables: */ . . . END; /* Close the cursor: */ EXEC SQL CLOSE MANAGER; ww# 1 0v COMMENT_ONB Adds or changes a comment about the following database objects: o Catalog o Collating sequence o Column o Constraint o Domain o Database o Function o Index o Index partition o Module o Outline o Procedure o Profile o Role o Schema o Sequence o Storage map o Storage map partition o Synonym o Table o Trigger o User o wViewC SQL displays the comments on these objects when you issue a SHOW statement. 2 Environment( You can use the COMMENT ON statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format7 COMMENT ON --+--> objects-1 -+-> IS -+-> 'string' -+->5 +--> objects-2 -+ +---- / <-----+ x objects1 = @ -+> -> ( + IS +-> 'string' -++> ) --+->> | | +---- / <-----+| |> | +----------- , <---------------+ |> +> CATALOG ---------------------------------+> +> COLLATING SEQUENCE -----------------+> +> COLUMN . -------------------------+> +> CONSTRAINT ---------------------------+> +> DATABASE -+-------------------- y----+--------------------+> | +-> ALIAS --+ |> +> DOMAIN -----------------------------------+> +> FUNCTION -------------------------------+> +> INDEX -+-------------------------------+---+> | +-> PARTITION -+ |> +> MODULE -----------------------------------+> +> PROCEDURE -----------------------------+> +> PROFILE -- z-------------------------------+ objects2 = C -+> ROLE -----------------------------------------+-->@ +> SCHEMA -------------------------------------+@ +> SEQUENCE ---------------------------------+@ +> STORAGE MAP +--------------------------------+-+@ | +--> PARTITION -+ |@ +> SYNONYM -----------------------------------+@ +> TABLE ------------------------{---------------+@ +> TRIGGER -----------------------------------+@ +> USER -----------------------------------------+@ +> VIEW -----------------------------------------+ 2 Arguments 3 CATALOG? Names the catalog for which you want to create a comment. IfA the catalog is not in the default schema, you must qualify the? catalog name in the COMMENT ON statement with an alias name. 3 COLLATING_SEQUENCE> Names the col |lating sequence for which you want to create aC comment. If the collating sequence is not in the default schema,A you must qualify the collating sequence name in the COMMENT ON statement with an alias name. 3 COLUMND Names the column for which you want to create a comment. You mustB qualify the column name with a table name. If the column is not@ in a table in the default schema, you must qualify the columnA name in the COMMENT ON statement with both a table name and} an alias name. 3 CONSTRAINT_constraint-nameB Names the constraint for which you want to create a comment. IfD the constraint is not in the default schema, you must qualify theB constraint name in the COMMENT ON statement with an alias name. 3 DATABASE@ This statement writes the new comment to the database. If theD ALIAS clause is omitted, the default database is used. The alias-D name must be an alias specified by an ATTACH or CONNECT statement during ~this session. 3 DOMAINB Names the domain for which you want to create a comment. If theC domain is not in the default schema, you must qualify the domain7 name in the COMMENT ON statement with an alias name. 3 FUNCTION@ Names the function for which you want to create a comment. IfB the function is not in the default schema, you must qualify the@ function name in the COMMENT ON statement with an alias name. 3 INDEX Syntax options: INDEX index-name PARTITION partition-nameC Names the index and, optionally, a partition in the named index,> for which you want to create a comment. If the index is not@ in the default schema, you must qualify the index name in the+ COMMENT ON statement with an alias name. 3 IS_string@ Specifies the comment. SQL displays the text when it executesB a SHOW statement in interactive SQL. Enclose the comment within? single quotation marks (') and separate multiple lines in a! comment with a slash mark (/). 3 MODULEB Names the module for which you want to create a comment. If theC module is not in the default schema, you must qualify the module7 name in the COMMENT ON statement with an alias name. 3 PROCEDUREA Names the procedure for which you want to create a comment. IfC the procedure is not in the default schema, you must qualify theA procedure name in the COMMENT ON statement with an alias name. 3 PROFILE? Names the profile for which you want to create a comment. IfA the profile is not in the default schema, you must qualify the? profile name in the COMMENT ON statement with an alias name. 3 ROLE@ Names the role for which you want to create a comment. If theD role is not in the default schema, you must qualify the role name2 in the COMMENT ON statement with an alias name. 3 SCHEMAD Names the schema for which you want to create a comment. You must? create the schema first. If the schema is not in the default= schema, you must qualify the schema name in the COMMENT ON statement with an alias name. 3 SEQUENCE@ Names the sequence for which you want to create a comment. IfB the sequence is not in the default schema, you must qualify the@ sequence name in the COMMENT ON statement with an alias name. 3 STORAGE_MAP Syntax options: STORAGE MAP map-name PARTITION partition-nameB Names the storage map  and, optionally, a vertical or horizontalB partition within that storage map, for which you want to createB a comment. If the storage map is not in the default schema, you@ must qualify the storage map name in the COMMENT ON statement with an alias name. 3 SYNONYME This performs the same function as the ALTER SYNONYM . . . COMMENT> IS syntax. The synonym-name must be the name of an existingC synonym. A database alias can be used to select a database other# than the default database alias. 3 TABLEA Names the table for which you want to create a comment. If theA table is not in the default schema, you must qualify the table7 name in the COMMENT ON statement with an alias name. 3 table-name_col-nameD Names the table and the column or columns in that table for which you want to create a comment. 3 TRIGGER? Names the trigger for which you want to create a comment. IfA the trigger is not in the default schema, you must qualify the? trigger name in the COMMENT ON statement with an alias name. 3 USER> Names the user (created with the CREATE USER statement) for@ which you want to create a comment. If the user is not in theC default schema, you must qualify the user name in the COMMENT ON statement with an alias name. 3 VIEW@ Names the view for which you want to create a comment. If theD view is not in the default schema, you must qualify the view name2 in the COMMENT ON statement with an alias name. 2 Examples9 Example 1: Specifying a comment for columns and tables8 SQL> -- Change the comment for the WORK_STATUS table:' SQL> COMMENT ON TABLE WORK_STATUS IS5 cont> 'Links a status code with 1 of 3 statuses' ; SQL> SHOW TABLE WORK_STATUS$ Information for table WORK_STATUSI Comment on table WORK_STATUS: Links a status code with 1 of 3 statuses . . .3 SQL> -- Create a comment for the DEPARTMENT_CODE+ SQL> -- column in the DEPARTMENTS table:8 SQL> COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_CODE IS* cont> 'Also used in JOB_HISTORY table'; SQL> SHOW TABLE DEPARTMENTS$ Information for table DEPARTMENTS Comment on table DEPARTMENTS:/ information about departments in corporation! Columns for table DEPARTMENTS:: Column Name Data Type Domain: ----------- --------- ------G DEPARTMENT_CODE CHAR(4) DEPARTMENT_CODE_DOM1 Comment: Also used in JOB_HISTORY table . . . B Example 2: Specifying a comment containing more than one string literal2 SQL> COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID ISF cont> '1: Used in SALARY_HISTORY table as Foreign Key constraint' /B cont> '2: Used in JOB_HISTORY table as Foreign Key constraint';# SQL> SHOW TABLE (COL) EMPLOYEES;" Information for table EMPLOYEES Columns for table EMPLOYEES:: Column Name Data Type Domain: ----------- --------- ------: EMPLOYEE_ID CHAR(5) ID_DOML Comment: 1: Used in SALARY_HISTORY table as Foreign Key constraintI 2: Used in JOB_HISTORY table as Foreign Key constraint8 Primary Key constraint EMPLOYEES_PRIMARY_EMPLOYEE_IDA LAST_NAME CHAR(14) LAST_NAME_DOMB FIRST_NAME CHAR(10)  FIRST_NAME_DOMF MIDDLE_INITIAL CHAR(1) MIDDLE_INITIAL_DOMF ADDRESS_DATA_1 CHAR(25) ADDRESS_DATA_1_DOMF ADDRESS_DATA_2 CHAR(20) ADDRESS_DATA_2_DOM< CITY CHAR(20) CITY_DOM= STATE CHAR(2) STATE_DOMC POSTAL_CODE CHAR(5) POSTAL_CODE_DOM; SEX CHAR(1) SEX_DOM< BIRTH DAY DATE VMS DATE_DOMC STATUS_CODE CHAR(1) STATUS_CODE_DOM+ Example 3: Adding a Comment to a Trigger8 SQL> COMMENT ON TRIGGER EMPLOYEE_ID_CASCADE_DELETE IS> cont> 'When an employee is deleted from EMPLOYEES, delete'/> cont> 'corresponding records from the other tables in the'/ cont> 'database.';/ SQL> SHOW TRIGGER EMPLOYEE_ID_CASCADE_DELETE" EMPLOYEE_ID_CASCADE_DELETE Source: EMPLOYEE_ID_CASCAD E_DELETE1 BEFORE DELETE ON EMPLOYEESC (DELETE FROM DEGREES D WHERE D.EMPLOYEE_ID =. EMPLOYEES.EMPLOYEE_ID)& FOR EACH ROWI (DELETE FROM JOB_HISTORY JH WHERE JH.EMPLOYEE_ID =. EMPLOYEES.EMPLOYEE_ID)& FOR EACH ROWL (DELETE FROM SALARY_HISTORY SH WHERE SH.EMPLOYEE_ID =. EMPLOYEES.EMPLOYEE_I D)& FOR EACH ROWL -- Also, if an employee is terminated and that employeeJ -- is the manager of a department, set the manager_id1 -- null for that department.E (UPDATE DEPARTMENTS D SET D.MANAGER_ID = NULLC WHERE D.MANAGER_ID = EMPLOYEES.EMPLOYEE_ID)' FOR EACH ROW. . . .E Comment: When an employees is del eted from EMPLOYEES, deleteD corresponding records from the other tables in the database.< Example 4: Adding Comments to Multiple Columns in a Table7 SQL> COMMENT ON JOBS (JOB_CODE is 'Required column',: cont> WAGE_CLASS is 'Valid values are: 1, 2, 3, or 4');" SQL> SHOW TABLE (COLUMNS) JOBS; Information for table JOBS Columns for table JOBS:: Column Name Data Type Domain: ----------- --------- ------< JOB_CODE CHAR(4) JOB_CODE" Comment: Required column Missing Value: None> WAGE_CLASS CHAR(1) WAGE_CLASS2 Comment: Valid values are: 1, 2, 3, or 4= JOB_TITLE CHAR(20) JOB_TITLE Missing Value: None: MINIMUM_SALARY INTEGER(2) SALARY: MAXIMUM_SALARY INTEGER(2) SALARY wwK 1  COMMITC Ends a transaction and makes permanent any changes that you made6 during that transaction. The COMMIT statement also: o Releases all locksA o Closes all open cursors (unless they are WITH HOLD cursors)A o Prestarts a new transacation if prestarted transactions are enabled 2 Environment$ You can use the COMMIT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format commit-statement = % COMMIT WORK ---+---------------+--->! +-> AND CHAIN --+ 2 Arguments 3 AND_CHAINB When AND CHAIN is used, a new transaction is implicitly startedD using the same attributes as the previously commited transaction. 3 WORKB An optional keyword that has no effect on the COMMIT statement. 2 ExamplesA Example 1: Using the COMMIT statement to write a change to the database; This example gives a raise to an employee. To maintain aD consistent database, the program performs three operations within one transaction. The program:: o Prompts for an employee identification number (:ID).C o Prompts for a percentage increase, which is used to calculate the raise.C o Uses the UPDATE statement to change the current salary row byD changing its salary ending date from null to the current date.B o Uses the INSERT statement to create a new row in the SALARY_B HISTORY table. All the columns of the new row can be derived? from columns of the old row, except the start date, which@ must be calculated from the current date. SQL calculates aB new value for the SALARY_AMOUNT column from the old record'sB SALARY_AMOUNT column using the specified percentage increase (:PERC).C o Uses the COMMIT statement to make the changes to the database permanent.? The first two SQL statements in the example are the WHENEVER> SQLERROR and WHENEVER SQLWARNING statements. If an error or> warning occurs, control transfers to another paragraph thatC contains a ROLLBACK statement. Therefore, this set of operations% is never just partially completed. . . . PROCEDURE DIVISION. START-UP.1 DISPLAY "Enter employee's ID number: " WITH NO ADVANCING. ACCEPT ID.* DISPLAY "Percentage increase: " WITH NO ADVANCING. ACCEPT PERC. EXEC SQL9 WHENEVER SQLERROR GOTO ERROR-PAR END_EXEC. EXEC SQL< WHENEVER SQLWARNING GOTO ERROR-PAR END_EXEC.0 EXEC SQL SET TRANSACTION READ WRITE RESERVING2 SALARY_HISTORY FOR EXCLUSIVE WRITE END_EXEC. EXEC SQL& UPDATE SALARY_HISTORY SH6 SET SH.SALARY_END = CURRENT_TIMESTAMP) WHE RE SH.EMPLOYEE_ID = :ID* AND SH.SALARY_END IS NULL END_EXEC. EXEC SQL' INSERT INTO SALARY_HISTORY> (EMPLOYEE_ID, SALARY_AMOUNT, SALARY_START)' SELECT EMPLOYEE_ID,A (SALARY_AMOUNT * (1 + (:PERC / 100))),% SALARY_END* FROM SALARY_HISTORY- WHERE EMPLOYEE_ID = :IDH AND CAST(SALARY_END as DATE ANSI) = CURRENT_DATE END_EXEC. EXEC SQL# COMMIT WORK END_EXEC.= Example 2: Using the COMMIT statement with data definitionA This example shows a simple database and table definition. The9 COMMIT statement makes the table definition permanent.( SQL> CREATE DATABASE ALIAS INVENTORY; SQL> --# SQL> CREATE TABLE INVENTORY.PART cont> (TEST CHAR(10)); SQL> COMMIT; SQL> SHOW TABLES/ User tables in database with alias INVENTORY PART* Example 3: Using the AND CHAIN argument@ The following simple example executes SET TRANSACTION once atC the start of the procedure. Then periodically the transaction isB committed and restarted using the COMMIT AND CHAIN syntax. ThisC simplifies the application since there is only one definition of# the transaction characteristics.# SQL> -- process table in batches SQL>- SQL> set compound transactions 'internal';& SQL> set flags 'transaction,trace'; SQL> SQL> begin& cont> declare :counter integer = 0; cont> declare :emp integer; cont> cont> set transaction cont> read write5 cont> reserving employees for exclusive write; cont> cont> for :emp in 0 to 600 cont> do cont> begin cont> declare :id char(5)F cont> default substring (cast (:emp+100000 as varchar(6))4 cont> from 2 for 5);H cont> if exists (select * from employees where employee_id = :id) cont> then& cont> trace 'found: ', :id;! cont> if :counter > 20 cont> then& cont> commit and chain;& cont> set :counter = 1; cont> else1 cont> set :counter = :counter + 1; cont> end if; cont> end if; cont> end; cont> end for; cont> cont> commit; cont> end;& ~T Compile transaction (1) on db: 1* ~T Transaction Parameter Block: (len=2)! 0000 (00000) TPB$K_VERSION = 1( 0001 (00001) TPB$K_WRITE (read write)0 ~T Start_transaction (1) on db: 1, db count=1# ~T Rollback_transaction on db: 1& ~T Compile transaction (3) on db: 1+ ~T Transaction Parameter Block: (len=14)! 0000 (00000) TPB$K_VERSION = 1( 0001 (00001) TPB$K_WRITE (read write)H 0002 (00002) TPB$K_LOCK_WRITE (reserving) "EMPLOYEES" TPB$K_EXCLUSIVE0 ~T Start_transaction (3) on db: 1, db count=1 ~Xt: found: 00164 ~Xt: found: 00165 . . . ~Xt: found: 00185! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 12 ~T Restart_transaction (3) on db: 1, db count=1 ~Xt: found: 00186 ~Xt: found: 00187 . . . ~Xt: found: 00435 ~Xt: found: 00471! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 1 SQL> wwK1 Compound_Stmt> Allows you to include more than one SQL statement in an SQLC module procedure or in an embedded SQL progra m. Only by defining> a compound statement can you put multiple SQL statements in< a procedure. Procedures that contain one or more compound3 statements are called multistatement procedures.; In contrast, a simple statement can contain a single SQLA statement only. Procedures that contain a single SQL statementC are called simple-statement procedures. See the Simple_StatementC for a description of simple-statement procedures and how you use' them in SQL application progr amming.> A compound statement and a simple statement differ not just? in the number of SQL statements they can contain. A compound statement:B o Can include only a subset of the SQL statements allowed in aA simple statement procedure. (See the compound-use-statement; syntax diagram for a list of these valid statements.)B o Can include control flow statements, much like those you can@ use in a host language program. (See the control-statementC syntax diagrams for a list of flow control statements allowed in a compound statement.)< o Can include transaction management statements, such as ROLLBACK and COMMIT." o Can include local variables. o Can control atomicity.B o Can reference only one alias because each compound statement- represents a single Oracle Rdb request.? See the Oracle Rdb Guide to SQL Programming for a conceptual? description of compound statements and their relationship to multistatement procedures. 2 Environment$ You can use a compound statement:? o In interactive SQL, as a way to test syntax and prototype0 compound statements for use with programs.? o In embedded SQL, as part of a host language program to be) processed with the SQL precompiler.C o In SQL module language, as part of a multistatement procedure? in an SQL module file to be processed with the SQL module processor.A o In dynamic SQL, to prepare and execute compound statements. 2 Format compound-statement = B --+-----------------------+-> BEGIN --+--------------------+---+B +-> : -+ +-> pragma-clauses --+ |B +------------------------------ <------------------------------+% +-+----------------------------+--+% ++--> variable-declaration -++ |% +--------------------------+ |% +---------------------------------+H +-+-------------------------------+--> END --+--------------------+-->E ++-> compound-use-statement -++ +-> : -+$ +---------- <-----------------+ pragma-clauses = 1 --+-+-> pragma-option --+------------------+--->- | +------- <---------+ |- +-> PRAGMA ( -+-> pragma-option -+-> ) -+& +-------- , <-------+ pragma-option = ( --+-> ATOMIC ----------------------+-->% +-> NOT ATOMIC ------------------+% +-> ON ALIAS -------+% +-> with-clause -----------------+% +-> optimize-clause -------------+  optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  with-clause = 8 ---> WITH --> HOLD -+-------------------------------+->6 +-> PRESERVE --+-> ON COMMIT ---+6 +-> ON ROLLBACK -+6  +-> ALL ---------+6 +-> NONE --------+  variable-declaration = : ---> DECLARE --+-> -+-+--------------+--+: +-------- , <--------+ +-> CONSTANT --+ |: +-> UPDATABLE -+ |: +-------------------------------------------------------+G +-+-> data-type ----+-+-------------------+-+----------------------+->E +-> + +-> default-clause -+ +-> constraint-clause -+  constraint-clause = A --> CHECK --> (search-condition) -+--------------------------+->? +-> constraint-attributes -+ default-clause = 3 --+-> DEFAULT --+--+--> date-time-literal -+----->- +-> = ------+ +--> interval-literal -+- +--> numeric-literal --+- +--> string-literal ---+- +--> : -+ compound-use-statement = , ----+ -> call-statement --------------+--> ;' +-> commit-statement ------------+' +-> control-statement -----------+' +-> delete-statement ------------+' +-> get-diagnostics-statement ---+' +-> insert-statement ------------+' +-> lock-table-statement --------+' +-> rollback-statement ----------+' +-> set-transaction-statement ---+' +-> singleton-select-statement --+' +-> start-transaction-statement -+' +-> trace-statement -------------+'  +-> update-statement ------------+ control-statement = ( ---+-> simple-case-statement ------+-->% +-> case-searched-statement ----+% +-> compound-statement ---------+% +-> for-statement --------------+% +-> for-counted-loop-statement -+% +-> if-statement ---------------+% +-> iterate-statement ----------+% +-> leave-statement ------------+% +-> loop-statement -------------+% +-> repeat-statement -----------+% +-> return-statement -----------+% +-> set-assignment-statement ---+% +-> signal-statement -----------+% +-> trace-statement ------------+% +-> while-statement ------------+ 2 Arguments 3 ATOMIC Syntax options: ATOMIC | NOT ATOMICC Controls whether or not SQL statements in the compound statement: are undone when any statement in the compound statementC terminates with an exception. Compound statements are NOT ATOMIC by default.: Most single SQL statements ar e ATOMIC. Only the controlA statements are NOT ATOMIC. For example, an INSERT statement isD ATOMIC, and the entire insert operation either completes or fails; as a unit even if it is contained in a NOT ATOMIC block. o ATOMICC In a compound statement defined as ATOMIC, all SQL statements= in a compound statement succeed, or when any of the SQL? statements in the compound statement raises an exception,? they all fail as a unit. Any changes made up to the po intB of failure are undone. SQL terminates the compound statementA as soon as a statement within it fails. SQL does not change> variable assignments as a result of a statement failure.B All statements within an ATOMIC block must be atomic. If youC nest compound statements and specify ATOMIC, you must specifyD ATOMIC for any inner blocks. If you do not, Oracle Rdb returns an error. o NOT ATOMIC (default)< In a compound statement defined as  NOT ATOMIC, all SQL@ statements that complete successfully up to the point of aC failed statement are not undone as they would be in an ATOMIC@ compound statement. Partial success of the statements in a> NOT ATOMIC compound statement can occur, unlike the all-@ or-nothing behavior in ATOMIC compound statements. As with@ ATOMIC compound statements, NOT ATOMIC compound statementsD are terminated when an SQL statement returns an exception. TheC partial wo rk of the statement causing a compound statement to! terminate is always undone.? SQL restricts the use of SET TRANSACTION, START TRANSACTION,D COMMIT, and ROLLBACK statements to NOT ATOMIC compound statementsD because the nature of an ATOMIC compound statement conflicts with@ the properties of these statements. The property of an ATOMICD block is that all statements succeed, or all statements fail, andB this can not be guaranteed if a transaction is started or ended during the block. 3 BEGIN@ Begins a compound statement. The END keyword marks the end ofA a compound statement. The unit consisting of the BEGIN and ENDC keywords and all statements bounded by them is called a compoundC statement block or just a block. The simplest compound statement? block can consist of BEGIN, END, and a terminating semicolon (BEGIN END;). 3 beginning-label:A Assigns a name to a block. You use the label with the LEAVE orB ITERATE statements to perform a controlled exit from a block orA a LOOP statement. Named compound statements are called labeled@ compound statements. If a block has an ending label, you mustC also supply an identical beginning label. A label must be unique8 within the procedure in which the label is contained. 3 call-statementB Invokes an external or stored procedure. See the CALL Compound_2 Statement statement for a complete description. 3 case-searched-statement? See the CASE_Searched help topic for a complete description. 3 commit-statement@ Ends a transaction and makes any changes that you made duringD that transaction permanent. SQL does not allow a COMMIT statementD in an ATOMIC compound statement. The AND CHAIN clause can also be# used to start a new transaction.8 See the COMMIT help topic for a complete description. 3 compound-statementC Lets you nest compound statements in another compound statement. 3 compound-use-statement@ Identifies the SQL statements allowed in a compound statement block. 3 CONSTANT> CONSTANT changes the variable into a declared constant thatB can not be updated. If you specify CONSTANT, you must also haveC specified the DEFAULT clause to ensure the variable has a value.? CONSTANT also indicates that the variable can not be used asA the target of an assignment or be passed as an expression to a& procedure's INOUT or OUT parameter. 3 control-statement< The set of statements that provide conditional execution,B iterative execution, and cursor-like operations for controlling@ the execution flow of SQL statements in a compound statement. 3 default-clause9 You can use any value expression including subqueries,@ conditional, character, date/time, and numeric expressions asC default values. See Value Expressions for more information about value expressions.? The value expressions described in Value Expressions include@ DBKEY and aggregate functions. However, the DEFAULT clause is? not a valid location for referencing a DBKEY or an aggregate> function. If you attempt to reference either, you receive a compile-time error. 3 delete-statement& Deletes a row from a table or view.8 See the DELETE help topic for a complete description. 3 END# Ends a compound statement block. 3 ending-labelC Assigns a name to a block. If a block has a beginning label, you/ must use the same name for the ending label. 3 for-counted-loop-statement: See the FOR (Counted) Control help topic for a complete description. 3 for-statement= See the FOR_Control help topic for a complete description. 3 get-diagnostics-statement? Retrieves diagnostic information for the previously executed statement.A See the Get_Diagnostics help topic for a complete description. 3 if-statement< See the IF_Control help topic for a complete description. 3 insert-statement? Adds a new row, or a number of rows, to a table or view. For= compound statements, SQL restricts the INSERT statement to3 database insert operations in a single database.8 See the INSERT help topic for a complete description. 3 leave-statement? See the LEAVE_Control help topic for a complete description. 3 lock-table-statement< See the LOCK_TABLE help topic for a complete description. 3 loop-statement> See the LOOP_Control help topic for a complete description. 3 ON_ALIAS> Specifies an alias allowing your program or interactive SQLD statements to refer to more than one database. Use the same alias( as specified in the ATTACH statement.1 SQL> ATTACH 'ALIAS db1 FILENAME mf_personnel';' SQL> ATTACH 'ALIAS db2 FILENAME d1'; SQL> DECLARE :x CHAR(5); SQL> BEGIN ON ALIAS db16 cont> SELECT EMPLOYEE_ID INTO :x FROM db1.EMPLOYEES# cont> WHERE EMPLOYEE_ID='00164'; cont> END; SQL> PRINT :x; X 00164 3 OPTIMIZE_AS, Assigns a name to the compound statement. 3 OPTIMIZE_USINGB Names the query outline to be used with the compound statement,? even if the outline ID for the query and for the outline are different. 3 OPTIMIZE_WITHB Selects one of three optimization controls: DEFAULT (as used by@ previous versions of Oracle Rdb), AGGRESSIVE (assumes smaller= numbers of rows will be selected), and SAMPLED (which uses= literals in the query to perform preliminary estimation on indices). 3 PRAGMA= These options may only be specified on the outermost BEGIN5 statement. The exception is ATOMIC and NOT ATOMIC. 3 repeat-statement@ See the REPEAT_Control help topic for a complete description. 3 return-statementB Returns the result for stored functions. See the RETURN_Control) help topic for a complete description. 3 rollback-statement@ Ends a transaction and undoes all changes you made since thatC transaction began. SQL does not allow a ROLLBACK statement in anC ATOMIC compound statement. The AND CHAIN clause can also be used to start a new transaction.: See the ROLLBACK help topic for a complete description. 3 set-assignment-statement= See the SET_Control help topic for a complete description. 3 set-transaction-statement: Starts a transaction and specifies its characteristics.A See the SET_TRANSACTION help topic for a complete description. 3 signal-statement@ See the SIGNAL_Control help topic for a complete description. 3 simple-case-statement= See the CASE_Simple help topic for a complete description. 3 singleton-select-statement$ Specifies a one-row result table.; See the SELECT Singleton_Select statement for a complete description. 3 start-transaction-statementC See the START_TRANSACTION help topic for a complete description. 3 trace-statementB Writes values to the trace log file. See the TRACE_Control help$ topic for a complete description. 3 UPDATABLE< UPDATABLE is the default (versus CONSTANT) and allows theA variable to be modified. An update of a variable can occur dueA to a SET assignment, an INTO assignment (as part of an INSERT,A UPDATE, or SELECT statement), or as a procedure's OUT or INOUT parameter. 3 update-statement% Modifies a row in a table or view.8 See the UPDATE help topic for a complete description. 3 variable-declarationA Declares local variables for a compound statement. SQL createsC variables when it executes a compound statement and deletes them1 when execution of the compound statement ends. 3 while-statement? See the WHILE_Control help topic for a complete description. 3 WITH_HOLDB Can be applied to a table cursor so that it remains open across COMMIT and ROLLBACK actions. 2 Examples7 Example 1: Using a compound statement to update rowsD The following compound statement uses variables to update rows inC the JOBS table. It uses the SET asssignment control statement to* assign a value to the variable MIN_SAL. SQL> BEGIN! cont> -- Declare the variable.* cont> DECLARE :MIN_SAL INTEGER(2);* cont> -- Set the value of the variable.K cont> SET :MIN_SAL = (SELECT MIN(MINIMUM_SALARY) FROM JOBS) * 1.08;. cont> -- Update the rows in the JOBS table. cont> UPDATE JOBS1 cont> SET MINIMUM_SALARY = :MIN_SALA cont> WHERE MINIMUM_SALARY < (:MIN_SAL * 1.08); cont> END;& Example 2: Using the DEFAULT clauseD The following example shows several variable declarations using a7 variety of value expressions for the DEFAULT clause. SQL> SET FLAGS 'TRACE'; SQL> SQL> BEGIN) cont> DECLARE :x INTEGER DEFAULT -1; cont> TRACE :x; cont> END; ~Xt: -1 SQL> SQL> BEGIN+ cont> DECLARE :x INTEGER DEFAULT NULL;' cont> TRACE COALESCE (:x, 'NULL'); cont> END; ~Xt: NULL SQL> SQL> BEGIN, cont> DECLARE :x INTEGER DEFAULT (1+1); cont> TRACE :x; cont> END; ~Xt: 2 SQL> SQL> BEGING cont> DECLARE :x INTEGER DEFAULT (SELECT COUNT(*) FROM EMPLOYEES); cont> TRACE :x; cont> END; ~Xt: 100B Example 3: Specifying a LOOP statement using the DEFAULT clauseA The following example shows some simple value expressions. TheD default value is applied to :y on each iteration of the loop, not1 just the first time the statement is executed. SQL> BEGIN* cont> DECLARE :x INTEGER DEFAULT 0; cont> WHILE :x < 10 cont> LOOP cont> BEGIN1 cont> DECLARE :y INTEGER DEFAULT 1;! cont> TRACE :x, :y;% cont> SET :x = :x + :y;$ cont> SET :y = :y + 1; cont> END; cont> END LOOP; cont> END; ~Xt: 0 1 ~Xt: 1 1 ~Xt: 2 1 ~Xt: 3 1 ~Xt: 4 1 ~Xt: 5 1 ~Xt: 6 1 ~Xt: 7 1 ~Xt: 8 1 ~Xt: 9 1( Example 4: Using the CHECK constraint> This example shows the use of a CHECK constraint to preventB illegal values being assigned to control variables for a REPEATD loop. The singleton SELECT will actually return zero to the local= variable P which will cause a variable validation to fail. SQL> begin: cont> declare :v integer = 0 check (value is not null);I cont> declare :p integer = 1 check (value is not null and value <> 0); cont> cont> repeat$ cont> select count(*) into :p cont> from employees) cont> where employee_id = '00000'; cont> set :v = :v + :p; cont> until :v > 1000 cont> end repeat; cont> end;C %RDB-E-NOT_VALID, validation on field P caused operation to fail( Example 5: Using the WITH HOLD clause@ The following example shows the use of the WITH HOLD PRESERVEA ON COMMIT clause in a procedure which purges old data from theA AUDIT_HISTORY table. It commits the transaction every 100 rows (:MAX_UNIT).& SQL> declare transaction read only; SQL> set flags 'TRACE';- SQL> set compound transactions 'internal';! SQL> declare :purge_date date;C SQL> accept :purge_date prompt 'Purge date for AUDIT_HISTORY? ';+ Purge date for AUDIT_HISTORY? 1-jan-1989 SQL> SQL> begin) cont> with hold preserve on commit2 cont> declare :max_unit constant integer = 100;) cont> declare :rc integer = :max_unit; cont>$ cont> set transaction read write; cont> for :ah& cont> as table cursor ah_cursor, cont> for select * from audit_history* cont> where job_start < :purge_date cont> do& cont>  delete from audit_history, cont> where current of ah_cursor; cont> if :rc = 0 cont> then cont> commit;% cont> set :rc = :max_unit;, cont> set transaction read write; cont> else# cont> set :rc = :rc - 1; cont> end if; cont> end for;) cont> get diagnostics :rc = ROW_COUNT; cont> commit;' cont> trace 'Processed rows: ', :rc; cont> end; ~Xt: Processed rows: 1096 wws  1 CONNECTC Creates a database environment and a connection, and specifies a( connection name for that association.D A connection specifies an association between the set of cursors,B intermediate result tables, and procedures in all modules of an? application and the database environment currently attached.> A database environment is one or more databases that can beC attached or detached as a unit. The connection name designates aC particular connection and datab ase environment. When you execute; a procedure, it executes in the context of a connection.C When you issue a CONNECT statement, SQL creates a new connection< from all the procedures in your application and creates a> new environment from all the databases named in the CONNECT? statement. The new environment can include databases already' attached in the default environment.9 There are two ways to attach a database to the default environment:B o Use an ATTACH statement to specify a database environment atD run time. All the databases you specify with subsequent ATTACH8 statements become part of the default environment.9 o Use a DECLARE ALIAS statement to specify a databaseC environment at compile time in precompiled SQL and SQL module@ language. All the databases that you specify using DECLAREC ALIAS statements also become part of the default environment.> A CONNECT statement creates a new connection with a new s et? of attachments, and does an implicit SET CONNECT to that new= connection. Although a CONNECT statement does not create a@ transaction, each connection has its own implicit transaction? context. You can issue two different CONNECT statements that: attach to the same database, but each attach is unique.D Once you have specified a connection name in a CONNECT statement,B you can refer to that connection name in subsequent SET CONNECTC statements. You can use a SET CONNECT statement to specify a newA connection for an application to run against without having toB detach and recompile queries. See the SET_CONNECT statement for more information.= The DISCONNECT statement detaches from databases, ends theC transactions in the connections that you specify, and rolls back; all the changes you made since those transactions began. 2 Environment% You can use the CONNECT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format CONNECT --+ +---------+/ +-+---------------------------------------+--+/ +-> TO --+-> --+ |/ +-> -------+ |/ +-> + |/ +--------------------------------------------+/ +-+---------------------------------------+--+/ +-> AS --> runtime-options (1) ---------+ |/ +--------------------------------------------+/ +-+-----------------------------+------------+/ +-> user-authentication ----+ |/ +--------------------------------------------+0 ++------------------------------------------+-+0 ++-+-> CATALOG --> runtime-options (2) +-+-+ |0 | +-> SCHEMA ---> runtime-options (3) + | |0 +--------------- , <--------------------+ |0 +---------------------------------------------+0 +-+---------------------------------------+--->, +-> NAMES runtime-options (4) ----------+  user-authentication = E --> USER -+-> '' --+---+-----------------------------+-->B +-> parameter ---+ +-> USING -+- '' +--+? +-> parameter --+  connect-string-literal = ' --> ' --> connect-expression --> ' --> connect-expression = ---+--> DEFAULT ------------+-> ++-> db-specification -+-+  +-------- , <---------+ db-specification = > -+-+-> ALIAS ---------------------------------------+> | | +----------------- <----------------------------------+H | | +-+-------------------------------------------------------+-+-+->F | | +-> FILENAME 'attach-spec' -+-+----------------------+--+ | |F | | +-> PATHNAME ---+ +-> literal-user-auth -+ | |F | | | |F | +-> ATTACH attach-expression ----------------------------------+ |F +--------------------------------, <-------------------------------+  literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  attach-expression = : -+------------------++-> FILENAME -> '' -+-+: +-> ALIAS -++-> PATHNAME -> ----+ |: +------------------------------------------------------+: ++------------------------+----------------------------+: +--> literal-user-auth --+ |: +------------------------------------------------------+; ++-----------------------------+------------------------>" +-+-+-> database-options --+-++! | +-> attach-options ----+ |! +----------- <-------------+  attach-spec = * --+----------------+-> -----> +-> -+ node-spec = + -+-> -+-------------------+-+->) |  +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  database-options = % --+--> ELN ---------------------+-->" +--> NSDS --------------------+" +--> rdb-options -------------+" +--> VIDA --------------------+" +--> VIDA V1 -----------------+" +--> VIDA V2 -----------------+" +--> VIDA V2N ----------------+" +--> NOVIDA ------------------+" +--> DBIV1 -------------------+" +--> DBIV31 ------------------+" +--> DBIV70 ------------------+  rdb-options =  -+-> RDBVMS --+--> +-> RDB030 --+ +-> RDB031 --+ +-> RDB040 --+ +-> RDB041 --+ +-> RDB042 --+ +-> RDB050 --+ +-> RDB051 --+ +-> RDB060 --+ +-> RDB061 --+ +-> RDB070 --+ +-> RDB071 --+ attach-options = 5 -+-> DBKEY -+-> SCOPE IS -+-> ATTACH -------+----+->3 +-> ROWID -+ +-> TRANSACTION --+ |3 +-> MULTISCHEMA IS -+-> ON --+------------------+3 | +-> OFF -+ |3 +-> PRESTARTED TRANSACTIONS ARE -+-> ON --+-----+3 | +-> OFF -+ |3 +-+-------+-> RESTRICTED ACCESS ----------------+3 | +-> NO -+ |3 +-> DISPLAY CHARACTER SET -+ runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 ALIAS_alias: Specifies a name for a particular attach to a database.B Specifying an alias in the connect expression lets your programA or interactive SQL statements refer to more than one database.B You do not have to specify an alias in the CONNECT statement if2 you are referring only to the default database.< If you specify an alias, but do not specify a FILENAME or? PATHNAME, SQL uses the path name or file name in the DECLAREB ALIAS statement for that database by default. The alias must be# part of the default environment. 3 ASC Specifies an identifier for the association between the group ofB databases being attached (the environment) and the database and8 request handles that reference them (the connection).B The connection name must be unique within your application. Use? a literal string enclosed within single quotation marks, for example:F CONNECT TO 'ALIAS CORP FILENAME corporate_data' AS 'JULY_CORP_DATA'B If you do not specify a connection name, SQL generates a unique connection name. For example: SQL> CONNECT TO( cont> 'ATTACH FILENAME mf_personnel'; SQL> SHOW CONNECTIONS! RDB$DEFAULT_CONNECTION -> SQL$CONN_00000000 3 ATTACH_attach_expressionB Specifies an alias that is not part of the default environment.C See the ATTACH statement for details about the FILENAME 'attach-C spec', PATHNAME path-name, database-options, and attach-options. 3 CATALOG> Specifies the default catalog for dynamic statements in the connection.= You can supply a parameter marker from dynamic SQL, a host@ language variable from a precompiled SQL program, a parameter? from an SQL module language module, or a string literal. TheD argument that you supply must be a character string that contains8 a connect expression that is interpreted at run time. 3 db-specificationB Specifies one or more valid aliases. An alias, which identifiesB a particular database, is valid only if that database is either? declared in any of the modules in the current application or> attached with the ATTACH statement. You can issue an ATTACH- statement as part of the db-specification. 3 FILENAMEC A quoted string containing full or partial information needed to access a database.> When you use the FILENAME argument, any changes you make to? database definitions are entered only to the database system= file, not to the repository. If you specify FILENAME, yourB application attaches to the database with that file name at run time.D For information regarding node-spec and file-spec, see Oracle Rdb Attach Specifications. 3 literal-user-auth? Specifies the user name and password for the specified alias> in the connection. This clause enables access to databases,! particularly remote databases.B This literal lets you explicitly provide user name and password@ information for each alias in the CONNECT statement. For more? information about when to use this clause, see the statement ATTACH. 3 NAMES> Specifies a character set name that is used as the default,@ identifier, and literal character sets for the session of theB current connection. The value of runtime-options must be one ofB the character sets listed in the Supported_Characters_Sets HELP topic .= You can supply a parameter marker from dynamic SQL, a host@ language variable from a precompiled SQL program, a parameter? from an SQL module language module, or a string literal. TheD argument that you supply must be a character string that contains8 a connect expression that is interpreted at run time. 3 PATHNAME D A full or relative repository path name that specifies the sourceA of the schema definitions. When you use the PATHNAME argument,@  any changes you make to schema definitions are entered in theA repository and the database system file. Oracle Rdb recommendsA using the PATHNAME argument if you have the repository on your= system and you plan to use any data definition statements.D The path name that you specify overrides the path name associated with the alias at run time.D If you specify PATHNAME at run time, your application attaches to8 the database file name extracted from the repository. 3 runtime-options+ 'literal' | parameter | parameter-marker> Specifies a character set name that is used as the default,@ identifier, and literal character sets for the session of theB current connection. The value of runtime-options must be one of the character sets listed in 3 SCHEMAA Specifies the schema for dynamic statements in the connection.= You can supply a parameter marker from dynamic SQL, a host@ language variable from a precompiled SQL program, a parameter? from an SQL module language module, or a string literal. TheD argument that you supply must be a character string that contains8 a connect expression that is interpreted at run time. 3 TO Syntax options: connect-string-literal connect-parameter connect-parameter-marker>Specifies the database environment. You can supply a parameterDmarker from dynamic SQL, a host language variable from a precompiledASQL program, a parameter from an SQL module language module, or a@string literal. The argument that you supply must be a characterDstring that contains a connect expression that is interpreted at runtime. 3 USER_clause Syntax options:# USER 'username' | USER parameterA A character string literal that specifies the operating systemB user name that the database system uses for privilege checking. 3 USING_clause Syntax options:% USING 'password' | USING parameterD A character s tring literal that specifies the user's password for. the user name specified in the USER clause. 3 user-authentication; Specifies the user name and password to enable access to, databases, particularly remote databases.A This clause lets you explicitly provide user name and passwordC information in the CONNECT statement. If you do not specify userB name and password information in the ALIAS clause or the ATTACH@ clause, SQL uses the user name and password specified in this2 clause as the default for each alias specified.> For more information about when to use this clause, see the ATTACH statement. 2 ExamplesD Example 1: Creating a default connection and one other connectionB The following example shows how a user attaches to one databaseA with two different connections: the default connection and the named connection TEST.2 SQL> attach 'alias MIA1 filename MIA_CHAR_SET';@ SQL> connect to 'alias MIA1 filename MIA_CHAR_SET' as 'TEST'; SQL> show connections;! RDB$DEFAULT_CONNECTION -> TEST SQL> show connections TEST; Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias MIA1:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI9 Example 2: Creating a default connection and two other connections @ The following example attaches to three databases: personnel_? northwest, personnel_northeast, and personnel_southeast. (ByB not specifying an alias for personnel_northwest, it is assigned; the default alias.) Several connections are established,@ including EAST_COAST, which includes both personnel_northeast and personnel_southeast.< Use the SHOW DATABASE statement to see the changes to the database. SQL> --O SQL> -- Attach to the personnel_northwest and per sonnel_northeast databases.L SQL> -- Personnel_northwest has the default alias, so personnel_northeast SQL> -- requires an alias.I SQL> -- All of the attached databases comprise the default connection. SQL> --. SQL> ATTACH 'FILENAME personnel_northwest';> SQL> ATTACH 'ALIAS NORTHEAST FILENAME personnel_northeast'; SQL> --0 SQL> -- Add the personnel_southeast database. SQL> --> SQL> ATTACH 'ALIAS SOUTHEAST FILENAME personnel_southeast'; SQL> --; SQL> -- Conne ct to personnel_southeast. CONNECT does an@ SQL> -- implicit SET CONNECT to the newly created connection. SQL> --A SQL> CONNECT TO 'ALIAS SOUTHEAST FILENAME personnel_southeast'' cont> AS 'SOUTHEAST_CONNECTION'; SQL> --I SQL> -- Connect to both personnel_southeast and personnel_northeast asH SQL> -- EAST_COAST connection. SQL replaces the current connection toJ SQL> -- the personnel_southeast database with the EAST_COAST connectionK SQL> -- when you issue the CONN ECT statement. You now have two different8 SQL> -- connections that include personnel_southeast. SQL> --A SQL> CONNECT TO 'ALIAS NORTHEAST FILENAME personnel_northeast,: cont> ALIAS SOUTHEAST FILENAME personnel_southeast' cont> AS 'EAST_COAST'; SQL> --O SQL> -- The DEFAULT connection still includes all of the attached databases. SQL> -- SQL> SET CONNECT DEFAULT; SQL> --B SQL> -- DISCONNECT releases the connection name EAST_COAST, but@ SQL> -- does not detach from the EAST_COAST databases because8 SQL> -- they are also part of the default connection. SQL> -- SQL> DISCONNECT 'EAST_COAST'; SQL> --! SQL> SET CONNECT 'EAST_COAST';C %SQL-F-NOSUCHCON, There is not an active connection by that name SQL> --K SQL> -- If you disconnect from the default connection, and have no otherL SQL> -- current connections, you are longer be attached to any databases. SQL> -- SQL> DISCONNECT DEFAULT; SQL> SHOW DATABASES;J %SQL-F-ERRATTDEF, Could not use database file specified by SQL$DATABASEP -RDB-E-BAD_DB_FORMAT, SQL$DATABASE does not reference a database known to Rdb -RMS-E-FNF, file not found wwÊ 1 CREATE 2 CACHE& NOTE@ You cannot issue CREATE CACHE as an independent statement.A It is a clause allowed only as part of a CREATE DATABASE or IMPORT statement.@ You can also create a row cache using the ADD CACHE clause& of the ALTER DATABASE statement.= Creates a row cache that allows frequently referenced rows= to remain in memory even when the associated page has been? transferred back to disk. This saves in memory usage becauseC only the more recently referenced rows are cached versus caching the entire buffer.; See the ALTER DATABASE statement and the CREATE DATABASE@ statement for more information regarding the row cache areas. 3 EnvironmentD  You can use the CREATE CACHE clause only within a CREATE DATABASED or IMPORT statement. You can use the ADD CACHE clause only within the ALTER DATABASE statement. 3 Format> CREATE CACHE -+-+----------------------+-+->< | +-> row-cache-params1 -+ |< | +-> row-cache-params2 -+ |< +------------ <------------+ add-row-cache-clause = @ ---> ADD CACHE -+-+----------------------+-+->> | +-> row-cache-params1 -+ |> | +-> row-cache-params2 -+ |> +-------------<------------+ row-cache-params1 = = --+-> ALLOCATION IS -+--+-----------+----------------+->; +-> EXTENT IS -----+ +-> BLOCK --+ |; | +-> BLOCKS -+ |; +-> CACHE SIZE IS -+----> ROW --+---------------- --+; | +----> ROWS -+ |; +-> CHECKPOINT -+> UPDATED ROWS TO -+> BACKING FILE -+-+; | | +> DATABASE -----+ |; | +> ALL ROWS TO BACKING FILE ---------+ |; +-> LARGE MEMORY IS ----+-+-> ENABLED --+--------------+; +-> ROW REPLACEMENT IS -+ +-> DISABLED -+ |; +-> LOCATION IS --> ------------------+; +-> NO LOCATION ---------------------------------------+  row-cache-params2 = A --+-> NUMBER OF -+-> RESERVED -+-> ROWS IS --------------+->? | +-> SWEEP ----+ |? +-> ROW LENGTH IS -+-------------+---------------------+? | +----> BYTE --+ |? | +----> BYTES -+ |? | |? +-> ROW SNAPSHOT IS --+-> ENABLED rs-opt -+---------------+? |  +-> DISABLED --------+ |? | |? +-> SHARED MEMORY IS --+----> SYSTEM -------------------+--+< +----> PROCESS --+-------------+-+: | |: +-> RESIDENT -+ rs-opt =( --+-------------------------------+--->$ +-> (CACHE SIZE IS ROWS) ---+ 3 Arguments 4 ALLOCATION Syntax options:1 ALLOCATION IS n BLOCK | ALLOCATION IS n BLOCKSC Specifies the initial allocation of the row cache file (.rdc) to! which cached rows are written.D If the ALLOCATION clause is not specified, the default allocationC in blocks is approximately 40 percent of the CACHE SIZE for this cache.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 CACHE Creates a row cache. 4 CACHE_SIZE Syntax options:- CACHE SIZE IS n ROW | CACHE SIZE IS n ROWSB Specifies the number of rows allocated to the row cache. As theA row cache fills, rows more recently referenced are retained inC the row cache while those not referenced recently are discarded.< Adjusting the allocation of the row cache helps to retainB important rows in memory. If not specified, the default is 1000 rows. 4 CHECKPOINT Syntax options:) CHECKPOINT ALL ROWS TO BACKI NG FILE- CHECKPOINT UPDATED ROWS TO BACKING FILE) CHECKPOINT UPDATED ROWS TO DATABASED Specifies the source records and target for checkpoint operations@ for the row cache. If ALL ROWS is specified, then the recordsA written during each checkpoint operation are both the modified? and the unmodified rows in the row cache. If UPDATED ROWS is> specified, then just the modified rows in the row cache are checkpointed each time.B If the target of the checkpoint ope ration is BACKING FILE, thenB the row cache server (RCS) process writes the row cache entriesC to the backing (.rdc) files. The row cache LOCATION, ALLOCATION,@ and EXTENT clauses are used to create the backing files. UponA recovery from a node failure, the database recovery process isB able to repopulate the row caches in memory from the rows found in the backing files.A If the target is DATABASE, then the updated rows (only UPDATED= ROWS is allowed) are written back to the database. The rowC cache LOCATION, ALLOCATION, and EXTENT clauses are ignored. UponB recovery from a node failure, the database recovery process hasC no data on the contents of the row cache. Therefore, it does not' repopulate the row caches in memory.A This CHECKPOINT clause overrides the database-level CHECKPOINT clause. 4 EXTENT Syntax options:) EXTENT IS n BLOCK | EXTENT IS n BLOCKS@ Specifies the file extent size for the row cache file (.rdc).? If the EXTENT clause is not specified, the default number of- blocks is CACHE SIZE * 127 for this cache.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 LOCATION Syntax options: LOCATION IS directory-spec9 Specifies the name of the directory to which row cache? information is written. The database system generates a file@ name (row-cache-name.rdc) automatically for each row cache atB checkpoint time. Specify a device name and directory name only,C enclosed within single quotation marks. By default, the locationC is the directory of the database root file. These .rdc files are permanent database files.D This LOCATION clause overrides a previously specified location at the database level.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 NO_LOCATIOND Removes the location previously specified in a LOCATION IS clause? for the row cache. If you specify NO LOCATION, the row cache< location becomes the directory of the database root file.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 NUMBER_OF_RESERVED_ROWS Syntax options: NUMBER OF RESERVED ROWS IS n@ Specifies the maximum number of cache rows that each user can> reserve for insertion into the cache. Processes reserve, orC allocate, entries in a cache to be used when insert ing rows intoB the cache. To improve efficiency, multiple entries are reservedD at one once. Once a user's reserved list becomes depleted, OracleC Rdb attempts to reserve another group of entries. The default is 20 rows.B This value is also used when searching for available slots in aA row cache. The entire row cache is not searched on the initialA pass. This value specifies the maximum number of rows that areD searched for a free slot. If at least one free slot is found, theC insert operation can proceed. If no free slots are found in thisC initial search, Oracle Rdb continues searching through the cache until it finds a free slot. 4 NUMBER_OF_SWEEP_ROWS Syntax options: NUMBER OF SWEEP ROWS IS nB Specifies the number of modified rows that will be written fromC the row cache back to the database by the row cache server (RCS)B process during a sweep operation. When the RCS is notified that@ a cache is "full" of modi fied data, the RCS starts a sweep to@ make space available in the cache for subsequent transactions? to be able to insert rows into the cache. Oracle CorporationA recommends that you initially specify the number of sweep rows? to be approximately 5 percent of the total number of rows in? the cache. Then monitor performance and adjust the number ofD sweep rows, if necessary. Allowable values must be in the range 2? through 524288. If not specified, the default is 3,000 rows. 4 ROW_LENGTH Syntax options: ROW LENGTH IS n BYTESD Specifies the length of each row allocated to the row cache. RowsD are not cached if they are too large for the row cache. area. TheD ROW LENGTH is an aligned longword rounded up to the next multiple of 4 bytes.8 The maximum row length in a row cache is 65535 bytes.= When the name of the cache matches the name of an existingB logical area, ADD CACHE will calculate ROW LENGTH from the size> of the table row, or the size of the index node (for SORTED> RANKED, or UNIQUE SORTED indices). This cache is known as a logical area cache. 4 ROW_REPLACEMENT Syntax options:; ROW REPLACEMENT IS ENABLED | ROW REPLACEMENT IS DISABLEDB Specifies whether or not Oracle Rdb replaces rows in the cache.> When ROW REPLACEMENT IS ENABLED, rows are replaced when theA row cache becomes full. When ROW REPLACEMENT IS DISABLED, rows? are not replaced when the row cache is full. The type of rowC replacement policy depends upon the application requirements for each cache. The default is ENABLED. 4 ROW_SNAPSHOT_IS_DISABLED= Disables storing snapshot copies of rows within the cache. 4 ROW_SNAPSHOT_IS_ENABLEDD The ROW SNAPSHOT IS ENABLED (CACHE SIZE IS n ROWS) option enablesD storage of snapshot copies of rows within the cache and specifies< the number of snapshot "slots" to allocate for the cache.B The default for new caches, and existing caches is to have this feature disabled.C If you do not specify the CACHE SIZE clause for the ROW SNAPSHOTD IS ENABLED option, Oracle Rdb creates a cache that can contain up to 1000 snapshot rows. 4 SHARED_MEMORY Syntax options:5 SHARED MEMORY IS SYSTEM | SHARED MEMORY IS PROCESSA Determines whether cache global sections are created in systemC space or process space. The default is SHARED MEMORY IS PROCESS.< When you use cache global sections created in the processC space, you and other users share physical memory and the OpenVMSC operating system maps a row cache to a private address space forD each user. As a result, all users are limited by the free virtualD address range and each use a percentage of memory in overhead. IfC many users are accessing the database, the overhead can be high.A When many users are accessing the database, consider using theA SHARED MEMORY IS SYSTEM clause. This gives users more physicalD memory because they share the system space of memory and there isD none of the overhead associated with the process space of memory. $4 SHARED_MEMORY_IS_PROCESS_RESIDENTC The SHARED MEMORY clause determines whether database root globalB sections (including global buffers when enabled) or whether the? cache global sections are created in system space or processB space. The RESIDENT option extends the PROCESS option by making& the global section memory resident. 3 Examples" Example 1: Creating a row cacheD This example creates a database, creates a row cache, and assigns# the row cache to a storage area.( SQL> CREATE DATABASE FILENAME test_db cont> ROW CACHE IS ENABLED cont> CREATE CACHE test1" cont> CACHE SIZE IS 100 ROWS" cont> CREATE STORAGE AREA area1 cont> CACHE USING test1; SQL> SHOW CACHE2 Cache Objects in database with filename test_db TEST1 SQL> SHOW CACHE test1 TEST1* Cache Size: 100 rows+ Row Length: 256 bytes) Row Replacement: Enabled) Shared Memory: Process* Large Memory: Disabled% Window Count: 100$ Reserved Rows: 20& Sweep Rows: 3000 No Sweep Thresholds, Allocation: 100 blocks, Extent: 100 blocks SQL> SHOW STORAGE ARE A area1 AREA1& Access is: Read write# Page Format: Uniform$ Page Size: 2 blocks: Area File: SQL_USER1:[DAY.V70]AREA1.RDA;1/ Area Allocation: 402 pages. Area Extent Minimum: 99 pages0 Area Extent Maximum: 9999 pages0 Area Extent Percent: 20 percent: Snapshot File: SQL_USER1:[DAY.V70]AREA1.SNP;1/ Snapshot Allocation: 100 pages. Snapshot Extent Minimum: 99 pages0 Snapshot Extent Maximum: 9999 pages0 Snapshot Extent Percent: 20 percent" Extent : Enabled Locking is Row Level Using Cache TEST1- No database objects use Storage Area AREA13 Example 2: Creating and modifying various cachesB 1 The cache named CUSTOMER_STATUS is created with a row length? of 577 bytes with 88000 cache "slots" for storage of liveD data base rows and 7000 slots for storage of snapshot copies ofA rows. This cache is also configured to be memory- resident.> 2 The cache named MACHINE_FLOW_IDX_1 is created with a rowC length of 430 bytes with 5000 cache slots for storage of liveB database rows and 12000 slots for storage of snapshot copiesC of rows. This cache is set to disallow replacement of rows in the cache.A 3 The cache named SALES_CALLS is created with a row length ofD 160 bytes with 3000 cache "slots" for storage of live databaseC rows and, using the default because an explicit count was notC specified, 1000 slots for storage of snapshot copies of rows.C 4 The cache named CUSTOMER_ORDER does not specify "ROW SNAPSHOTB IS ENABLED" so no snapshot row copies will be stored in this cache.? 5 The cache named "SALES" is modified to disable storage of snapshot rows in cache.> 6 The cache named "CLEARING" is modified to enable storageA of snapshot rows in the cache with a snapshot cache size of 12,345 rows.& SQL> ALTER DATABASE FILENAME HDB_DB 1 ADD CACHE CUSTOMER_STATUS* ROW LENGTH IS 577 BYTES+ CACHE SIZE IS 88000 ROWSD ROW SNAPSHOT IS ENABLED (CACHE SIZE IS 7000 ROWS)4 SHARED MEMORY IS PROCESS RESIDENT! 2 ADD CACHE MACHINE_FLOW_IDX_1* ROW LENGTH IS 430 BYTES* CACHE SIZE IS 5000 ROWS. ROW REPLACEMENT IS DISABLEDE ROW SNAPSHOT IS ENABLED (CACHE SIZE IS 12000 ROWS) 3 ADD CACHE SALES_CALLS* ROW LENGTH IS 160 BYTES* CACHE SIZE IS 3000 ROWS* ROW SNAPSHOT IS ENABLED 4 ADD CACHE CUSTOMER_ORDER* ROW LENGTH IS 760 BYTES* CACHE SIZE IS 9000 ROWS6 CHECKPOINT UPDATED ROWS TO DATABASE 5 ALTER CACHE SALES+   ROW SNAPSHOT IS DISABLED 6 ALTER CACHE CLEARINGF ROW SNAPSHOT IS ENABLED (CACHE SIZE IS 12345 ROWS);" SQL> SHOW CACHE CUSTOMER_STATUS CUSTOMER_STATUS, Cache Size: 88000 rows+ Row Length: 580 bytes) Row Replacement: Enabled2 Shared Memory: Process Resident* Large Memory: Disabled% Window Count: 100$ Working Set Count: 10$  Reserved Rows: 20, Allocation: 100 blocks, Extent: 100 blocks) Snapshot in Cache: Enabled+ Snapshot Cache Size: 7000 rows% SQL> SHOW CACHE MACHINE_FLOW_IDX_1 MACHINE_FLOW_IDX_1+ Cache Size: 5000 rows+ Row Length: 432 bytes* Row Replacement: Disabled) Shared Memory: Process* Large Memory:  Disabled% Window Count: 100$ Working Set Count: 10$ Reserved Rows: 20, Allocation: 100 blocks, Extent: 100 blocks) Snapshot in Cache: Enabled, Snapshot Cache Size: 12000 rows SQL> SHOW CACHE SALES_CALLS SALES_CALLS+ Cache Size: 3000 rows+ Row Length: 160 bytes) Row Replacement: Enabled)   Shared Memory: Process* Large Memory: Disabled% Window Count: 100$ Working Set Count: 10$ Reserved Rows: 20, Allocation: 100 blocks, Extent: 100 blocks) Snapshot in Cache: Enabled+ Snapshot Cache Size: 1000 rows! SQL> SHOW CACHE CUSTOMER_ORDER CUSTOMER_ORDER+ Cache Size: 9000 rows+ Row  Length: 760 bytes) Row Replacement: Enabled) Shared Memory: Process* Large Memory: Disabled% Window Count: 100$ Working Set Count: 10$ Reserved Rows: 20, Allocation: 100 blocks, Extent: 100 blocks9 Row cache: checkpoint updated rows to database 2 CATALOGC Creates a name for a group of schemas in a multischema database. 3 Environment, You can use the CREATE CATALOG statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format% CREATE CATALOG --> -+% +---------------------------------+' +-+-------------------------------+->% +---> create-schema-statement -++$ +-+-> schema-element -+--------+ +---------<---------+  catalog-name = . -+------> --------------+->, | |, +-> " -> . ->" -+  schema-element = . -+-> create-collating-sequence-statement -+->, +-> create-domain-statement -------------+, +-> create-index-statement --------------+, +-> create-sequence-statement -----------+, +-> create-storage-map-statement --------+, +-> create-table-statement --------------+, +-> create-trigger-statement ------------+, +-> create-view-statement ---------------+, +-> grant-statement ---------------------+  3 Arguments 4 alias.name-of-catalogD Specifies an optional name for the attach to the database. AlwaysA qualify the catalog name with an alias if your program or your> interactive SQL statements refer to more than one database.A Separate the name of the catalog from the alias with a period,@ and enclose the qualified name within double quotation marks. 4 catalog-nameA The name of the catalog definition you want to create. Use any? valid SQL name that is unique among all catalog names in theA database. For more information on catalog names, see the User_ Supplied_Names HELP topic. 4 create-schema-statement9 For more information, see the CREATE SCHEMA statement. 4 schema-element? One or more CREATE statements or a GRANT statement. For more0 information, se e the CREATE SCHEMA statement. 3 Examples> Example 1: Creating a catalog for a database using an aliasA This example shows how an interactive user could attach to the@ sample database called personnel and create a catalog in that@ database. (You must use the personnel sample database created= with the multischema attribute for this example.) Using anB alias, the user distinguishes the personnel database from other< databases that may be attached later in the same session.4 SQL> ATTACH 'ALIAS CORPORATE FILENAME personnel - cont> MULTISCHEMA IS ON'; SQL> --> SQL> -- SQL creates a default catalog called RDB$CATALOG in% SQL> -- each multischema database. SQL> -- SQL> SHOW CATALOG;! Catalogs in database personnel "CORPORATE.RDB$CATALOG" SQL> --D SQL> -- The SET QUOTING RULES 'SQL99' statement allows the use of> SQL> -- double quotation marks, which SQL requires when you0 SQL> -- qualify a catalog name with an alias. SQL> --" SQL> SET QUOTING RULES 'SQL99';- SQL> CREATE CATALOG "CORPORATE.MARKETING"; SQL> -- SQL> SHOW CATALOG;! Catalogs in database personnel "CORPORATE.MARKETING" "CORPORATE.RDB$CATALOG"A Example 2: Creating a catalog in the database with the default aliasD This example shows a CREATE CATALOG clause used in an interactiveA CREATE DATABASE statement. In this example, the user creates a@ database without specifying an alias. Because the u ser is not@ attached to any other databases, the new database becomes the default alias.* SQL> CREATE DATABASE FILENAME inventory cont> MULTISCHEMA IS ON cont> CREATE CATALOG PARTS3 cont> CREATE SCHEMA PRINTERS AUTHORIZATION DAVIS9 cont> CREATE TABLE LASER EXTERNAL NAME IS DEPT_2_LASER' cont> (SERIAL_NO INT, LOCATION CHAR)4 cont> CREATE SCHEMA TERMINALS AUTHORIZATION DAVIS= cont> CREATE TABLE TERM100 EXTERNAL NAME IS DEPT_2_TERM100( cont> (SERIAL_NO INT, LOCATION CHAR); SQL> SHOW CATALOG;/ Catalogs in database with filename inventory PARTS RDB$CATALOG SQL> show schemas;. Schemas in database with filename inventory PARTS.PRINTERS PARTS.TERMINALS RDB$SCHEMA 2 COLLATING_SEQUENCEB Identifies a collating sequence that has been defined using the? OpenVMS National Character Set (NCS) utility. Use the CREATE? COLLATING SEQUENCE statement to identify collating sequencesC other than the database default collating sequence that you planC to use with certain domains. (The default collating sequence forC a database is established by the COLLATING SEQUENCE IS clause inC the CREATE SCHEMA statement; if you omit that clause at database3 definition time, the default sequence is ASCII.)D You must enter a CREATE COLLATING SEQUENCE statement specifying aC collating sequence before you enter the name of that sequence in# any of the following statements:, o CREATE DOMAIN . . . COLLATING SEQUENCE o DROP COLLATING SEQUENCE+ o ALTER DOMAIN . . . COLLATING SEQUENCE o SHOW COLLATING SEQUENCE 3 Environment7 You can use the CREATE COLLATING SEQUENCE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format. CREATE COLLATING SEQUENCE  --+. +-----------------------------------------+0 +--+-------------------------------------+--+0 +-> STORED NAME IS -----+ |0 +-------------------------------------------+- +--+-----------------------------------+-+- +-> COMMENT IS --+-> '' --+-+ |- +------ / <------+ |- +----------------------------------------+0 +----> +-----------------------+->. +-> FROM +  3 Arguments 4 COMMENT_IS@ Adds a comment about the collating sequence. SQL displays the? text when it executes a SHOW COLLATING SEQUENCE statement in? interactive SQL. Enclose the comment within single quotationC marks (') and separate multiple lines in a comment with a slash mark (/). 4 FROM_library_nameC Specifies the name of an NCS library other than the default. The2 default NCS library is SYS$LIBRARY:NCS$LIBRARY. 4 ncs-name@ Specifies the name of a collating sequence in the default NCSD library, SYS$LIBRARY:NCS$LIBRARY, or in the NCS library specified by the library-name argument.A The collating sequence can be either one of the predefined NCSB collating sequences or one that you defined yourself using NCS. 4 sequence-name> Specifies the name by which the collating sequence named inA the ncs-name argument is known to the schema. The ncs-name and+ sequence-name arguments can be the same.  4 STORED_NAME_IS> Specifies a name that Oracle Rdb uses to access a collating> sequence created in a multischema database. The stored nameA allows you to access multischema definitions using interfaces,> such as Oracle RMU, the Oracle Rdb management utility, that@ do not recognize multiple schemas in one database. You cannotD specify a stored name for a collating sequence in a database that# does not allow multiple schemas. 3 Example2 Example 1: Creating a French collating sequence; The following example creates a collating sequence using> the predefined collating sequence FRENCH. It then shows theB defined collating sequence by using the SHOW COLLATING SEQUENCE statement.0 SQL> CREATE COLLATING SEQUENCE FRENCH FRENCH; SQL> -- SQL> SHOW COLLATING SEQUENCE@ User collating sequences in schema with filename SQL$DATABASE FRENCHA Example 2: Create a Spanish collating sequence specifying more than one comment- SQL> CREATE COLLATING SEQUENCE SPANISH_COL6 cont> COMMENT IS 'first comment' / 'second comment' cont> SPANISH;, SQL> SHOW COLLATING SEQUENCE SPANISH_COL; SPANISH_COL Comment: first comment! second comment 2 DATABASE@ Creates database system files, metadata definitions, and user? data that comprise a database. The CREATE DATABASE statementD lets you specify in a single SQL statement all data and privilegeC definitions for a n ew database. (You can also add definitions toA the database later.) For information about ways to ensure goodA performance and data consistency, see the Oracle Rdb7 Guide to# Database Performance and Tuning.> The many optional elements of the CREATE DATABASE statementC make it very flexible. In its simplest form, the CREATE DATABASEB statement creates database system files, specifies their names,? and determines the physical characteristics of the database.D Using the o ptional elements of the CREATE DATABASE statement, you can also specify:D o Whether the database created with CREATE DATABASE is multifileA (separate database root file and storage area data file) or? single file (combined database root file and storage areaA data file). Multifile databases can have many storage areas= for user data, all separate from the database root fileC created by the CREATE DATABASE statement. Multifile databases@ include CREATE ! STORAGE AREA clauses in the CREATE DATABASEB statement to create multiple storage area files for enhanced performance.@ The presence or absence of a CREATE STORAGE AREA clause inA a CREATE DATABASE statement determines whether the databaseB is single file or multifile. To create a multifile database,A you must include a CREATE STORAGE AREA clause in the CREATEB DATABASE statement. To create a single-file database, do notA include a CREATE STORAGE A "REA clause in the CREATE DATABASE statement.D o Values for various database root file parameters that override? the system defaults. Database root file (.rdb) parametersB describe characteristics of the database root file. DatabaseD root file parameters affect the entire database, whether it is, a single-file or a multifile database.= o Values for storage area parameters that override systemC defaults. Storage area parameters describe characteristics # ofA the database storage area files. In a single-file database,= because the storage area data file is combined with theC database root file, storage area parameters apply to a singleA storage area and affect the entire database. In a multifile@ database, storage area parameters specify defaults for theB main storage area, RDB$SYSTEM, and for any subsequent CREATE@ STORAGE AREA clauses within the CREATE DATABASE statement.> o Any number of database $ elements. Database elements are a@ CREATE CATALOG statement, a CREATE STORAGE AREA clause, orC a GRANT statement. The CREATE DATABASE statements that create@ single-file databases cannot include a CREATE STORAGE AREAA clause because this is specific to multifile databases. The@ CREATE DATABASE statements that create multifile databases; must include at least one CREATE STORAGE AREA clause.: Unlike the same statements outside a CREATE DATABASED stat %ement, database elements do not use statement terminators.A The first statement terminator that SQL encounters ends theA CREATE DATABASE statement. Later CREATE or GRANT statements@ are not within the scope of the CREATE DATABASE statement.D o The database default character set and national character set.C For information regarding identifier character sets, databaseB default character sets, and national character sets, see the Character_Sets HELP topic.& 3 Environment- You can use the CREATE DATABASE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format( CREATE DATABASE -+------------------++( +-> ALIAS -+|( +------------ <-----------------------+C ++-----------------------------++------------------------------+-+C +++-> root-f'ile-params-1 ---++++++-> storage-area-params-1 -+++ |C |+-> root-file-params-2 ---+| |+-> storage-area-params-2 -+| |C |+-> root-file-params-3 ---+| +-------------- <------------+ |C |+-> root-file-params-4 ---+| |C +----------- <--------------+ |C +-------------------------- <------------------------------------+= ++--------------------+--+-----------------------+--------->3 +-> character-sets --+ ++-> datab(ase-element -++2 +-------- <-----------+  root-file-params-1 = = -+-> FILENAME -++----------------------++->; +-> PATHNAME ----++-> literal-user-auth -+|; +-> attach-options -------------------------------------+; +-> COLLATING SEQUENCE -----+ |; | +-------------------<---------------------+ |; | ++-----------------------------------+----+ |; | +-> COMMENT IS --- )+-> '' --++ | |; | +------- / <-----+ | |; | +-------------------<---------------------+ |; | +--> -+-----------------------+-----------+; | +-> FROM + |; +-> NUMBER OF USERS -------> ------------+; +-> NUMBER OF BUFFERS -----> ----------+; +-> NUMBER OF CLUSTER NODES ----> --+ |; | +-------------------------*-------------------+ |; | ++----------------------------------------+-------+; | +> ( -+-> SINGLE ---+-> INSTANCE --> ) --+ |; | +-> MULTIPLE -+ |; +-> NUMBER OF RECOVERY BUFFERS -> -----+; +-> BUFFER SIZE IS -> --> BLOCKS -------+ db-attach-spec = ( --+----------------+-> ---> +-> -+ node-spec = + -+-> -+-------------------+-+->+) | +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  attach-options = H -+-> DBKEY -+-> SCOPE IS -+-> ATTACH -------+-----------------------+->F +-> ROWID -+ +-> TRANSACTION --+ , |F +-> MULTISCHEMA IS -+-> ON --+-------------------------------------+F | +-> OFF -+ |F +-> PRESTARTED TRANSACTIONS ARE -+-> ON --+------------------------+F | +-> OFF -+ |F +-+-------+-> RESTRICTED ACCESS -----------------------------------+ +-> NO -+ root-file-params-2 = G -+-> global-buffer-params -----------------------------------------+->E +-> -SNAPSHOT IS ----+-----> ENABLED -+-> IMMEDIATE +-+-----------+E | | +-> DEFERRED -+ | |E | +-----> DISABLED -----------------+ |E +-> DICTIONARY IS ---+---> REQUIRED -------+----------------------+E | +---> NOT REQUIRED ---+ |E +-> ADJUSTABLE LOCK GRANULARITY IS -+-> ENABLED -> alg-options -+-+E | +-> DISABLED ---------------+ |E +-> LO.CK TIMEOUT INTERVAL IS SECONDS ------------+E +-> SEGMENTED STRING -+-> STORAGE AREA IS ------------+E +-> LIST -------------+ |E +-> DEFAULT ----------+ |E +-> PROTECTION IS ---+---> ANSI --+-------------------------------+E | +---> ACLS --+ |E +-> RESERVE +-> CACHE SLOTS ----+-----------------------------+E | / +-> JOURNALS -------+ |E | +-> STORAGE AREAS --+ |E | +-> SEQUENCES ------+ |E +-+-> SET ---+-> TRANSACTION MODES --> ( -+-> txn-modes -+-> ) ---+< +-> ALTER -+ +----- , <-----+ global-buffer-params= 7 --> GLOBAL BUFFERS ARE -+-> ENABLED --+--------------+7 +-> DISABLED -+ |7 +--------------0--------------------------------------+: +---------------------------------------------------+--->6 +> ( -++-> NUMBER IS ----++> ) +1 |+-> USER LIMIT IS ---+|1 |+-> PAGE TRANSFER VIA --+-> DISK ---+--+|1 || +-> MEMORY -+ |1 |+-> LARGE MEMORY IS --+--> ENABLED --+--+1 | +--> DISABLED -+ |1 +------------------- , <----------------+  alg-options = & --+--1----------------------------+--># +-> ( --> COUNT IS --> ) --+ txn-modes = 1 -+-+-------+-+-> READ ONLY -----------------+-->. | +-> NO -+ +-> READ WRITE ----------------+. | +-> BATCH UPDATE --------------+. | +-> SHARED ----+--+----------+-+. | +-> PROTECTED -+ +-> READ --+ |. | +-> EXCLUSIVE -+ +-> WRITE -+ |. +-------------> ALL -----------------------+. +-------------> NONE ----------------------+  root-fi 2le-params-3 = H -+> CARDINALITY COLLECTION IS -------------------------++> ENABLED -+-+H +> CARRY OVER LOCKS ARE ------------------------------++> DISABLED + |H +> GALAXY SUPPORT IS ---------------------------------+ |H +> LOCK PARTITIONING IS ------------------------------+ |H +> LOGMINER SUPPORT IS -------------------------------+ |H +> METADATA CHANGES ARE ------------------------------+ |H +> STATISTICS COLLECTION IS ------------3--------------+ |H +> WORKLOAD COLLECTION IS ----------------------------+ |H +> SYSTEM INDEX -+-> COMPRESSION IS -+-> ENABLED ---+-----+----------+H | | +-> DISABLED --+ | |H | +-> ( -+-> system-index-options -+-> ) --+ |H | +---------- , <-----------+ |H +> prestarted-transaction-params ------------------------------------+H +> SECURITY CHECKING IS --> 4security-checking-options ---------------+H +> SYNONYMS ARE ENABLED ---------------------------------------------+H +> NOTIFY IS -+-> ENABLED --> notify-options -+---------------------+2 +-> DISABLED --------------------+ system-index-options = F -+-> COMPRESSION IS --------------------------------++- ENABLED -++->D +-> PREFIX CARDINALITY COLLECTION IS --------------++> DISABLED +|D +-> PREFIX CARDINALITY COLLECTION IS ENABLED FULL ---------------+D +-> TYPE IS 5SORTED --+-----------+-------------------------------+$ +-> RANKED -+ prestarted-transaction-params = Q -> PRESTARTED TRANSACTIONS ARE -++--> ENABLED -++----------------------------++>P |+--> ON -----++->(prestart-trans-options) -+|P +-+-> DISABLED --+----------------------------+3 +-> OFF -------+ prestart-trans-options = ' -+-------------------------6--------+->% +-> WAIT SECONDS FOR TIMEOUT -+% +-> WAIT MINUTES FOR TIMEOUT -+% +-> NO TIMEOUT -------------------+ security-checking-options = E -+-> EXTERNAL -+------------------------------------------------++->C | +-> ( -> PERSONA SUPPORT IS -+-> ENABLED --+> ) -+|C | +-> DISABLED -+ |C +-> INTERNAL -+-----------------------------------------------+-+A +-> ( -> ACCOUNT CHECK IS -+---> E7NABLED --+> ) +< +---> DISABLED -+ notify-options = = --+-----------------------------------------------------+-->: +--> ( ALERT OPERATOR -+--> operator-class -+-- ) --+2 +--------- + <---------+  root-file-params-4 = H -+-> ASYNC BATCH WRITES ARE +> ENABLED -> async-bat-wr-options -+---+->F | +> DISABLED ------------------------+ |F ++------------+-> ASYNC PREFETCH I8S --+ |F |+> DETECTED -+ +-------------------+ |F | +-+-> ENABLED ---> async-prefetch-options +------+F | +-> DISABLED ---------------------------+ |F +-> ROW CACHE IS -+-> ENABLED --+-+----------------------+---------+F | +-> DISABLED -+ +-> row-cache-options -+ |F +-+------+-> INCREMENTAL BACKUP SCAN OPTIMIZATION -----------------+F | +> NO -+ 9 |F +-> MULTITHREAD AREA ADDITIONS ----> multithread-options ----------+F +-> RECOVERY JOURNAL -> ( -> ruj-options -> ) ---------------------+F +-> OPEN IS -+> MANUAL --------------------------------------------+F | +> AUTOMATIC -+--------------------------------------++F | +->(WAIT -> MINUTES -> FOR CLOSE) -+|F +-> SHARED MEMORY IS -+-> SYSTEM -------------------+--------------+7 +-> PROCESS -+--:-----------+--+4 +-> RESIDENT -+ asynch-bat-wr-options = C -+----------------------------->-------------------------------+->A + ( ++-> CLEAN BUFFER COUNT IS BUFFERS --++> ) +< |+-> MAXIMUM BUFFER COUNT IS BUFFERS +|< +------------------- , <-----------------------------+  async-prefetch-options = A --+-----------------------------------------------------------+>@ +-> ( -+-+-> DEPTH IS <;number-buffers> BUFFERS -----+--+> )-+; | +-> THRESHOLD IS BUFFERS -+ |; +----------------- , <--------------------------+  row-cache-options = L -> ( -++-> CHECKPOINT -+-> ALL ROWS TO BACKING FILE -----------+-++-> ) -->D || +-> TIMED EVERY SECONDS ------------+ ||D || +-> UPDATED ROWS TO -+-> BACKING FILE -++ ||D || +-> DATABASE -----+ ||D |+-> LOCATI <ON IS --> ---------------------+|D |+-> NO --+--> LOCATION --------+--------------------------+|D || +--> SWEEP INTERVAL --+ ||D |+-> NUMBER OF SWEEP ROWS IS --------------------------+|D |+-> SWEEP INTERVAL IS SECONDS ------------------------+|D +-------------------------- , <-----------------------------+ multithread-options = 2 ---+-----------------------------------------+-->/ +-> ( --+-> AL=L AREAS -----------+--> ) --+& +-> LIMIT TO AREAS --+  ruj-options = , -+-> LOCATION IS --> -+-->) +-> NO LOCATION ----------------------+) +-> BUFFER MEMORY IS -+-> LOCAL ------+) +-> GLOBAL -----+ storage-area-params-1 = ; --+-> ALLOCATION IS ---> --> PAGES -----+->9 +-> CACHE USING --------------------+9 +-> NO ROW CACHE ------------------------------------+9 +-> e>xtent-params -----------------------------------+9 +-> INTERVAL IS --> -------------+9 +-> LOCKING IS --+-> ROW --+--> LEVEL ---------------+9 | +-> PAGE -+ |9 +-> PAGE FORMAT IS +-> UNIFORM -+--------------------+9 | +-> MIXED ---+ |9 +-> PAGE SIZE IS ----> --> BLOCKS -----+  extent-params = 6 --+-> EXTENT IS -+-> ENABLED -------------------++-->3 | ? +-> DISABLED ------------------+|3 | +-> --> PAGES --+|3 | +-> (extension-options) -------+|3 +---------------------<------------------------+  extension-options = ' ---> MINIMUM OF PAGES, --+' +------------------------------------+' +--> MAXIMUM OF PAGES, --+' +------------------------------------+) +--> PERCENT GROWTH IS ------->  storage-area-params-2 = @ --+-> C @HECKSUM CALCULATION IS -----------+--+-> ENABLED --+-+->> +-> SNAPSHOT CHECKSUM CALCULATION IS --+ +-> DISABLED -+ |> +-> SNAPSHOT ALLOCATION IS --> ----> PAGES ---+> +-> SNAPSHOT EXTENT IS -+-> ----> PAGES --++> | +-> (extension-options) ---------+|> +-> SNAPSHOT FILENAME --> --------------------+> +-> THRESHOLDS ARE ( +-----------------------+> ) -+> | +> , -+----------++ |>A | +> , + |> +------------------------------<--------------------------+  character-sets = 9 -+-+--> DEFAULT CHARACTER SET --+-+->7 | +--> NATIONAL CHARACTER SET -+ |7 | +--> IDENTIFIER CHARACTER SET -+ |7 | +--> DISPLAY CHARACTER SET ----+7 +---------------------- <---------------------------+ database-element = / -+-> create-cache-c Blause -----------------+-->, +-> create-catalog-statement ------------+, +-> create-collating-sequence-statement -+, +-> create-domain-statement -------------+, +-> create-function-statement -----------+, +-> create-index-statement --------------+, +-> create-module-statement -------------+, +-> create-procedure-statement ----------+, +-> create-sequence-statement -----------+, +-> create-schema-statement -------------+, +-> create-storage-area-clause ----------+, +-> create-stoCrage-map-statement --------+, +-> create-table-statement --------------+, +-> create-trigger-statement ------------+, +-> create-view-statement ---------------+, +-> grant-statement ---------------------+ 3 Arguments 4 ADJUSTABLE_LOCK_GRANULARITY Syntax options:, ADJUSTABLE LOCK GRANULARITY IS ENABLED- ADJUSTABLE LOCK GRANULARITY IS DISABLEDDEnables or disables whether or not the database system automatically=maintains as few locks as possible on Ddatabase resources. TheCdefault is ENABLED and results in fewer locks against the database.DHowever, if contention for database resources is high, the automaticDadjustment of locks can become a CPU drain. Such databases can tradeCmore restrictive locking for less CPU usage by disabling adjustablelock granularity. 4 alias< Specifies the alias for the implicit database declarationD executed by the CREATE DATABASE statement. An alias is a name forB a particular attach to a da Etabase that identifies that database in subsequent SQL statements.& NOTE> If you attach to a database using an alias, you must useA that alias in subsequent statements to qualify the names of elements in that database.@ If you omit the FILENAME argument from the database root file? parameters, SQL also uses the alias as the file name for the> database root file and creates the root file in the currentB default directory. (SQL F generates a syntax error if you includeC a disk or directory specification in the alias clause.) You must1 specify either the FILENAME or alias argument.B Schema elements in the CREATE DATABASE statement do not need to? use the alias, however, they cannot specify any other alias.A The alias clause is optional. The default alias in interactive> SQL and in precompiled programs is RDB$DBHANDLE. In the SQL= module language, the default is the alias specified in the? modul Ge header. Using the default alias (either by specifyingB it explicitly in the ALIAS clause or omitting the ALIAS clause)> declares the database as the default database. Specifying a< default database means that statements outside the CREATE? DATABASE statement that refer to the default database do not need to use an alias.B If a default database was already declared, and you specify theC default alias in the ALIAS clause (or specify any alias that wasD already declared), Hthe results depend on the environment in which+ you issue the CREATE DATABASE statement.A o In interactive SQL, you receive a prompt asking if you want> to override the default database declaration. Unless you= explicitly override the default declaration, the CREATE DATABASE statement fails.: SQL> -- Assume a default database has been declared: SQL> --5 SQL> -- Now create a database without an alias.; SQL> -- SQL asks if you want to override I the default:) SQL> CREATE DATABASE FILENAME test;+ This alias has already been declared.: Would you like to override this declaration (No)? NOL %SQL-F-DEFDBDEC, A database has already been declared with the default alias? o In embedded SQL or in the SQL module language, specifying@ an already-declared alias in the CREATE DATABASE statementC generates an error when you precompile the program or compile the module.D o In dynamic SQL, Jspecifying an already-declared alias overrides the earlier declaration.> For more information about default databases, see the User_ Supplied_Names HELP topic. 4 ALL_AREASA Specifies that all storage areas be created and initialized in parallel.D All storage areas are created asynchronously. If you are creatingB a large number of storage areas, you may exceed process quotas,. resulting in the database creation failing. 4 ALLOCATION_n_pagesD T Khe number of database pages allocated to the database initially.D SQL automatically extends the allocation to handle the loading ofB data and subsequent expansion. Pages are allocated in groups ofD 3. An ALLOCATION of 25 pages would actually provide for 27 pages.C The default is 700 pages. If you are loading a large database, a6 large allocation helps to prevent fragmented files. 4 ALTER_TRANSACTION_MODESA Enables the modes specified, leaving the previously defined or> L default modes enabled. For example, if the only transaction@ mode you want to disable are batch updates, use the following statement:- SQL> CREATE DATABASE FILENAME mf_personnel5 cont> ALTER TRANSACTION MODES (NO BATCH UPDATE);9 If not specified, the default transaction mode is ALL. 4 ASYNC_BATCH_WRITES Syntax options:C ASYNC BATCH WRITES ARE ENABLED | ASYNC BATCH WRITES ARE DISABLED= Specifies whether asynchronous batch-writes are enabled or d Misabled.@ Asynchronous batch-writes allow a process to write batches ofC modified data pages to disk asynchronously (the process does notB stall while waiting for the batch-write operation to complete).> Asynchronous batch-writes improve the performance of update3 applications without the loss of data integrity.C By default, batch-writes are enabled. For more information aboutC when to use asynchronous batch-writes, see the Oracle Rdb7 Guide& to Database Performance andN Tuning.C You can enable asynchronous batch-writes by defining the logical name RDM$BIND_ABW_ENABLED. 4 ASYNC_PREFETCH Syntax options:9 ASYNC PREFETCH IS ENABLED | ASYNC PREFETCH IS DISABLEDA Specifies whether or not Oracle Rdb reduces the amount of timeB that a process waits for pages to be read from disk by fetching6 pages before a process actually requests the pages.= Prefetch can significantly improve performance, but it may@ cause excessive resOource usage if it is used inappropriately.D Asynchronous prefetch is enabled by default. For more information< about asynchronous prefetch, see the Oracle Rdb7 Guide to# Database Performance and Tuning.D You can enable asynchronous prefetch by defining the logical name RDM$BIND_APF_ENABLED. 4 BUFFER_SIZED Specifies the number of blocks SQL allocates per buffer. You need@ to specify an unsigned integer greater than zero. The default? buffer size is 3 times the PAGE P SIZE value (6 blocks for the default PAGE SIZE of 2).A The buffer size is a global parameter and the number of blocks= per page (or buffer) is constrained to less than 64 blocksA per page. The page size can vary by storage area for multifileD databases, and the page size should be determined by the sizes of8 the records that will be stored in each storage area.D When choosing the number of blocks per buffer, choose a number soC that a round number of pages fits in th Qe buffer. In other words,@ the buffer size is wholly divisible by all page sizes for all@ storage areas in your multifile database. For example, if youA have three storage areas with page sizes of 2, 3, and 4 blocksA each respectively, choosing a buffer size of 12 blocks ensuresB optimal buffer utilization. In contrast, choosing a buffer sizeC of 8 wastes 2 blocks per buffer for the storage area with a pageB size of 3 pages. Oracle Rdb reads as many pages as fit into the? bRuffer; in this instance it reads two 3-block pages into the# buffer, leaving 2 wasted blocks. 4 CACHE_USINGC Assigns the named row cache as the default for all storage areasD in the database. All rows stored in an area, whether they consist@ of table data, segmented string data, or special rows such as index nodes, are cached.> You must create the row cache before terminating the CREATE# DATABASE statement. For example:( SQL> CREATE DATABASE FILENAME test_db S cont> ROW CACHE IS ENABLED cont> CACHE USING test1 cont> CREATE CACHE test1" cont> CACHE SIZE IS 100 ROWS# cont> CREATE STORAGE AREA area1;< You can override the database default row cache by eitherB specifying the CACHE USING clause after the CREATE STORAGE AREA? clause or by later altering the database and storage area toA assign a new row cache. Only one row cache is allowed for each storage area.C If you do not specify the CACHE USING clause or theT NO ROW CACHE8 clause, NO ROW CACHE is the default for the database. 4 CARDINALITY_COLLECTION Syntax options:' CARDINALITY COLLECTION IS ENABLED( CARDINALITY COLLECTION IS DISABLED:Specifies whether or not the optimizer records cardinalityAupdates in the system table. When enabled, the optimizer collects>cardinalities for the table and non-unique indexes as rows are@inserted or deleted from tables. The update of the cardinalitiesDis performed at commit time, iUf sufficient changes have accumulated,or at disconnect time.< In high update environments, it may be more convenient to@ disable cardinality updates. If you disable this feature, youC should manually maintain the cardinalities using the RMU AnalyzeB Cardinality command so the optimizer is given the most accurate" values for estimation purposes.0 Cardinality collection is enabled by default. 4 CARRY_OVER_LOCKS Syntax options:? CARRY OVER LOCKS ARE ENABLED | VCARRY OVER LOCKS ARE DISABLED? Enables or disables carry-over lock optimization. Carry-over locks are enabled by default.A While attached to the database, a process can have some active= locks (locks attached to the database) and some carry-over? locks (locks requested in earlier transactions that have not@ been demoted). If a transaction needs a lock it has currentlyC marked as carry-over, it can reuse the lock by changing it to anA active lock. The same lock can go W from active to carry-over toD active multiple times without paying the cost of lock request andC demotion. This substantially reduces the number of lock requests3 if a process accesses the same areas repeatedly.D As part of the carry-over lock optimization, a NOWAIT transactionB requests, acquires, and holds a NOWAIT lock. This signals otherD processes accessing the database that a NOWAIT transaction existsC and causes Oracle Rdb to release all carry-over locks. If NOWAITCX transactions are noticeably slow when executing, you can specifyB CARRY OVER LOCKS ARE DISABLED with the ALTER DATABASE or CREATE DATABASE statement.@ This feature is available as an online database modification. 4 CHECKPOINT_TIMED Syntax option:# CHECKPOINT TIMED EVERY n SECONDSA For the row-cache-options clause, specifies the frequency withD which the row-cache server (RCS) process checkpoints the contentsC of the row caches back to disk. The RCS proYcess does not use the: checkpoint frequency options of the FAST COMMIT clause.A The frequency of RCS checkpointing is important in determiningD how much of an .aij file must be read during a recovery operation? following a node failure. It also affects the frequency withB which marked records get flushed back to the database for thoseC row caches that checkpoint to the database. The default is every 15 minutes (900 seconds). 4 Checkpoint_Rows Syntax options:Z* CHECKPOINT UPDATED ROWS TO BACKING FILE& CHECKPOINT UPDATED ROWS TO DATABASE& CHECKPOINT ALL ROWS TO BACKING FILE< Specifies the default source and target during checkpointD operations for all row caches. If ALL ROWS is specified, then theC source records written during each checkpoint operation are bothB the modified and the unmodified rows in a row cache. If UPDATEDD ROWS is specified, then just the modified rows in a row cache are checkpointed each time.= I [f the target of the checkpoint operation is BACKING FILE,> then the RCS process writes the source row cache entries to@ the backing (.rdc) files. The row cache LOCATION, ALLOCATION,@ and EXTENT clauses are used to create the backing files. UponA recovery from a node failure, the database recovery process isB able to repopulate the row caches in memory from the rows found in the backing files.< If the target is DATABASE, then updated row cache entries< are written back to t\he database. The row cache LOCATION,A ALLOCATION, and EXTENT clauses are ignored. Upon recovery fromC a node failure, the database recovery process has no data on theC contents of the row cache. Therefore, it does not repopulate the row caches in memory.A The CHECKPOINT clause of the CREATE CACHE, ADD CACHE, or ALTER@ CACHE clause overrides this database-level CHECKPOINT clause. 4 CHECKSUM_CALCULATION Syntax options:% CHECKSUM CALCULATION IS ENABLED& ] CHECKSUM CALCULATION IS DISABLED@This option allows you to enable or disable calculations of pageDchecksums when pages are read from or written to the storage area orsnapshot files. The default is ENABLED.& NOTE; Oracle Corporation recommends that you leave checksum1 calculations enabled, which is the default.@ With current technology, it is possible that errors may occur< that the checksum calculation can detect but that may ^ not= be detected by either the hardware, firmware, or software.C Unexpected application results and database corruption may occurD if corrupt pages exist in memory or on disk but are not detected.B Oracle Corporation recommends performing checksum calculations,2 except in the following specific circumstances:B o Your application is stable and has run without errors on theA current hardware and software configuration for an extended period of time.> o You _have reached maximum CPU utilization in your current; configuration. Actual CPU utilization by the checksum? calculation depends primarily on the size of the database? pages in your database. The larger the database page, theC more noticeable the CPU usage by the checksum calculation may become.& NOTE? Oracle Corporation recommends that you carefully evaluate> the trade-off between reducing CPU usage by the checksum`B calculation and the potential for loss of database integrity, if checksum calculations are disabled.@ Oracle Rdb allows you to disable and, subsequently, re-enable= checksum calculation without error. However, once checksum< calculations have been disabled, corrupt pages may not be> detected even if checksum calculations are subsequently re- enabled. 4 CLEAN_BUFFER_COUNT Syntax options:- CLEAN BUFFER COUNT IS buffer-count BUFFERS; Specifies t ahe number of buffers to be kept available for immediate reuse.= Oracle Rdb maintains the number of buffers at the end of aA process' least recently used queue of buffers for replacement.= The default is five buffers. The minimum value is one; the9 maximum value can be as large as the buffer pool size.? You can override the number of clean buffers by defining theD logical name RDM$BIND_CLEAN_BUF_CNT. For information about how toD set the values, see the Oracle Rdb7b Guide to Database Performance and Tuning. 4 COLLATING_SEQUENCEA Specifies a default collating sequence to be used for all CHAR< and VARCHAR columns in the database. SQL uses the default@ collating sequence if you do not specify a collating sequence* in subsequent CREATE DOMAIN statements.D Collation-name is a name of your choosing; you must use this nameA in any COLLATING SEQUENCE clauses that refer to this collating, sequence for operations on this database.c 4 COMMENT Syntax option: COMMENT IS 'string'@ Adds a comment about the collating sequence. SQL displays the? text when it executes a SHOW COLLATING SEQUENCE statement inA interactive SQL. Enclose the comment in single quotation marksB (') and separate multiple lines in a comment with a slash mark (/). 4 COUNT_IS_n? Specifies the number of levels on the page lock tree used toC manage locks. For example, if you specify COUNT IS 3, the fanoudtD factor is (10, 100, 1000). Oracle Rdb locks a range of 1000 pages@ and adjusts downward to 100 and then to 10 and then to 1 page when necessary.D If the COUNT IS clause is omitted, the default is 3. The value of n can range from 1 through 8. 4 create-cache-clause0 See the CREATE CACHE clause for more details. 4 create-catalog-statement0 See the CREATE CATALOG statement for details.@ If you want to specify a CREATE CATALOG statement in a CREATEA e DATABASE statement, you must first specify a MULTISCHEMA IS ON0 clause in the same CREATE DATABASE statement.C The CREATE CATALOG statement is committed immediately and cannotC be rolled back. Before you specify the CREATE CATALOG statement,) the following conditions must be true:. o The database is enabled for multischema.! o No transactions are active.? o The catalog alias must be the same as the database alias.C For information about enabling the databasef for multischema, see& the User_Supplied_Names HELP topic. &4 create-collating-sequence-statement; See the CREATE COLLATING_SEQUENCE statement for details.A If you want to specify a collating sequence in a CREATE DOMAIND statement embedded in a CREATE DATABASE statement, you must firstC specify a CREATE COLLATING SEQUENCE statement in the same CREATE DATABASE statement. 4 create-domain-statement/ See the CREATE DOMAIN statement for details.< You can gnot use the FROM path-name clause when embedding a> CREATE DOMAIN statement in a CREATE DATABASE statement. YouC can, however, issue a separate CREATE DOMAIN statement followingB the CREATE DATABASE statement. You can also describe the domain- directly in the CREATE DATABASE statement.? If you want to specify a collating sequence in your embedded; CREATE DOMAIN statement, you must first specify a CREATE; COLLATING SEQUENCE statement in the same CREATE DATABASE statementh. 4 create-function-statementD A CREATE FUNCTION statement. See the CREATE Routine statement for details. 4 create-index-statement. See the CREATE INDEX statement for details. 4 create-module-statement/ See the CREATE MODULE statement for details. 4 create-procedure-statementA A CREATE PROCEDURE statement. See the CREATE Routine statement for details. 4 create-schema-statement/ See the CREATE SCHEMA statement for details.iD The schema you create must have the same alias as the catalog andC database that contain the schema, or they must share the default alias. 4 create-sequence-statement1 See the CREATE SEQUENCE statement for details. 4 create-storage-area-clause: See the CREATE STORAGE_AREA statement for more details. 4 create-storage-map-statement4 See the CREATE STORAGE_MAP statement for details. 4 create-table-statement. See the CREATE TABLE stat jement for details.C You cannot use the FROM path-name clause when embedding a CREATED TABLE statement in a CREATE DATABASE statement. You can, however,? issue a separate CREATE TABLE statement following the CREATEB DATABASE statement. You can also describe the table directly in! the CREATE DATABASE statement.A The CREATE TABLE statements in a CREATE DATABASE statement can@ refer to domains not yet created, provided that CREATE DOMAIN= statements for the domains are in tkhe same CREATE DATABASE statement. 4 create-trigger-statement0 See the CREATE TRIGGER statement for details. 4 create-view-statement- See the CREATE VIEW statement for details. 4 database-elementA Database elements are a CREATE STORAGE AREA clause, any of theC CREATE statements (except CREATE DOMAIN . . . FROM path-name and< CREATE TABLE . . . FROM path-name), or a GRANT statement. 4 DBKEY_SCOPE Syntax options:5 DBKEY SCOPE l IS ATTACH | DBKEY SCOPE IS TRANSACTIOND Controls when the database key of a deleted row can be used againB by SQL. This setting is not a database root file parameter, but? a characteristic of the implicit database attach executed byC the CREATE DATABASE statement. Thus, the DBKEY SCOPE clause in aB CREATE DATABASE statement takes effect only for the duration of5 the session of the user who entered the statement.? o The default DBKEY SCOPE IS TRANSACTION means that SQL ca mnB reuse the database key of a deleted table row (to refer to aA newly inserted row) as soon as the transaction that deletedA the original row completes with a COMMIT statement. (If theD user who deleted the original row enters a ROLLBACK statement,@ then the database key for that row cannot be used again by SQL.)> During the connection of the user who entered the CREATE? DATABASE statement, the DBKEY SCOPE IS TRANSACTION clauseA specifies nthat a database key is guaranteed to refer to the4 same row only within a particular transaction.D o The DBKEY SCOPE IS ATTACH clause means that SQL cannot use theA database key again (to refer to a newly inserted row) untilA all users who have attached with DBKEY SCOPE IS ATTACH have! detached from the database.< Also it only requires one process to attach with DBKEY@ SCOPE IS ATTACH to force all database users to assume this characteristic.D o o Oracle Corporation recommends using DBKEY SCOPE IS TRANSACTION? to prevent excessive consumption of storage area space by> overhead needed to support DBKEY SCOPE IS ATTACH, and to9 prevent performance problems when storing new rows.> During the connection of the user who entered the CREATED DATABASE statement, the DBKEY SCOPE IS ATTACH clause specifies@ that a database key is guaranteed to refer to the same row0 until the user detaches from the databpase.2 For more information, see the DBKEY HELP topic. 4 DEFAULT_CHARACTER_SETB Specifies the database default character set for this database.= For a list of allowable character set names, see Supported Character Sets. 4 DEFAULT_STORAGE_AREA> Specifies a default storage area to which all user data andB unmapped indexes are stored. The DEFAULT STORAGE AREA parameterC separates user data from the system data, such as system tables.A RDB$SYSTEM is the def!qault area if you do not specify a default storage area.C In addition to user data, Oracle Rdb stores the following system& tables in the default storage area: o RDB$INTERRELATIONS o RDB$MODULES o RDB$ROUTINES o RDB$PARAMETERS o RDB$QUERY_OUTLINES o RDB$SEQUENCES o RDB$PROFILES o RDB$GRANTED_PROFILES o RDB$TYPES o RDB$TYPE_FIELDS o RDB$WORKLOAD o RDB$OBJECT_SYNONYMS o RDB$SYNONYMS o RDB$rCATALOG_SCHEMA9 For information on moving these system tables to otherA storage areas, see the Oracle Rdb Guide to Database Design and Definition.@ The DEFAULT STORAGE AREA parameter must reference an existingB storage area. You must create the storage area using the CREATEC STORAGE AREA clause in the same CREATE DATABASE statement as the" DEFAULT STORAGE AREA parameter. 4 DEPTH_buffers_option Syntax option:" DEPTH IS number-buffers BUFFERS= Specisfies the number of buffers to prefetch for a process.C The default is one-quarter of the buffer pool, but not more thanB eight buffers. You can override the number of buffers specifiedB in the CREATE or ALTER DATABASE statements by using the logical name RDM$BIND_APF_DEPTH.D You can also specify this option with the DETECTED ASYNC PREFETCH clause. 4 DETECTED_ASYNC_PREFETCH Syntax options:( DETECTED ASYNC PREFETCH IS ENABLED) DETECTED ASYNC PREFETC tH IS DISABLEDCSpecifies whether or not Oracle Rdb reduces the amount of time that/a process waits for pages to be read from disk.D By using heuristics, detected asynchronous prefetch determines ifB an I/O pattern is sequential in behavior even if sequential I/OB is not actually executing at the time. For example, when a LIST@ OF BYTE VARYING column is fetched, the heuristics detect thatD the pages being fetched are sequential and asynchronously fetchesA pages further in the usequence. This avoids wait times when the page is really needed.8 Detected asynchronous prefetch is enabled by default. 4 DICTIONARY Syntax options:6 DICTIONARY IS REQUIRED | DICTIONARY IS NOT REQUIRED@ Specifies whether or not definition statements issued for theA database must also be stored in the repository. If you specifyB REQUIRED, any data definition statements issued after a DECLARED DATABASE statement that does not use the PATHNAME argument fails.v> If you omit the PATHNAME clause from the database root file@ parameters in the CREATE DATABASE statement, SQL generates an4 error if you also specify DICTIONARY IS REQUIRED.- The default is DICTIONARY IS NOT REQUIRED. 4 DISPLAY_CHARACTER_SETD Specifies the character set encoding and characteristics expected8 of text strings returned back to SQL from Oracle Rdb. 4 EXTENT_clause Syntax options:) EXTENT IS ENABLED | EXTENT IS DISABLED? Enables owr disables extents. Extents are enabled by default.> You can encounter performance problems when creating hashed= indexes in storage areas with the mixed page format if theB storage area was created specifying the wrong size for the areaA and if extents are enabled. By disabling extents, this problem? can be diagnosed early and corrected to improve performance. 4 EXTENT_pages Syntax options:> EXTENT IS extent-pages PAGES| EXTENT IS (extension-options)B Spexcifies the number of pages of each storage area file extent.: For more information, see the SNAPSHOT EXTENT argument. 4 FILENAME_file_spec7 The file specification associated with the database.D You can omit the FILENAME clause if you specify the ALIAS clause.C If you omit the FILENAME clause, the file specification uses the following defaults:0 o Device: the current device for the process6 o Directory: the current directory for the processD o File name: y the alias, if any was specified; otherwise omitting, the FILENAME clause generates an error9 Use either a full file specification or a partial file specification.7 You can use a logical name for all or part of a file specification.A If you use a simple file name, SQL creates the database in theC current default directory. Because the CREATE DATABASE statementC may create more than one file with different file extensions, do< not specify a file extension wi zth the file specification.< The file specification may contain an OpenVMS remote nodeB specification. Oracle Rdb must be installed on that remote nodeB so that the CREATE DATABASE statement can be executed remotely.B Note that all other file specifications in the command (storageD areas, snapshot files, recovery journal location, and so on) mustD be specified using the logical names and device names relative to that remote node.D The number and type of files created using {the file specificationB in the FILENAME clause depend on whether you create a multifile or single-file database.? o In multifile CREATE DATABASE statements (any that includeC CREATE STORAGE AREA clauses), SQL uses the file specification" to create up to three files:9 - A database root file with an .rdb file extensionB - A storage area file, with an .rda file extension, for theC main storage area, RDB$SYSTEM, (unless the CREATE DATABASED | statement contains a CREATE STORAGE AREA RDB$SYSTEM clause,1 which overrides this file specification)> - A snapshot file, with an .snp file extension, for theB main storage area, RDB$SYSTEM (unless the CREATE DATABASED statement contains a CREATE STORAGE AREA RDB$SYSTEM clause,1 which overrides this file specification)B o In single-file CREATE DATABASE statements (any that omit theB CREATE STORAGE AREA clause), SQL uses the file specification} to create two files:B - A combined root and data file with an .rdb file extension4 - A snapshot file with an .snp file extensionC If you create a single-file database, you cannot later createB additional data and snapshot files with ALTER DATABASE . . .C ADD STORAGE AREA statements. If you want to change a databaseB from a single-file to a multifile database, you must use the# EXPORT and IMPORT statements. 4 FROM_library_name> S~pecifies the name of an NCS library other than the default? library. The default NCS library is SYS$LIBRARY:NCS$LIBRARY. 4 GALAXY_SUPPORT Syntax options:7 GALAXY SUPPORT IS ENABLED|GALAXY SUPPORT IS DISABLED9 Allows global memory to be shared in an OpenVMS Galaxy8 configuration. Galaxy support is disabled by default.B OpenVMS Galaxy is a software architecture for the OpenVMS AlphaA operating system that enables multiple instances of OpenVMS toA execute coo peratively in a single computer. An instance refersC to a copy of the OpenVMS Alpha operating system. As an extensionD of the existing OpenVMS cluster support within Oracle Rdb, OracleB Rdb provides support for databases opened on multiple instances@ (or nodes) within a Galaxy system to share data structures inA memory. Within an Oracle Rdb Galaxy environment, all instances with an open database share:D o Database root objects (for example, TSN blocks and SEQ blocks)!  o Global buffers (if enabled)@ o Row caches and Row Cache Server process (RCS) (if enabled) 4 GLOBAL_BUFFERS Syntax options:; GLOBAL BUFFERS ARE ENABLED | GLOBAL BUFFERS ARE DISABLED= Specifies that Oracle Rdb maintains one global buffer pool@ per VMScluster node for each database. By default, Oracle RdbC maintains a local buffer pool for each attach. For more than one@ attach to use the same page, each must read it from disk intoA its local buffer pool. A page in the global buffer pool may beC read by more than one attach at the same time, although only oneD process reads the page from the disk into the global buffer pool.@ Global buffering provides improved performance because I/O is) reduced and memory is better utilized.& NOTE? If GALAXY SUPPORT is enabled, then a single global buffer) pool is shared by all Galaxy nodes. 4 grant-statement' See the GRANT statement for details. 4 IDENTIFIER_CHARACTER_SETD Specifies the identifier character set for user-supplied databaseD object names, such as table names and column names. The character< set must contain ASCII characters. See the Oracle Rdb SQL; Reference Manual for a list of allowable character sets. '4 INCREMENTAL_BACKUP_SCAN_OPTIMIZATION Syntax option:* INCREMENTAL BACKUP SCAN OPTIMIZATION- NO INCREMENTAL BACKUP SCAN OPTIMIZATIONBSpecifies whether Orac le Rdb checks each area's SPAM pages or each8database page to find changes during incremental backup.B If you specify INCREMENTAL BACKUP SCAN OPTIMIZATION, Oracle Rdb? checks each area's SPAM pages and scans the SPAM interval ofA pages only if the SPAM transaction number (TSN) is higher thanD the root file backup TSN, which indicates that a page in the SPAMB interval has been updated since the last full backup operation.7 Updates in the SPAM interval result in an extra I/O.D  Specify INCREMENTAL BACKUP SCAN OPTIMIZATION if your database hasB large SPAM intervals or infrequently occurring updates, and you5 want to increase the speed of incremental backups.A If you specify NO INCREMENTAL BACKUP SCAN OPTIMIZATION, OracleB Rdb checks each page to find changes during incremental backup.@ Specify the NO INCREMENTAL BACKUP SCAN OPTIMIZATION clause ifA your database has frequently occurring updates, uses bulk-loadB operations, or does not use incremental backups, or if you want# to improve run-time performance.7 The default is INCREMENTAL BACKUP SCAN OPTIMIZATION. 4 INTERVALC Specifies the number of data pages between space area managementC (SPAM) pages in the storage area file, and therefore the maximumD number of data pages each space area management page will manage.A The default, and also the minimum interval, is 216 data pages.A The first page of each storage area is a space area managementC page. T he interval you specify determines where subsequent space? area management pages are to be inserted, provided there areC enough data pages in the storage file to require more space area management pages.= You cannot specify the INTERVAL storage area parameter for@ single-file databases, and you cannot specify INTERVAL unless4 you also explicitly specify PAGE FORMAT IS MIXED.? Oracle Rdb calculates the maximum interval size based on the@ number of blocks per page and r eturns an error message if youB exceed this value. For example, when the page size is 2 blocks,= the maximum interval is 4008 pages. If you try to create aA storage area with the interval set to 4009, Oracle Rdb returns the following error message:P %RDB-E-BAD_DPB_CONTENT, invalid database parameters in the database parameter block (DPB)M -RDMS-F-SPIMAX, spam interval of 4009 is more than the Rdb maximum of 4008 -RDMS-F-AREA_NAME, area NEW; For more information about setting space area management@ parameters, see the Oracle Rdb Guide to Database Maintenance. 4 LARGE_MEMORY Syntax options:5 LARGE MEMORY IS ENABLED | LARGE MEMORY IS DISABLEDB Specifies whether or not large memory is used to manage the rowB cache. Very large memory (VLM) allows Oracle Rdb to use as much# physical memory as is available.? Use the LARGE MEMORY IS ENABLED clause only when both of the following are true:# o You have enabled row caching.A o You want to cache large amounts of data, but the cache does+ not fit in the virtual address space.6 The default is the LARGE MEMORY IS DISABLED clause. 4 LIMIT_TO_n_AREASC Specifies the number of storage areas to be created in parallel.A The number of areas should be smaller than the current processD file open quota. The number of areas can range from between 1 and- the number of storage areas being created. 4 LIST_STORAGE_AREA>  Specifies the name of the storage area to be used for tableA columns defined through SQL with the LIST OF BYTE VARYING data type.@ You can specify the LIST STORAGE AREA parameter for multifile databases only.B By default, columns with the LIST OF BYTE VARYING data type areD stored in the RDB$SYSTEM storage area. If you specify a differentB storage area in this clause, the CREATE DATABASE statement must? include a CREATE STORAGE AREA clause defining that area. For? i nformation about creating multiple list storage areas for a- table, see the CREATE STORAGE_AREA clause.& NOTE@ If you plan to store lists with segments of widely varying= sizes, you should specify a MIXED page format area just@ for list storage. (Do not assign tables and indexes to the area.)A The database system looks for free space in an area when it? stores each segment of a segmented string. If size varies= significantly among the different segments of the lists? that you plan to store, the interval and threshold valuesA that the database system automatically sets for page format? areas you specify as UNIFORM can make storing lists time-@ consuming. For a mixed page format area, you can customizeA interval and thresholds values to reduce the amount of timeA that the database system spends looking for free space when@ it stores different segments of the same segmented string.@ The following example shows valid syntax for the LIST STORAGE AREA clause:% SQL> CREATE DATABASE FILENAME test+ cont> LIST STORAGE AREA IS registry_areaD cont> CREATE STORAGE AREA RDB$SYSTEM FILENAME maintenance_areaE cont> CREATE STORAGE AREA registry_area FILENAME registry_area;' SQL> CREATE STORAGE MAP registry_map& cont> STORE LISTS IN registry_area; 4 literal-user-auth@ Specifies the user name and password for access to databases, particularly remote database.B This literal lets you explicitly provide user name and password0 information in the CREATE DATABASE statement. 4 LOCATION_IS_directory_specA Specifies the name of the backing store directory to which row@ cache information is written. The database system generates aB file name (row-cache-name.rdc) automatically for each row cache? at checkpoint time. Specify a device name and directory nameA only, enclosed within single quotation marks. The file name is? the row-cache-name specified when creating the row cache. ByD default, the location is the directory of the database root file.? These .rdc files are permanent database backing store files.? The LOCATION clause of the CREATE CACHE, ADD CACHE, or ALTERA CACHE clause overrides this location, which is the default for the database.C This clause is ignored if the row cache is defined to checkpoint to the database. 4 LOCK_PARTITIONING Syntax options:? LOCK PARTITIONING IS ENABLED | LOCK PARTITIONING IS DISABLED< Specifies whether more than one lock tree is used for the@ database or all lock trees for a database are mastered by one database resource tree.D When partitioned lock trees are enabled for a database, locks forB storage areas are separated from the database resource tree andD all locks for each storage area are independently mastered on theB VMScluster node that has the highest traffic for that resource.C OpenVMS determines the node that is using each resource the most1 and moves the resource hierarchy to that node.A You cannot enable lock partitioning for single-file databases.C You should not enable lock partitioning for single-node systems,> because all lock requests are local on single-node systems.- By default, lock partitioning is disabled. 4 LOCK_TIMEOUT_INTERVAL Syntax option:2 LOCK TIMEOUT INTERVAL IS number-seconds SECONDS A Specifies the number of seconds for processes to wait during a@ lock conflict before timing out. The number of seconds can be between 1 and 65,000 seconds.@ Specifying 0 is interpreted as no lock timeout interval being+ set. It is not interpreted as 0 seconds.@ The lock timeout interval is database-wide; it is used as theA default as well as the upper limit for determining the timeout@ interval. For example, if the database definer specified LOCKC TIMEOUT INTERVAL IS 25 SECONDS in the CREATE DATABASE statement,@ and a user of that database specified SET TRANSACTION WAIT 30@ or changed the logical name RDM$BIND_LOCK_TIMEOUT_INTERVAL toA 30, SQL uses the interval of 25 seconds. For more information,A see the SET_TRANSACTION statement and the Oracle Rdb7 Guide to Distributed Transactions. 4 LOCKING_level Syntax options:/ LOCKING IS ROW LEVEL | LOCKING IS PAGE LEVELC Specifies page-level or row-level locking as the defa ult for theD database. This clause provides an alternative to requesting locks? on records. You can override the database default lock level@ at the storage area level. The default is ROW LEVEL, which is3 compatible with previous versions of Oracle Rdb.B When many records are accessed in the same area and on the sameD page, the LOCKING IS PAGE LEVEL clause reduces the number of lockD operations perfomed to process a transaction; however, this is at@ the expense of reduced concurrency. Transactions that benefit> most with page-level locking are of short duration and also4 access several database records on the same page.B Use the LOCKING IS ROW LEVEL clause if transactions are long in duration and lock many rows.> The LOCKING IS PAGE LEVEL clause causes fewer blocking ASTs> and provides better response time and utilization of systemA resources. However, there is a higher contention for pages andB increased potential for deadlocks and long transactions may use excessive locks.C Page-level locking is never applied to RDB$SYSTEM or the DEFAULTB storage area, either implicitly or explicitly, because the lock% protocol can stall metadata users.B You cannot specify page-level locking on single-file databases. 4 LOGMINER_SUPPORT Syntax options:; LOGMINER SUPPORT IS ENABLED|LOGMINER SUPPORT IS DISABLEDA Allows additional information to be written to the after-image> journal file to allow the use of the RMU Unload After_Image= command. See Oracle RMU Reference Manual for more details.+ Logminer support is disabled by default.= The LOGMINER SUPPORT clause allows the continuous mode for' LogMiner to be enabled and disabled.. o LOGMINER SUPPORT IS ENABLED (CONTINUOUS)" Enables continuous LogMiner.2 o LOGMINER SUPPORT IS ENABLED (NOT CONTINUOUS)@ Disables continuous LogMiner, but leaves LogMiner enabled." o LOGMINER SUPPORT IS DISABLEDA  Disables LogMiner, including disabling continuous LogMiner. 4 MAXIMUM_BUFFER_COUNT7 Specifies the number of buffers a process will write asynchronously.D The default is one-fifth of the buffer pool, but not more than 10D buffers. The minimum value is 2 buffers; the maximum value can be as large as the buffer pool.7 You can override the number of buffers to be writtenB asynchronously by defining the logical name RDM$BIND_BATCH_MAX.C For information about how to set the values, see the Oracle Rdb7, Guide to Database Performance and Tuning. 4 MAXIMUM_extent_pages Syntax option: MAXIMUM OF max-pages PAGESD Specifies the maximum number of pages of each extent. The default is 9999 pages. 4 METADATA_CHANGES Syntax options:? METADATA CHANGES ARE ENABLED | METADATA CHANGES ARE DISABLED? Specifies whether or not data definition changes are allowed; to the database. This attribute becomes effecti ve at the? next database attach and affects all ALTER, CREATE, and DROPB statements (except ALTER DATABASE, which is needed for database@ tuning) and the GRANT, REVOKE, TRUNCATE TABLE, COMMENT ON and" RENAME statements. For example:' SQL> CREATE DATABASE FILENAME sample' cont> METADATA CHANGES ARE DISABLED;# SQL> CREATE TABLE t (a INTEGER); SQL> DISCONNECT ALL;! SQL> ATTACH 'FILENAME sample';# SQL> CREATE TABLE s (b INTEGER);0 %RDB-E-NO_META_UPDATE, metadata update failed7 -RDMS-E-NOMETADATA, metadata operations are disabledD The METADATA CHANGES ARE DISABLED clause prevents data definition= changes to the database. If you specify this clause in theD CREATE DATABASE statement, system index compression is implicitly enabled.A The METADATA CHANGES ARE ENABLED clause allows data definitionB changes to the database by users granted the DBADMIN privilege./ METADATA CHANGES ARE ENABLED is the default. 4 MINIMUM_extent_pages Syntax option: MINIMUM OF min-pages PAGESD Specifies the minimum number of pages of each extent. The default is 99 pages. 4 MULTISCHEMA Syntax options:) MULTISCHEMA IS ON | MULTISCHEMA IS OFFA Specifies the multischema attribute for the database. You must@ specify the multischema attribute for your database to createD multiple schemas and store them in catalogs. Each time you attach@ to a database created with the multischema attr ibute, you canB specify whether you want multischema naming enabled or disabledA for subsequent statements. For more information on multischema2 naming, see the User_Supplied_Names HELP topic.B If you prefer to access a database created with the multischemaC attribute as though it were single-schema database, you can turnD off multischema naming using the MULTISCHEMA IS OFF clause in the% ATTACH or DECLARE ALIAS statement.C If you have turned off the multischema attribute, you can enable? it again using the MULTISCHEMA IS ON clause in the ATTACH or? DECLARE ALIAS statement. You can use multischema naming only@ when you are attached to a database that was created with the> multischema attribute. For more information, see the ATTACH statement.- Multischema naming is disabled by default. 4 MULTITHREAD_AREA_ADDITIONS< Specifies whether Oracle Rdb creates all storage areas in? parallel, creates a specified number in parallel, or creates areas serially.= This clause lets you determine the number of storage areas= to be created in parallel, possibly saving time during the= initial database creation. However, if you specify a large@ number of storage areas and many areas share the same device,C multithreading may cause excessive disk head movement, which may@ result in the storage area creation taking longer than if theC areas were created serially. In addition, if you specify a largeD number of storage areas, you may exceed process quotas, resulting$ in the database creation failing.B This setting is not saved as a permanent database attribute. ItB is used only during the execution of the CREATE DATABASE, ALTER" DATABASE, or IMPORT statements.C If you do not specify the MULTITHREAD AREA ADDITIONS clause, theB default is to create one storage area at a time. If you specify? the MULTITHREAD AREA ADDITIONS clause, but do not specify an< option, the default is all areas are created in parallel. 4 NATIONAL_CHARACTER_SETB Specifies the database national character set when you create aB database. For a list of allowable national character set names, see Supported Character Sets. 4 ncs-name> The OpenVMS National Character Set (NCS) utility provides aA set of predefined collating sequences and also lets you define? collating sequences of your own. In the default NCS library,? SYS$LIBRARY:NCS$LIBRARY, ncs-name is the na me of a collating@ sequence or ncs-name is the name of the collating sequence inC the NCS library specified by the library-name argument. (In most@ cases, it is simplest to make the collating sequence name theE same as the ncs-name, for example, CREATE DATABASE . . . COLLATING> SEQUENCE IS SPANISH SPANISH.) The COLLATING SEQUENCE clauseD accepts both predefined and user-defined NCS collating sequences.C If you omit the COLLATING SEQUENCE clause in the CREATE DATABASEA statement at database definition time, the default sequence is- the DEC Multinational Character Set (MCS). 4 NO_LOCATIONB This is a subclause of other clauses and has different effects,= depending upon the clause in which it is used, as follows:% o In the row-cache-options clause@ Removes the location previously specified in a LOCATION IS? clause for the row cache. If you specify NO LOCATION, theC row cache location becomes the directory of the database root file.B The LOCATION clause of the CREATE CACHE, ADD CACHE, or ALTERD CACHE clause overrides this location, which is the default for the database.? o In a CREATE CACHE, ADD CACHE, or ALTER CACHE clause (row- cache-params1 clause)@ Removes the location previously specified in a LOCATION IS> clause for the row cache backing file. If you specify NO? LOCATION, the row cache location becomes the directory of the database root file.; This clause is ignored if the row cache is defined to! checkpoint to the database. 4 NO_ROW_CACHEC Specifies that the database default is not to assign a row cacheB to all storage areas in the database. You cannot specify the NO: ROW CACHE clause if you specify the CACHE USING clause.> Alter the storage area and name a row cache to override theC database default. Only one row cache is allowed for each storage area.C If you do not specify the CACHE USING clause or the NO ROW CACHE8 clause, NO ROW CACHE is the default for the database. 4 NOTIFY Syntax options:) NOTIFY IS ENABLED | NOTIFY IS DISABLED@ Specifies whether system notification is enabled or disabled.B When the system notification is enabled, the system is notifiedD (using the OpenVMS OPCOM facility) in the event of events such as+ running out of disk space for a journal.A If you specify the NOTIFY IS ENABLED clause and do not specifyC the ALERT OPERATOR clause, the operator classes used are CENTRAL@ and CLUSTER. To specify other operator classes, use the ALERT OPERATOR clause.D The NOTIFY IS ENABLED clause replaces any operator classes set by, the RMU Set After_Journal Notify command. The default is disabled. 4 NUMBER_global_buffers Syntax option: NUMBER IS number-glo-buffers? Specifies the default number of global buffers to be used onC one node when global buffers are en abled. This number appears asD "global buffer count" in RMU Dump command output. Base this valueB on the database users' needs and the number of attachments. The@ default is the maximum number of attachments multiplied by 5.& NOTE? Do not confuse the NUMBER IS parameter with the NUMBER OF> BUFFERS IS parameter. The NUMBER OF BUFFERS IS parameter9 determines the default number of buffers Oracle Rdb9 allocates to each user process  that attaches to theB database. The NUMBER OF BUFFERS IS parameter applies to, and@ has the same meaning for, both local and global buffering.A The NUMBER IS parameter has meaning only within the context of global buffering.C You can override the default number of user-allocated buffers byC defining a value for the logical name RDM$BIND_BUFFERS. For moreA information, see the Oracle Rdb7 Guide to Database Performance and Tuning.? Although you can change the NUMBER IS parameter on line, theB change does not take effect until the next time the database is opened. 4 NUMBER_OF_BUFFERS@ Specifies the number of buffers SQL allocates for each attach= to this database. This number is displayed as the "defaultB database buffer count" in the output from the RMU Dump command.@ The default buffer count applies to local and global buffers.B Specify an unsigned integer greater than or equal to 2 and less6 than or equal to 32,767. The default is 20 buffers. 4 NUMBER_OF_CLUSTER_NODES Syntax option:' NUMBER OF CLUSTER NODES number-nodesB Sets the upper limit on the maximum number of VMS cluster nodes? from which users can access the shared database. The default> is 16 nodes. The range is 1 to 96 nodes. The actual maximumA limit is the current VMS cluster node limit set by your system administrator.@ The Oracle Rdb root file data structures (.rdb) are mapped toA shared memo ry. Each such shared memory copy is known as an RdbD instance. When there is only one copy of shared memory containing> root file information, several optimizations are enabled to@ reduce locking and root file I/O during database activity. ToD enable these optimizations, specify NUMBER OF CLUSTER NODES 1, or" use the SINGLE INSTANCE clause.= MULTIPLE INSTANCE means that the Oracle Rdb root file dataD structures are mapped on different system and are kept consistent= through  disk I/O. Such systems can not benefit from single< instance optimizations. MULTIPLE INSTANCE is the default. 4 NUMBER_OF_RECOVERY_BUFFERS= Specifies the number of buffers allocated to the automatic? recovery process that Oracle Rdb initiates after a system or@ process failure. This recovery process uses the recovery-unit journal (.ruj) file.B Specify an unsigned integer greater than or equal to 2 and less? than or equal to 32,767. The default value for the NUMB ER OFA RECOVERY BUFFERS parameter is 20 buffers. If you have a large,B multifile database and you are working on a system with a largeC amount of memory, specify a large number of buffers. This resultD is faster recovery time. However, make sure your buffer pool doesA not exceed the amount of memory you can allocate for the pool.D if the number of buffers is too large for the amount of memory onB your system, the system may be forced to perform virtual pagingA of the buffer  pool. This can slow performance time because theA operating system must perform the virtual paging of the buffer> pool in addition to reading database pages. You may want toA experiment to determine the optimal number of buffers for your database.C Use the NUMBER OF RECOVERY BUFFERS option to increase the number0 of buffers allocated to the recovery process.* SQL> CREATE DATABASE FILENAME personnel) cont> NUMBER OF RECOVERY BUFFERS 150;C This option is used only if the NUMBER OF RECOVERY BUFFERS valueD is larger than the NUMBER OF BUFFERS value. For more information,4 see the Oracle Rdb Guide to Database Maintenance. 4 NUMBER_OF_SWEEP_ROWS Syntax option: NUMBER OF SWEEP ROWS IS nB Specifies the number of modified rows that will be written fromC the row cache back to the database by the row cache server (RCS)B process during a sweep operation. When the RCS is notified that@ a cache is "full" of modified data, the R CS starts a sweep to@ make space available in the cache for subsequent transactions? to be able to insert rows into the cache. Oracle CorporationA recommends that you initially specify the number of sweep rows? to be approximately 5 percent of the total number of rows in? the cache. Then monitor performance and adjust the number ofD sweep rows, if necessary. Allowable values must be in the range 2? through 524288. If not specified, the default is 3,000 rows. 4 NUMBER_ OF_USERS> Specifies the maximum number of users allowed to access theC database at one time. The default is 50 users. After the maximum= is reached, the next user who tries to invoke the databaseA receives an error message and must wait. The maximum number of= users you can specify is 16368, and the minimum is 1 user.A Note that "number of users" is defined as the number of active> attachments to the database. Thus, if a single process runsB one program but that program performs 12 attach operations, the@ process is responsible for 12 active users as defined by this argument. 4 OPEN Syntax options:% OPEN IS MANUAL | OPEN IS AUTOMATICB Specifies whether or not the database must be explicitly openedA before users can attach to it. The default, OPEN IS AUTOMATIC,A means that any user can open a previously unopened or a closed= database by attaching to it and executing a statement. The@ OPEN IS MANUAL option means that a privileged user must issue< an explicit OPEN statement through Oracle RMU, the Oracle? Rdb management utility, before other users can attach to the database.A The OPEN IS MANUAL option limits access to databases. You must6 have the DBADM privilege to attach to the database.; You receive an error message if you specify both OPEN IS( AUTOMATIC and OPEN IS MANUAL options.? You can modify the OPEN IS option through the ALTER DATABASE statement. 4 PAGE_FORMAT Syntax options:0 PAGE FORMAT IS UNIFORM | PAGE FORMAT IS MIXED8 Specifies the on-disk structure for the storage area.A o The default is PAGE FORMAT IS UNIFORM and creates a storageC area data file that is divided into clumps. Clump size, which? is derived from buffer size, is 3 pages by default. A set? of clumps forms a logical area that can contain rows from? a single table only. For more information on uniform pageD formats, see the Oracl e Rdb7 Guide to Database Performance and Tuning.? Uniform page format storage areas generally give the bestD performance if the tables in the storage area are subject to a wide range of queries.A o The PAGE FORMAT IS MIXED clause creates a storage area with@ a format that lets rows from more than one table reside onC or near a particular page of the storage area data file. ThisA is useful for storing related rows from different tables onB the same page of the data file. For storage areas subject to@ repeated queries that retrieve those related rows, a mixed? page format can greatly reduce I/O overhead if the mix ofC rows on the page is carefully controlled. However, mixed pageA format storage areas degrade performance if the mix of rows@ on the page is not suited for the queries made against the storage area.& NOTE: The main storage area created by the CREATE DATABASE? statement, called RDB$SYSTEM, must have uniform pages. If@ you specify PAGE FORMAT IS MIXED as a default storage area> parameter, SQL generates a warning message and overrides? that default when it creates the RDB$SYSTEM storage area. 4 PAGE_SIZE Syntax option:" PAGE SIZE IS page-blocks BLOCKSC The size in blocks of each database page. Page size is allocatedD in 512-byte blocks. The default is 2 blocks (1024 bytes). If yourD largest row is larger than approximately 950 bytes, allocate moreD blocks per page to prevent fragmented rows. If you specify a pageB size larger than the buffer size, an error message is returned. 4 PAGE_TRANSFER Syntax options:4 PAGE TRANSFER VIA DISK | PAGE TRANSFER VIA MEMORYD Specifies whether Oracle Rdb transfers (flushes) pages to disk or to memory.C When you specify PAGE TRANSFER VIA MEMORY, processes on a single= node can share and update database pages in memory withoutD transferring the pages to disk. It is not necessary for a processC to write a modified page to disk before another process accesses the page.C The default is to DISK. If you specify PAGE TRANSFER VIA MEMORY,8 the database must have the following characteristics:D o The NUMBER OF CLUSTER NODES must equal one, or SINGLE INSTANCE> must be specified in the NUMBER of CLUSTER NODES clause.% o GLOBAL BUFFERS must be enabled.- o After-image journaling must be enabled." o FAST COMMIT must be enabled.B If the database does not have these characteristics, Oracle Rdb( will perform page transfers via disk.A For more information about page transfers, see the Oracle Rdb7, Guide to Database Performance and Tuning. 4 PATHNAME_path_nameB The repository path name for the repository directory where the! database definition is stored. Specify one of the following:< o A full repository path name, such as CDD$TOP.SQL.DEPT34 o A relative repository path name, such as DEPT3A o A logical name that refers to a full or relative repository path name? If you use a relative path name, CDD$DEFAULT must be definedB as all the path name segments preceding the relative path name.C For example, define CDD$DEFAULT as CDD$TOP.SQL, and then use the relative path name DEPT3. SQL> SHOW DICTIONARY. The current data dictionary is CDD$TOP.SQL7 SQL> CREATE DATAB ASE ALIAS PERSONNEL PATHNAME DEPT3;D There is no default path name. If you do not specify a repository: path name for the database, SQL does not store databaseD definitions in the repository. Subsequent data definitions cannotA use the repository. However, Oracle Rdb recommends that you doA specify a repository path name when you create a database. For= more information, see the Oracle Rdb SQL Reference Manual.A If you use the PATHNAME argument and your system does not have, the repository, SQL ignores the argument.@ When you use the PATHNAME argument, the repository associatesD the path name with the file specification exactly as given in theB CREATE DATABASE statement. If that file specification is a fileD name, not a logical name, you cannot alter or delete the databaseB by specifying the path name unless the database root file is in* the current, default working directory. 4 PERCENT_extent_growth Syntax option: PERCENT GROWTH IS growthA Specifies the percent growth of each extent. The default is 20 percent growth. 4 PRESTARTED_TRANSACTIONS Syntax options:) PRESTARTED TRANSACTIONS ARE ENABLED* PRESTARTED TRANSACTIONS ARE DISABLED7 Enables or disables the prestarting of transactions.? Note that the keyword ON, available in previous versions, isB synonymous with ENABLED, and the OFF keyword is synonymous with the DISABLED keyword.D This clause is used t o establish a permanent database setting forC prestarted transactions. In prior versions, this clause was onlyB used to temporarily set the mode for prestarted transaction forB the implicit attach performed by the CREATE DATABASE and IMPORT DATABASE statements.B The prestart-trans-options can be one of the following clauses: o WAIT n SECONDS FOR TIMEOUT; The n represents the number of seconds to wait beforeD aborting the prestarted transaction. Timing out the prestartedB transaction may prevent snapshot file growth in environmentsC where servers stay attached to the database with long periods of inactivity. o WAIT n MINUTES FOR TIMEOUTD The n represents the number of minutes to wait before aborting! the prestarted transaction. o NO TIMEOUT7 This is the default for a prestarted transaction. Syntax options:C PRESTARTED TRANSACTIONS ARE ON | PRESTARTED TRANSACTIONS ARE OFF 4 PROTECTION Syntax options:* PROTECTION IS ANSI | PROTECTION IS ACLS@ Specifies whether the database root file will be invoked withB ACL-style or ANSI/ISO-style privileges. If no protection clause5 is specified, the default is ACL-style privileges.> For ACL-style databases, the access privilege set is order-< dependent. When a user tries to perform an operation on aB database, SQL reads the associated access privilege set, called? the access control list (ACL), from top t o bottom, comparingC the identifier of the user with each entry. As soon as SQL finds? a match, it grants the rights listed in that entry and stopsA the search. All identifiers that do not match a previous entryD "fall through" to the entry [ *,*] (equivalent to the SQL keyword2 PUBLIC). The default access for PUBLIC is NONE.< See the GRANT statement and the REVOKE statement for more' information on ACL-style privileges.< For ANSI/ISO-style databases, the access privil ege set is@ not order-dependent. The user matches the entry in the accessC privilege set; gets whatever privileges have been granted on theB database, table, or column; and gets the privileges defined forC PUBLIC. A user without an entry in the access privilege set getsD only the privileges defined for PUBLIC. There is always an accessB privilege entry for PUBLIC, even if that entry has no access to" the database, table, or column.? ANSI/ISO-style databases grant access to the creator when an@ object is created. Because only the creator is granted accessA to the newly created object, additional access must be granted explicitly.A See the GRANT_ANSI statement and the REVOKE_ANSI statement for1 more information on ANSI/ISO-style privileges.A You can change the PROTECTION IS parameter by using the IMPORT< statement. See the IMPORT statement for more information. #4 RECOVERY_JOURNAL_(BUFFER_MEMORY) Syntax options: BUFFER  MEMORY IS LOCAL BUFFER MEMORY IS GLOBALBSpecifies whether RUJ buffers will be allocated in global or localmemory.A The RUJ buffers used by each process are normally allocated inD local virtual memory. With the introduction of row caching, theseA buffers now can be assigned to a shared global section (globalD memory) on OpenVMS, so that the recovery process can process this5 in-memory buffer and possibly avoid a disk access.@ You can define this buffer memory to be global to improve row@ caching performance for recovery. If row caching is disabled,& then buffer memory is always local. 4 RECOVERY_JOURNAL_(LOCATION) Syntax options:0 RECOVERY JOURNAL (LOCATION IS directory-spec)C Specifies the location in which the recovery-unit journal (.ruj)= file is written. Do not include node names, file names, or@ process-concealed logical names in the directory-spec. Single? quotation marks are required around the directory-spec. This. clause overrides the RDMS$RUJ logical name.: If this clause is omitted, then NO LOCATION is assumed.- Following is an example using this clause:& SQL> ALTER DATABASE FILENAME SAMPLEC cont> RECOVERY JOURNAL (LOCATION IS 'SQL_USER1:[DBDIR.RECOVER]')< See the Oracle Rdb Guide to Database Maintenance for more. information on recovery-unit journal files. !4 RECOVERY_JOURNAL_(NO_LOCATION)< If you specify NO LOCATION, the recovery journal uses the? current user's login device and the directory [RDM$RUJ]. SeeD the Oracle Rdb Guide to Database Maintenance for more information" on recovery-unit journal files. 4 RESERVE_n_CACHE_SLOTSB Specifies the number of row caches for which slots are reserved in the database.A You can use the RESERVE CACHE SLOTS clause to reserve slots in@ the database root file for future use by the ADD CACHE clauseB of the ALTER DATABASE statement. You can only add row caches if@ row cache slo ts are available. Slots become available after aA DROP CACHE clause or a RESERVE CACHE SLOTS clause of the ALTER DATABASE statement.B The number of reserved slots for row caches cannot be decreasedA once the RESERVE clause is issued. If you reserve 10 slots andC later reserve 5 slots, you have a total of 15 reserved slots for row cachesD If you do not specify the RESERVE CACHE SLOTS clause, the default number of row caches is one.? Reserving row cache slots is an offline operation (requiringC exclusive database access). See the CREATE CACHE clause for more information. 4 RESERVE_n_JOURNALS< Specifies the number of journal files for which slots are@ reserved in the database. If your database is not a multifile@ database, you cannot reserve additional slots later using the ALTER DATABASE statement.A You must reserve slots before you can add journal files to the database.> See the ALTER DATABASE statement for more information about< adding journal files and enabling the journaling feature.? The following SQL statements create a multifile database and, reserve 5 slots for future journal files.% SQL> CREATE DATABASE FILENAME test cont> RESERVE 5 JOURNALS& cont> CREATE STORAGE AREA sa_one& cont> ALLOCATION IS 10 PAGES; 4 RESERVE_n_SEQUENCESD Specifies the number of sequences for which slots are reserved inD the database. Sequences are reserved in multiples  of 32. Thus, ifD you specify a value less than 32 for n, 32 slots are reserved. If? you specify a value of 33, 64 slots are reserved, and so on.? You can use the RESERVE SEQUENCES clause to reserve slots in? the database root file for future use by the CREATE SEQUENCEA statement. Sequences can be created only if sequence slots areD available. Slots become available after a DROP SEQUENCE statementC or a RESERVE SEQUENCES clause of the ALTER DATABASE statement is executed.B The number of reserved slots for sequences cannot be decreased.C If you do not specify the RESERVED SEQUENCES clause, the default" number of sequence slots is 32. 4 RESERVE_n_STORAGE_AREAS< Specifies the number of storage areas for which slots areB reserved in the database. The number of slots for storage areas/ must be a positive number greater than zero.? You can use the RESERVE STORAGE AREA clause to reserve slots> in the database root file for future use by the ADD STORAGEA AREA clause of the ALTER DATABASE statement. Storage areas canA be added only if there are storage area slots available. SlotsA become available after a DROP STORAGE AREA clause or a RESERVE STORAGE AREA clause.; The number of reserved slots for storage areas cannot be@ decreased once the RESERVE clause is issued. If you reserve 5D slots and later reserve 10 slots, you have a total of 15 reserved slots for storage areas.= If you do not specify the RESERVE STORAGE AREA clause, the+ default number of storage areas is zero. 4 RESTRICTED_ACCESS Syntax option:+ RESTRICTED ACCESS | NO RESTRICTED ACCESSB Restricts access to the database. This allows you to access theC database but locks out all other users until you disconnect fromC the database. Setting restricted access to the database requires DBADM privileges.' The default is NO RESTRICTED ACCESS. 4 root-file-paramsC Param eters that control the characteristics of the database root@ file or characteristics stored in the database root file thatA apply to the entire database. You can specify these parameters1 for either single-file or multifile databases.= Some database root file parameters specified in the CREATE? DATABASE statement cannot be changed with the ALTER DATABASE< statement. To change these database root file parameters,@ you must use the EXPORT and IMPORT statements. See the EXPORTB statement and the IMPORT statement for information on exporting and importing your database. 4 ROW_CACHE Syntax options:/ ROW CACHE IS ENABLED | ROW CACHE IS DISABLEDA Specifies whether or not you want Oracle Rdb to enable the row caching feature.= When a database is created or is converted from a previousB version of Oracle Rdb without specifying row cache support, theD default is ROW CACHE IS DISABLED. Enabling row cache support doesB not affect database operations until a row cache is created and) assigned to one or more storage areas.C When the row caching feature is disabled, all previously createdD and assigned row cache definitions remain in existence for future/ use when the row caching feature is enabled.D The following conditions must be true in order to use row caches:( o The number of cluster nodes is one' o After-image journaling is enabled o Fast commit is enabled* o One or more cache slots are reserved o Row caching is enabled? Use the RMU Dump Header command to check if you have met theB requirements for using row caches. The following command output< displays a warning for every requirement that is not met: . . . Row Caches... - Active row cache count is 0" - Reserved row cache count is 1 - Sweep interval is 1 second' - Default cache file directory is ""3 - WARNING: Maximum node count is 16 instead of 10 - WARNING: After-image journaling is disabled% - WARNING: Fast commit is disabled . . . 4 ROWID_SCOPE Syntax options:5 ROWID SCOPE IS ATTACH | ROWID SCOPE IS TRANSACTION@ The ROWID keyword is a synonym for the DBKEY keyword. See the- DBKEY_SCOPE argument for more information. 4 SECURITY_CHECKINGB Traditionally, Oracle Rdb has performed security checking using@ the operating system security layer (for example, the UIC and7 rights identifiers of the OpenVMS operating system).C The access control list (ACL) information stored in the databaseC contains a granted privilege mask and a set of users represented, by a unique integer (for example, a UIC)., There are two modes of security checking:# 1. SECURITY CHECKING IS EXTERNAL@ This is the default. External security checking recognizesA database users (created with the SQL CREATE USER statement)D as operating syste m user identification codes (UICs) and rolesA as special rights identifiers or groups. PERSONA support is% enabled or disabled as follows:C o SECURITY CHECKING IS EXTERNAL (PERSONA SUPPORT IS ENABLED)@ Enables the full impersonation of an OpenVMS user. ThisD means the UIC and the granted right identifiers are used to/ check access control list permissions.D o SECURITY CHECKING IS EXTERNAL (PERSONA SUPPORT IS DISABLED)A Disables the full impersonation of an OpenVMS user. OnlyB the UIC is used to check access control list permissions.B This is the default for a new database, or for a database6 converted from a prior version of Oracle Rdb.# 2. SECURITY CHECKING IS INTERNALC In this mode, Oracle Rdb records users (username and UIC) andA roles (rights identifiers) in the database. The CREATE USERD and CREATE ROLE statements perform this action explicitly, andC GRANT wi ll perform this implicitly. This type of database canA now be moved to another system and is only dependent on the# names of the users and roles.A o SECURITY CHECKING IS INTERNAL (ACCOUNT CHECK IS ENABLED)C The ACCOUNT CHECK clause ensures that Oracle Rdb validates> the current database user with the user name (such asA defined with an SQL CREATE USER statement) stored in theC database. This prevents different users with the same nameB  from accessing the database. Therefore, this clause might& prevent a breach in security.B The ACCOUNT CHECK IS ENABLED clause on OpenVMS forces theD user session to have the same user name and UIC as recorded in the database.B o SECURITY CHECKING IS INTERNAL (ACCOUNT CHECK IS DISABLED)B If you specify the ACCOUNT CHECK IS DISABLED clause, thenA a user with a matching UIC (also called a profile-id) is@ considered the same as the user even if his or her userD name is different. This allows support for multiple OpenVMS! users with the same UIC. 4 SEGMENTED_STRING_STORAGE_AREA& Another name for LIST STORAGE AREA. 4 SET_TRANSACTION_MODESC Enables only the modes specified, disabling all other previouslyD defined modes. For example, if a database is to be used for read-C only access and you want to disable all other transaction modes, use the following statement :- SQL> CREATE DATABASE FILENAME mf_personnel- cont> SET TRANSACTION MODES (READ ONLY);9 If not specified, the default transaction mode is ALL.D Specifying a negated transaction mode or specifying NONE disablesB all transaction usage. Disabling all transaction usage would beD useful when, for example, you want to perform major restructuringA of the physical database. Execute the ALTER DATABASE statementC to re-enable transaction modes or use Oracle RMU, the Oracle Rdb management utility. $4 SHARED_MEMORY_IS_PROCESS_RESIDENTC The SHARED MEMORY clause determines whether database root globalB sections (including global buffers when enabled) or whether the? cache global sections are created in system space or processB space. The RESIDENT option extends the PROCESS option by making& the global section memory resident. 4 SHARED_MEMORY Syntax options:5 SHARED MEMORY IS SYSTEM | SHARED MEMORY IS PROCESS> Determine s whether database root global sections (including> global buffers when enabled) are created in system space or) process space. The default is PROCESS.A When you use global sections created in the process space, youB and other users share physical memory and the OpenVMS operatingD system maps a row cache to a private address space for each user.A As a result, all users are limited by the free virtual addressA range and each use a percentage of memory in overhead. If many>  users are accessing the database, the overhead can be high. 4 SNAPSHOT_ALLOCATION Syntax option:) SNAPSHOT ALLOCATION IS snp-pages PAGESC Changes the number of pages allocated for the snapshot file. TheD default is 100 pages. If you have disabled the snapshot file, you. can set the snapshot allocation to 0 pages. 4 SNAPSHOT_CHECKSUM_ALLOCATION Syntax option:- SNAPSHOT CHECKSUM ALLOCATION IS ENABLED. SNAPSHOT CHECKSUM ALLOCATION IS DISABLED/See the CHECKSUM ALLOCATION clause for details. 4 SNAPSHOT_IS_ENABLED Syntax options:? SNAPSHOT IS ENABLED IMMEDIATE | SNAPSHOT IS ENABLED DEFERRED@ Specifies when read/write transactions write database changesA they make to the snapshot file used by read-only transactions.9 The default is ENABLED IMMEDIATE and causes read/writeC transactions to write copies of rows they modify to the snapshot@ file, regardless of whether or not a read-only transact ion is active.; The ENABLED DEFERRED option lets read/write transactions@ avoid writing copies of rows they modify to the snapshot file@ (unless a read-only transaction is already active). Deferring? snapshot writing in this manner improves the performance forC the read/write transaction. However, read-only transactions thatA attempt to start after an active read/write transaction starts> must wait for all active read/write users to complete their transactions. 4 SNAPSHOT_EXTENT Syntax options:% SNAPSHOT EXTENT IS extent-pages, SNAPSHOT EXTENT IS (extension-options)CSpecifies the number of pages of each snapshot or storage area file>extent. The default extent for storage area files is 99 pages.C Specify a number of pages for simple control over the extension.C For greater control, and particularly for multivolume databases,A use the MINIMUM, MAXIMUM, and PERCENT GROWTH extension options instead.B If you use the MINIMUM, MAXIMUM, and PERCENT GROWTH parameters,( you must enclose them in parentheses. 4 SNAPSHOT_FILENAME> Provides a separate file specification for the storage areaA snapshot file. The SNAPSHOT FILENAME argument can only be used with a multifile database.B In a multifile database, the file specification is used for theD RDB$SYSTEM storage area snapshot file, unless the CREATE DATABASEB statement contains a CREATE STORAGE AREA RDB$SYSTEM clause that-  contains its own SNAPSHOT FILENAME clause.B Do not specify a file extension other than .snp to the snapshot@ file specification. Oracle Rdb will assign the extension .snp> to the file specification, even if you specify an alternate extension.A If you omit the SNAPSHOT FILENAME argument, the .snp file getsA the same device, directory, and file name as the database root file. 4 SNAPSHOT_IS_DISABLED@ Specifies that snapshot writing is disabled. Snapshot writi ngA is enabled by default. If you specify the SNAPSHOT IS DISABLED? option, you cannot specify either of the SNAPSHOT IS ENABLEDA options, and you cannot back up the database on line. You can,B however, continue to set snapshot options in the event that youC will enable snapshots in the future. SQL warns you of a possibleB conflict in the setting of snapshot options while snapshots are0 disabled, but SQL will execute the statement. 4 SNAPSHOT_IS_ENABLED Syntax options:? SNAPSHOT IS ENABLED IMMEDIATE | SNAPSHOT IS ENABLED DEFERRED@ Specifies when read/write transactions write database changesA they make to the snapshot file used by read-only transactions.9 The default is ENABLED IMMEDIATE and causes read/writeC transactions to write copies of rows they modify to the snapshot@ file, regardless of whether or not a read-only transaction is active.; The ENABLED DEFERRED option lets read/write transactions@ avoid writing copies of rows they modify to the snapshot file@ (unless a read-only transaction is already active). Deferring? snapshot writing in this manner improves the performance forC the read/write transaction. However, read-only transactions thatA attempt to start after an active read/write transaction starts> must wait for all active read/write users to complete their transactions. 4 STATISTICS_COLLECTION Syntax options:& STATISTICS COLLECTION IS ENABLED' STATIS TICS COLLECTION IS DISABLEDBSpecifies whether the collection of statistics for the database isBenabled or disabled. When you disable statistics for the database,Astatistics are not displayed for any of the processes attached toDthe database. Statistics are displayed using the RMU Show Statisticscommand.C The default is STATISTICS COLLECTION IS ENABLED. You can disable= statistics using the ALTER DATABASE and IMPORT statements.C For more information on the RMU Show Statistics command, see the Oracle RMU Reference Manual.? You can enable statistics collection by defining the logicalB name RDM$BIND_STATS_ENABLED. For more information about when toC use statistics collection, see the Oracle Rdb7 Guide to Database Performance and Tuning. 4 storage-area-paramsB Parameters that control the characteristics of database storage? area files. You can specify most storage area parameters forC either single-file or multifile databases, but the effect of the clauses differs.< o For single-file databases, the storage area parameters@ specify the characteristics for the single storage area in the database.B o For multifile databases, the storage area parameters specify> a set of default values for any storage areas created byA the CREATE DATABASE statement that do not specify their ownA values for the same parameters. The default values apply toB the RDB$SYSTEM storage area, plus any others named in CREATE% STORAGE AREA database elements.D The CREATE STORAGE AREA clauses in a CREATE DATABASE statement> can override these default values. The default values doA not apply to any storage areas created later with the ALTER DATABASE statement. 4 SWEEP_INTERVAL Syntax option: SWEEP INTERVAL IS n SECONDS@ Specifies the interval, in seconds, between each Record CacheC Server (RCS) sweep. Allowable values must be in the range from 15 second to 3600 seconds (1 hour). The default is 1.= The Record Cache Server (RCS) is a detached server processC automatically invoked by the monitor when row caching is active.A A sweep is one full pass through all active row cache areas to: write modified rows back to the database storage areas. '4 SYSTEM_INDEX_(COMPRESSION_IS_._._._)C This clause allows the database creator choose compressed systemB indexes. The default is SYSTEM INDEX (COMPRESSION IS DISABLED).; If enabled Oracle Rdb uses run-length compression, which@ compresses any sequences of two or more spaces from text data< types or two or more binary zeros from non-character data? types. Compressing system indexes results in reduced storage@ and improved I/O. Unless your applications frequently performB concurrent data definition, you should compress system indexes.9 Once you create a database specifying the SYSTEM INDEXC (COMPRESSION IS . . . ) clause, you only can change it using theA EXPORT and IMPORT statements. You cannot alter the database to change the compression mode.> The clause SYSTEM INDEX COMPRESSION IS is identical to this? clause and is retained for compatibility with older versions of Oracle Rdb. 94 SYSTEM_INDEX_(PREFIX_CARDINALITY_COLLECTION_IS_._._._)? This clause allows the database creator to adjust the prefixA cardinality collection for system indices. Refer to the CREATED INDEX Statement for more details on these clauses. The default is, PREFIX CARDINALITY COLLECTION IS ENABLED. 4 SYSTEM_INDEX_(TYPE_IS_._._._)C This clause allows the database creator choose between SORTED orA SORTED RANKED indices for system table. The default is SORTED.C SORTED RANKED indices have advantages in space usage and reduced? CPU during DDL operations for those system indices with many duplicates. 4 SYNONYMS_ARE_ENABLED= Adds the optional system table RDB$OBJECT_SYNONYMS that is@ used for the CREATE SYNONYM, ALTER . . . RENAME TO and RENAME2 statements. The default if omitted is disabled. 4 THRESHOLD_pages_option Syntax option:" THRESHOLD IS number-pages PAGESB This number represents the number of sequential buffer accessesC that must be detected before prefetching is started. The default is four buffers.D If you specify the THRESHOLD option, you must have also specifiedB the DETECTED ASYNC PREFETCH clause. You receive an error if youB attempt to specify the THRESHOLD option with the ASYNC PREFETCH clause. 4 THRESHOLDS_values Syntax options+ THRESHOLDS ARE ( val1 [,val2 [,val3] ] )? Specifies one, two, or three threshold values. The threshold< values represent a fullness percentage on a data page andA establish four possible ranges of guaranteed free space on theC data pages. When a data page reaches the percentage defined by aD given threshold value, the sp ace area management (SPAM) entry forB the data page is updated to reflect the new fullness percentage and its remaining free space.< The default thresholds are 70, 85, and 95 percent. If you@ specify only one or two values, unspecified values default to 100 percent.? You cannot specify the THRESHOLDS storage area parameter forB single-file databases, and you cannot specify THRESHOLDS unless? you also explicitly specify PAGE FORMAT IS MIXED. To specifyC thresholds for uniform storage areas, use the CREATE STORAGE MAP statement.; For more information about setting space area management@ parameters, see the Oracle Rdb Guide to Database Maintenance. 4 USER_username Syntax option: USER 'username'A A character string literal that specifies the operating systemB user name that the database system uses for privilege checking.; This clause also sets the value of the SYSTEM_USER value expression. 4 USER_LIMI T Syntax option: USER LIMIT IS max-glo-buffers= Specifies the maximum number of global buffers each attach; allocates. Because global buffer pools are shared by allA attachments, you must define an upper limit on how many globalC buffers a single attach can allocate. This limit prevents a userA from defining the RDM$BIND_BUFFERS logical name to use all the@ buffers in the global buffer pool. (The behavior of RDM$BIND_A BUFFERS which depends on whether you are using local or global= buffers, is explained in the Oracle Rdb7 Guide to Database Performance and Tuning.)C The user limit cannot be greater than the total number of global? buffers. The default is 5 buffers. The user limit appears as= "maximum global buffer count per user" in RMU Dump command output.< Decide the maximum number of global buffers a process can= allocate per attach by dividing the total number of global= buffers set by the NUMBER IS clause by the total number of< attachments for which you want to guarantee access to theB database. For example, if the total number of global buffers isB 200 and you want to guarantee at least 10 attachments access toD the database, set the maximum number of global buffers per attach to 20.> In general, when you use global buffers, you should set the? maximum global buffer count per user higher than the defaultA database buffer count. For maximum performance on a VMScluster@ system, tune the two global buffer parameters on each node inA the cluster using the RMU Open command with the Global_Buffers qualifier.C Although you can change the USER LIMIT IS parameter on line, theB change does not take effect until the next time the database is opened.> The NUMBER IS and USER LIMIT IS parameters are the only two: buffer parameters specific to global buffers. They are,? therefore, in effect on a per node rather than a per process basis. 4  USING_password Syntax option: USING 'password'D A character string literal that specifies the user's password for. the user name specified in the USER clause. 4 txn-modes4 Specifies the transaction modes for the database. Mode Description( ALL All modes are enabled.' NONE No modes are enabled., Transaction Types@ [NO]READ Allows read-only transactions on the database.  ONLYA [NO]READ Allows read/write transactions on the database. WRITEC [NO] BATCH Allows batch-update transactions on the database.= UPDATE This mode executes without the overhead, or< security, or a recovery-unit journal file.> The batch-update transaction is intended for? the initial loading of a database. Oracle Rdb8 recommends that this mode be disabled.+ Rese rving ModesD [NO] SHARED Allows tables to be reserved for shared mode. That= [READ | is, other users can work with those tables. WRITE]B [NO] Allows tables to be reserved for protected mode.B PROTECTED That is, other users can read from those tables. [READ | WRITE]D [NO] Allows tables to be reserved for exclusive access.D EXCLUSIVE That is, other users are prevented access to those9 [READ | tables, even in READ ONLY transactions. WRITE]= ALL Allows other users to work with all tables.- NONE Allows no access to tables.= For detailed information about the txn-modes, see the SET_ TRANSACTION statement. 4 WAIT_option Syntax option: WAIT n MINUTES FOR CLOSE< Specifies the amount of time that Oracle Rdb waits beforeC automatically closing a database. If anyone attaches during that) wait time, the database is not closed.= The default value for n is zero (0) if the WAIT clause is= not specified. The value for n can range from zero (0) toA 35,791,394. However, Oracle Rdb does not recommend using large values. 4 WORKLOAD_COLLECTION Syntax options:C WORKLOAD COLLECTION IS ENABLED | WORKLOAD COLLECTION IS DISABLED: Specifies whether or not the optimizer records workload= information in the system table RDB$WORKLOAD. The WORKLOAD? COLLECTION IS ENABLED clause creates this system table if  it@ does not exist. If you later disable workload collection, the, RDB$WORKLOAD system table is not deleted.? A workload profile is a description of the interesting table@ and column references used by queries in a database workload.> When workload collection is enabled, the optimizer collectsA and records these references in the RDB$WORKLOAD system table.A This work load is then processed by the RMU Analyze Statistics? command which records useful statistics about the work load.B These workload statistics are used by the optimizer at run time. to deliver more accurate access strategies.. Workload collection is disabled by default. 3 Examples- Example 1: Creating a single-file database@ This command file example creates a single-file database thatC contains one table, EMPLOYEES, made up of domains defined withinB the CREATE DATABASE statement. The EMPLOYEES table has the same7 definition as that in the sample personnel database.C For an example that creates a multifile version of the personnel) database, see the CREATE STORAGE_AREA.@ SQL> -- By omitting a FILENAME clause, the database root file. SQL> -- takes the file name from the alias:' SQL> CREATE DATABASE ALIAS personnel cont> --8 cont> -- This CREATE DATABASE statement takes defaultA cont> -- database root file and storage area parameter values. cont> -- cont> -- Create domains.I cont> -- Note that database elements do not terminate with semicolons. cont> --% cont> CREATE DOMAIN ID_DOM CHAR(5) cont> --- cont> CREATE DOMAIN LAST_NAME_DOM CHAR(14) cont> --. cont> CREATE DOMAIN FIRST_NAME_DOM CHAR(10) cont> --1 cont> CREATE DOMAIN MIDDLE_INITIAL_DOM CHAR(1) cont> --2 cont> CREATE DOMAIN ADDRESS_DATA_1_DOM CHAR(25) cont> --2 cont> CREATE DOMAIN ADDRESS_DATA_2_DOM CHAR(20) cont> --( cont> CREATE DOMAIN CITY_DOM CHAR(20) cont> --( cont> CREATE DOMAIN STATE_DOM CHAR(2) cont> --. cont> CREATE DOMAIN POSTAL_CODE_DOM CHAR(5) cont> --& cont> CREATE DOMAIN SEX_DOM CHAR(1) cont> --$ cont> CREATE DOMAIN DATE_DOM DATE cont> --. cont> CREATE DOMAIN STATUS_CODE_DOM CHAR(1) cont> -- cont> -- Create a table: cont> -- cont> CREATE TABLE EMPLOYEES cont> (# cont> EMPLOYEE_ID ID_DOM5 cont> CONSTRAINT EMP_EMPLOYEE_ID_NOT_NULL cont> NOT NULL cont> NOT DEFERRABLE,+ con t> LAST_NAME LAST_NAME_DOM,, cont> FIRST_NAME FIRST_NAME_DOM,0 cont> MIDDLE_INITIAL MIDDLE_INITIAL_DOM,0 cont> ADDRESS_DATA_1 ADDRESS_DATA_1_DOM,0 cont> ADDRESS_DATA_2 ADDRESS_DATA_2_DOM,& cont> CITY CITY_DOM,' cont> STATE STATE_DOM,- cont> POSTAL_CODE POSTAL_CODE_DOM,% cont> SEX SEX_DOM,+ cont> CONSTRAINT EMP_SEX_VALUES cont> CHECK (= cont>  SEX IN ('M', 'F') OR SEX IS NULL cont> ) cont> NOT DEFERRABLE,& cont> BIRTHDAY DATE_DOM,- cont> STATUS_CODE STATUS_CODE_DOM,3 cont> CONSTRAINT EMP_STATUS_CODE_VALUES cont> CHECK (; cont> STATUS_CODE IN ('0', '1', '2')3 cont> OR STATUS_CODE IS NULL cont> ) cont> NOT DEFERRABLE cont> ) cont> --: cont> -- End CREATE DATABASE by specifying a semicolon: cont> ;: Example 2: Creating a database not using the repository The following example:D o Creates the database root file acct.rdb in the default working directory? o Creates the snapshot file acct.snp in the default working directory> o Does not store the database definition in the repository* o Enables writing to the snapshot file; o Sets the allocation of the snapshot file to 200 pages% SQL>  CREATE DATABASE ALIAS acct cont> FILENAME acct* cont> SNAPSHOT IS ENABLED IMMEDIATE. cont> SNAPSHOT ALLOCATION IS 200 PAGES;A Example 3: Creating a database with the snapshot file disabled@ This statement creates a database root file and, to save diskC space, disables snapshot writing and sets the initial allocation size to 1.% SQL> CREATE DATABASE ALIAS PERS cont> FILENAME personnel! cont> SNAPSHOT IS DISABLED, cont> SNAPSHOT ALLOCATION IS 1 PAGES;@ Example 4: Creating a database with ANSI/ISO-style privileges@ This statement creates a database in which all ANSI/ISO-styleB privileges are granted to the creator of the database, WARRING,D and no privileges are granted to the identifier [*,*], the PUBLIC identifier.( SQL> CREATE DATABASE ALIAS EXAMPLE cont> FILENAME ansi_test cont> PROTECTION IS ANSI; SQL>, SQL> SHOW PROTECTION ON DATABASE EXAMPLE; Protection on Ali as EXAMPLE [SQL,WARRING]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,I DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN# Without Grant Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONEB Example 5: Creating a database with a German collating sequenceC This statement creates a database named LITERATURE and specifiesC a collating sequence named GERMAN (based on the GERMAN collating( sequence defined in the NCS library).+ SQL> CREATE DATABASE FILENAME literature* cont> COLLATING SEQUENCE GERMAN GERMAN; SQL> SHOW COLLATING SEQUENCE> User collating sequences in schema with filename LITERATURE GERMAN 5 Example 6: Creating a database with global buffers5 This statement creates a database named parts.rdb.2 SQL> CREATE DATABASE ALIAS PARTS FILENAME partsF cont> GLOBAL BUFFERS ARE ENABLED (NUMBER IS 110, USER LIM IT IS 17);A Example 7: Creating a database specifying the database default and national character sets@ The following SQL statements create a database specifying the? database default character set of DEC_KANJI and the nationalA character set of KANJI. Use the SHOW DATABASE statement to see the database settings. SQL> SET DIALECT 'SQL99';- SQL> CREATE DATABASE FILENAME mia_char_set+ cont> DEFAULT CHARACTER SET DEC_KANJI( cont> NATIONAL CHARACTER SET K ANJI/ cont> IDENTIFIER CHARACTER SET DEC_KANJI; SQL> -- SQL> SHOW CHARACTER SET;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI: See the SHOW for information on the SHO W CHARACTER SETS statement./ Example 8: This example demonstrates how to:! o Create a multifile databaseD o Reserve slots for journal files, storage areas, and row caches= o Restrict access to the database for the current session@ o Enable system index compression, row caching, and workload collection3 o Disable statistics and cardinality collection$ o Specify a default storage area< o Specify ROW as the lock-level default for the database  o Delay closing the database5 o Create and assign a row cache to a storage area< o Specify the location of the recovery-unit journal file' SQL> CREATE DATABASE FILENAME sample cont> SNAPSHOT IS DISABLED cont> RESERVE 10 JOURNALS# cont> RESERVE 10 STORAGE AREAS cont> RESERVE 5 CACHE SLOTS. cont> SYSTEM INDEX COMPRESSION IS ENABLED cont> ROW CACHE IS ENABLED) cont> WORKLOAD COLLECTION IS ENABLED cont> RESTRICTED ACCESS, cont>  STATISTICS COLLECTION IS DISABLED- cont> CARDINALITY COLLECTION IS DISABLED cont> LOCKING IS ROW LEVEL( cont> DEFAULT STORAGE AREA IS area17 cont> OPEN IS AUTOMATIC (WAIT 5 MINUTES FOR CLOSE); cont> RECOVERY JOURNAL (LOCATION IS 'SQL_USER1:[DAY]') cont> CREATE CACHE cache1" cont> CACHE SIZE IS 1000 ROWS# cont> ROW LENGTH IS 1000 BYTES" cont> CREATE STORAGE AREA area1 cont> CACHE USING cache1; SQL> SQL> SHOW DATABASE *; Default alias :) Oracle Rdb database in file sample' Multischema mode is disabled, Number of users: 50, Number of nodes: 16+ Buffer Size (blocks/buffer): 6, Number of Buffers: 20, Number of Recovery Buffers: 20! Snapshots are Disabled' Carry over locks are enabled- Lock timeout interval is 0 seconds> Adjustable lock granularity is enabled (count is 3)G Global buffers are disabled (number is 250, user limit is 5,, page transfer via disk)* Journal fast commit is disabled5 ( checkpoint interval is 0 blocks,6 checkpoint timed every 0 seconds,7 no commit to journal optimization,2 transaction interval is 256 )- AIJ File Allocation: 512- AIJ File Extent: 512, Statistic s Collection is DISABLED, Unused Storage Areas: 10, Unused Journals: 10. System Index Compression is ENABLED Restricted Access Journal is Disabled" Backup Server: Manual" Log Server: Manual$ Overwrite: Disabled$ Notification: Disabled8 Asynchronous Prefetch is Enabled (depth is 5)O Asynchronous Batch Write is Enabled (clean buffers 5, max buf fers 4)( Lock Partitioning is DISABLED8 Incremental Backup Scan Optim uses SPAM pages& Shutdown Time is 60 minutes) Unused Cache Slots: 5) Workload Collection is Enabled- Cardinality Collection is Disabled' Metadata Changes are Enabled< Row Cache is Enabled (Sweep interval is 1 second, No Location)K Detected Asynch Prefetch is Enabled (depth is 4, threshold is 4)% D efault Storage Area AREA1< Mode is Open Automatic (Wait 5 minutes for close), RUJ File Location SQL_USER1:[DAY]0 Database Transaction Mode(s) Enabled: ALL" Dictionary Not Required ACL based protections1 Storage Areas in database with filename sample: RDB$SYSTEM List storage area.= AREA1 Default storage area., Journals in database with filename sample No Journals Found1 Cache Objects in database with filename sample CACHE1 SQL> SHOW CACHE cache1; CACHE1+ Cache Size: 1000 rows, Row Length: 1000 bytes) Row Replacement: Enabled) Shared Memory: Process* Large Memory: Disabled% Window Count: 100$ Reserved Rows: 20& Sweep Rows: 3000% Reserving Slots for Sequences No Sweep Thresholds, Allocation: 100 blocks, Extent: 100 blocks + Example 9: Reserving Slots for Sequences/ SQL> CREATE DATABASE FILENAME many_sequences cont> RESERVE 320 SEQUENCES;3 Example 10: Creating a Database with a Row Cache SQL> create database cont> filename SAMPLE! cont> snapshot is disabled cont> reserve 10 journals% cont> reserve 10 storage areas" cont> r eserve 5 cache slotsF cont> system index (compression is enabled, type sorted ranked)! cont> row cache is enabled+ cont> workload collection is enabled cont> restricted access* cont> default storage area is AREA19 cont> open is automatic (wait 5 minutes for close) cont>% cont> create cache CACHE_AREA1) cont> shared memory is process) cont> row length is 1000 bytes' cont> cache size is 204 rows4 cont>  checkpoint all rows to backing file cont>& cont> create storage area AREA1' cont> page format is UNIFORM( cont> cache using CACHE_AREA1 cont> ; SQL> SQL> show database * Default alias:) Oracle Rdb database in file SAMPLE' Multischema mode is disabled, Number of users: 50, Number of nodes: 16+ Buffer Size (blocks/buffer): 6, Number of Buffers:  20, Number of Recovery Buffers: 20! Snapshots are Disabled' Carry over locks are enabled- Lock timeout interval is 0 seconds> Adjustable lock granularity is enabled (count is 3)G Global buffers are disabled (number is 250, user limit is 5,, page transfer via disk)* Journal fast commit is disabled5 ( checkpoint interval is 0 blocks,6 checkpoint timed every 0 seconds,7 no commit to journal optimization,2 transaction interval is 256 )- AIJ File Allocation: 512- AIJ File Extent: 512+ Statistics Collection is ENABLED, Unused Storage Areas: 10, Unused Journals: 10+ Unused Cache Slots: 5, Unused Sequences: 32 Restricted Access Journal is Disabl ed" Backup Server: Manual" Log Server: Manual$ Overwrite: Disabled$ Notification: Disabled8 Asynchronous Prefetch is Enabled (depth is 5)O Asynchronous Batch Write is Enabled (clean buffers 5, max buffers 4)( Lock Partitioning is DISABLED8 Incremental Backup Scan Optim uses SPAM pages& Shutdown Time is 60 minutes) Workload Collection is Enabled, Cardinality Collect ion is Enabled' Metadata Changes are Enabled Row Cache is Enabled! Row cache: No Location= Row cache: checkpoint updated rows to backing fileK Detected Asynch Prefetch is Enabled (depth is 4, threshold is 4)% Default Storage Area AREA1< Mode is Open Automatic (Wait 5 minutes for close) No RUJ File Location7 recovery journal buffers are in local memory0 Database Transaction Mode(s) Enabled: ALL) Shared Memory: Process* Large Memory: Disabled( Security Checking is External. System Index Compression is ENABLED System Index:$ Type is sorted ranked7 Prefix cardinality collection is enabled' Logminer support is disabled% Galaxy support is disabled. Prestarted transactions are enabled" Dictionary Not Required ACL based protections1 Storage Areas in database with filename SAMPLE< AREA1 Default storage area: RDB$SYSTEM List storage area., Journals in database with filename SAMPLE No Journals Found1 Cache Objects in database with filename SAMPLE CACHE_AREA1 2 DOMAIN Creates a domain definition.? A domain defines the set of values, character set, collating? sequence, and formatting clause that a column in a table canC have. The CREATE DOMAIN statement specifies the set of values by. associating a data type with a domain name.5 There are two ways to specify a domain definition:? o With a domain name, data type, and any combination of the! following optional clauses: - Default value - Stored name - Collating sequence? - Formatting clauses such as EDIT STRING or QUERY HEADERD o With the FROM clause and a repository path n ame that refers to/ a field already defined in the repositoryA When the CREATE DOMAIN statement executes, SQL adds the domain definition to the database.C If you attached to the database with the PATHNAME specification,9 the domain definition is also added to the repository.? You can refer to a domain instead of an SQL data type in the= CREATE and ALTER TABLE statements, and in formal parameterA declarations in functions and procedures. If the domain has toA  change, you need only change that one domain definition (using= the ALTER DOMAIN statement) to change all the tables. This; ability makes it easier to keep applications consistent.9 A domain can be referenced in the following locations:. o CREATE, ALTER and DROP DOMAIN statements> o CREATE and ALTER TABLE statements as the data type for a column> o CREATE and ALTER MODULE statements as the data type of a> routine parameter, or the data type of declared va riable> o CREATE FUNCTION statement as the data type of a function" parameter or function result@ o CREATE PROCEDURE statement as the data type of a procedure parameterA o CREATE and ALTER SYNONYM statement as the base object for a synonym* o as the datatype of a CAST expressionC o as a data type of a DECLARE variable statement in interactive SQLD o as the source in the EDIT USING clause of the SELECT and PRINTA statements in in!teractive SQL. The EDIT STRING is inherited from that domain. 3 Environment+ You can use the CREATE DOMAIN statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format CREATE DOMAIN -+ +--------------+9 +-> +-----------------------------------++9 | +-> STORED NAME IS ---+|9 |+-----------------------------------------------------+9 |++-> IS data-type -+-+----------------------------+---+9 | +-> AS data-type -+ +--> DEFAULT value-expr -----+ |9 | +--------------------------------------------------+7 | +-+--------------------------------------------+-+7 | +-> COLLATING SEQUENCE IS --+ |7 | +-> NO COLLATING SEQUENCE -------------------+ |7 | +------------------------------------------------+= | +-+------#----------------+-+------------------------++->; | +-> domain-constraint -+ ++> sql-and-dtr-clause -++|; | +---------<------------+ |; +-> FROM -> +----------------->----------+---+7 +-> DATABASE ALIAS --+ domain-name = 7 -+---------------------------+-> ---> +-+-> -+-> . -+ +-> -------+ data-type = 6 --+-> char-data-types ----------------- $----------+-->3 +-> TINYINT --------------+-----+----------+---+3 +-> SMALLINT -------------+ +-> () -+ |3 +-> INTEGER --------------+ |3 +-> BIGINT ---------------+ |3 +-> LIST OF BYTE VARYING -+ |3 +-> DECIMAL -++-----------------------------+--+3 +-> NUMERIC -++-> ( -> +----------+-> ) + |3 | +-> , -+ |3 +-> FLOAT -+----------+------------------------+3 |% +-> () -+ |3 +-> REAL --------------------------------------+3 +-> DOUBLE PRECISION --------------------------+3 +-> date-time-data-types ----------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+ |K +-> CHARACTER VARYING &+ |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER -+ ' |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+---------------(--+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac --------------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+  interval-qualifier = ; --+-> YEAR ---> prec --+-------------+-----------------+->9 | +-> TO MONTH -+ |9 +-> MONTH --> prec ----------------------------------+9 +-> DAY ----> prec --+----------------------- )--------+9 | +-> TO -+-> HOUR ---------------+9 | +-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> HOUR ---> prec --+-------------------------------+9 | +-> TO -+-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> MINUTE -> prec --+-------------------------------+9 | +-> TO SECOND ------> frac -----+9 +-> SECOND *-> seconds-prec --------------------------+ literal = --+-> numeric-literal ----+---> +-> string-literal -----+ +-> date-time-literal --+ +-> interval-literal ---+  domain-constraint = > --+----------------------------------------------------+---->9 +-> CHECK ( predicate ) -+--------------------------++8 +-> constraint-attributes -+  sql-and-dtr-clause = @ -+-> QUERY HEADER IS -+> +----------- +-------+->> | +------ / <--------+ |> +-> EDIT STRING IS ------------------------+> | |> +-> QUERY NAME FOR -+-> DTR --------+-> IS +> | +-> DATATRIEVE -+ |> +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS ---+> | +-> DATATRIEVE -+ |> +-> NO QUERY HEADER ------------------------,---------------+> +-> NO EDIT STRING ----------------------------------------+> +-> NO QUERY NAME ----+--> FOR -+-> DTR --------+----------+> +-> NO DEFAULT VALUE -+ +-> DATATRIEVE -+ |> +-> COMMENT IS -+-> -+---------------------+( +------ / <----------+  3 Arguments 4 char-data-types; A character type. See the Data_Types HELP topic for more information on data types. 4 character-set-name A valid- character set. 4 COLLATING_SEQUENCE7 Specifies a collating sequence for the named domain.> The OpenVMS National Character Set (NCS) utility provides aA set of predefined collating sequences and also lets you defineA collating sequences of your own. The COLLATING SEQUENCE clauseD accepts both predefined and user-defined NCS collating sequences.B Before you use the COLLATING SEQUENCE clause in a CREATE DOMAINC statement, you must first specify the NCS collating s.equence forC SQL using the CREATE COLLATING SEQUENCE statement. The sequence-B name argument in the COLLATING SEQUENCE clause must be the sameC as the sequence-name in the CREATE COLLATING SEQUENCE statement. 4 COMMENT_IS@ Adds a comment about the domain. SQL displays the text of the@ comment when it executes a SHOW DOMAIN statement. Enclose the? comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 DATABAS/E_ALIAS_aliasA In the FROM path-name clause, specifies the name for an attachB to a particular database. SQL adds the domain definition to the% database referred to by the alias.D If you do not specify an alias, SQL adds the domain definition toC the default database. See the User_Supplied_Names HELP topic for5 more information on default databases and aliases. 4 date-time-data-types@ A data type that specifies a date, time, or interval. See theB Data_Types 0HELP topic for more information about date-time data types. 4 DEFAULT_value-expr) Provides a default value for a domain.9 You can use any value expression including subqueries,@ conditional, character, date/time, and numeric expressions asC default values. See Value Expressions for more information about value expressions.D For more information about NULL, see the NULL_Keyword HELP topic.? The value expressions described in Value Expressions include@ 1 DBKEY and aggregate functions. However, the DEFAULT clause is? not a valid location for referencing a DBKEY or an aggregate> function. If you attempt to reference either, you receive a compile-time error.@ If you do not specify a DEFAULT for a column, it inherits the? DEFAULT from the domain. If you do not specify a default for? either the column or domain, SQL assigns NULL as the default value. 4 domain-constraint- Creates a constraint for the named domain. 2@ Specify a domain constraint when you create a domain to limitD which values can be stored in columns based on the domain. DomainD constraints specify that columns based on the domain contain onlyA certain data values or that data values can or cannot be null.@ Use the CHECK clause to specify that a value must be within a@ specified range or that it matches a list of values. When youB specify a CHECK clause for a domain constraint, you ensure that? all values stored in co3lumns based on the domain are checked consistently. 4 domain-nameC The name of a domain you want to create. The domain name must beC unique among domain names in the schema. You can qualify it with= an alias or (in multischema databases only) a schema name. 4 FROM_pathname; Specifies the repository path name of a repository field? definition. SQL creates the domain using the definition fromD this field and gives the domain the name of the field definitio 4n.? Creating a domain based on a repository domain definition isC useful when many applications share the same definition. ChangesA to the common definition can be automatically reflected in all applications that use it.B You can create a domain using the FROM path-name clause only if@ the field definition in the repository was originally createdD using the repository CDO utility. For instance, you cannot createA a domain using the FROM path-name clause if the definitio 5n was> created in the repository as part of an SQL session. Oracle? Rdb requires that the field names referenced in the VALID IFC expression of the CDO utility match the name of the global field being defined or changed.& NOTE9 Changes by other users or applications to the field9 definition in the repository will affect the domain= definition once the database is integrated to match the= repository with an INTEGRATE DATAB6ASE . . . ALTER FILES statement.A You can use the FROM path-name clause only if the database was> attached specifying PATHNAME. You can specify either a full; repository path name or a relative repository path name.D You cannot specify formatting clauses when you use the FROM path-, name form of the CREATE DOMAIN statement.C You cannot use the FROM path-name clause when embedding a CREATE3 DOMAIN statement in a CREATE DATABASE statement. 4 data-type 7 Syntax options: IS data-type AS data-type@ A valid SQL data type. See the Data_Types HELP topic for more information on data types. 4 NO_COLLATING_SEQUENCEA Specifies that this domain uses the standard default collatingD sequence, that is, ASCII. Use the NO COLLATING SEQUENCE clause toB override the collating sequence defined for the database in the/ CREATE DATABASE or ALTER DATABASE statement. 4 sql-and-dtr-clauseD Optional SQL and DATA 8TRIEVE formatting clause. See the DATATRIEVE9 HELP topic for more information on formatting clauses. 4 STORED_NAME_ISC Specifies a name that Oracle Rdb uses to access a domain created= in a multischema database. The stored name lets you access@ multischema definitions using interfaces, such as Oracle RMU,D the Oracle Rdb management utility, that do not recognize multipleB schemas in one database. You cannot specify a stored name for aA domain in a database that does 9not allow multiple schemas. ForC more information about stored names, see the User_Supplied_Names HELP topic. 3 Examples: Example 1: Creating a domain for a standard EMPLOYEE_ID definitionC The following example creates the domain ID_DOM, which will be a6 standard definition of columns for the employee ID:$ SQL> CREATE DOMAIN ID_DOM CHAR(5) SQL> COMMENT IS. cont> 'standard definition of employee id'; 1 Example 2: Creating a domain for standard dat:eD The following example creates the domain STANDARD_DATE_DOM, which( includes the edit string DD-MMM-YYYY:, SQL> CREATE DOMAIN STANDARD_DATE_DOM DATE% cont> EDIT STRING IS 'DD-MMM-YYYY' SQL> COMMENT IS2 cont> 'standard definition for complete dates';2 Example 3: Creating domains with default valuesC The following example creates two domains: ADDRESS_DATA2_DOM andD WORK_STATUS_DOM. The ADDRESS_DATA2_DOM domain has a default valueB of NULL; the WORK_STATUS_DOM ;domain has a default value of 1 to! signify full-time work status.0 SQL> CREATE DOMAIN ADDRESS_DATA2_DOM CHAR(20) cont> DEFAULT NULL; SQL> --. SQL> CREATE DOMAIN WORK_STATUS_DOM SMALLINT cont> DEFAULT 1;> Example 4: Basing a domain on a repository field definition> The following example illustrates using the repository as a: source for the definition in a CREATE DOMAIN statement: $ SQL$4 SQL> ATTACH 'PATHNAME CDD$TOP.SQL.RDB.TEST.DATE';' SQL> CREATE D<OMAIN FROM DOMAIN_TEST; SQL> SHOW DOMAIN) User domains in database with pathname2 SYS$COMMON:[CDDPLUS]SQL.RDB.TEST.DATE;1) DOMAIN_TEST BIGINT9 Example 5: Creating a domain with a collating sequenceA The following example creates a domain with the predefined NCSC collating sequence SPANISH. Note that you must first execute the' CREATE COLLATING SEQUENCE statement: SQL> --2 SQL> CREATE COLLATING SEQUENCE SPANISH SPANISH;0 SQL> =CREATE DOMAIN LAST_NAME_SPANISH CHAR(14)' cont> COLLATING SEQUENCE IS SPANISH; SQL> --% SQL> SHOW DOMAIN LAST_NAME_SPANISH+ LAST_NAME_SPANISH CHAR(14) Collating sequence: SPANISH D Example 6: Creating a domain using the database default character set> For each of the following examples, assume the database was@ created specifying the database default character set as DEC_1 KANJI and the national character set as KANJI.C The following exa>mple creates the domain DEC_KANJI_DOM using the" database default character set: SQL> SHOW CHARACTER SET;% Default character set is DEC_KANJI" National character set is KANJI( Identifier character set is DEC_KANJI% Literal character set is DEC_KANJI Alias RDB$DBHANDLE:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI, SQL> CREATE DOMAIN DEC_KANJI_DOM CHAR(8); SQL> SHOW DOM?AIN6 User domains in database with filename MIA_CHAR_SET* DEC_KANJI_DOM CHAR(8)C Because the CREATE DOMAIN statement does not specify a character@ set, Oracle Rdb defines the domain using the database default= character set. The database default character set does not* display with the SHOW DOMAIN statement.B An equivalent statement to the previous CREATE DOMAIN statement is:D SQL> CREATE DOMAIN DEC_KANJI_DOM CHAR(8) CHARACTER SET DEC_KANJI;@ @ Example 7: Creating a domain using the national character set? The following example creates the domain KANJI_DOM using theB NCHAR data type to designate use of the national character set:) SQL> CREATE DOMAIN KANJI_DOM NCHAR(8); SQL> SHOW DOMAIN6 User domains in database with filename MIA_CHAR_SET* DEC_KANJI_DOM CHAR(8)* KANJI_DOM CHAR(8)* KANJI 8 Characters, 16 Octets@ When a character set other than the default iAs specified, theC SHOW DOMAIN statement displays the character set associated with the domain.D Two statements equivalent to the previous CREATE DOMAIN statement are:1 SQL> CREATE DOMAIN KANJI_DOM NATIONAL CHAR(8);< SQL> CREATE DOMAIN KANJI_DOM CHAR(8) CHARACTER SET KANJI;* Example 8: Creating a domain constraint5 The following example creates a domain constraint:I SQL> -- The SET DIALECT 'SQL99' statement sets the default date format/ SQL> -- to the ANSIB/ISO SQL standard format. SQL> -- SQL> SET DIALECT 'SQL99'; SQL> --Q SQL> -- The following domain ensures that any dates inserted into the database* SQL> -- are later than January 1, 1900: SQL> --# SQL> CREATE DOMAIN TEST_DOM DATE cont> DEFAULT NULL1 cont> CHECK (VALUE > DATE'1900-01-01' OR$ cont> VALUE IS NULL)" cont> NOT DEFERRABLE; SQL>M SQL> -- The following example creates a table with one column based on theC SQL> -- domain TEST_DOM: SQL> -- SQL> CREATE TABLE DOMAIN_TEST% cont> (DATE_COL TEST_DOM); SQL> --K SQL> -- SQL returns an error if you attempt to insert data that does not, SQL> -- conform to the domain constraint: SQL> -- SQL> INSERT INTO DOMAIN_TEST% cont> VALUES (DATE'1899-01-01');J %RDB-E-NOT_VALID, validation on field DATE_COL caused operation to fail 2 FUNCTIONC Creates an external function as a schema object in an Oracle Rdb D database.? The CREATE FUNCTION statement is documented under the CREATE< Routine. For complete information on creating an external: function definition, see the CREATE Routine Help topic. 2 INDEXA Creates an index for a table. An index allows direct access to7 the rows in the table to avoid sequential searching.B You define an index by listing the columns in a table that makeD up the index. You can define more than one index for a table. TheA index can be madeE up of one column, or two or more columns. AnB index made up of two or more columns is called a multisegmented index.D Optional arguments to the CREATE INDEX statement let you specify:? o The type of index structure (hashed, sorted nonranked, or sorted ranked)C o The names of a storage area or storage areas that contain the indexC o Physical characteristics of a sorted index structure, such asA index node size and the initial fullness percentage Fof each nodeD o Compression characteristics, including compressed key suffixesB for text indexes and integer column compression for smallint or integer numeric columnsA o Compression of space characters from text data types and of* binary zeros from nontext data types? o Thresholds for the logical storage areas that contain the index( o A comment for the index definition> o Whether logging to the .ruj and .aij files is enabled or- G disabled for the create index operation 3 Environment* You can use the CREATE INDEX statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format? CREATE -+-----------+-> INDEX ------------------+? +-> UNIQUE -+ |? +------------------------------------ H------------------------+? +--+-----------------------------------+-> ON --+? +-> STORED NAME IS ---+ |? +----------------------------- <-----------------------------+ +> ( +> --+ | +--------------+B | +-+-------------++-----------------------------+-+- ) -+B | +> ASCENDING -++> SIZE IS ---------------+ | |B | +> DESCENDING ++> MAPPING VALUES TO -+ | |B +-------------I--------- , <--------------------------+ |B +------------------------------ <-------------------------------+? ++----------------+-+----------------------------+-----------+? +-> type-clause -+ +-> index-attributes-clause -+ |? +------------------------------<-----------------------------+B ++-----------------------+--------------------------------------> +-> index-store-clause -+  type-clause = E -> TYPE IS +> HASHED +-------------+--------------------------- J---+>D | +> ORDERED ---+ |D | +> SCATTERED -+ |D +> SORTED +-----------------------------------------+-+|D +> RANKED -+-----------------------------++ ||D +> DUPLICATES ARE COMPRESSED -+ ||D +---------------------------------------------+|D +-+-----------------------+--------------------+/ K +> sorted-index-clause -+  sorted-index-clause = 2 --+-+-> NODE SIZE ----------+-+-->/ | +-> PERCENT FILL ---------+ |/ | +-> USAGE -+-> UPDATE -+---------------+ |/ | +-> QUERY --+ |/ +------------------- <---------------------+  index-attributes-clause = C -+-+---------------------------------------------------------+-+->A | +-> ENABLE COMPRESSION rlc-attr ------------------------- L+ |A | +-> DISABLE COMPRESSION ----------------------------------+ |A | +-> threshold-clause -------------------------------------+ |A | +-> LOGGING ----------------------------------------------+ |A | +-> NOLOGGING --------------------------------------------+ |A | +-> COMMENT IS -+-> '' -+-------------------------+ |A | | +------- / <----+ | |A | +-> PREFIX CARDINALITY COLLECTION IS -+-> ENABLED ------+-+ |A | | M +-> ENABLED FULL -+ | |A | | +-> DISABLED -----+ | |A | +-> MAINTENANCE IS -+-> DISABLED -----------------+-------+ |A | +-> ENABLED -+--------------+-+ |A | +-> DEFERRED --+ |A | +-> IMMEDIATE -+ |A +---------------------------- <-------------------------------+ rlc-attr = / --+--------------------------N------+--------->% +--> (MINIMUM RUN LENGTH ) --+ index-store-clause =  STORE ----------------------+ +---------------------------+B ++-> IN area-spec ---------------------------------------------+>A +-> USING -> ( -+--> -+-> ) ----------+ |A +------- , <--------+ | |A +---------------------------------------------------+ |A ++> IN area-spec -------------------------------------+ |A | +-- O------------------------------------------------+ |A | +-> WITH LIMIT OF -> ( -+--> -+-> ) ---+---+ |A | +------ , <-----+ | | |A +-----------------------<--------------------------+ | |A +--------------------------------------------------------+ |A ++------------------------------------------------------------++@ +-> OTHERWISE IN area-spec ----------------------------------+ threshold-clause = = --+-> T PHRESHOLD -+-> IS -+-> ( --> --> ) ---------+->; | +-> OF -+ |; | |; +-> THRESHOLDS -+-> ARE -+-----------+ |; +-> OF -+ | |; +----------------------------------+ |; +-> ( --> -+---------------------------+-> ) -+4 +-> , -+-------------+4 Q +-> , -+ area-spec = I --> -+---------------------------------------------------+->G +-> ( -++-> threshold-clause ---------------++-> ) -+@ |+-> LOGGING ------------------------+|@ |+-> NOLOGGING ----------------------+|@ |+-> PARTITION ---------------+|@ |+-> COMMENT IS -+--> 'string' ---+--+|@ | R +------- / <-----+ |@ +---------------- , -----------------+ 3 Arguments 4 ASCENDING@ An optional keyword that causes SQL to create ascending index= segments. If you omit the ASCENDING or DESCENDING keyword, ascending is the default. 4 BUILD_ALL_PARTITIONSC This clause operates on an index in build-pending state (createdC using MAINTENANCE IS ENABLED DEFERRED) and builds all incompleteB partitions. If the index isS not in build-pending state then the3 statement completes successfully with a warning.A No other clauses may appear in the same ALTER INDEX statement. !4 BUILD_PARTITION_partition-nameC This clause operates on an index in build-pending state (created> using MAINTENANCE IS ENABLED DEFERRED) and builds the namedA partition. If the index is not in build-pending state then the3 statement completes successfully with a warning.A No other clauses may appear in the sameT ALTER INDEX statement. 4 column-name@ The name of the column or columns that make up the index key.B You can create a multisegmented index key by naming two or moreC columns, which are joined to form the index key. All the columnsA must be part of the same table. Separate multiple column names with commas.& NOTE@ If column-name refers to a column defined as CHAR, VARCHAR? or LONG VARCHAR data type, the size of the columUn must beA less than or equal to 254 characters, or the SIZE IS clause must be used. 4 COMMENT_IS_'string_'A Adds a comment about the storage map definition for the index.? SQL displays the text of the comment when it executes a SHOWC INDEXES statement. Enclose the comment in single quotation marksB ( ') and separate multiple lines in a comment with a slash mark (/). 4 DESCENDINGA An optional keyword that causes SQL to create descending indeVx= segments. If you omit the ASCENDING or DESCENDING keyword, ascending is the default. 4 DISABLE_COMPRESSION Disables compression indexes.A If compression is disabled, no form of compression is used forB hashed indexes, and prefix compression or suffix compression isA used for sorted indexes. Prefix compression is the compressionD of the first bytes of an index key that are common in consecutiveB index keys. Prefix compression saves space by not storing theseWA common bytes of information. Conversely, suffix compression isD the compression of the last bytes from adjacent index keys. These3 bytes are not necessary to guarantee uniqueness.< You cannot enable index compression using the ALTER INDEXA statement once you specified the DISABLE COMPRESSION clause of the CREATE INDEX statement., Index compression is disabled by default. 4 DUPLICATES_ARE_COMPRESSED? Specifies that duplicates are compressed. If a sorted ranke XdB index allows duplicate entries, you can store many more records< in a small space when you compress duplicates, therefore,= minimizing I/O and increasing performance. Oracle Rdb uses= patented technology called byte-aligned bitmap compression? to represent the dbkeys for the duplicate entries instead ofD chaining the duplicate entries together with uncompressed dbkeys.= Duplicates are compressed by default if you specify RANKED; without specifying the DUPLICATES ARE CYOMPRESSED clause.? You cannot use the DUPLICATES ARE COMPRESSED clause when youC create nonranked indexes or when you specify the UNIQUE keyword.A See the Oracle Rdb Guide to Database Design and Definition for4 more information on sorted ranked B-tree indexes. 4 ENABLE_COMPRESSION; Specifies that sorted and hashed indexes are stored in a compressed form.D If compression is enabled, Oracle Rdb uses run-length compression@ to compress a sequence of space c Zharacters (octets) from textA data types and binary zeros from nontext data types. Different= character sets have different representations of the spaceC character. Oracle Rdb compresses the representation of the spaceA character for the character sets of the columns comprising the index values.= You cannot disable index compression using the ALTER INDEX@ statement once you specified the ENABLE COMPRESSION clause of the CREATE INDEX statement.A For more informatio[n on compressed indexes, see the Oracle Rdb+ Guide to Database Design and Definition. 4 IN_area_name@ Associates the index directly with a single storage area. All; entries in the index are stored in the area you specify. 4 index-name? The name of the index. You can use this name to refer to theB index in other statements. You must qualify the index name with@ the authorization identifier if the schema is not the defaultD schema. When choosing a name, spe\cify a valid name. See the User_2 Supplied_Names HELP topic for more information. 4 index-store-clauseB A storage map definition for the index. You can specify a storeD clause for indexes in a multifile database only. The STORE clauseB in a CREATE INDEX statement allows you to specify which storage2 area files are used to store the index entries:? o All index entries can be associated with a single storage area.9 o Index entries can be systematically dist ]ributed, orB partitioned, among several storage areas by specifying upperB limits on the values for a key in a particular storage area.B If you omit the storage map definition, the default is to storeA all the entries for an index in the main default storage area.A You should define a storage area for an index that matches the9 storage map for the table with which it is associated.> In particular, under the following conditions, the databaseC system stores the i ^ndex entry for a row on or near the same data% page that contains the actual row:= o The storage areas for a table have a mixed page format.C o You specify an identical store clause for the index as exists' in the storage map for the table.? o The storage map for the table also names the index in the! PLACEMENT VIA INDEX clause.B Such coincidental clustering of indexes and rows can reduce I/OC operations. With hashed indexes and coincidental clustering, _theC database system can retrieve rows for exact-match queries in one I/O operation.B For sorted indexes, specifying an identical storage map reduces! I/O contention on index nodes. 4 LOGGING Syntax options:C LOGGING |NOLOGGING The LOGGING clause specifies that index nodesC and hash buckets be logged when written to the database. LoggingD includes writing data and management records to the recovery-unitA journal file (.ruj) and after-image journal files ` (.aij). When@ the NOLOGGING clause is specified then only a small number ofB management records are logged in the recovery-unit journal fileC (.ruj) and after-image journal files (.aij). See the Usage Notes below for more information.: LOGGING and NOLOGGING can be specified per storage areaB (partition) or as a default for the CREATE INDEX statement. The@ LOGGING and NOLOGGING clauses are mutually exclusive; specify/ only one. The LOGGING clause is the default. 4 a MAINTENANCE_IS_DISABLEDB An index created using this clause is not maintained. The index( definition serves only as a template. "4 MAINTENANCE_IS_ENABLED_DEFERREDA An index created using this clause does not contain index keys? for the current rows in the table. Until this index is builtC (using ALTER INDEX . . . BUILD), the index is placed in a build-A pending state. Any table with a build-pending index can not be: updated using the INSERT, DELETE, or UPDATE statebments. #4 MAINTENANCE_IS_ENABLED_IMMEDIATE1 This is the default behavior for CREATE INDEX. 4 MAPPING_VALUES l to hC A compression clause for all-numeric columns that translates theA column values into a compact, encoded form. You can mix mapped@ and unmapped columns, but the most storage space is gained by@ building indexes of multiple columns of data type SMALLINT orA INTEGER. Oracle Rdb attempts to compress all such columns into the smallest posscible space.B The l (low) through h (high) specifies the range of integers as the value of the index key.: The Oracle Rdb SQL Reference Manual describes addiional$ restrictions about this argument. 4 MINIMUM_RUN_LENGTH? Specifies the minimum length of the sequence that Oracle Rdb@ should compress. You cannot alter this value once you set it.= If you specify MINIMUM RUN LENGTH 2, Oracle Rdb compressesA sequences of two or more spaces or of two or more binary dzeros? for single-octet character sets, and compresses one space orC one binary zero for multi-octet character sets. As it compressesA the sequences, Oracle Rdb replaces the sequence with the value> of the minimum run length plus 1 byte. If many of the index= values contain one space between characters in addition toA trailing spaces, use a minimum run length of 2, so that you doC not inadvertently expand the index beyond the 255-byte limit. IfC you inadvertently expand ethe index beyond 255 bytes during index2 creation, Oracle Rdb returns a warning message.B The default minimum run length value is 2. Valid values for the@ minimum run length range from 1 to 127. Oracle Rdb determines# which characters are compressed. 4 NODE_SIZE( The size in bytes of each index node.? The number and level of the resulting index nodes depend on: o This number-bytes value+ o The number and size of the index keys> o The value speciffied in the PERCENT FILL or USAGE clauses: If you omit the NODE SIZE clause, the default value is:@ o 430 bytes if the total index key size is 120 bytes or lessB o 860 bytes if the total index key size is more than 120 bytesB The index key size is the number of bytes it takes to represent( the column value in the sorted index.9 See the Oracle Rdb SQL Reference Manual for details onD determining the valid range for a user-specified index node size. 4 OTHERWISE_IgN_area_name@ For partitioned storage maps only, specifies the storage area@ that is used as the overflow partition. An overflow partition? is a storage area that holds any values that are higher than@ those specified in the last WITH LIMIT TO clause. An overflowC partition holds those values that "overflow" the partitions that have specified limits. 4 PARTITION_name? Names the partition. The name can be a delimited identifier.A Partition names must be unique hwithin the index. If you do notC specify this clause, Oracle Rdb generates a default name for the partition. 4 PERCENT_FILLA Specifies the initial fullness percentage for each node in theA index structure being changed. The valid range is 1 percent to* 100 percent. The default is 70 percent.D Both the PERCENT FILL and USAGE clauses specify how full an indexB node should be initially. Specify either PERCENT FILL or USAGE, but not both. ,4 PREFIX_CARDIN iALITY_COLLECTION_IS_DISABLEDA This setting disables the cardinality collection and, instead,? uses a fixed scaling algorithm which assumes a well balanced index tree. +4 PREFIX_CARDINALITY_COLLECTION_IS_ENABLED@ This is the default behavior for CREATE INDEX. The Oracle RdbB optimizer collects approximate cardinality values for the indexC columns to help in future query optimization. Note that no extraC I/O is incurred to collect these values and, therefore, adjacenjtD key values from other index nodes can not be checked. Hence, someC inaccuracy may be seen for these indexes. In most cases, this is$ adequate for query optimizations. 04 PREFIX_CARDINALITY_COLLECTION_IS_ENABLED_FULLB This setting requests that extra I/O be performed, if required,> to ensure that the cardinality values reflect the key value# changes of adjacent index nodes. 4 REBUILD_ALL_PARTITIONSD This clause combines the TRUNCATE and BUILD actions into ka single@ function. No other clauses may appear in the same ALTER INDEX statement. #4 REBUILD_PARTITION_partition-nameD This clause combines the TRUNCATE and BUILD actions into a singleC function for the named partition. No other clauses may appear in" the same ALTER INDEX statement. 4 SIZE_IS_n@ A compression clause for text or varying text index keys thatB limits the number of characters used for retrieving data. The nA specifies the number of characterls of the key that are used in the index.& NOTE= Although you can create a SIZE IS index and specify theA UNIQUE clause, truncating the index key values may make theB key values non-unique. In this case, the index definition or' insert or update statements fail. 4 STORE_IN_area_name@ Associates the index directly with a single storage area. All; entries in the index are stored in the area you specify. 4 STO mRE_USING8 Specifies columns whose values are used as limits forC partitioning the index across multiple storage areas. You cannot4 name columns not specified as index key segments.B If the index key is multisegmented, you can include some or all> the columns that are joined to form the index key. You must@ specify the columns in the order in which they were specified? when the index key was defined. If you only include a subset? of the columns, you must include the leadin ng segments of the multisegmented index.7 For example, if a CREATE INDEX statement specifies aC multisegmented index based on the columns LAST_NAME, FIRST_NAME,C and MIDDLE_INITIAL, then the USING clause must include the first? segment LAST_NAME, or the first two segments, LAST_NAME, andA FIRST_NAME, or all the segments of the index. This is true for sorted indices only.B The database system uses the values of the columns specified in@ the STORE USING clause as a o key to determine in which storage? area an index entry associated with a new table row belongs.C There is no restriction for hashed scattered indexes. For hashed@ ordered indexes, all segments listed, except the last segment= can be included. Also, HASHED ORDERED indexes have further@ restrictions on the data type of the final column; it must be, a date/time or integer numeric data type. 4 STORED_NAME_ISC Specifies a name that Oracle Rdb uses to access an index cr peatedB in a multischema database. The stored name allows you to access@ multischema definitions using interfaces, such as Oracle RMU,D the Oracle Rdb management utility, that do not recognize multiple@ schemas in one database. You cannot specify a stored name forC an index in a database that does not allow multiple schemas. ForC more information about stored names, see the User_Supplied_Names HELP topic. 4 table-nameC The name of the table that includes the index q. The table must be# in the same schema as the index. 4 threshold-clauseD Specifies one, two, or three default threshold values for logical= areas that contain the index in storage areas with uniform? page formats. By setting threshold values, you can make sureA that Oracle Rdb does not overlook a page with sufficient space> to store compressed data. The threshold values (val1, val2,? and val3) represent a fullness percentage on a data page andB establish three r possible ranges of guaranteed free space on theB data pages. For more information about logical area thresholds, see the CREATE STORAGE_MAP.; If you use data compression, you should use logical area4 thresholds to obtain optimum storage performance.B You cannot specify the thresholds for the storage map attribute@ for any area that is a mixed page format. If you have a mixedA page format, set the thresholds for the storage area using the> ADD STORAGE AREA or CREATE STORsAGE AREA clause of the ALTER3 DATABASE, CREATE DATABASE, or IMPORT statements.B For more information about SPAM pages, see the Oracle Rdb Guide% to Database Design and Definition. 4 TRUNCATE_ALL_PARTITIONSD This clause operates in a similar way to TRUNCATE TABLE, but justA on one index. The index is automatically set to MAINTENANCE ISB ENABLED DEFERRED (i.e. build-pending state) if it was currently= ENABLED IMMEDIATE. Otherwise is stays in a disabled state.A Nto other clauses may appear in the same ALTER INDEX statement. $4 TRUNCATE_PARTITION_partition-nameD This clause operates on just the named index partition. The index@ is automatically set to MAINTENANCE IS ENABLED DEFERRED (thatB is, build-pending state) if it was currently ENABLED IMMEDIATE.* Otherwise is stays in a disabled state.A No other clauses may appear in the same ALTER INDEX statement. 4 TYPE_HASHED Syntax options:4 TYPE IS HASHED ORDERED | TYPE u IS HASHED SCATTERED= Specifies that the index is a hashed index. If you specify? HASHED, you cannot use the NODE SIZE, PERCENT FILL, or USAGE? clauses. You can, however, specify if the data is ORDERED or' SCATTERED. SCATTERED is the default.C The TYPE IS HASHED SCATTERED clause is appropriate in situationsB where data is not evenly distributed across storage areas. This@ option places a record in a page that is chosen by applying a> hashing algorithm to the index key.v As a result, the record@ distribution pattern is not guaranteed to be even; therefore,? some pages may be chosen more often than others. The TYPE ISC HASHED SCATTERED clause is the default and is recommended unless@ your data meets the following criteria for the TYPE IS HASHED ORDERED clause:C o The last column of the index key must be one of the following data types: - TINYINT - SMALLINT - INTEGER - BIGINT! - DATE (bwoth ANSI and VMS) - TIME - TIMESTAMP - INTERVAL" o The index must be ascending.> o The index must not be compressed or have mapping values.D The TYPE IS HASHED ORDERED clause is ideal for applications whereD the index key values are evenly distributed across a given range.@ This places a record in a page derived by applying an orderedD hashing algorithm to the index key. As a result, the distributionA pattern is guaranteed to follow the ind xex key distribution. In> addition, if you know the range of values, you can size the= storage area and pages to minimize overflows. If the index@ key values are not evenly distributed, use the TYPE IS HASHED SCATTERED clause.> Hashed indexes must be stored in storage areas created withB mixed page format, which means they are valid only in multifile databases.A Hashed indexes provide fast and direct access to specific rowsC and are effective mainly for queries that y specify an exact-match> retrieval on a column or columns that are also the key to aA hashed index. (For instance, SELECT EMPLOYEE_ID FROM EMPLOYEES? WHERE EMPLOYEE_ID = "00126", makes effective use of a hashed, index with EMPLOYEE_ID as the index key.)@ In a hashed indexing scheme, the index key value is converted? mathematically to a relative page number in the storage area@ of a particular table. A hash bucket is a data structure thatC maintains information about an in zdex key, and a list of internalA pointers, called database keys or dbkeys, to rows that containA the particular value of the index key. To find a row using theD hashed index, the database system searches the hash bucket, finds9 the appropriate dbkey, and then fetches the table row.C Hashed indexes are most effective for random, direct access whenD the query supplies the entire index key on which the hashed index? is defined. For these types of access, I/O operations can be {@ significantly reduced. This is particularly useful for tables? with many rows and large indexes. For example, to retrieve aB row using a sorted index that is four levels deep, the databaseD system may need to perform five I/O operations. By using hashing,; the number of I/O operations is reduced to two, at most.@ You can define a hashed index and a sorted index for the sameC column. Then, depending on the type of query you use, the OracleA Rdb optimizer chooses the appro |priate method of retrieval. For@ example, if your query contains an exact-match retrieval, the= optimizer uses hashed index access. If your query contains? a range retrieval, the optimizer uses the sorted index. This= strategy incurs the additional overhead of maintaining twoB indexes, therefore, you need to consider the advantages of fastB retrieval against the disadvantages of updating two indexes for every change to data.A See the Oracle Rdb Guide to Database Design a }nd Definition forA a detailed discussion of the relative advantages of hashed and sorted indexes. 4 TYPE_IS_SORTEDB Specifies that the index is a sorted, nonranked (B-tree) index.@ If you omit the TYPE IS clause, SORTED is the default. SortedA indexes improve the performance of queries that compare valuesC using range operators (like BETWEEN and greater than (>)). (For? example, SELECT EMPLOYEE_ID FROM EMPLOYEES WHERE EMPLOYEE_ID> > 200 is a query that specifi ~es a range retrieval and makes$ effective use of a sorted index.)@ You can define a hashed index and a sorted index for the sameC column. Then, depending on the type of query you use, the OracleA Rdb optimizer chooses the appropriate method of retrieval. For@ example, if your query contains an exact-match retrieval, the@ optimizer may use hashed index access. If your query contains? a range retrieval, the optimizer uses the sorted index. This= strategy incurs the additiona l overhead of maintaining two@ indexes; however, you need to consider the advantages of fastB retrieval against the disadvantages of updating two indexes for every change to data.A See the Oracle Rdb Guide to Database Design and Definition forC more information on the relative advantages of hashed and sorted indexes.< If you specify a SORTED index, you can optionally specify> NODE SIZE, PERCENT FILL, and USAGE clauses that control the- characteristics of the nodes in the index. 4 TYPE_IS_SORTED_RANKED? Specifies that the index is a sorted, ranked (B-tree) index.A The ranked B-tree index allows better optimization of queries,B particularly queries involving range retrievals. Oracle Rdb canC make better estimates of cardinality, reducing disk I/O and lockA contention. Oracle Rdb recommends using ranked sorted indexes. 4 UNIQUEB A keyword that specifies whether or not each value of the index@ must be unique. If you try to store the same value twice in aA column or set of columns that have an index defined as UNIQUE,B SQL returns an error message the second time and does not storeC or modify the row that contains the value. This is true for null% values as well as any other value.D If you specify UNIQUE, SQL checks as it executes the CREATE INDEXB statement to see if the table already contains duplicate values for the index. 4 USAGE Syntax options: USAGE UPDATE | USAGE QUERYC Specifies a PERCENT FILL value appropriate for update- or query-C intensive applications. The USAGE UPDATE clause sets the PERCENTD FILL value at 70 percent. The USAGE QUERY clause sets the PERCENT FILL value at 100 percent. 4 WITH_LIMIT_OFB Specifies the highest value for the index key that resides in aA particular storage area if ASCENDING is defined. If DESCENDINGC is defined, the lowest value is specified for the index key thatC resides in a part icular storage are. For multicolumn index keys,+ specify a literal value for each column.D The number of literals in the list must be the same as the numberB of columns in the USING clause. Repeat this clause to partitionA the entries of an index among multiple storage areas. The dataD type of the literals must agree with the data type of the column.B For character columns, enclose the literals in single quotation marks.B If you are creating a multisegmented index using multisegmented? keys and the STORE USING . . . WITH LIMIT clause, and if the@ values for the first key are all the same, then set the limitB for the first key at that value. This ensures that the value ofB the second key determines the storage area in which each row is stored. 3 Examples+ Example 1: Creating a simple table indexA This statement names the index (EMP_EMPLOYEE_ID) and names the2 column to serve as the index key (EMPLOYEE_ID).A The UNIQUE argument causes SQL to return an error message if a? user tries to store an identification number that is already assigned.8 SQL> CREATE UNIQUE INDEX EMP_EMPLOYEE_ID ON EMPLOYEES cont> (EMPLOYEE_ID);> Example 2: Creating an index with descending index segments= This statement names the index (EMP_EMPLOYEE_ID) and names? the column to serve as the descending index key (EMPLOYEE_ID DESCENDING).D The DESCENDING keyword causes the keys to be sorted in descendingB order. If you do not specify DESCENDING or ASCENDING, SQL sorts the keys in ascending order.8 SQL> CREATE UNIQUE INDEX EMP_EMPLOYEE_ID ON EMPLOYEES% cont> (EMPLOYEE_ID DESCENDING);- Example 3: Creating a multisegmented index/ SQL> CREATE INDEX EMP_FULL_NAME ON EMPLOYEES cont> (LAST_NAME, cont> FIRST_NAME, cont> MIDDLE_INITIAL);B This statement names three columns to be used in the index EMP_> FULL_NAME. SQL concatenates these three columns to make the multisegmented index.1 Example 4: Creating a compressed numeric index) SQL> CREATE INDEX YEAR1_IND ON DEGREES< cont> (YEAR_GIVEN ASCENDING MAPPING VALUES 1950 TO 1970);@ This statement creates ascending index segments for the YEAR_B GIVEN column in the DEGREES table, compressing the year values.- Example 5: Creating a truncated text index- SQL> CREATE INDEX COL_NAME_IND ON COLLEGES# cont> (COLLEGE_NAME SIZE IS 20);B This statement create s a compressed index, COL_NAME_IND, on theD COLLEGES table so that the number of octets from the COLLEGE_NAME9 column that are used as a key cannot exceed 20 octets. > Example 6: Creating an index in a uniform storage area with thresholds., SQL> ALTER DATABASE FILENAME mf_personnel> cont> ADD STORAGE AREA UNIFORM1 PAGE FORMAT IS UNIFORM;, SQL> ALTER DATABASE FILENAME mf_personnel> cont> ADD STORAGE AREA UNIFORM2 PAGE FORMAT IS UNIFORM;' SQL> ATTACH 'FILENAME  mf_personnel';E SQL> CREATE UNIQUE INDEX EMP_THRESHOLDS ON EMPLOYEES (EMPLOYEE_ID) cont> TYPE IS SORTED& cont> STORE USING (EMPLOYEE_ID): cont> IN RDB$SYSTEM (THRESHOLDS ARE (60,75,90)), cont> WITH LIMIT OF ('00200')0 cont> IN UNIFORM1 (THRESHOLD IS (65)), cont> WITH LIMIT OF ('00400')& cont> OTHERWISE IN UNIFORM2) cont> (THRESHOLD OF (90));L %RDB-W-META_WARN, metadata successfully updated with the reported warningE -RDMS-W-IDXCOLEXIST, an index with this column list already exists SQL> --! SQL> SHOW INDEX EMP_THRESHOLDS Indexes on table EMPLOYEES:: EMP_THRESHOLDS with column EMPLOYEE_ID No Duplicates allowed Type is Sorted' Key suffix compression is DISABLED Node size 430, Store clause: STORE USING (EMPLOYEE_ID)4 IN RDB$SYSTEM (THRESHOLDS ARE (60,75,90))& WITH LIMIT OF ('00200')* IN UNIFORM1 (THRESHOLD IS (65))& WITH LIMIT OF ('00400') OTHERWISE IN UNIFORM2" (THRESHOLD OF (90))C This statement uses the STORE clause to partition the index intoD different uniform page format storage areas and apply thresholds.C In Examples 7 and 8, the table COLOURS in the database MIA_CHAR_ SET is defined as: SQL> CREATE TABLE COLOURS) cont> (ENGLISH MCS_DOM,) cont> FRENCH MCS_DOM,+ cont> JA PANESE KANJI_DOM,/ cont> ROMAJI DEC_KANJI_DOM,. cont> KATAKANA KATAKANA_DOM,+ cont> HINDI HINDI_DOM,+ cont> GREEK GREEK_DOM,, cont> ARABIC ARABIC_DOM,. cont> RUSSIAN RUSSIAN_DOM);< Example 7: Creating a simple table index using the octets) character length, which is the default& SQL> SET CHARACTER LENGTH 'OCTETS';A SQL> CREATE INDEX COLOUR_INDEX ON COLOURS (JAPANESE SIZE IS 4) cont> TYPE IS SORTED; SQL> SHOW INDEX COLOUR_INDEX; Indexes on table COLOURS:7 COLOUR_INDEX with column JAPANESE@ size of index key is 4 octets Duplicates are allowed Type is Sorted= The previous statement creates a compressed index key of 4 octets.> Example 8: Creating an index using the CHARACTERS character length* SQL> SET CHARACTER LENGTH 'CHARACTERS';C SQL> CREATE INDEX COLOUR_INDEX_2 ON COLOURS (JAPANESE SIZE IS 4) cont> TYPE IS SORTED;" SQL> SHOW INDEX COLOUR_INDEX_2; Indexes on table COLOURS:7 COLOUR_INDEX_2 with column JAPANESED size of index key is 4 characters Duplicates are allowed Type is Sorted= The previous statement creates a compressed index key of 4 characters.8 Example 9: Creating an index that enables compression@ The following example shows how to create an index and enable. compression with a minimum run length of 2:) SQL> CREATE INDEX EMP_NDX ON EMPLOYEES cont> (EMPLOYEE_ID SIZE IS 4)4 cont> ENABLE COMPRESSION (MINIMUM RUN LENGTH 2); SQL> SHOW INDEX EMP_NDX; Indexes on table EMPLOYEES:: EMP_NDX with column EMPLOYEE_ID9 size of index key is 4 Duplicates are allowed Type is Sorted4 Compression is ENABLED (Minimum run length 2) 0 Example 10: Using the Index Attributes Clause( SQL> CREATE UNIQUE INDEX JOB_JOB_CODE cont> ON JOBS ( cont> JOB_CODE cont> ASC) cont> TYPE IS SORTED" cont> THRESHOLDS ARE (75,83,90) cont> ENABLE COMPRESSION cont> NOLOGGING8 cont> COMMENT IS 'Used for translation of job codes';L %RDB-W-META_WARN, metadata successfully updated with the reported warningN -RDMS-W-DATACMIT, unjournaled changes made; database may not be recoverableD SQL> -- SQL returned this message because the NOLOGGING attribute SQL> -- was set.@ Example 11: Creating an Index and Displaying the Default Node Size5 SQL> -- Create a simple table upon which to define SQL> -- some indexes SQL>% SQL> CREATE TABLE TEST_INDEX_TABLE cont> (A CHAR(70), cont> B INTEGER); SQL>% SQL> -- Default value is 430 bytes SQL>* SQL> CREATE UNIQUE INDEX TEST_INDEX_DEF& cont> ON TEST_INDEX_TABLE (A, B) cont> TYPE IS SORTED  cont> USAGE UPDATE; SQL>+ SQL> SHOW TABLE (INDEX) TEST_INDEX_TABLE) Information for table TEST_INDEX_TABLE0 TEST_INDEX_DEF with column A/ and column B No Duplicates allowed Type is Sorted Compression is DISABLED Node size 430 Percent fill 70 Example 12: Naming Partitions9 SQL> -- Alter mf_personnel database to add three slots> SQL> -- for storage areas and then add three stor age areas., SQL> ALTER DATABASE FILENAME MF_PERSONNEL! cont> RESERVE 3 STORAGE AREAS;S %RDMS-W-DOFULLBCK, full database backup should be done to ensure future recovery, SQL> ALTER DATABASE FILENAME MF_PERSONNEL# cont> ADD STORAGE AREA WAGE_LOW;, SQL> ALTER DATABASE FILENAME MF_PERSONNEL# cont> ADD STORAGE AREA WAGE_MID;, SQL> ALTER DATABASE FILENAME MF_PERSONNEL$ cont> ADD STORAGE AREA WAGE_HIGH;+ SQL> ATTACH 'FILENAME MF_PERSONNEL.RDB';D SQL> -- Create an index on the JOBS table and name the partitions8 SQL> CREATE INDEX WAGE_CLASS_IDX ON JOBS (WAGE_CLASS) cont> TYPE IS SORTED! cont> STORE USING (WAGE_CLASS)= cont> IN WAGE_LOW (PARTITION WAGE_LOW) WITH LIMIT OF ('1')= cont> IN WAGE_MID (PARTITION WAGE_MID) WITH LIMIT OF ('3')6 cont> OTHERWISE IN WAGE_HIGH (PARTITION WAGE_HIGH);= Example 13: Creating a Large Index Partitioned Across Many Storage Areas) First, create the database definition:= SQL> CREATE INDEX ... MAINTENANCE IS ENABLED DEFERRED ...;B Next submit batch jobs to build each partition in parallel. For@ example, each batch job would execute a script similar to the following:" ATTACH 'filename testdatabase'; SET FLAGS 'index_stats';9 ALTER INDEX TRANSACTIONS_INDEX BUILD PARTITION PART_1; COMMIT;= Finally, after the batch jobs have completed, the database> administrator must make the index active for query usage by> changing the maintenance mode to ENABLED IMMEDIATE. A BUILD? ALL PARTITIONS clause could be added in case any step failed; (possibly due to resource limitations or a failed node). SQL> SET FLAGS 'index_stats';D SQL> SET TRANSLATION READ WRITE RESERVING...FOR EXCLUSIVE WRITES;- SQL> ALTER INDEX ... BUILD ALL PARTITIONS;9 SQL> ALTER INDEX ... MAINTENANCE IS ENABLED IMMEDIATE; SQL> COMMIT;A This scheme has several advantages over issuing a CREATE INDEX statement directly:< o The build actions can be run  in parallel, which allowsC better resource usage (read and sort fewer rows), and reduced, execution time for the index creation.> o The partitions being processed are relatively small whenC compared to the full index and, therefore, smaller quantitiesA of data will be processed. This will result in smaller .ruj; files and less AIJ file space for these transactions.> o Each build partition runs in a separate transaction, can> easily be repeated if a step fails, and does not require2 repeating the entire CREATE INDEX statement.A o If any steps have failed, they will also be repeated by the9 BUILD ALL PARTITIONS clause included in the script. 2 MODULEB Defines a module as an object in an Oracle Rdb database. StoredB with the module are its functions and procedures. A function orD procedure written in SQL that resides with the data in a database? is called a stored function or stored procedure. Likewise, aB  module stored in a database is called a stored module. A storedB routine refers to either a stored procedure or stored function.? You invoke a stored procedure with the CALL statement from aC simple statement procedure in embedded SQL, SQL module language,> or interactive SQL or with the CALL statement from within a compound statement.D You invoke a stored function by specifying the function name in a value expression.A SQL uses the concept of a module as its mecha nism for storing,D showing, deleting, and granting and revoking privileges on storedC routines within a database. This means you cannot store, delete,@ or grant and revoke privileges on individual stored routines.D Should you need to remove a stored routine, use the DROP FUNCTION> routine-name CASCADE or DROP PROCEDURE routine-name CASCADE syntax.< In general, SQL operates on modules, not stored routines.; However, there are a few exceptions: DROP FUNCTION, DROPB PROCEDURE, RENAME, SHOW FUNCTION, SHOW PROCEDURE, and CALL. The@ SHOW FUNCTION statement displays information about functions.C The SHOW PROCEDURE statement displays individual procedures in aD stored module. The CALL statement can invoke only a single stored procedure. 3 Environment@ You can use the CREATE MODULE statement in a simple statement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure  in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatE CREATE MODULE -> +---------------------------------+-+E +-> STORED NAME IS -+ |E +------------------------------------<-----------------------------+E +-+-------------------+---+----------------------------+-----------+E +-> LANGUAGE SQL ---+ +-> AUTHORIZATION -+ |E +------------------------------------------------------------------+E ++---------------------------------+-+--------------------+--------+E +-> COMMENT IS -+-> 'string' ---+-+ +-> declare-clause --+ |E +------ / <-----+ |E +------------------------------------------------------------------+- +-+-> routine-clause ---+--> END MODULE ---> +-------- <-----------+  declare-clause = 8 --+-+-> declare-transaction-statement -----------+-+-->5 | +-> declare-l ocal-temporary-table-statement -+ |5 | +-> declare-variable-statement --------------+ |5 +----------------------<-------------------------+ routine-clause = E -+> PROCEDURE +-+-------------------> -----------++E +> FUNCTION --+ +> STORED NAME IS -+|E +----------------------------------------- <-----------------------+6 +---+--------------------> ---------------------+---+6 +--> ( -+----------------------------+-- ) -+ |6 ++-> parameter-decl --------++ |6 +----------- , <-----------+ |6 +---------------------------------------------------+B ++----------------------------++----------------------+---------+B +> RETURNS result-data-type -++---> function-attr ---+ |B +------------------------------------------ <-------------------+N ++--------------------------------+-> ; -+-> compound-statement -----+> ; -->G +> routine-attr -----------------+ +-> compou nd-use-statement -+G +-> external-body-clause ---+ parameter-decl = > --+----------++---------------------++-> data-type -----+---+> +-> IN ----++-> -++-> -+ |> +-> OUT ---+ |> +-> INOUT -+ |> +------------------------------<--------------------------+> +-+---------------------+-+-----------------------+-------+> +-> mechanism-clause -+ +-> DEFAULT value-expr -+ |> +---------------------------------------------------------+B +--+--------------------------------+------------------------->( +-> COMMENT IS -+-> 'string' ---++' +------ / <-----+ function-attr = % -++--------+-+-> VARIANT -------++-># |+-> NOT -+ +-> DETERMINISTIC -+|# +--> LANGUAGE SQL --------------+  routine-attr = ) --+-> COMMENT IS --+-> 'string' --+-+-->&  | +------ , <----+ |& +-> USAGE IS -+-> LOCAL ---+------+ +-> GLOBAL --+ 3 Arguments 4 AUTHORIZATION_auth_id@ A name that identifies the definer of a module and is used toB perform privilege validation for the module. the User_Supplied_= Names HELP topic for information about using authorization identifiers. 4 COMMENT_IS? Adds a comment about the module, routine, and parameter. SQLC displays the text of the comment when it executes a SHOW MODULE,B SHOW FUNCTION, or SHOW PROCEDURE statement. Enclose the commentB in single quotation marks (') and separate multiple lines in a! comment with a slash mark (/). 4 compound-statement@ Allows you to include more than one SQL statement in a stored: routine. See the Compound_Statement HELP topic for more information. 4 compound-use-statementC Allows you to include one SQL statement in a stored routine. See: the Compound_Statement HELP topic for more information.C If you are defining a stored function, the simple statement must be the RETURNS clause. 4 data-type@ A valid SQL data type. Specifying an explicit data type is anC alternative to specifying a domain name. See the Data_Types HELP, topic for more information on data types. "4 decl-local-temp-table-statementC Declares a local temporary table for the module. See the DECLARE8 LOCAL_TEMPORARY_TABLE statement for more information. 4 declare-transaction-statement; Declares a transaction for the module. Only one declare-B transaction-statement is permitted for each module. If omitted,> an implicit DECLARE TRANSACTION READ WRITE is used. See the6 DECLARE TRANSACTION statement for more information. 4 declare-variable-statement? Declares a global variable for the module. See the statement) DECLARE Variable for more information. 4 DEFAULT_value-expr? Specifies the default value of a parameter for a function orC procedure defined with mode IN. If you omit this parameter or ifD the Call statement argument list or function invocation specifies? the DEFAULT keyword, then the value-expr specified with thisC clause is used. The parameter uses NULL as the default if you do- not specify a value expression explicitly. 4 DETERMINISTIC Syntax options:$ DETERMINISTIC | NOT DETERMINISTICD The clause controls the evaluation of an external function in the scope of a query: o NOT DETERMINISTIC? Specifying the NOT DETERMINISTIC clause forces evaluation= of corresponding functions (in scope of a single query)A every time the function appears. If a function can return aB different result each time it is invoked, you should use the DETERMINISTIC clause. o DETERMINISTIC@ Specifying the DETERMINISTIC clause can result in a single@ evaluation of corresponding functi on expressions (in scope@ of a single query), and the resulting value is used in allD occurrences of the corresponding function expression. When youC use the DETERMINISTIC clause, Oracle Rdb evaluates whether or6 not to invoke the function each time it is used. For example:4 SELECT * FROM T1 WHERE F1() > 0 AND F1() < 20;B If you define the F1 function as DETERMINISTIC, the functionD F1() may be evaluated just once depending on the optimizer. IfC you define the F1 function as NOT DETERMINISTIC, the function F1() is evaluated twice.# DETERMINISTIC is the default.B The DETERMINISTIC or NOT DETERMINISTIC clause is not allowed on procedure definitions. 4 domain-nameA The name of a domain created in a CREATE DOMAIN statement. ForC more information about domains, see the CREATE DOMAIN statement. 4 DEFAULT_value-expr? Specifies the default value of a parameter for a function orC procedure defined with mode IN. If you omit this parameter or ifD the Call statement argument list or function invocation specifies? the DEFAULT keyword, then the value-expr specified with thisC clause is used. The parameter uses NULL as the default if you do- not specify a value expression explicitly. 4 FUNCTION_function-nameD A user-supplied name that you give to a function in a module. TheB name you specify must be unique within the database definition. 4 IN_parameter_name> Specifies the parameter modes used in the procedure. The IN? parameter names the parameter that is read into the routine,1 however is never set and cannot be written to.; The IN parameter is the only mode allowed for functions.9 Each parameter name must be unique within the routine. 4 INOUT_parameter_nameA Specifies the parameter modes used in the procedure. The INOUTD parameter names a parameter that inputs data (is read) as well asB receives data (is set). The INOUT parameter is a parameter that is modified.; Each parameter name must be unique within the procedure.@ You cannot use the INOUT parameter mode for stored functions. 4 LANGUAGE_SQL= The LANGUAGE keyword and the SQL argument signify that theD procedures in a module are to be invoked by SQL statements, not a host language program.D With unstored procedures, the LANGUAGE keyword specifies the nameA of a host language; this identifies the host language in which8 the program calling a module's procedures is written.B Beginning with Oracle Rdb Release 7.1, this clause is optional. 4 module-name4 A user-supplied name that you assign to a module.A See the User_Supplied_Names HELP topic for more information on user-supplied names. 4 OUT_parameter_name? Specifies the parameter modes used in the procedure. The OUTC parameter names the parameter into which data is being sent. The( OUT parameter is set, but never read.; Each parameter name must be unique within the procedure.> You cannot use the OUT parameter mode for stored functions. 4 parameter-declC Specifies the parameters and parameter modes used in a stored or external routine. 4 PROCEDURE_procedure-nameA A user-supplied name that you give to a procedure in a module.: The name you specify must be unique within the database definition. 4 RETURNS_result_data_typeB Specifies the data type or domain of the result of the functionB invocation. This clause is only valid when defining a function.@ You can only use the RETURNS clause when defining a function. 4 routine-clauseB The definition of a stored function or stored procedure created in a module. 4 STORED_NAME_IS; Specifies a name that Oracle Rdb uses to access a module> procedure or function created in a multischema database. OrA specifies a name that Oracle Rdb uses to access a procedure or) a function created in a stored module. 4 USAGE_IS9 Specifies how the function or procedure can be called:B o USAGE IS GLOBAL indicates that the function or procedure can@ be called outside the current module. This is the default.@ o USAGE IS LOCAL specifies that the routine is restricted to? references within the module. This clause is provided forD compatibility with CREATE MODULE but is not allowed for CREATE# FUNCTION or CREATE PROCEDURE. 4 VARIANT Syntax options: VARIANT | NOT VARIANT; These clauses are synonyms for the DETERMINISTIC and NOTA DETERMINISTIC clauses. The DETERMINISTIC clause indicates thatA the same inputs to the function will generate the same output.B It is the same as the NOT VARIANT clause. The NOT DETERMINISTICC clause indicates that the output of the function does not depend7 on the inputs. It is the same as the VARIANT clause.8 This clause is deprecated. Use DETERMINISTIC instead. 4 variant-clause Syntax options:$ DETERMINISTIC | NOT DETERMINISTICD The clause controls the evaluation of an external function in the scope of a query: o NOT DETERMINISTIC? Specifying the NOT DETERMINISTIC clause forces evaluation= of corresponding functions (in scope of a single query)A every time the function appears. If a function can return aB different result each time it is invoked, you should use the DETERMINISTIC clause. o DETERMINISTIC@ Specifying the DETERMINISTIC clause can result in a single@ evaluation of corresponding function expressions (in scope@ of a single query), and the resulting value is used in allD occurrences of the corresponding function expression. When youC use the DETERMINISTIC clause, Oracle Rdb evaluates whether or6 not to invoke the function each time it is used. For example:4 SELECT * FROM T1 WHERE F1() > 0 AND F1() < 20;B If you define the F1 function as DETERMINISTIC, the functionD F1() may be evaluated just once depending on the optimizer. IfC you define the F1 function as NOT DETERMINISTIC, the function F1() is evaluated twice.# DETERMINISTIC is the default.B The DETERMINISTIC or NOT DETERMINISTIC clause is not allowed on procedure definitions. 3 Examples; Example 1: Creating a stored module and stored procedure@ The following example shows how to create a stored module and* stored procedure using interactive SQL:* SQL> CREATE MODULE testmod LANGUAGE SQL cont> PROCEDURE testproc; cont> COMMIT; cont> END MODULE; SQL> SHOW MODULE testmod Module name is: TESTMOD Source: TESTMOD LANGUAGE SQL Owner is: Module ID is: 1? Example 2: Creating a stored module with SQL module languageB The following code fragment shows how to create a stored module0 as part of a procedure in a nonstored module: PROCEDURE create_them SQLCODE;8 CREATE MODULE my LANGUAGE SQL AUTHORIZATION smith# PROCEDURE p1 ( :x CHAR(5) ); BEGIN, INSERT INTO s (snum) VALUES (:x); END;$ PROCEDURE p2 ( :y SMALLINT ); BEGIN7 SELECT STATUS INTO :y FROM s LIMIT TO 1 ROW; END;+ PROCEDURE p3 (:x INT, :y SMALLINT ); BEGIN, INSERT INTO s (snum) VALUES (:x);8 SELECT STATUS INTO :y FROM s WHERE snum = :x; END;/ PROCEDURE p4 (:x CHAR(5), :y CHAR(20) ); BEGIN6 INSERT INTO s (snum,sname) VALUES (:x, :y);7 SELECT sname INTO :y FROM s WHERE snum = :x; END; END MODULE;C Example 3: Creating a stored module containing a stored routines' SQL> CREATE MODULE utility_functions cont> LANGUAGE SQL cont> --& cont> -- Define a stored procedure.  cont> --+ cont> PROCEDURE trace_date (:dt DATE); cont> BEGIN cont> TRACE :dt; cont> END; cont> --6 cont> FUNCTION mdy (IN :dt DATE) RETURNS CHAR(10)? cont> COMMENT 'Returns the date in month/day/year format'; cont> BEGIN$ cont> IF :dt IS NULL THEN( cont> RETURN '**/**/****'; cont> ELSE* cont> CALL trace_date (:dt);P cont> RETURN CAST(EXTRACT(MONTH FROM :dt) AS VARCHAR(2)) || '/' ||N cont> CAST(EXTRACT(DAY FROM :dt) AS VARCHAR(2)) || '/' ||F cont> CAST(EXTRACT(YEAR FROM :dt) AS VARCHAR(4)); cont> END IF; cont> END; cont> END MODULE;; Example 4: Using a stored function in a SELECT statement$ SQL> SELECT mdy(job_end), job_end8 cont> FROM job_history WHERE employee_id = '00164'; JOB_END **/**/**** NULL 9/20/1981 20-Sep-1981 2 rows selected= Example 5: Using declared local temporary tables in stored proceduresK SQL> -- The following table must exist in order to execute the following SQL> -- queries. SQL> -- SQL> CREATE TABLE payroll cont> (employee_id CHAR(5), cont> hours_worked INTEGER, cont> hourly_sal REAL, cont> week_date CHAR(10)); SQL> COMMIT; SQL> --I SQL> -- Create the module containing a declared local temporary table. SQL> --' SQL> CREATE MODULE paycheck_decl_mod cont>  LANGUAGE SQLA cont> DECLARE LOCAL TEMPORARY TABLE module.paycheck_decl_tab& cont> (employee_id ID_DOM,' cont> last_name CHAR(14) ,( cont> hours_worked INTEGER,) cont> hourly_sal INTEGER(2),+ cont> weekly_pay INTEGER(2))* cont> ON COMMIT PRESERVE ROWS cont> --0 cont> -- Create the procedure to insert rows. cont> --' cont> PROCEDURE paycheck_ins_decl; cont> BEGIN1 cont> INSERT INTO m odule.paycheck_decl_tabP cont> (employee_id, last_name, hours_worked, hourly_sal, weekly_pay)5 cont> SELECT p.employee_id, e.last_name,: cont> p.hours_worked, p.hourly_sal,: cont> p.hours_worked * p.hourly_sal5 cont> FROM employees e, payroll p= cont> WHERE e.employee_id = p.employee_id9 cont> AND p.week_date = '1995-08-01'; cont> END; cont> --8 cont> -- Create the procedure to count the low hours. cont> --3 cont> PROCEDURE low_hours_decl (:cnt INTEGER); cont> BEGIND cont> SELECT COUNT(*) INTO :cnt FROM module.paycheck_decl_tab, cont> WHERE hours_worked < 40; cont> END; cont> END MODULE; SQL> --1 SQL> -- Call the procedure to insert the rows. SQL> --! SQL> CALL paycheck_ins_decl(); SQL> --J SQL> -- Declare a variable and call the procedure to count records with SQL> -- low hours. SQL> --$ SQL> DECLARE :low_hr_cnt integer;) SQL> CALL low_hours_decl(:low_hr_cnt); LOW_HR_CNT 2 SQL> --L SQL> -- Because the table is a declared local temporary table, you cannotE SQL> -- access it from outside the stored module that contains it. SQL> --/ SQL> SELECT * FROM module.paycheck_decl_tab;O %SQL-F-RELNOTDCL, Table PAYCHECK_DECL_TAB has not been declared in module or environment= Example 6: Creating a stored procedure containing a simple statement SQL> CREATE MODULE a cont> LANGUAGE SQL" cont> PROCEDURE new_salary_proc cont> (:id CHAR (5)," cont> :new_salary INTEGER (2)); cont> UPDATE salary_history8 cont> SET salary_end = CURRENT_TIMESTAMP2 cont> WHERE employee_id = :id; cont> END MODULE; A Example 7: Declaring a Global Variable to Exchange Information Between Two Routines SQL> CREATE MODULE sample cont> LANGUAGE SQL% cont> DECLARE :iter_count INTEGER. cont> PROCEDURE set_iter (IN :val INTEGER)> cont> COMMENT IS 'Validate the iteration count and assign'- cont> / 'to a global variable.'; cont> BEGIN. cont> IF (:val IS NULL) OR (:val < 1) THEN, cont> SIGNAL 'XXXXX'; --illegal value cont> ELSE$ cont> SET :iter_count =:val;3 cont> TRACE 'Iteration count set to ', :val; cont> END IF; cont> END; cont> FUNCTION GET_ITER () cont> RETURNS INTEGER> cont> COMMENT IS 'Trace the value used and then return the'- cont> / 'value from the global variable.'; cont> BEGIN5 cont> TRACE 'Using iteration count ', :iter_count; cont> RETURN :iter_count; cont> END; cont> END MODULE;= Example 8: Using a cursor implemented by external routinesA This example uses multiple external routines to manage a table< cursor in the external routine database environment. ThisD management includes the OPEN, FETCH and CLOSE  of a single cursor.B Several domains are defined so that parameter data types can beD consistently defined in the database that contain the application7 and also the database upon which the cursor is open.$ create domain SQLSTATE_T char(5);% create domain STATUS_CODE char(1);% create domain STATUS_NAME char(8);& create domain STATUS_TYPE char(14);? The external function interface is contained within a single9 CREATE MODULE statement. This module also contains the0 application in a single stored SQL procedure. create module EX language SQL> -- These procedure define the interface to the externalG -- routines that implement the transaction and cursor operations --" procedure EX_START_READ_TXN" (inout :ss sqlstate_t);2 external location 'TEST$SCRATCH:EX.EXE' language general" general parameter style6 comment is 'start a READ ONLY transaction'; procedure EX_COMMIT" (inout :ss sqlstate_t);2 external location 'TEST$SCRATCH:EX.EXE' language general# general parameter style; procedure EX_OPEN_CURSOR" (inout :ss sqlstate_t);2 external location 'TEST$SCRATCH:EX.EXE' language general" general parameter styleJ comment is 'find all rows in WORK_STATUS order by STATUS_CODE'; procedure EX_CLOSE_CURSOR" (inout :ss sqlsta te_t);2 external location 'TEST$SCRATCH:EX.EXE' language general# general parameter style; procedure EX_FETCH_CURSOR! (inout :ss sqlstate_t,= out :s_code STATUS_CODE, out :s_code_ind integer,= out :s_name STATUS_NAME, out :s_name_ind integer,> out :s_type STATUS_TYPE, out :s_type_ind integer);2 external location 'TEST$SCRATCH:EX.EXE' language general# general parameter style;= -- This SQL procedures implements a simple application -- procedure WORK_STATUSH comment is 'Use an external cursor to fetch all rows in the'+ / 'WORK_STATUS table'; begin' declare :s_code STATUS_CODE;' declare :s_name STATUS_NAME;' declare :s_type STATUS_TYPE;A declare :s_code_ind, :s_name_ind, :s_type_ind integer;" declare :ss sqlstate_t;E -- start a read-only transaction on the PERSONNEL database( call EX_START_READ_TXN (:ss);! if :ss ^= '00000' then SIGNAL :ss; end if;6 -- open the cursor on the work-status table% call EX_OPEN_CURSOR (:ss);! if :ss ^= '00000' then SIGNAL :ss; end if;- -- now loop and fetch all the rows FETCH_LOOP: loop) call EX_FETCH_CURSOR (:ss,;  :s_code, :s_code_ind,; :s_name, :s_name_ind,< :s_type, :s_type_ind); case :ss$ when '02000' then/ -- no more rows to fetch( leave FETCH_LOOP;$ when '00000' then beginK -- we have successfully fetched a row, so display itG trace  'Status Code: ', case when :s_code_ind < 0> then 'NULL'? else :s_code2 end;G trace 'Status Name: ', case when :s_name_ind < 0> then 'NULL'? else :s_name2 end;G  trace 'Status Type: ', case when :s_type_ind < 0> then 'NULL'? else :s_type2 end;# trace '***'; end; elseK -- signal will implicitly leave the stored procedure" SIGNAL :ss; end case; end loop; -- close the cursor& call EX_CLOSE_CURSOR (:ss);! if :ss ^= '00000' then SIGNAL :ss; end if;$ -- commit the transaction call EX_COMMIT (:ss);! if :ss ^= '00000' then SIGNAL :ss; end if; end; end module;B The external procedures for this this example are written usingD the SQL module language. However, any language with embedded SQL,# such as C, could have been used. module EX language GENERAL parameter colons -- EX: Sample application8 -- Process the WORK_STATUS table using a table cursor --% declare alias filename 'PERSONNEL' declare c cursor for3 select status_code, status_name, status_type from WORK_STATUS order by status_code procedure EX_START_READ_TXN (sqlstate); begin& -- abort any stray transactions rollback;' -- start a READ ONLY transaction! set transaction read only; end; procedure EX_COMMIT (sqlstate); commit work; procedure EX_ROLLBACK (sqlstate); rollback work; procedure EX_OPEN_CURSOR (sqlstate); open c; procedure EX_CLOSE_CURSOR (sqlstate); close c; procedure EX_FETCH_CURSOR (sqlstate,' :s_code STATUS_CODE,# :s_code_ind integer,' :s_name STATUS_NAME,# :s_name_ind integer,' :s_type STATUS_TYPE,$ :s_type_ind integer); fetch c+ into :s_code indicator :s_code_ind,+ :s_name indicator :s_name_ind,+ :s_type indicator :s_type_ind; procedure EX_DISCONNECT (sqlstate); disconnect default;A When run the application calls the external procedures to openA the cursor and fetch the rows and display them using the TRACE statement. SQL> set flags 'trace'; SQL> SQL> call WORK_STATUS (); ~Xt: Status Code: 0 ~Xt: Status Name: INACTIVE# ~Xt: Status Type: RECORD EXPIRED ~Xt: *** ~Xt: Status Code: 1 ~Xt: Status Name: ACTIVE ~Xt: Status Type: FULL TIME ~Xt: *** ~Xt: Status Code: 2 ~Xt: Status Name: ACTIVE ~Xt: Status Type: PART TIME ~Xt: *** SQL>A Oracle recommends that the cursors be closed, and the externalC routines database environment be disconnected b efore the calling@ session is disconnected. This can be achieved by using NOTIFY routines.B For example, the external procedure that starts the transactionD could be modified as shown below to declare a NOTIFY routine (EX_B RUNDOWN) that when called would close the cursors, rollback the0 transaction and disconnect from the database." procedure EX_START_READ_TXN" (inout :ss sqlstate_t);2 external location 'TEST$SCRATCH:EX.EXE' language ge neral" general parameter style$ notify EX_RUNDOWN on BIND6 comment is 'start a READ ONLY transaction';? The BIND notification ensures that EX_RUNDOWN will be calledC during the DISCONNECT of the caller and allow the transaction toB be rolled back and the session disconnected. ROLLBACK or COMMITA will implicitly close any open cursors, unless the cursor wereC defined as WITH HOLD. In this case it is important to also closeD that cursor. Code similar to the following (in C) could implement this rundown routine. #include  #include & #define RDB$K_RTX_NOTIFY_ACTV_END 2 #define SQLSTATE_LEN 5 void sql_signal ();7 void EX_CLOSE_CURSOR (char sqlstate [SQLSTATE_LEN]);5 void EX_DISCONNECT (char sqlstate [SQLSTATE_LEN]);3 void EX_ROLLBACK (char sqlstate [SQLSTATE_LEN]); extern void EX_RUNDOWN (int *func_code,H int *u1, /* U1, U2, U3 are currently unused */H int *u2, /* and are reserved for future use */ int *u3) { char sqlstate [SQLSTATE_LEN];3 if (*func_code == RDB$K_RTX_NOTIFY_ACTV_END) {; /* we are running down this external routine, so * close the cursor */& EX_CLOSE_CURSOR (sqlstate);< if (memcmp ("00000", sqlstate, SQLSTATE_LEN) != 0@ && memcmp ("24000", sqlstate, SQLSTATE_LEN) != 0)E /* we expect success or maybe 24000 (bad cursor state) */ sql_signal ();& /* rollback the transaction */" EX_ROLLBACK (sqlstate);< if (memcmp ("00000", sqlstate, SQLSTATE_LEN) != 0@ && memcmp ("25000", sqlstate, SQLSTATE_LEN) != 0)J /* we expect success or maybe 25000 (bad transaction state) */ sql_signal ();* /* disconnect from the database  */$ EX_DISCONNECT (sqlstate);= if (memcmp ("00000", sqlstate, SQLSTATE_LEN) != 0)J /* we expect success or maybe 25000 (bad transaction state) */ sql_signal (); } }C The application can be compiled and built using this fragment of DCL code: $ create ex.opt2 symbol_vector = (EX_START_READ_TXN = procedure)* symbol_vector = (EX_COMMIT = procedure), symbol_vector = (EX_ROLLBACK = procedure)/ symbol_vector = (EX_OPEN_CURSOR = procedure)0 symbol_vector = (EX_CLOSE_CURSOR = procedure)0 symbol_vector = (EX_FETCH_CURSOR = procedure). symbol_vector = (EX_DISCONNECT = procedure)+ symbol_vector = (EX_RUNDOWN = procedure)( psect_attr = RDB$MESSAGE_VECTOR,noshr" psect_attr = RDB$DBHANDLE,noshr, psect_attr = RDB$TRANSACTION_HANDLE,noshr sql$user/library $ $ cc EX_RUNDOWN $ sql$mod EX- $ link/share EX,EX_RUNDOWN,EX/option 2 OUTLINE= Creates a new query outline and stores this outline in the database.< A query outline is an overall plan for how a query can be? implemented and may contain directives that control the joinC order, join methods, index usage (or all of these) the optimizer? selects when processing a query. Use of query outlines helpsD ensure that query performance is highly stable across releases of Oracle Rdb. 3 EnvironmentD You can use the CREATE OUTLINE statement on ly in interactive SQL. 3 FormatC CREATE OUTLINE -+--------------------------------++C +> STORED NAME IS -+|C +------------------------- <-------------------------------------+< ++-> FROM --> ( --> --> ) ----------+---------+< +-> on-clause ---------------------------------+ |< +-> ID 'id-number' ----------------------------+ |< +------------------------------ <-----------------------+< + -----+------------++--------------------------------+--+< +> MODE mode ++> AS ---+>( -> query-list -> )--+ |< +> USING + |< +--------------------------- <----------------------------+< ++-----------------------------+--------------------------+< +> COMPLIANCE -+-> MANDATORY -+ |< +-> OPTIONAL --+ |< +--------------------------- <----------------------------+< ++-------------------------------------------------------++< +> EXECUTION OPTIONS --> ( --> execution-options --> ) -+|< +--------------------------- <----------------------------+B ++--------------------------------+----------------------------->$ +> COMMENT IS --+-> 'string' ---++# +----- / <------+ on-clause = 4 ---> ON --+-> PROCEDURE -+-+-> ID proc-id ----+-+->2 +-> FUNCTION --+ +-> NAME ---+ |2 +-> COLUMN ------+-----> ------+  +-> CONSTRAINT --+ +-> TRIGGER -----+ +-> VIEW --------+ query-list = - ---+-> QUERY (source) ----------+---------->" +-------------<--------------+ source = A -+-+-------------+--+-> table-access --------------+--+-------->8 | +-> FLOATING -+ +-> ORDERED ---+--> (source) --+ |8 | +-> UNORDERED -+ | |8 | +-> subquery-list -------------+ |8 | +--------------------------------------------------+3 | +-> JOIN BY -+--> CROSS ------+--- TO -----+--+3 | | +--> MATCH ------+ | |3 | | +--> ANY METHOD -+ | |3 | +-> UNION WITH ----------------------------+ |3 +------------------------<----------------------+  table-access = = ---> -+-------------------------+-> context --+= +-> MODULE -+ |= +----------------------------------------------------------+< +-> ACCESS --> PATH ---+------------------------------+--->8 +--> ANY ----------------------+8 +--> SEQUENTIAL ---------------+8 +--> DBKEY --------------------+8 +--> ROWID --------------------+8 +--> NO INDEX -----------------+8 +--> INDEX -+> --++7 +------ , <-------+  subquery-list = - ---+-> SUBQUERY (source) -------+---------->" +-------------<--------------+  execution-options =  -+-> ANY --------+------> +-> NONE -------+ +-> FAST FIRST -+ +-> TOTAL TIME -+  3 Arguments 4 ACCESS_PATH Syntax options: ACCESS PATH ANY ACCESS PATH SEQUENTIAL ACCESS PATH DBKEY ACCESS PATH ROWID ACCESS PATH NO INDEXB See also ACCESS_PATH_INDEX. Specifies the access path to use toB retrieve data  from the underlying database table. The following& table lists the valid access paths. Path MeaningB ANY Indicates that the optimizer may choose the most% appropriate method.B SEQUENTIAL Indicates that sequential access should be used.@ DBKEY Indicates the access by database key should be used.@ ROWID Indicates the access by database key should be used.> NO INDEX Indicates that any access path not requiring@ an index can be used. NOINDEX is accepted as a' synonym for NO INDEX.D There is no default access path. An access path must be specified; for each database table specified within a query outline definition. 4 ACCESS_PATH_INDEXD Specifies that data should be retrieved using the specified index? or list of indexes. If more that one index can be used, then) separate each index name with a comma.= Any index name specified should indicate an existing index< associated with the table with which the access method is associated. 4 AS_query_list. Provides the main definition of an outline.B This clause is only required when creating an outline using the ID id-number clause. 4 COMMENT_ISB Adds a comment about the outline. SQL displays the text when itA executes a SHOW OUTLINES statement in interactive SQL. EncloseD the comment in single quotation marks ( ') and separate multiple, lines in a comment with a slash mark (/). 4 COMPLIANCE Syntax options:- COMPLIANCE MANDATORY | COMPLIANCE OPTIONAL3 Specifies the compliance level for this outline.@ MANDATORY indicates that all outline directives such as table@ order and index usage should be followed as specified. If theD optimizer is unable to follow any outline directive, an exception is raised.B OPTIONAL indicates that all outline directi ves are optional andB that if they cannot be followed, no exception should be raised.A If OPTIONAL is specified, the strategy chosen by the optimizerA to carry out the underlying request may not match the strategy specified within the outline.B Use MANDATORY when the strategy that the optimizer chooses must> be followed exactly as specified from version to version ofC Oracle Rdb even if the optimizer finds a more efficient strategy% in a future version of Oracle Rdb.& The default is COMPLIANCE OPTIONAL. 4 contextC Specifies the context number for this table. Specify an unsignedB integer. This number is allocated to the table by the optimizerB during optimization. Context numbers are unique within queries. 4 EXECUTION_OPTIONS@ Specifies options that the optimizer should take into accountD during optimization. The following table lists the valid options. Option Meaning= ANY Indicates that the optimizer can choose any% optimization methodA FAST FIRST Indicates that the optimizer can use FAST FIRST6 optimization if and when appropriateB NONE Indicates that optional optimizations should not be appliedA TOTAL TIME Indicates that the optimizer can use TOTAL TIME6 optimization if and when appropriate* The default is EXECUTION OPTIONS (ANY). 4 FLOATINGC Specifies that the followin g data source should be considered toD be floating and that the order of the data source relative to the9 other data sources within the same level is not fixed. 4 FROM_sql_queryC Enables an outline to be created directly from an SQL statement.C If the AS clause is not specified, the sql-query is compiled andB the resulting outline is stored. If the AS clause is specified,B the sql-query provides an alternate means of specifying the ID.? If the USING clause is spec ified, the sql-query is optimized4 using the designated outline as a starting point.D The only statement accepted as an sql-query in the FROM clause isA a SELECT statement. Do not end the sql-query with a semicolon. 4 ID_id_numberC Specifies the internal hash identification number of the requestD to which this outline should be applied. Specify a 32-byte stringC representing a 32-hexadecimal character identification code. TheB internal hash identification code is generated by the optimizerB whenever query outlines are created by the Oracle Rdb optimizer during optimization.B You can optionally specify the MODE clause. You are required toB specify the AS clause. You cannot specify the USING clause with the ID id-number clause. 4 JOIN_BY Syntax options: JOIN BY CROSS JOIN BY MATCH JOIN BY ANY METHODBSpecifies the method with which two data sources should be joined.,The following table lists the valid methods. Method Meaning@ CROSS Indicates that a cross strategy should be used@ MATCH Indicates that a match strategy should be usedD ANY METHOD Indicates that the optimizer can choose any method. to join the two data sources& NOTE> The match join strategy requires that an equivalent join= column exist between the inner and outer context of the? join order. If the query for which the outline is createdA does not have an equivalent join column, then the optimizerB cannot use the match join strategy specified in the outline.# There is no default join method. 4 MODE_modeA Mode is a value assigned to an outline when it is generated byB the optimizer. The default mode is 0. Specify a signed integer.C If you create multiple outlines for a single query, the outlines@ cannot have the same outline mode. When more than one outline= exists for a query, you can set the RDMS$BIND_OUTLINE_MODED logical name to the value of the outline mode for the outline youC want the optimizer to use. For example, if you have a query thatD runs during the day and at night and you created two outlines forB the query, you could keep the default outline mode of 0 for theC outline to be used during the day, and assign an outline mode ofD -1 for the outline to be used at night. By setting the RDMS$BIND_D OUTLINE_MODE logical name to -1 at night, the appropriate outline" is run at the appropriate time.> Valid values for modes are -2,147,483,648 to 2,147,483,647.= Positive mode values are reserved for future use, so it isD recommended that you specify a value between 0 and -2,147,483,648 for the mode value. 4 MODULE_module_nameA Associates an outline with a declared local temporary table byC qualifying the table name with the name of the stored module. InD order to apply the outline to the declared local temporary table," the keyword MODULE is required. 4 ON_COLUMN Syntax options: ON COLUMN nameC Generates an outline for the specified columns DEFAULT, COMPUTEDC BY or AUTOMATIC expression. This is a partial outline which willA be used when the column is referenced. If a column has both anA AUTOMATIC UPDATE AS clause and a DEFAULT expression, then only3 one outline is created for the AUTOMATIC clause. 4 ON_CONSTRAINT Syntax option s: ON CONSTRAINT name@ Generates an outline definition for the specified constraint. 4 ON_FUNCTION Syntax options:1 ON FUNCTION ID proc-id | ON FUNCTION NAME name; Generates an outline definition for the specified stored function. 4 ON_PROCEDURE Syntax options:3 ON PROCEDURE ID proc-id | ON PROCEDURE NAME name; Generates an outline definition for the specified stored procedure. 4 ON_TRIGGER Syntax options: ON TRIGGER name= Generates an outline definition for the specified trigger. 4 ON_VIEW Syntax options: ON VIEW name: Generates an outline definition for the specified view. 4 ORDERED9 Specifies that all nonfloating data sources within the? parentheses should be retrieved in the order specified. Join, items in the group are placed adjacently. 4 outline-nameC The name of the new query outline. The name has a maximum length of 31 characters. 4 QUERYC Specifies that the data sources within the parentheses belong to a separate query. 4 SUBQUERYC Specifies that the data sources within the parentheses belong to a separate subquery. 4 table-name* Specifies the name of a database table. 4 UNION_WITH+ Specifies the union of two data sources.C Either a join or union method must be specified between all data5 sources with the exception of QUERY source blocks.&  NOTE> When a join method appears immediately before an ordered@ or unordered group, the join method is associated with the) first join item named in the group.B The union strategy is only valid for queries that use the UNIONA operator, and all queries that specify the UNION operator must use the union strategy. 4 UNORDEREDC Specifies that all data sources within the parentheses should beB considered floating and that no order is implied. Join items in# the group are placed adjacently. 4 USING_query_listC Specifies the outline to be used for compilation of the contents of the FROM and ON clauses.; You cannot use this clause with the ID id-number clause. 3 Examples; Example 1: Creating an outline named AVAILABLE_EMPLOYEES* SQL> CREATE OUTLINE available_employees6 cont> ID '09ADFE9073AB383CAABC4567BDEF3832' MODE 0 cont> AS ( cont> QUERY ( cont> --C  cont> -- Cross the employees table with departments table first. cont> --F cont> employees 0 ACCESS PATH SEQUENTIAL JOIN BY MATCH TON cont> departments 3 ACCESS PATH INDEX dept_index JOIN BY MATCH TO cont> SUBQUERY (P cont> job_fitness 2 ACCESS PATH INDEX job_fit_emp, job_fit_dept$ cont> JOIN BY CROSS TO/ cont> SKILLS 4 ACCESS PATH ANY2 cont> ) JOIN BY MATCH TO cont> SUBQUERY (D cont> major_proj 1 ACCESS PATH ANY JOIN BY CROSS TO2 cont> education 6 ACCESS PATH ANY3 cont> ) JOIN BY CROSS TO@ cont> research_projects 5 ACCESS PATH ANY UNION WITH cont> --9 cont> -- Always do the union with employees table last cont> --- cont> employees 7 ACCESS PATH ANY cont> ) cont> ) cont> COMPLIANCE OPTIONAL* cont> COMMENT IS 'Available employees'; 7 Example 2: Creating an outline using the FROM clause/ SQL> CREATE OUTLINE degrees_for_emps_over_65 cont> FROM= cont> (SELECT e.last_name, e.first_name, e.employee_id,, cont> d.degree, d.year_given- cont> FROM employees e, degrees d2 cont> WHERE e.birthday < '31-Dec-1930'3 cont> AND e.employee_id = d.employee_id' cont> ORDER BY e.last_name) cont> USING cont> (QUERY cont> (SUBQUERY3 cont>  (degrees 1 ACCESS PATH SEQUENTIAL# cont> JOIN BY CROSS TO. cont> employees 0 ACCESS PATH ANY cont> ) cont> ) cont> ) cont> COMPLIANCE OPTIONALQ cont> COMMENT IS 'Outline to find employees over age 65 with college degrees'; SQL> --- SQL> SHOW OUTLINE degrees_for_emps_over_65 DEGREES_FOR_EMPS_OVER_65M Comment: Outline to find employees over age 65 with college degrees Source:/ -- Rdb Generated Outline : 13-NOV-1995 15:28* create outline DEGREES_FOR_EMPS_OVER_65( id 'B6923A6572B28E734D6F9E8E01598CD8' mode 0 as ( query ( subquery (/ DEGREES 1 access path sequential join by cross to? EMPLOYEES 0 access path index EMPLOYEES_HASH ) ) ) compliance optional ;> Example 3: Creating an outline using the ON FUNCTION clause SQL> CREATE OUTLINE out1$ cont> ON FUNCTION NAME function1; SQL> COMMIT; SQL> SHOW OUTLINE out1 OUT1 Source:/ -- Rdb Generated Outline : 2-FEB-1996 15:46 create outline OUT1( id '264A6DDADCB483AE5B2CDF629C9C8C0F' mode 0 as ( query ( subquery (? EMPLOYEES 0 access path index EMPLOYEES_HASH ) ) ) compliance optional ;@ Example 4: Creating an outline on a procedure that accesses aB declared local temporary table (see the CREATE MODULE statement; for the stored procedure and temporary table definition) SQL> CREATE OUTLINE outline1, cont> ON PROCEDURE NAME paycheck_ins_decl cont> MODE 0 cont> AS ( cont> QUERY (E cont> module.paycheck_decl_tab MODULE paycheck_decl_mod cont> 0* cont> ACCESS PATH SEQUENTIAL cont> ) cont> ) cont> COMPLIANCE OPTIONAL; SQL> SHOW OUTLINE outline1 OUTLINE1 Source: create outline OUTLINE1 mode 0 as ( query (9 PAYCHECK_DECL_TAB MODULE PAYCHECK_DECL_MOD 0 access path sequential ) ) compliance optional ; , Example 5: New Output from Query Outlines SQL> BEGIN cont> DECLARE :x INTEGER; cont> -- Assignment0 cont> SET :x = (SELECT COUNT(*) FROM TOUT_1); cont> -- Delete statement cont> DELETE FROM TOUT_1; cont> -- Update statement cont> UPDATE TOUT_10 cont> SET a = (SELECT AVG(a) FROM TOUT_2) cont> WHERE a IS NULL; cont> -- Singleton Select cont> SELECT a INTO :x cont> FROM TOUT_1 cont> WHERE a = 1;0 cont> -- Trace (nothing if TRACE is disabled)J cont> TRACE 'The first value: ', (SELECT a FROM TOUT_1 LIMIT TO 1 ROW); cont> END;B The query outline generated by Oracle Rdb appears with comments* after the QUERY keyword in the outline./ -- Rdb Generated Outline : 29-MAY-1997 23:17. create outline QO_C11395E6020C6FFA_00000000( id 'C11395E6020C6FFA5A183A6CCE7C1F33' mode 0 as ( query ( -- Set subquery (/ TOUT_1 0 access path sequential ) ) query ( -- Delete subquery (/ TOUT_1 0 access path sequential ) ) query ( -- Update subquery ( subquery (1 TOUT_2 1 access path sequential ) join by cross to subquery (1  TOUT_1 0 access path sequential ) ) ) query ( -- Select subquery (/ TOUT_1 0 access path sequential ) ) query ( -- Trace subquery (/ TOUT_1 0 access path sequential ) ) ) compliance optional ; 2 PROCEDURED Creates an external procedure as a schema object in an Oracle Rdb database.@ The CREATE PROCEDURE statement is  documented under the CREATE< Routine. For complete information on creating an external; procedure definition, see the CREATE Routine Help topic. 2 PROFILE> Creates a profile that extends a user definition within the= database with special attributes that control transactionsA and resource usage. When a user attaches to the database usingA ATTACH, CONNECT or SET SESSION AUTHORIZATION, they will either@ load their assigned profile definition or inherit the default profile (if defined). 3 Environment, You can use the CREATE PROFILE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 FormatP CREATE -+--> PROFILE --> -------------+--+-> profile-options -+->N +--> DEFAULT PROFILE -+--------------------++ +---------<----------+5  +> ALIAS aliasname -+ profile-options = = --+-> COMMENT IS -+-> char-literal --+--------------------+>< | +------- / <-------+ |< +-> DEFAULT TRANSACTION --> txn-options ----------------+< +-> TRANSACTION MODES --> (txn-modes) ------------------+< +-> LIMIT -+-+-> ROWS limit-value --------------------+++< | | +-> TIME limit-value -----+-+-----------++||< | | +-> CPU TIME limit-value -+ +-> SECONDS + ||< | | +-> MINUTES + ||< | +-------------------- <---------------------+|< +-> NO -+> DEFAULT TRANSACTION --+----------------------+% +> TRANSACTION MODES -+-+# +> LIMIT-+-> CPU TIME -+# +-> ROWS ---+# +-> TIME ----+ limit-value = $ --+-> positive-integer-literal -+->" +-> UNLIMITED ----------------+" +-> DEFAULT ------------------+ 3 Arguments 4 ALIAS_aliasnameD When attached to multiple databases, the aliasname is required to9 direct the CREATE command to the appropriate database. 4 COMMENT_ISC This optional clause can be used to add several lines of comment> to the profile object. The comment is displayed by the SHOWD PROFILES statement. Enclose the comment in single quotation marksA (') and separate multiple lines in a comment with a slash mark (/). 4 DEFAULT_PROFILE@ Creates the s pecial profile RDB$DEFAULT_PROFILE. This profileC will be used by any user who is not assigned a profile using the- PROFILE clause of CREATE or ALTER PROFILE. 4 DEFAULT_TRANSACTIONC DEFAULT TRANSACTION provides a default transaction for the user.D By default, Oracle Rdb starts a READ WRITE transaction if none isC explicitly started. Use the DECLARE TRANSACTION or START DEFAULT@ TRANSACTION statement to make use of this definition. You canD override this clause with a DECLARE or SET TRANSACTION statement.& NOTE< Oracle Rdb does not permit the RESERVING or EVALUATING3 clauses to appear in the default transaction. 4 LIMIT_CPU_TIME Syntax options:% LIMIT CPU TIME | NO LIMIT CPU TIMEC LIMIT CPU TIME sets the maximum CPU time that can be used by theA query compiler. The keyword DEFAULT indicates that no value isB defined by this profile and is equivalent to NO LIMIT CPU TIME.@ If a numeric value or the keyword UNLIMITED is specified thenA this value will be used even when the SET QUERY LIMIT CPU TIME@ statement is present in the session, or when the logical name' RDMS$BIND_QG_CPU_TIMEOUT is defined.> NO LIMIT CPU TIME is the default. Units can be specified as seconds or minutes. 4 LIMIT_ROWS Syntax options: LIMIT ROWS | NO LIMIT ROWSB LIMIT ROWS sets the maximum number of rows that can be returned@ by a query started by the user. The keyword DEFAULT indicatesC that no value is defined by this profile and is equivalent to NO LIMIT ROWS.@ If a numeric value or the keyword UNLIMITED is specified then= this value will be used even when the SET QUERY LIMIT ROWS@ statement is present in the session, or when the logical name% RDMS$BIND_QG_REC_LIMIT is defined. NO LIMIT ROWS is the default. 4 LIMIT_TIME Syntax options: LIMIT TIME | NO LIMIT TIMEC LIMIT TIME sets the maximum elapsed time that can be used by theA query compiler. The keyword DEFAULT indicates that no value is> defined by this profile and is equivalent to NO LIMIT TIME.@ If a numeric value or the keyword UNLIMITED is specified then= this value will be used even when the SET QUERY LIMIT TIME@ statement is present in the session, or when the logical name# RDMS$BIND_QG_TIMEOUT is defined.B NO LIMIT TIME is the default. Units can be specified as seconds or minutes. 4 TRANSACTION_MODES Syntax options:+ TRANSACTION MODES | NO TRANSACTION MODES@ TRANSACTION MODES provides the list of allowable transactionsD for this user. Please see the SET TRANSACTION MODES clause of theD CREATE DATABASE and ALTER DATABASE statements for more details of txn-modes.= The transaction modes specified may include modes disabled> for all database users by CREATE, IMPORT, or ALTER DATABASEC statements. However, only the subset allowed by both profile and @ database settings will be used. For instance, if the database= specifies (READ ONLY, SHARED READ, PROTECTED READ) and the= profile specifies (READ ONLY, SHARED), the session will be/ allowed the subset (READ ONLY, SHARED READ). 3 Examples Example 1D The following example specifies the allowed transaction modes for" any user assigned this profile.' SQL> CREATE PROFILE DECISION_SUPPORTA cont> COMMENT IS 'limit transactions used by report writers'8 c ont> TRANSACTION MODES (NO READ WRITE, READ ONLY); Example 2D This example shows the use of the LIMIT clauses to set boundaries for standard database users.$ SQL> create profile STANDARD_USER cont> limit rows 10000! cont> limit time 10 minutes& cont> limit cpu time 20 seconds;# SQL> show profile STANDARD_USER; STANDARD_USER Limit rows 10000 Limit time 10 minutes! Limit CPU time 20 seconds# SQL> alter profile STANDA RD_USER" cont> limit time 60 minutes; 2 ROLE< Creates a role to which privileges and other roles can be@ granted. A role can be granted to a user or another role. For> example, you can create a role for members of a department.? When a user leaves the department, the departmental role canC be revoked from that user and thus exclude that user's access to the departmental data. 3 Environment) You can use the CREATE ROLE statement: o In interactive  SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format5 CREATE ROLE ---> ----------------------+5 +---------------------<----------------------------+5 +-----+--------------------------------+-----------+5 +--> IDENTIFIED EXTERNALLY ------+ |5 +--> NOT IDENTIFIED -------------+ |5 +-- ------------------<-----------------------------+7 +-----+----------------------------------+----------->+ +--> COMMENT IS --+-> 'string' --+-+) +------ / <----+ 3 Arguments 4 COMMENT_IS_'string'> Adds a comment about the role. SQL displays the text of the? comment when it executes a SHOW ROLES statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/). 4 IDENTIFIED_EXTERNALLYD The IDENTIFIED EXERNALLY clause indicates that SQL should inherit? the roles defined by the facilities of the operating system,B such as rights identifiers. When a session is started, any roleC that is defined externally is established as part of the current user's profile. 4 NOT_IDENTIFIED> Indicates that the role is used only with the database. TheD database must have SECURITY CHECKING IS INTERNAL set before using this clause. 4 role-name@ A user-supplied name that you assign to the role. The specialC roles BATCH, DIALUP, INTERACTIVE, LOCAL, NETWORK, and REMOTE are: reserved names that cannot be specified as a role-name. 3 Examples Example 1: Creating a Role2 SQL> ALTER DATABASE FILENAME 'mf_personnel.rdb'' cont> SECURITY CHECKING IS INTERNAL;+ SQL> ATTACH 'FILENAME mf_personnel.rdb'; SQL> CREATE ROLE WRITER; SQL> SHOW ROLES;3 Roles in database with filename mf_personnel.rdb WRITER C Example 2: Creating Roles and Granting Privileges to Those Roles0 SQL> ALTER DATABASE FILENAME mf_personnel.rdb' cont> SECURITY CHECKING IS INTERNAL;@ SQL> -- Create a role for employees in the payroll department+ SQL> ATTACH 'FILENAME MF_PERSONNEL.RDB'; SQL> CREATE ROLE PAYROLL? cont> COMMENT IS 'This role allows access to various tables'B cont> / 'and procedures for use by the PAYROLL dept.';9 SQL> -- Create another role for a sub set of employees. SQL> CREATE ROLE ANNUAL_LEAVE? cont> COMMENT IS 'This role is granted to PAYROLL personnel'7 cont> / 'who adjust the annual leave data';G SQL> -- Grant EXECUTE privilege on module and ALL privilege on tableG SQL> -- SALARY_HISTORY to all employees to whom the PAYROLL role hasL SQL> -- been granted. Grant EXECUTE privilege on module LEAVE_ADJUSTMENTJ SQL> -- only to those employees who have been granted both the PAYROLL" SQL> -- and ANNUAL_LEAV E roles.= SQL> GRANT EXECUTE ON MODULE PAYROLL_UTILITIES TO PAYROLL;5 SQL> GRANT ALL ON TABLE SALARY_HISTORY TO PAYROLL;0 SQL> GRANT EXECUTE ON MODULE LEAVE_ADJUSTMENT" cont> to PAYROLL, ANNUAL_LEAVE;A SQL> -- User STUART joins the personnel department. Grant him< SQL> -- the PAYROLL and ANNUAL_LEAVE roles so that he can; SQL> -- perform all functions in the payroll department. SQL> CREATE USER STUART cont> IDENTIFIED EXTERNALLY. SQL> GRANT PAYROLL, ANNUAL_LEAVE TO  STUART;9 SQL> -- User STUART is promoted to supervisor and thus> SQL> -- no longer needs access to the objects controlled by= SQL> -- the ANNUAL_LEAVE role. Revoke that role from user SQL> -- STUART.( SQL> REVOKE ANNUAL_LEAVE FROM STUART;< Example 3: Creating roles explictly using CREATE ROLE and implicitly using GRANTB This examples demonstrates creating roles that match an OpenVMS? rights identifiers. The CREATE ROLE statement is used first,B and then the GRANT statement. GRANT issues a warning message toC alert the database administrator of the side-effect of the GRANT statement. SQL> create database cont> filename SAMPLE) cont> security checking is internal; SQL> show roles;) Roles in database with filename sample No Roles found2 SQL> create role dba_mgr identified externally; SQL> show roles;) Roles in database with filename sample DBA_MGR" SQL> grant saldb_user to smith;L %RDB-W-META_WARN, metadata successfully updated with the reported warning7 -RDMS-W-PRFCREATED, some users or roles were created SQL> show roles;) Roles in database with filename sample DBA_MGR SALDB_USER SQL> 2 RoutineB Creates an external routine definition as a schema object in an@ Oracle Rdb database. External routine refers to both externalA functions and external procedures. A routine definition stores@ information in the database about a subprogra m (a function orC procedure) written in a 3GL language. The routine definition andC the routine image are independent of each other, meaning one canC exist without the other. However, to invoke an external routine,: you need both the routine definition and routine image.D SQL can invoke an external function from anywhere you can specify@ a value expression. External procedures are invoked using the CALL Compound_Statement. 3 EnvironmentC You can use the CREATE FUNCTION and CREATE PROCEDURE statements: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format? CREATE -+-> FUNCTION ---+-> ---------+? +-> PROCEDURE --+ |? +----------------------------<-----------------------------+? +-+--------------------------------+- ----------------------+? +-> STORED NAME IS -+ |? +----------------------------<-----------------------------+? +-> ( -+-----------------------+-> ) ----------------------+? ++-> parameter-list --+-+ |? +-------- , <--------+ |? +----------------------------<-----------------------------+? +-+-------------------+--> --+------------------+-> ; --> -+? +-> returns-c lause -+ +-> LANGUAGE SQL --+ |? |? +----------------------------<-----------------------------+B +----> external-body-clause ----------------------------------> parameter-list = D -+----------+-+-------------------+-+-> data-type -----+----------+D +-> IN ----+ +> + +-> -+ |D +-> OUT ---+ |D +-> INOUT -+  |D +-----------------------------------------------------------------+D +-+---------------------------+--+---------------------+----------+D +-> DEFAULT value-expr -----+ +-> mechanism-clause -+ |D +------------------------------<---------------------------------+F ++---------------------------------+------------------------------->& +-> COMMENT IS -+-> 'string' ---+-+$ +------ / <-----+ mechanism-clause = ! ----> BY --+-> DESCRIPTOR -+---> +-> LENGTH -----+ +-> REFERENCE --+ +-> VALUE ------+  external-body-clause = > --> EXTERNAL --+------------------------------+-------------+> +-> NAME -+ |> +----------------------------------- <----------------------+> ++-----------------------------+-> LANGUAGE language-name --+> +-> external-location-clause -+ |> +----------------------------------<------------------------+> ++-> PARAMETER STYLE GENERAL -+-----------------------------+> +-> GENERAL PARAMETER STYLE -+ |> +-----------------------------------<-----------------------+? ++----------------------------+------------------------------> +-> external-body-clause-2 --+ external-body-clause-2 = 4 ---+--+-> COMMENT IS -+-> ' ' -+----+--+-->1 | | +------ / <------+ | |1 | +-> b ind-site-clause -----------------+ |1 | +-> bind-scope-clause ----------------+ |1 | +-> notify-clause --------------------+ |1 | +-> CALLED ON NULL INPUT -------------+ |1 | +-> RETURNS NULL ON NULL INPUT -------+ |1 | +-> USAGE IS -+-> LOCAL ---+----------+ |1 | | +-> GLOBAL --+ | |1 | +-+--------+--+-------------------+---+ |1 | +-> NOT -+ +-> VARIANT --------+ |1 | +-> DETERMINISTIC --+ |1 +---------------------- <-------------------+ external-location-clause = A ---+--> DEFAULT LOCATION ------------+-------------------------+A +--> LOCATION '' -+ |A +-------------------------------<-----------------------------+A +-+----------------------------->--------------------------+-->> +--> WITH --+-> ALL -----+--> LOGICAL_NAME TRANSLATION --+ +-> SYSTEM --+ language-name =  --+-> ADA -----+--> +-> C -------+ +-> COBOL ---+ +-> FORTRAN -+ +-> PASCAL --+ +-> GENERAL -+  bind-site-clause = + --> BIND ON --+--> CLIENT --+--> SITE ---> +--> SERVER --+ bind-scope-clause = ) ---> BIND SCOPE --+-> CONNECT ------+-->& +-> TRANSACTION --+  notify-clause = > -> NOTIFY notify-entry-name --> ON -+-+-> BIND ---------+-+->< | +-> CONNECT ------+ |<   | +-> TRANSACTION --+ |< +--------- , <--------+ 3 Arguments 4 bind-site-clause Syntax options:, BIND ON CLIENT SITE | BIND ON SERVER SITEC Selects the execution model and environment for external routine execution.B CLIENT site binding causes the external routine to be activated< and executed in the OpenVMS database client (application)< process. This is the default binding. This binding !offers? the most efficient execution characteristics, allows sharingB resources such as I/O devices, and allows debugging of externalD routines as if they were part of the client application. However,B this binding may suffer from address space limitations. BecauseC it shares virtual memory with the database buffers, this bindingC is restricted to the client process system user environment, andB prohibits external routine execution in cases of an application$ running with el "evated privileges.B SERVER site binding causes the external routine to be activatedA in a separate process from the database client and server. The? process is started on the same node at the database process.> This binding offers reasonable execution characteristics, aA larger address space, a true session user environment, and has@ no restrictions regarding client process elevated privileges.? However, this binding does not permit sharing resources such= as I/O devices #with the client (in particular, there is no@ connection to the client interactive terminal), and debugging) of routines is generally not possible. 4 bind-scope-clause Syntax options:. BIND SCOPE CONNECT | BIND SCOPE TRANSACTIONB Defines the scope during which an external routine is activated= and at what point the external routine is deactivated. The default scope is CONNECT. o CONNECT? An active routine is deactivated when you detach from the+$ database (or exit without detaching). o TRANSACTION< An active routine is deactivated when a transaction is: terminated (COMMIT or ROLLBACK). In the event that a= transaction never occurs, the scope reverts to CONNECT. 4 COMMENT_IS> A description about the nature of the parameter or externalA routine. SQL displays the text of the comment when you executeC a SHOW FUNCTION or SHOW PROCEDURE statement. Enclose the commentB in single quotation m%arks (') and separate multiple lines in a comment with a slash (/). 4 DEFAULT_value-expr? Specifies the default value of a parameter for a function orC procedure defined with mode IN. If you omit this parameter or ifD the Call statement argument list or function invocation specifies? the DEFAULT keyword, then the value-expr specified with thisC clause is used. The parameter uses NULL as the default if you do- not specify a value expression explicitly. 4 D&ETERMINISTIC Syntax options:$ DETERMINISTIC | NOT DETERMINISTICD The clause controls the evaluation of an external function in the scope of a query: o NOT DETERMINISTIC? Specifying the NOT DETERMINISTIC clause forces evaluation= of corresponding functions (in scope of a single query)A every time the function appears. If a function can return aB different result each time it is invoked, you should use the DETERMINISTIC clause. o DE'TERMINISTIC@ Specifying the DETERMINISTIC clause can result in a single@ evaluation of corresponding function expressions (in scope@ of a single query), and the resulting value is used in allD occurrences of the corresponding function expression. When youC use the DETERMINISTIC clause, Oracle Rdb evaluates whether or6 not to invoke the function each time it is used. For example:4 SELECT * FROM T1 WHERE F1() > 0 AND F1() < 20;B If you def(ine the F1 function as DETERMINISTIC, the functionD F1() may be evaluated just once depending on the optimizer. IfC you define the F1 function as NOT DETERMINISTIC, the function F1() is evaluated twice.# DETERMINISTIC is the default.B The DETERMINISTIC or NOT DETERMINISTIC clause is not allowed on procedure definitions. 4 external-body-clauseA Identifies key characteristics of the routine: its name, whereB the executable image of the routine is )located, the language in, which the routine is coded, and so forth. 4 external-body-nameB The name of the external routine. If you do not specify a name,= SQL uses the name you specify in the external-routine-name clause.A This name defines the routine entry address that is called forD each invocation of the routine body. The named routine must existA in the external routine image selected by the location clause.8 Unquoted names are converted to uppercase cha*racters. 4 external-location-clause Syntax options: DEFAULT LOCATION LOCATION 'image-location'? A file specification referencing the image that contains the1 routine body and optional notify entry points. 4 external-routine-nameB The name of the external routine. The name must be unique amongB external and stored routines in the schema and can be qualified> with an alias or, in a multischema database, a schema name. 4 FUNCTION+ + Creates an external function definition.@ A function optionally accepts a list of IN parameters, always@ returns a value, and is referenced by name as an element of a value expression. 4 GENERAL_PARAMETER_STYLE9 This is synonymous with PARAMETER STYLE GENERAL and is deprecated. 4 language-name> The name of the host language in which the external routine@ was coded. You can specify ADA, C, COBOL, FORTRAN, PASCAL, orC GENERAL. The GENERAL keyword allows, you to call routines written in any language. 4 LANGUAGE_SQL- Names the language that calls the routine. 4 mechanism-clauseB Defines the passing mechanism. The following list describes the passing mechanisms. o BY DESCRIPTORB Allows passing character data with any parameter access modeC to routines compiled by language compilers that implement the OpenVMS calling standard. o BY LENGTH@ The LENGTH passing mechanism i-s the same as the DESCRIPTOR passing mechanism. o BY REFERENCE= Allows passing data with any parameter access mode as a# reference to the actual data.@ This is the default passing mechanism for parameters. This@ is also the default passing mechanism for a function value returning character data. o BY VALUE@ Allows passing data with the IN parameter access mode to a@ routine as a value and allows functions to return a value.@ . This is the default passing mechanism for a function value" returning noncharacter data. 4 notify-clauseD Specifies the name of a second external routine called (notified)B when certain external routine or database-related events occur.B This name defines the routine entry address that is called, for@ each invocation of the notify routine. The named routine must? exist in the external routine image selected by the location clause.? The events of interest to/ the notify routine are ON BIND, ONA CONNECT, and ON TRANSACTION. Multiple events can be specified.> The following describes the events and scope of each event:> BIND Routine activation to routine deactivation: CONNECT Database attach to database disconnect< TRANSACTION Start transaction to commit or roll back transaction 4 parameter-list< The optional parameters of the external routine. For eachB parameter you can s 0pecify a parameter access mode (IN, OUT, andA INOUT), a parameter name, a data type, and a passing mechanism0 (by DESCRIPTOR, LENGTH, REFERENCE, or VALUE).A The parameter access mode (IN, OUT, and INOUT) is optional and? specifies how the parameter is accessed (whether it is read,A written, or both). IN signifies read only, OUT signifies writeA only, and INOUT signifies read and write. The parameter access mode defaults to IN.: Only the IN parameter access mode may b 1e specified withB parameters to an external function. Any of the parameter accessD modes (IN, OUT, and INOUT) may be specified with parameters to an external procedure.< The optional parameter name is prefixed with a colon (:).@ The parameter name must be unique within the external routine parameters.@ The data type is required and describes the type of parameter2 using either an SQL data type or a domain name.B You cannot declare a parameter as the LIST OF BYTE VARY2ING data type. 4 PARAMETER_STYLE_GENERALA Passes arguments and returns values in a manner similar to theB OpenVMS convention for passing arguments and returning function values. 4 PROCEDURE, Creates an external procedure definition.= A procedure optionally accepts a list of IN, OUT, or INOUT= parameters, and is referenced by name in a CALL statement. 4 RETURNS@ Describes a function (returned) value. You can specify a dataB type and a pass3ing mechanism (BY DESCRIPTOR, LENGTH, REFERENCE,A or VALUE). The function value is, by definition, an OUT access mode value.@ The data type is required and describes the type of parameter2 using either an SQL data type or a domain name.B You cannot declare a function value as the LIST OF BYTE VARYING data type. 4 STORED_NAME_ISC The name that Oracle Rdb uses to access the routine when definedB in a multischema database. The stored name allows you to accessA4 multischema definitions using interfaces that do not recognize@ multiple schemas in one database. You cannot specify a stored@ name for a routine in a database that does not allow multiple? schemas. For more information about stored names, see Stored Names. 4 USAGE_IS9 Specifies how the function or procedure can be called:B o USAGE IS GLOBAL indicates that the function or procedure can@ be called outside the current module. This is the default.@ o US5AGE IS LOCAL specifies that the routine is restricted to? references within the module. This clause is provided forD compatibility with CREATE MODULE but is not allowed for CREATE# FUNCTION or CREATE PROCEDURE. 4 VARIANT Syntax options: VARIANT | NOT VARIANT; These clauses are synonyms for the DETERMINISTIC and NOTA DETERMINISTIC clauses. The DETERMINISTIC clause indicates thatA the same inputs to the function will generate the same output. 6B It is the same as the NOT VARIANT clause. The NOT DETERMINISTICC clause indicates that the output of the function does not dependC on the inputs. It is the same as the VARIANT clause. This clause, is deprecated. Use DETERMINISTIC instead. 3 Examples< Example 1: System provided integer absolute value routine6 SQL> CREATE FUNCTION IABS (IN INTEGER BY REFERENCE)$ cont> RETURNS INTEGER BY VALUE;" cont> EXTERNAL NAME MTH$JIABS, cont> LOCATION 'SYS$SHARE:DPML$7SHR.EXE' cont> LANGUAGE GENERAL" cont> PARAMETER STYLE GENERAL cont> NOT DETERMINISTIC; SQL> --2 SQL> SELECT IABS(-33) FROM JOBS LIMIT TO 1 ROW; 33 1 row selected@ Example 2: Using the NOT DETERMINISTIC clause, instead of the DETERMINISTIC clause? The first CREATE FUNCTION statement in the following example8 creates a function with the DETERMINISTIC clause. TheA DETERMINISTIC clause indicates to Oracle Rdb that the function> wou 8ld return the same result no matter how many times it isD called. Because the argument is a string literal (and could neverD change), Oracle Rdb optimizes the entire function call so that it1 is not called in subsequent select statements.9 SQL> -- Create a function with a DETERMINISTIC clause.> SQL> CREATE function DO_COM (IN VARCHAR(255) BY DESCRIPTOR) cont> RETURNS INTEGER;& cont> EXTERNAL NAME LIB$SPAWN7 cont> LOCATION 'SYS$SHARE:LIBRTL.EXE' 9 cont> LANGUAGE GENERAL& cont> PARAMETER STYLE GENERAL cont> DETERMINISTIC; SQL> --K SQL> -- Use a SELECT statement to pass a string literal to the function. SQL> --H SQL> -- Because Oracle Rdb optimizes functions with the DETERMINISTIC? SQL> -- clause, and the function is passed a string literal,@ SQL> -- Oracle Rdb does not call the function from subsequent SQL> -- statements. SQL> --M SQL> SELECT DO_COM('WRITE SYS$OUTPUT "HELLO"'), emp:loyee_id FROM employees cont> LIMIT TO 5 ROWS; HELLO DO_COM EMPLOYEE_ID 1 00164 1 00165 1 00166 1 00167 1 00168 5 rows selected SQL> --C SQL> -- Use the NOT DETERMINISTIC clause to create the function: SQL> --> SQL> CREATE function DO_COM (IN VARCHAR(255) BY DESCRIPTOR) cont> RETURNS INTEGER;& cont> EXTERNAL NAME lib$SPAWN7 cont> LOCA;TION 'SYS$SHARE:LIBRTL.EXE' cont> LANGUAGE GENERAL& cont> PARAMETER STYLE GENERAL! cont> NOT DETERMINISTIC;M SQL> SELECT DO_COM('WRITE SYS$OUTPUT "HELLO"'), EMPLOYEE_ID FROM EMPLOYEES cont> LIMIT TO 5 ROWS; HELLO HELLO DO_COM EMPLOYEE_ID 1 00164 HELLO 1 00165 HELLO 1 00166 HELLO 1 00167 1 00168 5 rows selectedA Example 3: External f<unction and external procedure definition& The following example demonstrates:4 o An external function and an external procedure. o Both CLIENT SITE and SERVER SITE binding o BIND SCOPE! o A NOTIFY routine and events= o SQL callback using embedded SQL and SQL module language2 o SQL$PRE options required when using callback1 o Linker options required when using callbackC In this example, a new column is added to the EMPLOYEES table inD the MF_ =PERSONNEL database. External routines are used to set thisA column to spaces and to the SOUNDEX value corresponding to theA various employee names. Transaction control at the application@ level (in this instance, in SQL) in conjunction with a notifyD routine demonstrates how the actions of the external routines can- be affected by actions of the application.A The space-filling is performed by an external function, CLEAR_? SOUNDEX, (written in C) containing embedded SQL, whic >h opensC another instance of the MF_PERSONNEL database and leaves it open until deactivated.A The SOUNDEX name-setting is performed by an external procedureA (written in FORTRAN), assisted by a notify routine (written inB FORTRAN) which performs the database connection and transactionC control. All the database operations are performed by SQL module? language routines. The procedure also opens another instance= of the MF_PERSONNEL database, which is disconnected by th?eC notify routine when the routine is deactivated at the end of theA transaction. Display statements executed by the notify routine@ serve to demonstrate the progress of the database operations.' SQL> ATTACH 'FILENAME MF_PERSONNEL'; SQL> --B SQL> -- Add the new column SOUNDEX_NAME to the EMPLOYEES table. SQL> --7 SQL> ALTER TABLE EMPLOYEES ADD SOUNDEX_NAME CHAR(4); SQL> --- SQL> -- Define the CLEAR_SOUNDEX function. SQL> --( SQL> CREATE FUNCTION CLEAR_SO @UNDEX ()# cont> RETURNS INTEGER BY VALUE;( cont> EXTERNAL NAME CLEAR_SOUNDEX+ cont> LOCATION 'CLEAR_SOUNDEX.EXE'A cont> LANGUAGE C PARAMETER STYLE GENERAL NOT DETERMINISTIC4 cont> BIND ON SERVER SITE BIND SCOPE CONNECT; SQL> --1 SQL> -- Define the ADD_SOUNDEX_NAME procedure. SQL> --) SQL> CREATE PROCEDURE ADD_SOUNDEX_NAME' cont> (INOUT INTEGER BY REFERENCE);+ cont> EXTERNAL NAME ADD_SOUNDEX_NAME) cont> LOCATION 'ADD_SOUNDEX.EXEA'5 cont> LANGUAGE FORTRAN PARAMETER STYLE GENERAL7 cont> BIND ON CLIENT SITE BIND SCOPE TRANSACTION< cont> NOTIFY ADD_SOUNDEX_NOTIFY ON BIND, TRANSACTION; SQL> -- SQL> COMMIT; SQL> DISCONNECT ALL; SQL> EXIT; 7 Example 4: The CLEAR_SOUNDEX.SC program written in CR /* Set the soundex_name column to spaces, return any error as function value */ static int state = 0; extern int clear_soundex () { exec sql include sqlca ;4 B exec sql declare alias filename MF_PERSONNEL; if (state == 0) {3 exec sql attach 'filename MF_PERSONNEL'; state = 1; }+ exec sql set transaction read write; if (SQLCA.SQLCODE < 0) return SQLCA.SQLCODE;; exec sql update employees set soundex_name = ' '; if (SQLCA.SQLCODE < 0) return SQLCA.SQLCODE; exec sql commit; if (SQLCA.SQLCODE < 0) return SQLCA.SQLCODE; returCn 0; }D Example 5: Compiling, creating a linker options file, and linking the CLEAR_SOUNDEX program? $ SQL$PRE/CC/NOLIST/SQLOPT=ROLLBACK_ON_EXIT CLEAR_SOUNDEX.SC $ CREATE CLEAR_SOUNDEX.OPT0 SYMBOL_VECTOR = (CLEAR_SOUNDEX=PROCEDURE)* PSECT_ATTR=RDB$MESSAGE_VECTOR,NOSHR$ PSECT_ATTR=RDB$DBHANDLE,NOSHR. PSECT_ATTR=RDB$TRANSACTION_HANDLE,NOSHR# $ LINK/SHARE=CLEAR_SOUNDEX.EXE -, CLEAR_SOUNDEX.OBJ, SQL$USER:/LIBRARY, - CLEAR_SOUNDEX.OPT/ODPT0 SYMBOL_VECTOR = (CLEAR_SOUNDEX=PROCEDURE)* PSECT_ATTR=RDB$MESSAGE_VECTOR,NOSHR$ PSECT_ATTR=RDB$DBHANDLE,NOSHR. PSECT_ATTR=RDB$TRANSACTION_HANDLE,NOSHR < Example 6: The ADD_SOUNDEX.FOR program written in FORTRANI C Set the soundex values, returning any error in the IN/OUT parameter. SUBROUTINE ADD_SOUNDEX_NAME (ERROR)+ CHARACTER ID*5,LAST*14,SX_NAME*4 INTEGER ERROR ERROR = 0 ID = '00000'* 10 E CALL GET_NAME (ID, LAST, ERROR)% IF (ERROR .NE. 0) GO TO 801 CALL MAKE_SOUNDEX_NAME (LAST, SX_NAME)5 CALL SET_SOUNDEX_NAME (ID, SX_NAME, ERROR)% IF (ERROR .EQ. 0) GO TO 10( 80 IF (ERROR .EQ. 100) ERROR = 0 90 RETURN ENDN C Perform database connection and transaction operations for notify eventsA SUBROUTINE ADD_SOUNDEX_NOTIFY (FUNC, RSV1, RSV2, RSV3)2 INTEGER FUNC, RSV1, RSV2, RSV3, SQLCODE F SQLCODE = 0* GO TO (10,20,5,5,30,40,50),FUNC7 5 TYPE *,'*** ADD_SOUNDEX_NOTIFY bad func ***' GO TO 907 10 TYPE *,'*** ADD_SOUNDEX_NOTIFY activate ***'# CALL ATTACH_DB (SQLCODE)' IF (SQLCODE .NE. 0) GO TO 80 GO TO 909 20 TYPE *,'*** ADD_SOUNDEX_NOTIFY deactivate ***'# CALL DETACH_DB (SQLCODE)' IF (SQLCODE .NE. 0) GO TO 80 GO TO 909 30 TYPE *,'*** ADD_SOUNDEXG_NOTIFY start tran ***'$ CALL START_TRAN (SQLCODE)' IF (SQLCODE .NE. 0) GO TO 80 GO TO 90: 40 TYPE *,'*** ADD_SOUNDEX_NOTIFY commit tran ***'% CALL COMMIT_TRAN (SQLCODE)' IF (SQLCODE .NE. 0) GO TO 80 GO TO 90< 50 TYPE *,'*** ADD_SOUNDEX_NOTIFY rollback tran ***'' CALL ROLLBACK_TRAN (SQLCODE)' IF (SQLCODE .NE. 0) GO TO 80 GO TO 90 80 CALL SQL_SIGNAL () 90 RETHURN ENDI C A 'substitute' SOUNDEX routine for demonstration purposes only< SUBROUTINE MAKE_SOUNDEX_NAME (NAME, SOUNDEX_NAME), CHARACTER NAME*(*),SOUNDEX_NAME*4& SOUNDEX_NAME(1:1)=NAME(1:1)# IV = ICHAR(NAME(1:1))+220 SOUNDEX_NAME(2:2)=CHAR(MOD(IV,10)+48)3 SOUNDEX_NAME(3:3)=CHAR(MOD(IV/10,10)+48), SOUNDEX_NAME(4:4)=CHAR(IV/100+48) RETURN END, Example 7: The ADD_SOUNDEXMI.SQLMOD module% -- Support for set soundex routine MODULE ADD_SOUNDEX LANGUAGE FORTRAN PARAMETER COLONS! PROCEDURE ATTACH_DB (SQLCODE);& ATTACH 'FILENAME MF_PERSONNEL';! PROCEDURE DETACH_DB (SQLCODE); DISCONNECT DEFAULT;" PROCEDURE START_TRAN (SQLCODE);" SET TRANSACTION READ WRITE;# PROCEDURE COMMIT_TRAN (SQLCODE); COMMIT;% PROCEDURE ROLLBACK_TRAN (SQLCODE); ROLLBACK;A PROCEDURE GET_NAME (:ID CHAR(5), :LASTNAME CHJAR(14), SQLCODE);8 SELECT EMPLOYEE_ID, LAST_NAME INTO :ID, :LASTNAME= FROM EMPLOYEES WHERE EMPLOYEE_ID > :ID LIMIT TO 1 ROW;G PROCEDURE SET_SOUNDEX_NAME (:ID CHAR(5), :SX_NAME CHAR(4), SQLCODE);L UPDATE EMPLOYEES SET SOUNDEX_NAME = :SX_NAME WHERE EMPLOYEE_ID = :ID;> Example 8: Compiling, creating the linker options file, and7 linking the FORTRAN and SQL module language programs# $ FORTRAN/NOLIST ADD_SOUNDEX.FOR $ SQL$MOD ADD_SOUNDEXM.SQLMOD $ CREAT KE ADD_SOUNDEX.OPT3 SYMBOL_VECTOR = (ADD_SOUNDEX_NAME=PROCEDURE)5 SYMBOL_VECTOR = (ADD_SOUNDEX_NOTIFY=PROCEDURE)* PSECT_ATTR=RDB$MESSAGE_VECTOR,NOSHR$ PSECT_ATTR=RDB$DBHANDLE,NOSHR. PSECT_ATTR=RDB$TRANSACTION_HANDLE,NOSHR! $ LINK/SHARE=ADD_SOUNDEX.EXE -< ADD_SOUNDEX.OBJ, ADD_SOUNDEXM.OBJ, SQL$USER:/LIBRARY, - ADD_SOUNDEX.OPT/OPT( SYMBOL_VECTOR = ADD_SOUNDEX_NAME* SYMBOL_VECTOR = ADD_SOUNDEX_NOTIFY* PSECT_ATTR=RDB$MESSAGE_VECTLOR,NOSHR$ PSECT_ATTR=RDB$DBHANDLE,NOSHR. PSECT_ATTR=RDB$TRANSACTION_HANDLE,NOSHR5 Example 9: Using the routines with interactive SQL $ SQL' SQL> ATTACH 'FILENAME MF_PERSONNEL'; SQL> -- SQL> DECLARE :ERROR INTEGER; SQL> --6 SQL> SELECT EMPLOYEE_ID,SOUNDEX_NAME FROM EMPLOYEES cont> LIMIT TO 3 ROWS; EMPLOYEE_ID SOUNDEX_NAME 00165 NULL 00190 NULL 00187 NULL 3 rows selected SQL> COMMIT; SQL> -- M SQL> BEGIN( cont> SET :ERROR = CLEAR_SOUNDEX (); cont> END; SQL> PRINT :ERROR; ERROR 0 SQL> --6 SQL> SELECT EMPLOYEE_ID,SOUNDEX_NAME FROM EMPLOYEES cont> LIMIT TO 3 ROWS; EMPLOYEE_ID SOUNDEX_NAME 00165 00190 00187 3 rows selected SQL> COMMIT; SQL> --" SQL> SET TRANSACTION READ ONLY; SQl> BEGIN cont> SET :ERROR = 0;) cont> CALL ADD_SOUNDEX_NAME (:ERROR); cont> END;& *** ADD_SOUNDEX_NNOTIFY activate ***( *** ADD_SOUNDEX_NOTIFY start tran *** SQL> PRINT :ERROR; ERROR 0 SQL> COMMIT;) *** ADD_SOUNDEX_NOTIFY commit tran ***( *** ADD_SOUNDEX_NOTIFY deactivate *** SQL> --6 SQL> SELECT EMPLOYEE_ID,SOUNDEX_NAME FROM EMPLOYEES cont> LIMIT TO 3 ROWS; EMPLOYEE_ID SOUNDEX_NAME 00165 S501 00190 O101 00187 L890 3 rows selected SQL> COMMIT; SQL> -- SQL> BEGIN( cont> SET O:ERROR = CLEAR_SOUNDEX (); cont> END; SQL> PRINT :ERROR; ERROR 0 SQL> --" SQL> SET TRANSACTION READ ONLY; SQL> BEGIN cont> SET :ERROR = 0;) cont> CALL ADD_SOUNDEX_NAME (:ERROR); cont> END;& *** ADD_SOUNDEX_NOTIFY activate ***( *** ADD_SOUNDEX_NOTIFY start tran *** SQL> PRINT :ERROR; ERROR 0 SQL> ROLLBACK;+ *** ADD_SOUNDEX_NOTIFY rollback tran ***( *** ADD_SOUNDEX_NOTIFY deactivate *** P SQL> --6 SQL> SELECT EMPLOYEE_ID,SOUNDEX_NAME FROM EMPLOYEES cont> LIMIT TO 3 ROWS; EMPLOYEE_ID SOUNDEX_NAME 00165 00190 00187 3 rows selected SQL> COMMIT; 2 SCHEMA; Creates a new schema in the current default catalog of a multischema database.& NOTE@ Use of the CREATE SCHEMA statement to create a database isA a deprecated feature. If you specify physical attributes ofA a database suc Qh as the root file parameters, you receive anA informational message, but SQL creates the database anyway.< SQL> CREATE SCHEMA FILENAME TEST SNAPSHOT IS DISABLED;H %SQL-I-DEPR_FEATURE, Deprecated Feature: SCHEMA (meaning DATABASE)< If you do not specify any physical attributes, you may: receive an error message noting that you must enable multischema naming. SQL> CREATE SCHEMA PARTSJ %SQL-F-SCHCATMULTI, Schemas and catalogs may only be referen Rced with multischema enabledC A schema is a group of definitions within a database. The CREATEB SCHEMA statement lets you specify in a single SQL statement allD data and privilege definitions for a new schema. You can also add# definitions to the schema later.C A database, in addition to schema definitions, includes databaseB system files and user data. If you need to specify any physical= database characteristics such as the database root file orB storage area Sparameters, use the CREATE DATABASE statement. See6 the CREATE DATABASE statement for more information.@ You can specify any number of optional schema elements to theA CREATE SCHEMA statement. Schema elements are any of the CREATEC statements (except CREATE STORAGE AREA, CREATE DOMAIN . . . FROM? path-name, and CREATE TABLE . . . FROM path-name) or a GRANT statement.C These statements require statement terminators, except when theyA are part of a CREATE SCHEMA or CREATTE DATABASE statement. WhenC you use these statements within a CREATE SCHEMA statement, use aB statement terminator on the last schema element only. The firstB statement terminator that SQL encounters ends the CREATE SCHEMAA statement. Later CREATE or GRANT statements are not within the( scope of the CREATE SCHEMA statement. 3 Environment+ You can use the CREATE SCHEMA statement: o In interactive SQL: o Embedded in host language programs to be precompiled-U o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format> CREATE SCHEMA -+-> -------------------------+-+> +-> AUTHORIZATION ---------------+ |> +-> AUTHORIZATION -+ |> +--------------------------------------------+= +-+-------------------------+--------------->- +-+--> schema-element --+-++ V +----------<----------+  schema-name = 2 --+---------------------------------------------+2 +------> --------------+->. ---+2 +-> " -> . ->" --+ |2 | +-----------------------------------------+2 | +--------------> ------+->0 +-> " -> . ->" ------+  schema-element = . -+-> create-collating-sequence-statement -+->, +-> create-domain-statement ----------W---+, +-> create-index-statement --------------+, +-> create-sequence-statement -----------+, +-> create-storage-map-statement --------+, +-> create-table-statement --------------+, +-> create-trigger-statement ------------+, +-> create-view-statement ---------------+, +-> grant-statement ---------------------+  3 Arguments 4 AUTHORIZATION_auth_idD If you do not specify a schema name, the authorization identifier specifies the default schema.A If you wa Xnt to comply with the ANSI/ISO 1989 standard, specifyA the AUTHORIZATION clause without the schema name. Specify bothB the AUTHORIZATION clause and the schema name to comply with the! current ANSI/ISO SQL standard. &4 create-collating-sequence-statement; See the CREATE COLLATING_SEQUENCE statement for details.A If you want to specify a collating sequence in a CREATE DOMAINB statement embedded in a CREATE SCHEMA statement, you must first@ specify a CREATE COLLATING YSEQUENCE statement within the same CREATE SCHEMA statement. 4 create-domain-statement/ See the CREATE DOMAIN statement for details.C You cannot use the FROM path-name clause when embedding a CREATEC DOMAIN statement in a CREATE SCHEMA statement. You can, however,@ issue a separate CREATE DOMAIN statement following the CREATE> SCHEMA statement. You can also describe the domain directly& within the CREATE SCHEMA statement.? If you want to specify a collating seZquence in your embedded; CREATE DOMAIN statement, you must first specify a CREATE= COLLATING SEQUENCE statement within the same CREATE SCHEMA statement. 4 create-function-statement0 See the CREATE Routine statement for details. 4 create-index-statement. See the CREATE INDEX statement for details. 4 create-module-statement/ See the CREATE MODULE statement for details. 4 create-procedure-statement0 See the CREATE Routine statement for [details. 4 create-sequence-statement1 See the CREATE SEQUENCE statement for details. 4 create-storage-map-statement4 See the CREATE STORAGE_MAP statement for details. 4 create-table-statement. See the CREATE TABLE statement for details.C You cannot use the FROM path-name clause when embedding a CREATEB TABLE statement in a CREATE SCHEMA statement. You can, however,? issue a separate CREATE TABLE statement following the CREATED SCHEMA statement.\ You can also describe the table directly within the CREATE SCHEMA statement.? The CREATE TABLE statements in a CREATE SCHEMA statement can@ refer to domains not yet created, provided that CREATE DOMAIN; statements for the domains are in the same CREATE SCHEMA statement. 4 create-trigger-statement0 See the CREATE TRIGGER statement for details. 4 create-view-statement- See the CREATE VIEW statement for details. 4 grant-statement' See the G]RANT statement for details. 4 schema-element/ Some CREATE statements or a GRANT statement. 4 schema-name@ Specifies the name of the schema created by the CREATE SCHEMA statement.D You can qualify the schema name with either a catalog name or theB catalog name qualified by the alias. You must enclose the aliasD and catalog name in double quotation marks and separate them withB a period. You must issue the SET QUOTING RULES statement before@ you specify ^ the alias and catalog name pair, or SQL issues an9 error message about the use of double quotation marks.> For information on qualifying schema names with aliases and9 catalog names, see the User_Supplied_Names HELP topic. 3 Example= Example 1: Creating a schema within a multischema database> The following interactive statements create a database thatB contains a schema within a catalog. You issue the CREATE SCHEMA= statement alone or as part of a CREATE DATABASE s_tatement. SQL> SET DIALECT 'SQL99';N SQL> CREATE DATABASE ALIAS PERS_ALIAS FILENAME personnel MULTISCHEMA IS ON;* SQL> CREATE CATALOG "PERS_ALIAS.ADMIN";1 SQL> CREATE SCHEMA "PERS_ALIAS.ADMIN".PAYROLL; SQL> SHOW SCHEMAS;! Schemas in database PERS_ALIAS! "PERS_ALIAS.ADMIN".PAYROLL* "PERS_ALIAS.RDB$CATALOG".RDB$SCHEMA 2 SEQUENCE; Creates a sequence. A sequence is a database object fromA which multiple users can generate unique integers. You can us`e: sequences to automatically generate primary key values. 3 Environment- You can use the CREATE SEQUENCE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format4 CREATE SEQUENCE ------------------+4 +--------------------<----------------------------+4 +---+--------------a-->-------------------------+--+4 +---> STORED NAME IS ----> --+ |4 +--------------------<----------------------------+4 +-+------------------>-------------------------+-->1 +-+-+---> sequence-attributes --------+-+----+, | +---> START WITH -+ |, +------------------<------------------+ sequence-attributes = 2 --+--> INCREMENT BY ---------+->0 +--> sequence-range -----------------------+0 +--> CYCLE --------------- b-----------------+0 +--> NOCYCLE ------------------------------+0 +--> CACHE ----------------+0 +--> NOCACHE ------------------------------+0 +--> ORDER --------------------------------+0 +--> NOORDER ------------------------------+0 +--> RANDOMIZE ----------------------------+0 +--> NORANDOMIZE --------------------------+0 +--> RESTART WITH -------------------------+0 +--> WAIT ---------------------------------+0 +--> NOWAIT --------------------c-----------+0 +--> DEFAULT WAIT -------------------------+0 +--> COMMENT -+-------+--+-> '' -+-+. +-> IS -+ +------ / <-----+ sequence-range = / -+-> MINVALUE -+-+--> -+--+-->, +-> MAXVALUE -+ +--> TINYINT ----+ |, | +--> SMALLINT ---+ |, | +--> INTEGER ----+ |, | +--> BIGINT -----+ |, +-> NOMINVALUE --------------------------+, +-> NOMAXVALUE -----------------d---------+ 3 Arguments 4 CACHE Syntax options: CACHE numeric-value | NOCACHED The CACHE clause specifies how many values of the sequence OracleC Rdb should preallocate and keep in memory for faster access. The2 numeric value must be between 2 and 2147483647.A You cannot cache more values than will fit in a given cycle ofB sequence numbers; thus, the maximum value allowed for the CACHEB clause must be less than the value resulting from the following e formula:% (MAXVALUE-MINVALUE)/ABS(INCREMENT)= The SET FLAGS option SEQ_CACHE can be used to override the? setting of CACHE at runtime. See the SET_FLAGS statement for more details.A A cache for a given sequence is populated at the first request; for a number from that sequence, and whenever a value isA requested when the cache is empty. If a system failure occurs,= or when the cache is released any unfetched values will be? discarded. The maximum number off lost values is equal to theB current cache size. This may be the value specified by CACHE or% by the SET FLAGS SEQ_CACHE option.A The NOCACHE clause specifies that values will be allocated oneB at a time. This will require more I/O to the Rdb root file than using a CACHE value.4 By default, Oracle Rdb caches 20 sequence values. 4 COMMENT_IS_'string_'B Adds a comment about the sequence. SQL displays the text of theB comment when it executes a SHOW SEQUENCE gstatement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/). 4 CYCLE Syntax options: CYCLE | NOCYCLE> The CYCLE clause specifies that the sequence is to continueD generating values after reaching either the MINVALUE or MAXVALUE.A After an ascending sequence reaches the MAXVALUE, the sequence> starts again from its MINVALUE. After a descending sequenceC reaches its MINVALUE, the sequence starts h again at its MAXVALUE.< The NOCYCLE clause specifies that the sequence should not? continue generating values after reaching either its minimumC or maximum value. An error is generated if an attempt is made toB increment the sequence beyond its limits. The NOCYCLE clause is the default. 4 INCREMENT_BY_numeric-valueC Specifies the size of the increment and the direction (ascendingD or descending) of the sequence. This numeric value must be in theB range -214748i3648 through 2147483647, excluding 0. The absoluteC value must be less than the difference of MAXVALUE and MINVALUE.? A negative value specifies a descending sequence; a positiveA value specifies an ascending sequence. By default, the numeric value is 1. 4 MAXVALUE Syntax options:& MAXVALUE numeric-value | NOMAXVALUE< The MAXVALUE clause specifies the maximum signed quadwordC (BIGINT) value that the sequence can generate. The numeric valueD must be betwejen -9223372036854775808 and 9223372036854775808. TheD MAXVALUE must be equal to or greater than the value specified forB the START WITH clause and greater than the value specified with@ the MINVALUE clause. The NOMAXVALUE clause specifies that theA maximum value for an ascending sequence is 9223372036854775808: (plus the cache size) and -1 for a descending sequence.( The NOMAXVALUE clause is the default. 4 MAXVALUE_integer Syntax options: MAXVALUE TINYINTk MAXVALUE SMALLINT MAXVALUE INTEGER MAXVALUE BIGINT? SQL allows the keyword TINYINT, SMALLINT, INTEGER and BIGINTB to follow MAXVALUE instead of a numeric value. This allows easyD range setting for sequences used with these data types. The valueC supplied will be the largest positive value that can be assigned to this data type. 4 MINVALUE Syntax options:& MINVALUE numeric-value | NOMINVALUE< The MINVALUE clause specifies the minimum s ligned quadword= (BIGINT) value that the sequence can generate. The numericC value must be equal to or greater than -9223372036854775808. TheB MINVALUE must be less than or equal to the value specified withC the START WITH clause and less than the value specified with theD MAXVALUE clause. The NOMINVALUE clause specifies that the minimumA value for an ascending sequence is 1, and -92233720368547758083 (plus the cache size) for a descending sequence.( The NOMINVALUE clausem is the default. 4 MINVALUE_integer-value Syntax options: MINVALUE TINYINT MINVALUE SMALLINT MINVALUE INTEGER MINVALUE BIGINT? SQL allows the keyword TINYINT, SMALLINT, INTEGER and BIGINTB to follow MINVALUE instead of a numeric value. This allows easyD range setting for sequences used with these data types. The valueD supplied will be the smallest negative value that can be assigned to this data type. 4 ORDER Syntax optinons: ORDER | NOORDERB The ORDER clause specifies that sequence numbers are guaranteed< to be assigned in order for each requesting process, thus? maintaining a strict history of requests. The NOORDER clause; specifies that sequence numbers are not guaranteed to be! generated in order of request.% The NOORDER clause is the default. 4 RANDOMIZE Syntax options: RANDOMIZE | NORANDOMIZEB The RANDOMIZE clause specifies that the sequence numbers are to o@ be returned with a random value in the most significant bytesA of the BIGINT value. This allows unique values to be generatedD that have a random distribution. When you specify the NORANDOMIZEC clause, sequence numbers are close in value to others created at the same time.C The advantage of the RANDOMIZE clause is that updates to columns? of a sorted index to which these values are written occur in? different locations in the index structure. This may improveA con pcurrent access for large indexes as leaf nodes in different@ parts of the index can be updated independently. In contrast,B the sequence numbers generated when you specify the NORANDOMIZEA clause (which are likely to be close in numeric value to other? sequences) result in index updates that occur in the same orB nearby index nodes, which may lead to contention in one part of the sorted index.@ The full range of values in the BIGINT value returned for the> sequence are usqed; therefore, the NOMAXVALUE and NOMINVALUE? clauses must be specified (or defaulted to) for the sequence< definition. The most significant bits of the BIGINT value> are set to a randomly generated positive value. A generatedA distinct value is returned in the least significant 32 bits so? that uniqueness is guaranteed. If you also specify the CYCLEC clause, then only the least significant 32 bits are cycled. When@ a query is performed on the column RDB$NEXT_SEQUENCE_VALUE in rA the RDB$SEQUENCES table, only the generated value of the leastB significant bits is returned, because the most significant bitsA are not assigned until the NEXTVAL pseudocolumn is referenced.; If you specify RANDOMIZE, you cannot also specify ORDER,@ MAXVALUE, or MINVALUE. The NORANDOMIZE clause is the default. 4 sequence-nameD The name of the sequence that you want to create. Use a name thatB is unique among all sequence, synonym, table, and view names in@ the s database, or in the schema if you are using a multischema$ database. Use any valid SQL name. 4 START_WITH_numeric-valueC Specifies the initial numeric value to be used for the sequence.A This value must be in the range specified by (or defaulted to)@ the other sequence attribute clauses. Valid values are in the5 range -9223373036854775808 to 9223372036854775807.< If omitted, the START WITH value defaults to the value of? MINVALUE for ascending sequences and MAXVALtUE for descending sequences. 4 STORED_NAME_IS_stored-name= Specifies a name that Oracle Rdb uses to access a sequenceC created in a multischema database. The stored name allows you toB access multischema definitions using interfaces, such as OracleC RMU, that do not recognize multiple schemas in one database. YouA cannot specify a stored name for a sequence in a database that# does not allow multiple schemas. 4 WAIT Syntax options: WAIT | NO uWAIT | DEFAULT WAIT@ Specifies what wait state is used when a reference to NEXTVAL= is used. A reference to NEXTVAL for a sequence may require= synchronization with other users of the sequence. When you? specify DEFAULT WAIT, the wait state (WAIT or NOWAIT) of the@ current transaction is used. This may mean that no waiting is) performed during a NOWAIT transaction.; If you specify WAIT (the default) for the sequence, thenD regardless of the wait state set for the currvent transaction, allD synchronization waits for the next value. This is the recommendedC setting if the application uses NOWAIT transactions. The currentC WAIT timeout interval defined for the transaction or database is used.A If you specify NOWAIT for the sequence, then regardless of theA current transaction setting, all synchronization does not wait for the next value. 3 Examples! Example 1: Creating a Sequence@ SQL> -- This example creates a new sequen wce using the defaultF SQL> -- values for NOMINVALUE, NOMAXVALUE, INCREMENT BY 1, NOCYCLE,< SQL> -- and CACHE 20. The START WITH value is set to 147.E SQL> -- Allyn Stuart will be assigned an EMPLOYEE_ID value of 147.= SQL> -- Nick Jones will be assigned an EMPLOYEE_ID of 148. SQL> --/ SQL> CREATE SEQUENCE EMPID START WITH 00147;M SQL> -- Use NEXTVAL to fetch a sequence number for the primary key column. SQL> INSERT INTO EMPLOYEES- cont> (EMPLOYEE_ID, LAST_NAME, FIRST_xNAME)2 cont> VALUES (EMPID.NEXTVAL, 'STUART', 'ALLYN') cont> RETURNING EMPLOYEE_ID; EMPLOYEE_ID 147 1 row insertedQ SQL> -- Use CURRVAL to reuse the EMPLOYEE_ID value for the foreign key columns$ SQL> -- in the associated tables." SQL> INSERT INTO SALARY_HISTORY> cont> (EMPLOYEE_ID, SALARY_AMOUNT,SALARY_START, SALARY_END): cont> VALUES (EMPID.CURRVAL, 35000, '6-FEB-1998', NULL) cont> RETURNING EMPLOYEE_ID; EMPLOYEE_ID 147 1 row insertedy SQL> INSERT INTO JOB_HISTORY; cont> (EMPLOYEE_ID, DEPARTMENT_CODE, JOB_START, JOB_END); cont> VALUES (EMPID.CURRVAL, 'ENGR', '6-FEB-1998', NULL) cont> RETURNING EMPLOYEE_ID; EMPLOYEE_ID 147 1 row inserted SQL> INSERT INTO EMPLOYEES- cont> (EMPLOYEE_ID, LAST_NAME, FIRST_NAME)2 cont> VALUES (EMPID.NEXTVAL, 'JONES ', 'NICK ') cont> RETURNING EMPLOYEE_ID; EMPLOYEE_ID 148 1 row inserted 2 STORAGE_AREA& z NOTE< You cannot issue CREATE STORAGE AREA as an independent@ statement. It is a clause allowed only as part of a CREATE# DATABASE or IMPORT statement.> You can also create a storage area using the ADD STORAGE2 AREA clause of the ALTER DATABASE statement.D Creates additional storage areas in a multifile database. Storage= areas are data and snapshot files that are associated with- particular tables in a multifile database.C A CREATE STORAGE {AREA clause specifies the names for the storage< area files and determines their physical characteristics.A Subsequent CREATE STORAGE MAP statements associate the storage/ area with particular tables in the database. 3 EnvironmentB You can use the CREATE STORAGE AREA clause only within a CREATE DATABASE or IMPORT statement. 3 FormatE CREATE STORAGE AREA -+-> -+-+-------------------------++E +-> RDB$SYSTEM --+ +-> FILENAME -+|E +-------------------------------------------------------------++ ++------------------------------+-+->) +-+-+-> storage-area-params-1 -+ |) | +-> storage-area-params-2 -+ |) +--------------- <-------------+  storage-area-params-1 = ; --+-> ALLOCATION IS ---> --> PAGES -----+->9 +-> CACHE USING --------------------+9 +-> NO ROW CACHE ------------------------------------+9 +-> extent-params -}----------------------------------+9 +-> INTERVAL IS --> -------------+9 +-> LOCKING IS --+-> ROW --+--> LEVEL ---------------+9 | +-> PAGE -+ |9 +-> PAGE FORMAT IS +-> UNIFORM -+--------------------+9 | +-> MIXED ---+ |9 +-> PAGE SIZE IS ----> --> BLOCKS -----+  extent-params = 6 --+-> EXTENT IS -+-> ENABLED -------------------++-->3 | +-~> DISABLED ------------------+|3 | +-> --> PAGES --+|3 | +-> (extension-options) -------+|3 +---------------------<------------------------+  extension-options = ' ---> MINIMUM OF PAGES, --+' +------------------------------------+' +--> MAXIMUM OF PAGES, --+' +------------------------------------+) +--> PERCENT GROWTH IS ------->  storage-area-params-2 = @ --+-> CHECKSUM CALCUL ATION IS -----------+--+-> ENABLED --+-+->> +-> SNAPSHOT CHECKSUM CALCULATION IS --+ +-> DISABLED -+ |> +-> SNAPSHOT ALLOCATION IS --> ----> PAGES ---+> +-> SNAPSHOT EXTENT IS -+-> ----> PAGES --++> | +-> (extension-options) ---------+|> +-> SNAPSHOT FILENAME --> --------------------+> +-> THRESHOLDS ARE ( +-----------------------+> ) -+> | +> , -+----------++ |> |  +> , + |> +------------------------------<--------------------------+  3 Arguments 4 ALLOCATION_PAGES Syntax option:# ALLOCATION IS number-pages PAGESB The number of database pages initially allocated to the storageA area. Rdb will automatically extend this allocation to account@ for internal structure pages, such as SPAM (spage management)B pages. For example, an allocation of 25 will be increased to 27 as shown in this example:, SQL> alter database filename MF_PERSONNEL% cont> add storage area DOC_EXAMPLE! cont> page format is uniform cont> allocation 25;' SQL> attach 'filename MF_PERSONNEL';% SQL> show storage area DOC_EXAMPLE DOC_EXAMPLE& Access is: Read write# Page Format: Uniform$ Page Size: 2 blocksF Area File: USER_DISK:[DOC.DATABASES]DOC_EXAMPLE.RDA;1. Area Allocation:  27 pages# Extent: Enabled. Area Extent Minimum: 99 pages0 Area Extent Maximum: 9999 pages0 Area Extent Percent: 20 percentF Snapshot File: USER_DISK:[DOC.DATABASES]DOC_EXAMPLE.SNP;1/ Snapshot Allocation: 100 pages. Snapshot Extent Minimum: 99 pages0 Snapshot Extent Maximum: 9999 pages0 Snapshot Extent Percent: 20 percent Locking is Row Level1  No Cache Associated with Storage Area3 No database objects use Storage Area DOC_EXAMPLE 4 CACHE_USING_row_cache_nameA Assigns the named row cache to the specified storage area. All@ rows stored in this area, whether they consist of table data,B segmented string data, or special rows such as index nodes, are) cached if those rows fit in the cache.A If the row cache does not exist, you must create the row cacheA before terminating the CREATE DATABASE statement. For example:( SQL> CREATE DATABASE FILENAME test_db cont> ROW CACHE IS ENABLED" cont> CREATE STORAGE AREA area1 cont> CACHE USING test1 cont> CREATE CACHE test1" cont> CACHE SIZE IS 100 ROWS$ cont> ROW LENGTH IS 200 BYTES;7 Only one row cache is allowed for each storage area.2 NO ROW CACHE is the default for a storage area. 4 CHECKSUM_CALCULATION Syntax options:7 CHECKSUM CALCULATION | SNAPSHOT CHECKSUM CALCULATIONC This option allows you to enable or disable calculations of pageB checksums when pages are read from or written to the storage or snapshot area files. The default is ENABLED.& NOTE; Oracle Corporation recommends that you leave checksum1 calculations enabled; which is the default.@ With current technology, it is possible that errors may occur< that the checksum calculation can detect but that may not= be detected by either the h ardware, firmware, or software.C Unexpected application results and database corruption may occurD if corrupt pages exist in memory or on disk but are not detected.B Oracle Corporation recommends performing checksum calculations,2 except in the following specific circumstances:B o Your application is stable and has run without errors on theA current hardware and software configuration for an extended period of time.> o You have reached maximum CPU utilization  in your current; configuration. Actual CPU utilization by the checksum? calculation depends primarily on the size of the database? pages in your database. The larger the database page, theC more noticeable the CPU usage by the checksum calculation may become.& NOTE? Oracle Corporation recommends that you carefully evaluate> the trade-off between reducing CPU usage by the checksumB calculation and the potential for loss of database integrity, if checksum calculations are disabled.@ Oracle Rdb allows you to disable and, subsequently, re-enable= checksum calculation without error. However, once checksum< calculations have been disabled, corrupt pages may not be> detected even if checksum calculations are subsequently re- enabled. 4 EXTENT Syntax options:# EXTENT ENABLED | EXTENT DISABLED? Enables or disables extents. Extents are ENABLED by default.> You may encounter performance problems when creating hashed= indexes in storage areas with the mixed page format if the= storage area was created specifying the incorrect size for= the area and if extents are enabled. By disabling extents,? this problem can be diagnosed early and corrected to improve performance. 4 EXTENT_IS Syntax options:? EXTENT IS extent-pages PAGES | EXTENT IS (extension-options)B Specifies the number of pages of each storage area file extent.? See also the description under the SNAPSHOT EXTENT argument. 4 FILENAME_file_specB Provides an explicit file specification for storage area files.C The CREATE STORAGE AREA clause creates two files: a storage areaA file with a file extension of .rda, and a snapshot file with aA file extension of .snp. If you omit the FILENAME argument, the3 file specification takes the following defaults:0 o Device: the current device for the process6 o Directory:  the current directory for the process8 o File name: the name specified for the storage area> Neither the file specification for the storage area nor the2 snapshot file may contain a node specification.? The file specification is used for both the storage area andD snapshot files that comprise the storage area (unless you use theA SNAPSHOT FILENAME argument to specify a different file for theD snapshot file). Because the CREATE STORAGE AREA clause can createB two files  with different file extensions, do not specify a file) extension with the file specification.7 You may use a logical name for all or part of a file specification.C One benefit of a multifile database is that its files can resideB on more than one disk. If you want storage area files to resideA on another disk, you must specify the FILENAME argument with a full file specification.> However, you may choose to create a multifile database even> if your main purpose in creating the storage area is not to? distribute storage area files across more than one disk. For1 instance, a multifile database enables you to:@ o Take advantage of hashed indexes. Hashed indexes require aA storage area with mixed page format and cannot be stored in" the RDB$SYSTEM storage area.@ o Set attributes such as page size to better correspond with5 tables that will be stored in the storage area. 4 INTERVAL Syntax options: INT ERVAL IS number-data-pages? Specifies the number of data pages between SPAM pages in theD storage area file, and thus the maximum number of data pages eachA SPAM page manages. The default, and also the minimum interval,C is 216 data pages. The first page of each storage area is a SPAMB page. The interval you specify determines where subsequent SPAMA pages are to be inserted if there are enough data pages in the+ storage file to require more SPAM pages.D You cannot spec ify the INTERVAL storage area parameter unless you0 also explicitly specify PAGE FORMAT IS MIXED.? Oracle Rdb calculates the maximum INTERVAL size based on theA number of blocks per page, and returns an error message if youB exceed this value. For example, when the page size is 2 blocks,= the maximum INTERVAL is 4008 pages. If you try to create aA storage area with the INTERVAL set to 4009, Oracle Rdb returns the following error message:P %RDB-E-BAD_DPB_CONTENT, invalid database parameters in the database parameter block (DPB)M -RDMS-F-SPIMAX, spam interval of 4009 is more than the Rdb maximum of 4008 -RDMS-F-AREA_NAME, area NEW; For more information about setting space area management@ parameters, see the Oracle Rdb Guide to Database Maintenance. 4 LOCKING_level Syntax options:/ LOCKING IS ROW LEVEL | LOCKING IS PAGE LEVELC Specifies if locking is at the page or row level for the storageC area. This clause provide s an alternative to requesting locks onB records. Specifying a lock level when you create a storage area@ overrides the database default lock level. The default is ROW LEVEL.B When many records are accessed in the same area and on the sameD page, the LOCKING IS PAGE LEVEL clause reduces the number of lockB operations performed to process a transaction; however, this isC at the expense of reduced concurrency because these pages' locksA are held until COMMIT/ROLLBACK. Trans actions that benefit most@ with page-level locking are of short duration and also accessC several database records on the same page. However, to guaranteeC consistency of the data in the absence of row locking these pageB level locks must be held until the transaction ends with COMMIT or ROLLBACK.D Use the LOCKING IS ROW LEVEL if transactions are long in duration and lock many rows.> The LOCKING IS PAGE LEVEL clause causes fewer blocking ASTs> and provides better response time and utilization of systemA resources. However, there is a higher contention for pages andB increased potential for deadlocks and long transactions may use excessive locks.C Page-level locking is never applied to RDB$SYSTEM or the DEFAULT= storage-area, either implicitly or explicitly, because the- locking protocol can stall metadata users.B You cannot specify page-level locking on single-file databases. 4 MAXIMUM_PAGES Syntax options: MAXIMUM OF max-pages PAGESD Specifies the maximum number of pages of each extent. The default is 9,999 pages. 4 MINIMUM_PAGES Syntax options: MINIMUM OF min-pages PAGESD Specifies the minimum number of pages of each extent. The default is 99 pages. 4 NO_ROW_CACHE> Specifies that a row cache is not assigned to the specifiedD storage area in the database. You cannot specify the NO ROW CACHE0 clause if you specify the CACHE USING clause.C Alter the storage area and name a row cache with the CACHE USINGB clause to assign a row cache to the storage area or to override? the database default. Only one row cache is allowed for each storage area. 4 PAGE_FORMAT Syntax options:0 PAGE FORMAT IS UNIFORM | PAGE FORMAT IS MIXED8 Specifies the on-disk structure for the storage area.@ o The default is PAGE FORMAT IS UNIFORM. A storage area withD uniform page format is a file that is divided into groups of  nB pages, called clumps, where n equals the buffer size divided? by the page size. Both buffer size and page size are user@ specified values. By default, the buffer size is 6 blocks,A and the page size is 1024 bytes or 2 blocks long, resultingC in clumps of three pages. The PAGE FORMAT IS UNIFORM argumentD creates a storage area file that is divided into clumps. A setA of clumps forms a logical area that can contain rows from a! single table or inde x only.? Uniform page format storage areas generally give the bestD performance if the tables in the storage area are likely to be) subject to a wide range of queries.C o The PAGE FORMAT IS MIXED argument creates a storage area withB a format that allows rows from more than one table to resideA on or near a particular page of the storage area file. ThisA is useful for storing related rows from different tables onB the same page of the data file. For storage areas subject to@ repeated queries that retrieve those related rows, a mixedA page format can greatly reduce input/output overhead if the? mix of rows on the page is carefully controlled. However,D mixed page format storage areas degrade performance if the mixD of rows on the page is not suited for the queries made against the storage area.D For more information on the relative advantages and disadvantagesB of uniform and mixed storage areas, see the Oracle Rdb Guide to Database Maintenance. 4 PAGE_SIZE_blocks Syntax options:" PAGE SIZE IS page-blocks BLOCKSA The size in blocks of each data page in the storage area. Page@ size is allocated in 512-byte blocks. The default is 2 blocksA (1024 bytes). If your largest row is larger than approximatelyA 950 bytes, allocate more blocks per page to prevent fragmentedC rows. If you specify a page size larger than the buffer size, an error message is returned. 4 PERCENT_GROWTH Syntax options: PERCENT GROWTH IS growthA Specifies the percent growth of each extent. The default is 20 percent growth. 4 SNAPSHOT_ALLOCATION Syntax options:) SNAPSHOT ALLOCATION IS snp-pages PAGESA Specifies the number of pages allocated for the snapshot file. The default is 100 pages. 4 SNAPSHOT_EXTENT Syntax options:C SNAPSHOT EXTENT IS extent-pages | SNAPSHOT EXTENT IS (extension- options)A Specifies the number of pages of each snapshot or storage area@ file extent. The default extent for storage area files is 100 pages.C Specify a number of pages for simple control over the extension.C For greater control, and particularly for multivolume databases,B use the MIN, MAX, and PERCENT GROWTH extension options instead.C If you use the MIN, MAX, and PERCENT GROWTH parameters, you must enclose them in parentheses. 4 SNAPSHOT_FILENAME  Syntax options: SNAPSHOT FILENAME file-specD Provides a separate file specification for the snapshot file. TheB SNAPSHOT FILENAME argument can only be specified with multifile databases.@ This argument lets you specify a different file name, device,C or directory for the snapshot file created by the CREATE STORAGEB AREA clause. Do not specify a file extension other than .snp to@ the file specification. Oracle Rdb assigns the extension .snp> to the file specification, even if you specify an alternate extension.@ If you omit the SNAPSHOT FILENAME argument, the snapshot file@ gets the same device, directory, and file name as the storage area file. 4 STORAGE_AREAA Specifies the name of the storage area you want to create. TheB name cannot be the same as any other storage area definition in the database. 4 STORAGE_AREA_RDB$SYSTEM< Specifies that you want the CREATE STORAGE AREA clause toB override the default characteristics for the main storage area,! RDB$SYSTEM, in a new database.B The RDB$SYSTEM storage area contains database system tables and@ indices. If an alternate DEFAULT STORAGE AREA is not assignedD then this area may also contain unmapped user tables and indices. 4 THRESHOLDS_values Syntax options:+ THRESHOLDS ARE ( val1 [,val2 [,val3] ] )A Specifies one, two, or three threshold values for mixed formatC pages. The threshold values represent a fullness percentage on aC data page and establish three possible ranges of guaranteed freeC space on the data pages. When a data page reaches the percentage@ defined by a given threshold value, the space area management? (SPAM) entry for the data page is updated to reflect the new4 fullness percentage and its remaining free space.B The default threshold values for mixed areas, if not specified,? are (70,85,95), which indicates that the nominal record sizeC should be used for SPAM  threshold calculations. Oracle Rdb neverB stores a record on a page at the third threshold. The value youD set for the highest threshold can be used to reserve space on the! page for future record growth.A When only val1 is specified, this is equivalent to (val1, 100,@ 100). When val1 and val2 are specified, this is equivalent toB (val1, val2, 100). The trailing, unspecified thresholds defaultC to 100 percent. For example, THRESHOLDS ARE (40) would appear as (40, 100, 100).B You cannot specify the THRESHOLDS storage area parameter unless4 you also explicitly specify PAGE FORMAT IS MIXED.; For more information about setting space area management@ parameters, see the Oracle Rdb Guide to Database Maintenance. 3 Examples+ Example 1: Defining a multifile databaseD This example shows the definition of a database and storage areas for a multifile database.1 SQL> -- Note that there is no semicolon before0 SQL> -- the first CRE ATE STORAGE AREA clause./ SQL> CREATE DATABASE ALIAS MULTIFILE_EXAMPLE: cont> FILENAME 'DB_DATA01:[DB.DATA]MULTIFILE_EXAMPLE'& cont> CREATE STORAGE AREA EMPID_LOW2 cont> FILENAME 'DB_DATA02:[DB.DATA]EMPID_LOW'! cont> ALLOCATION IS 10 PAGES8 cont> -- Notice that the snapshot file resides on a= cont> -- different disk than the storage area file. This= cont> -- strategy reduces disk input/output bottlenecks:; cont> SNAPSHOT FILENAME 'DB_SNAP03:[DB.SNAP]EMPID_LOW'* cont> SNAPSHOT ALLOCATION IS 10 PAGES cont> --& cont> CREATE STORAGE AREA EMPID_MID) cont> FILENAME 'DB_DATA04:EMPID_MID'! cont> ALLOCATION IS 10 PAGES; cont> SNAPSHOT FILENAME 'DB_SNAP05:[DB.SNAP]EMPID_MID'* cont> SNAPSHOT ALLOCATION IS 10 PAGES cont> --' cont> CREATE STORAGE AREA EMPID_OVER3 cont> FILENAME 'DB_DATA06:[DB.DATA]EMPID_OVER'! cont> ALLOCATION IS 10 PAGES< cont> SNAPSHOT FILENAME 'DB_SNAP07:[DB.SNAP]EMPID_OVER'* cont>  SNAPSHOT ALLOCATION IS 10 PAGES cont> --& cont> CREATE STORAGE AREA HISTORIES2 cont> FILENAME 'DB_DATA02:[DB.DATA]HISTORIES'! cont> ALLOCATION IS 10 PAGES; cont> SNAPSHOT FILENAME 'DB_SNAP03:[DB.SNAP]HISTORIES'* cont> SNAPSHOT ALLOCATION IS 10 PAGES cont> --" cont> CREATE STORAGE AREA CODES. cont> FILENAME 'DB_DATA04:[DB.DATA]CODES'! cont> ALLOCATION IS 10 PAGES7 cont> SNAPSHOT FILENAME 'DB_SNAP05:[DB.SNAP]CODES'* cont> SNAPSHOT ALLOCATION IS 10 PAGES cont> --% cont> CREATE STORAGE AREA EMP_INFO1 cont> FILENAME 'DB_DATA08:[DB.DATA]EMP_INFO'! cont> ALLOCATION IS 10 PAGES: cont> SNAPSHOT FILENAME 'DB_SNAP09:[DB.SNAP]EMP_INFO'* cont> SNAPSHOT ALLOCATION IS 10 PAGES cont> --. cont> -- End the CREATE DATABASE statement: cont> ; Example 2:D This example shows how to set page-level and row-level locking onB storage areas from both the database level and from the storage area level.' SQL> CREATE DATABASE FILENAME sample! cont> LOCKING IS PAGE LEVEL cont> --G cont> -- All storage areas will default to page-level locking unless0 cont> -- explicitly set to row-level locking. cont> --' cont> CREATE STORAGE AREA RDB$SYSTEM" cont> FILENAME sample_system cont> --L cont> -- You cannot specify page-level locking on RDB$SYSTEM. RDB$SYSTEM1 cont> -- always defaults to row-level locking. cont> --& cont> CREATE STORAGE AREA HASH_AREA cont> FILENAME sample_hash cont> PAGE FORMAT IS MIXED cont> --5 cont> -- HASH_AREA defaultS to page-level locking. cont> --& cont> CREATE STORAGE AREA DATA_AREA cont> FILENAME sample_data cont> LOCKING IS ROW LEVEL cont> --= cont> -- DATA_AREA is explicitly set to row-level locking. cont> -- cont> ;) SQL> SHOW STORAGE AREAS (ATTRIBUTES) *1 Storage Areas in database with filename sample RDB$SYSTEM List storage area.& Access is: Read write# Page Format: Uniform$ Page Size: 2 blocks . . ." Extent : Enabled Locking is Row Level HASH_AREA& Access is: Read write! Page Format: Mixed$ Page Size: 2 blocks . . ." Extent : Enabled! Locking is Page Level DATA_AREA& Access is: Read write# Page Format: Uniform$ Page Size: 2 blocks . . ." Extent : Enabled Locking is Row LevelC See the SHOW statement for information on the SHOW STORAGE AREAS statement.B Example 3: Creating and assigning a row cache to a storage area SQL> create database cont> filename SAMPLE_DB" cont> reserve 2 cache slots! cont> row cache is enabled* cont> default storage area is AREA1 cont> create cache CACHE1$ cont> cache size is 1000 rows% cont> row length is 1000 bytes# cont> create storage area AREA1 cont> cache using CACHE1 cont> ; SQL> show cache CACHE1 CACHE1+ Cache Size: 1000 rows, Row Length: 1000 bytes" Row Replacement: Enabled" Shared Memory: Process# Large Memory: Disabled Window Count: 100 Working Set Count: 10 Reserved Rows: 20% Allocation: 100 blocks% Extent: 100 blocks SQL> show storage area AREA1 AREA1& Access is: Read write# Page Format: Uniform$ Page Size: 2 blocks@ Area File: USER_DISK:[DOC.DATABASES]AREA1.RDA;1/ Area Allocation: 702 pages Extent: En abled. Area Extent Minimum: 99 pages0 Area Extent Maximum: 9999 pages0 Area Extent Percent: 20 percent@ Snapshot File: USER_DISK:[DOC.DATABASES]AREA1.SNP;1/ Snapshot Allocation: 100 pages. Snapshot Extent Minimum: 99 pages0 Snapshot Extent Maximum: 9999 pages0 Snapshot Extent Percent: 20 percent Locking is Row Level Using Cache CACHE1- Database objects usin g Storage Area AREA1:C Usage Object Name Map / PartitionS ---------------- ------------------------------- ------------------------------- Default Area 2 STORAGE_MAPC Associates a table with one or more storage areas in a multifileA database. The CREATE STORAGE MAP statement specifies a storageA map that controls which lists or rows of a table are stored in which storage areas.? In addition to creating storage maps, the CREATE STORAGE MAP& statement has options that control:A o Which index the database system uses when inserting rows in the table: o Whether or not the rows of the table are stored in a compressed format7 o Whether or not partitioning keys can be modified.C o Whether the table is partitioned vertically, horizontally, or both.@ o Whether logging is enabled or disabled for the duration of this operation 3 Environment0 You can use the CREATE STORAGE MAP statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format" CREATE STORAGE MAP --+" +------------------------------+* ++-----------------------------------+-+* +-> STORED NAME IS ---+ |* +--------------------------------------+A +> FOR ++-------------------- -----------------++-+A | |++> ENABLE -+> COMPRESSION -----------+| |A | ||+> DISABLE + || |A | |+-> PLACEMENT VIA INDEX -+| |A | |+-> partition-updatable-clause -------+| |A | |+-> threshold-clause -----------------+| |A | |+-> LOGGING ---------------------------+ |A | |+-> NOLOGGING -------------------------+ |A |  |+-> COMMENT IS -+-> '' ---+----+ |A | | +-------- / <-----+ | |A | +-----------------<---------------------+ |A | +---------------------------------------------------------+B | +-+----------------------+-+------------------------------->" | +-> partition-clause --+ |" +> store-lists-clause ---------+ partition-updatable-clause = . ---> PARTITIONING IS -+-> NOT UPDATABLE -+-->+  +-> UPDATABLE -----+  threshold-clause = = --+-> THRESHOLD -+-> IS -+-> ( --> --> ) ---------+->; | +-> OF -+ |; | |; +-> THRESHOLDS -+-> ARE -+-----------+ |; +-> OF -+ | |; +----------------------------------+ |; +-> ( --> -+---------------------------+-> ) -+4 +-> , -+-------------+4 +-> , -+  partition-clause = H -+> STORE -+------------------++--------------------+> store-clause -+>G | +> columns-clause -++> store-attributes -+ |G +------------------------------- <----------------------------------+  columns-clause = / -> COLUMNS --> ( -+-> -+-> ) -->' +-------- , <------+  store-attributes = + --+-+-+-> ENABLE --+-> COMPRESSION -+-+-->( | | +-> DISABLE -+ | |( | +-> thresholds-clause ----------+ |( | +-> VERTICAL PARTITION --+ |( +--------------- <------------------+ store-clause = 1 ---+-> IN area-spec ------------------------+-->. +-> across-clause -----------------------+. +-> using-clause ------------------------+ area-spec = I --> -+---------------------------------------------------+->G +-> ( -++-> threshold-clause ---------------++-> ) -+@ |+-> LOGGING ------------------------+|@ |+-> NOLOGGING ----------------------+|@ |+-> PARTITION ---------------+|@ |+-> COMMENT IS -+--> 'string' ---+--+|@ | +------- / <-----+ |@ +---------------- , -----------------+ across-clause =  ---> RANDOMLY ACROSS ---+ +----------------------+" +-> ( -+> area-spec --+--> ) --> +----- , <-----+ using-clause = A ---> USING ---> ( -+-> -+-> ) ------------------+A +-------- , <------+ |A +--------------------------------------------------------------+A ++-> IN area-spec -> WITH LIMIT OF --> ( +-> -+> ) +-+A | +------ , <----+ | |A +--------------------------<--------------------------------+ |A +--------------------------<----------------------------------+C ++------------------------------------------------+------------->5 +> OTHERWISE IN area-spec -----------------------+ store-lists-clause =  ---> STORE LISTS ---+ +------------------+< +-+-> IN -+-> area-spec ---------------+---+----------->0 | +-> ( +> area-spec -> ) ----++ |0 | +------ , <-----------+ |0 | +------ ---------------------------------+; | +-+------------------------>-----------------------+; | +-> FOR -> ( -+-> ---------+-> ) -+ |; | +-> + | |; | +-------- , <-------------+ | |; | +--------------------------------------+ |; | +---+------------>----------+------------+; | +-> FILL RANDOMLY -----+ |; | +-> FILL SEQUENTIALLY --+ |; +----------------------------<-----------------------+  3 Arguments 4 across-clause7 Associates the table with two or more storage areas. 4 COMMENT_IS_'string'_A Adds a comment about the storage map. SQL displays the text of> the comment when it executes a SHOW STORAGE MAPS statement.A Enclose the comment in single quotation marks (') and separate5 multiple lines in a comment with a slash mark (/). 4 COMPRESSION_option Syntax options:+ ENABLE COMPRESSION | DISABLE COMPRESSIONA Specifies whether the rows for the partition are compressed orB uncompressed when stored. You can enable or disable compressionA on each vertical partition. You enable compression to conserveB disk space, but there is a small CPU overhead for inserting and retrieving compressed rows.A If you omit this clause, the default compression is that whichC was specified for the storage map before the first STORE COLUMNS- clause. The default is ENABLE COMPRESSION. 4 FILL Syntax options:$ FILL RANDOMLY | FILL SEQUENTIALLYC Specifies whether to fill the area set randomly or sequentially.? Specifying FILL RANDOMLY or FILL SEQUENTIALLY requires a FOR@ clause. When a storage area is filled, it is removed from the@ list of available areas. Oracle Rdb does not attempt to storeB any more lists in that area during the current database attach.> Instead, Oracle R db starts filling the next specified area.@ When a set of areas is filled sequentially, Oracle Rdb stores? lists in the first specified area until that area is filled.; If the set of areas is filled randomly, lists are stored@ across multiple areas. This is the default. Random filling isA intended for read/write media, which will benefit from the I/O) distribution across the storage areas.? The keywords FILL RANDOMLY and FILL SEQUENTIALLY can only be2 applied to areas contained within an area list. 4 FOR_(table_name)? Specifies the table or tables to which this list storage mapC applies. The named table must already be defined. If you want toC store lists of more than one table in the storage area, separate> the names of the tables with commas. For each area, you can2 specify one FOR clause and list of table names. 4 FOR_(table_name.col_name)A Specifies the name of the table and column containing the listA to which this storage map applies. Separate the table name andA the column name with a period (.). The named table and column? must already be defined. If you want to store multiple lists? in the storage area, separate the table name and column nameC combinations with commas. For each area, you can specify one FOR% clause and a list of column names. 4 LOGGING Syntax options: LOGGING | NOLOGGING> The LOGGING clause specifies that rows written to the table@ during the current transaction (the transaction in which this= table was created) be logged when written to the database.> Logging includes writing data and management records to theB recovery-unit journal file (.ruj) and after-image journal filesC (.aij). When the NOLOGGING clause is specified then only a small? number of management records are logged in the recovery-unitD journal file (.ruj) and after-image journal files (.aij). See the* Usage Notes below for more information.:  LOGGING and NOLOGGING can be specified per storage areaD (partition) or as a default for the CREATE STORAGE MAP statement.D The LOGGING and NOLOGGING clauses are mutually exclusive; specify/ only one. The LOGGING clause is the default. 4 OTHERWISE_IN@ For partitioned storage maps only, specifies the storage areaC that is used as the overflow partition. An overflow partition isB a storage area that holds any values that are higher than those? specified in the WITH LIM IT OF clause. An overflow partition? holds those values that exceed the highest specified limits. 4 partition-clauseB Defines vertical partitioning, horizontal partitioning, or both for the specified table.@ Horizontal partitioning means that you divide the rows of theD table among storage areas according to data values in one or moreC columns. Vertical partitioning means that you divide the columnsC of the table among storage areas. A given storage area will thenD contain only some of the columns of a table. You can combine both6 horizontal and vertical partitions in a single map.? Vertical partitioning reduces disk I/O operations by placingD frequently used data in one area, so that you can read and update> those portions of the table in a single disk I/O operation.A See the Oracle Rdb Guide to Database Design and Definition for+ more information regarding partitioning. 4 PARTITION_nameA Names the partition. The na me can be a delimited identifier ifD the dialect or quoting rules are set to SQL92 or SQL99. Partition= names must be unique within the storage map. If you do not? specify this clause, Oracle Rdb generates a default name for the partition. 4 PARTITIONING_IS_NOT_UPDATABLE= Specifies that the value of the partitioning key cannot beA modified and that the row is always stored in the storage areaD based on the partitioning criteria in the STORE USING clause. TheA p artitioning key is the column or list of columns specified in the STORE USING clause.D Specifying the PARTITIONING IS NOT UPDATABLE clause allows OracleA Rdb to quickly retrieve data because the partitioning criteria) can be used when optimizing the query.B To update columns that are partitioning keys in a NOT UPDATABLEC storage map, you must delete the rows and then reinsert the rows: to ensure that they are placed in the correct location.D If you specify the PARTITIONING clause, you must also specify the2 STORE USING clause when defining a storage map.@ If the PARTITIONING clause is not specified, UPDATABLE is the default.A See the Oracle Rdb Guide to Database Design and Definition for+ more information regarding partitioning. 4 PARTITIONING_IS_UPDATABLE; Specifies that the partitioning key can be modified. TheA partitioning key is the column or list of columns specified in the STORE USING clause.B If you modify  a row in an UPDATABLE storage map, the row is notA moved to a different storage area even if the new value of the@ partitioning key is not within the limits of original storage@ area. As a result, Oracle Rdb must consider all storage areas= specified in the STORE USING clause when retrieving a row.D If you specify the PARTITIONING clause, you must also specify the2 STORE USING clause when defining a storage map.@ If the PARTITIONING clause is not specified, UPDATABLE is the default.A See the Oracle Rdb Guide to Database Design and Definition for+ more information regarding partitioning. 4 PLACEMENT_VIA_INDEX> Directs the database system to store a column in a way thatD optimizes access to that column by the indicated path. Oracle RdbC chooses a target page for any columns being stored by rules that@ take into account the type of index named (sorted or hashed),A the type of storage areas involved (uniform or mixed), and how4 i ndexes and tables are assigned to storage areas.@ For a hashed index, Oracle Rdb calculates the page containingC the hashed index node that points to the column. If that page isC within the same storage area in which the column will be stored,@ it is used as the target page for storing the column. If that? page is not within the same storage area in which the column@ is to be stored, Oracle Rdb chooses a target page in the sameD relative position within the appropriate storage area (if it is aC mixed storage area) or a page in a clump reserved for that table% (if it is a uniform storage area).D For a sorted index, Oracle Rdb finds the database key of the nextA lowest row to the one being stored and uses the page number in' the database key as the target page. 4 STORAGE_MAP@ Specifies the name of the storage map you want to create. TheC name cannot be the same as any other definition in the database. 4 store-clauseC The s torage map definition. The store-clause in a CREATE STORAGEC MAP statement lets you specify which storage area files are used to store rows from the table.A o All rows of a table can be associated with a single storage area.? o Rows of a table can be randomly distributed among several storage areas.; o Rows of a table can be systematically distributed, orB partitioned, among several storage areas by specifying upper? limits on the values for a column in a particular storage3 area. This is called horizontal partitioning.@ o Columns of a table can be partitioned among storage areas.+ This is called vertical partitioning.B If you omit the storage map definition, the default is to store@ all the rows for a table in the default storage area. See the? CREATE and IMPORT DATABASE statements for information on the default storage area. 4 STORE_COLUMNS Syntax option: STORE COLUMNS (column-name)@ Lists the columns which will be stored in the subsequent map.? Multiple STORE COLUMNS clauses may appear in a map to spread? across multiple storage areas. A column name may only appearB in one STORE COLUMNS clause. A final STORE clause can appear to< provide a location for all remaining unspecified columns. 4 STORE_IN_area_name@ Associates the table directly with a single storage area. All8 rows in the table are stored in the area you specify. 4 STORE_L ISTS_INB Directs the database system to store the lists from tables in aC specified storage area or in a set of areas. You can create only2 one storage map for lists within each database.C You must specify the default storage area for lists in the STOREB LISTS clause. The default list storage area contains lists from? system tables as well as lists not directed elsewhere by theD STORE LISTS clause. You can also use the LIST STORAGE AREA clause@ of the CREATE DATABASE st atement to specify a default storageB area for lists. If you do not use the STORE LISTS clause and doD not specify a list storage area in the CREATE DATABASE statement,? Oracle Rdb uses the default storage area as the default listB storage area. The following example directs Oracle Rdb to placeD all lists in the LISTS storage area unless otherwise specified in a storage map:- SQL> CREATE DATABASE FILENAME mf_personnel" SQL> LIST STORAGE AREA IS LISTS" SQL> CREATE STORA GE AREA LISTS;? The accompanying storage map statement must also specify the2 LISTS storage area as the default storage area.$ SQL> CREATE STORAGE MAP LISTS_MAP5 cont> STORE LISTS IN LISTS1 FOR (EMPLOYEES.RESUME) cont> IN LISTS;D You can use an area set to specify that data is to be distributed@ across several areas. The following example shows how you canA store data in three storage areas (LISTS1, LISTS2, and LISTS3)@ for two different columns in TABLE1. The default list storage area is LISTS1. CREATE STORAGE MAP LISTS_MAPM STORE LISTS IN (LISTS1,LISTS2,LISTS3) FOR (TABLE1.COL1,TABLE1.COL2) IN LISTS1;B You can store lists from different tables in the same area. The> following example shows how you can store data from TABLE1,A TABLE2, and TABLE3 in the LISTS storage area. The default list storage area is RDB$SYSTEM.N SQL> CREATE STORAGE MAP LISTS_MAP -- to direct the list data to area LISTS;  cont> STORE LISTS IN LISTS FOR (TABLE1, TABLE2, TABLE3) cont> IN RDB$SYSTEM;? Alternatively, you can store lists from each table in uniqueA areas. The following example shows list data from TABLE1 beingD stored in the LISTS1 storage area and list data from TABLE2 beingC stored in the LISTS2 storage area. The default list storage area is RDB$SYSTEM. CREATE STORAGE MAP LISTS_MAP+ STORE LISTS IN LIST1 FOR (TABLE1)+ IN LIST2 FOR (TABLE2)$ IN RDB$SYSTEM;B You can also specify that different columns from the same tableA go into different areas. The following example shows data from? different columns in TABLE1 being stored in either LISTS1 or7 LISTS2. The default list storage area is RDB$SYSTEM. CREATE STORAGE MAP LISTS_MAP1 STORE LISTS IN LISTS1 FOR (TABLE1.COL1)1 IN LISTS2 FOR (TABLE1.COL2)$ IN RDB$SYSTEM; 4 STORE_RANDOMLY_ACROSS Syntax option:$ STORE RANDOMLY ACROSS (area-name)C As rows are inserted in the table, they are distributed randomly? across the storage areas named in the list. You must name at* least two storage areas in this clause. 4 STORE_USING Syntax option:) STORE USING (column-name) IN area-nameC The database system compares values in the columns to the values= in the WITH LIMIT OF clause to determine placement of rowsC inserted into the table. See the Oracle Rdb SQL Reference Manual for further information.C Use RMU EXTRACT to have the store using expression expanded. See Example 9. 4 STORED_NAME@ Specifies a name that Oracle Rdb uses to access a storage map@ created in a multischema database. The stored name allows youA to access multischema definitions using interfaces that do notC recognize multiple schemas in one database. You cannot specify aB stored name for a storage map in a database t hat does not allowB multiple schemas. For more information on stored names, see the" User_Supplied_Names HELP topic. 4 THRESHOLD_clauseD Specifies one, two, or three default threshold values for logicalB areas in storage areas with uniform format pages. The thresholdC values (val1, val2, and val3) represent a fullness percentage on@ a data page and establish three possible ranges of guaranteed= free space on the data pages. When a data page reaches the@ percentage defined by a given threshold value, the space areaB management (SPAM) entry for the data page is updated to reflect< the new fullness percentage and its remaining free space.? Oracle Rdb never stores a record at the third threshold. TheA value you set for the highest threshold can be used to reserve. space on the page for future record growth.A When only val1 is specified, this is equivalent to (val1, 100,@ 100). When val1 and val2 are specified, this is equivalent toB ( val1, val2, 100). The trailing, unspecified thresholds defaultC to 100 percent. For example, THRESHOLDS ARE (40) would appear as (40, 100, 100).> If no thresholds are specified for the area, the default isB (0,0,0). This causes the SPAM algorithm to set thresholds basedB on the nominal record length for the logical area; for example,D the node size for the index or the uncompressed length of the row for a table.B You cannot specify the thresholds for the storage map att ribute@ for any area that is a mixed page format. If you have a mixedA page format, set the thresholds for the storage area using the> ADD STORAGE AREA or CREATE STORAGE AREA clause of the ALTER3 DATABASE, CREATE DATABASE, or IMPORT statements. 4 VERTICAL_PARTITION_name: Names a vertical partition. The name can be a delimitedA identifier if the dialect or quoting rules are set to SQL92 orC SQL99. Partition names must be unique within the storage map. IfA you do not specify this clause, Oracle Rdb generates a default name for the partition. 4 using-clause8 Specifies columns whose values are used as limits for> partitioning the table horizontally across multiple storage areas. 4 WITH_LIMIT_OFC Specifies the maximum values that the columns named in the USINGB clause can have when rows are initially stored in the specifiedD storage area. Repeat this clause to partition the rows of a table among multiple storage ar eas.B The number of literals listed must be the same as the number ofB columns in the USING clause. The data type of the literals mustA agree with the data type of the column. For character columns,2 enclose the literals in single quotation marks.B The values in the WITH LIMIT OF clause only affect placement ofC rows when they are initially stored. If UPDATE statements changeD data in a row so that values in columns named in the USING clauseB exceed values specified in th e WITH LIMIT OF clause, the row is+ not moved into a different storage area. 3 Examples< Example 1: Defining storage maps for a multifile databaseD This example shows the definition of storage maps for a multifileB database. The tables named in the CREATE STORAGE MAP statements= have the same definitions as those in the sample database.@ See the CREATE STORAGE_AREA clause for an example of a CREATEB DATABASE statement with CREATE STORAGE AREA clauses that create1 the storage areas referred to in this example./ SQL> -- Declare the database as the default:, SQL> ATTACH 'FILENAME multifile_example'; SQL> --5 SQL> CREATE STORAGE MAP EMPLOYEE_MAP FOR EMPLOYEES" cont> STORE USING (EMPLOYEE_ID)/ cont> IN EMPID_LOW WITH LIMIT OF ('00200')/ cont> IN EMPID_MID WITH LIMIT OF ('00500')# cont> OTHERWISE IN EMPID_OVER; SQL> --% SQL> CREATE STORAGE MAP RESUME_MAP= cont> STORE LISTS IN EMP_INFO FOR (TABLE1, TABLE2, TABLE3)  cont> IN RDB$SYSTEM; SQL> --: SQL> CREATE STORAGE MAP JOB_HISTORY_MAP FOR JOB_HISTORY cont> STORE IN HISTORIES; SQL> --@ SQL> CREATE STORAGE MAP SALARY_HISTORY_MAP FOR SALARY_HISTORY cont> STORE IN HISTORIES; SQL> --, SQL> CREATE STORAGE MAP JOBS_MAP FOR JOBS cont> STORE IN CODES; SQL> --: SQL> CREATE STORAGE MAP DEPARTMENTS_MAP FOR DEPARTMENTS cont> STORE IN CODES; SQL> --4 SQL> CREATE STORAGE MAP COLLEGES_MAP FOR COLLEGES cont> STORE IN CODES; SQL> --2 SQL> CREATE STORAGE MAP DEGREES_MAP FOR DEGREES cont> STORE IN EMP_INFO; SQL> --: SQL> CREATE STORAGE MAP WORK_STATUS_MAP FOR WORK_STATUS cont> STORE IN HISTORIES; SQL> -- SQL> -- SQL> -COMMIT; SQL> -- ; Example 2: Defining storage maps that place and override& thresholds on uniform storage areas) SQL> CREATE DATABASE FILENAME birdlist& cont> CREATE STORAGE AREA AREA1& cont> CREATE STORAGE AREA AREA2& cont> C REATE STORAGE AREA AREA3& cont> CREATE STORAGE AREA AREA4! cont> CREATE TABLE SPECIES* cont> ( GENUS CHAR (30),* cont> SPECIES CHAR (30),* cont> COMMON_NAME CHAR (40),( cont> FAMILY_NUMBER INT (3),' cont> SPECIES_NUMBER INT (3) cont> )7 cont> CREATE INDEX I1 ON SPECIES (FAMILY_NUMBER)" cont> CREATE TABLE SIGHTING( cont> ( SPECIES_NUMBER INT (3),* cont> COMMON_NAME CH AR (40),* cont> CITY CHAR (20),* cont> STATE CHAR (20),* cont> SIGHTING_DATE DATE ANSI,( cont> NOTES_NUMBER INT (5))9 cont> CREATE INDEX I2 ON SIGHTING (SPECIES_NUMBER)% cont> CREATE TABLE FIELD_NOTES* cont> ( WEATHER CHAR (30),* cont> TIDE CHAR (15),( cont> SPECIES_NUMBER INT (3),- cont> SIGHTING_TIME TIMESTAMP(2),+ cont> NOTES CHAR (500), ( cont> NOTES_NUMBER INT (5)): cont> CREATE INDEX I3 ON FIELD_NOTES (NOTES_NUMBER) cont> ; SQL> --@ SQL> -- The following CREATE STORAGE MAP statements place and7 SQL> -- override thresholds on uniform storage area. SQL> --9 SQL> -- Note that the default threshold clause for the? SQL> -- storage map is not enclosed in parentheses, but eachA SQL> -- threshold clause associated with a particular area is. SQL> --) SQL> CREATE STORAGE MAP M1 FOR SPECIES( cont> THRESHOLDS ARE (30, 50, 80) cont> ENABLE COMPRESSION# cont> PLACEMENT VIA INDEX I1 cont> STORE cont> IN AREA1' cont> (THRESHOLD (10) ); SQL> --* SQL> CREATE STORAGE MAP M2 FOR SIGHTING cont> THRESHOLD IS (40) cont> STORE cont> RANDOMLY ACROSS (* cont> AREA1 (THRESHOLD OF (10) ),4 cont> AREA2 (THRESHOLDS ARE (30, 50, 98) ), cont> AREA3 cont> ); SQL> --- SQL> CR EATE STORAGE MAP M3 FOR FIELD_NOTES# cont> THRESHOLDS OF (50,70,90) cont> STORE3 cont> USING (SPECIES_NUMBER, NOTES_NUMBER) cont> IN AREA14 cont> (THRESHOLDS OF (20, 80, 90) )- cont> WITH LIMIT OF (30, 88) cont> IN AREA2- cont> WITH LIMIT OF (40, 89) cont> IN AREA3- cont> WITH LIMIT OF (50, 90)% cont> OTHERWISE IN AREA45 cont> (THRESHOLDS ARE (20, 30, 40)); SQL> -- SQL> SHOW STORAGE MAP *;7 User Storage Maps in database with filename birdlist M1 For Table: SPECIES Placement Via Index: I1 Partitioning is: UPDATABLE Store clause: STORE IN AREA1 (THRESHOLD (10) )* Partition information for storage map: Compression is: ENABLED Partition: (1) SYS_P00062 Storage Area: AREA1 M2 For Table: SIGHTING Partitioning is: UPDATABLE Store clause: STORE RANDOMLY ACROSS ($ AREA1 (THRESHOLD OF (10) ),. AREA2 (THRESHOLDS ARE (30, 50, 98) ), AREA3 )* Partition information for storage map: Compression is: ENABLED Partition: (1) SYS_P00063 Storage Area: AREA1 Partition: (2) SYS_P00064 Storage Area: AREA2 Partition: (3) SYS_P00065 Storage Area: AREA3 M3 For Table: FIELD_NOTES Partitioning is: UPDATABLE  Store clause: STORE- USING (SPECIES_NUMBER, NOTES_NUMBER) IN AREA1. (THRESHOLDS OF (20, 80, 90) )' WITH LIMIT OF (30, 88) IN AREA2' WITH LIMIT OF (40, 89) IN AREA3' WITH LIMIT OF (50, 90) OTHERWISE IN AREA4. (THRESHOLDS ARE (20, 30, 40))* Partition information for storage map: Compression is: ENABLED Partition: (1) SYS_P00066 Storage Area: AREA1 Partition: (2) SYS_P00067 Storage Area: AREA2 Partition: (3) SYS_P00068 Storage Area: AREA3 Partition: (4) SYS_P00069 Storage Area: AREA4 SQL> -- SQL> ROLLBACK;6 Example 3: Creating a storage map that stores listsC This example creates a storage map that stores lists on specific storage areas.% SQL> CREATE DATABASE FILENAME test8 cont> CREATE STORAGE AREA LISTS1 PAGE FORMAT IS MIXED8 cont> CREATE STORAGE AREA LISTS2 PAGE FORMAT IS MIXED cont> cont> CREATE TABLE EMPLOYEES cont> (EMP_ID CHAR(5),* cont> RESUME LIST OF BYTE VARYING); SQL> --% SQL> CREATE STORAGE MAP LISTS_MAP cont> STORE LISTS IN3 cont> (LISTS1,LISTS2) FOR (EMPLOYEES.RESUME) cont> FILL SEQUENTIALLY cont> IN RDB$SYSTEM;' Example 4: Creating an alternate mapD This example following storage map shows an alternate mapping for9 the EMPLOYEES table in the same MF_PERSONNEL database.( SQL> create storage map EMPLOYEES_MAP cont> for EMPLOYEES/ cont> placement via index EMPLOYEES_HASHF cont> -- store the primary information horizontally partitionedG cont> -- across the areas EMPIDS_LOW, EMPIDS_MID and EMPIDS_OVERI cont> -- disable compress because these columns are accessed often cont> store1 cont> columns (EMPLOYEE_ID, LAST_NAME,6 cont> FIRST_NAME, MIDDLE_INITIAL)$  cont> disable compression$ cont> using (EMPLOYEE_ID)" cont> in EMPIDS_LOW0 cont> with limit of ('00200')" cont> in EMPIDS_MID0 cont> with limit of ('00400')- cont> otherwise in EMPIDS_OVER cont>= cont> -- place all the address information in EMP_INFO@ cont> -- make sure these character columns are compressed- cont> -- to remove the trailing spaces cont> storeF  cont> columns (ADDRESS_DATA_1, ADDRESS_DATA_2, CITY, STATE,& cont> POSTAL_CODE)# cont> enable compression cont> in EMP_INFO cont>) cont> -- the remaining columns get1 cont> -- written randomly over these areas cont> store# cont> enable compression8 cont> randomly across (SALARY_HISTORY, JOBS); B Example 5: Disabling logging and naming horizontal and vertical partitions) SQL> CREATE DATABASE FILENAME birdlist& cont> CREATE STORAGE AREA AREA1& cont> CREATE STORAGE AREA AREA2& cont> CREATE STORAGE AREA AREA3& cont> CREATE STORAGE AREA AREA4& cont> CREATE STORAGE AREA AREA5& cont> CREATE STORAGE AREA AREA6& cont> CREATE STORAGE AREA AREA7& cont> CREATE STORAGE AREA AREA8! cont> CREATE TABLE SPECIES& cont> ( GENUS CHAR (30),& cont> SPECIES CHAR (30),& cont> COMMON_NAME CHAR (40),$ cont> FAMILY_NUMBER INT (3),# cont> SPECIES_NUMBER INT (3) cont> )7 cont> CREATE INDEX I1 ON SPECIES (FAMILY_NUMBER)" cont> CREATE TABLE SIGHTING$ cont> ( SPECIES_NUMBER INT (3),& cont> COMMON_NAME CHAR (40), cont> CITY CHAR (20), cont> STATE CHAR (20),& cont> SIGHTING_DATE DATE ANSI," cont> NOTES_NUMBER INT (5))9 cont> CREATE INDEX I2 ON SIGHTING (SPECIES_NUMBER)% cont> CREATE TABLE FIELD_NOTES c ont> ( WEATHER CHAR (30), cont> TIDE CHAR (15),( cont> SIGHTING_TIME TIMESTAMP(2), cont> NOTES CHAR (500)," cont> NOTES_NUMBER INT (5),$ cont> SPECIES_NUMBER INT (3)); cont> CREATE INDEX I3 ON FIELD_NOTES (NOTES_NUMBER); SQL> --9 SQL> -- Note that the default threshold clause for the? SQL> -- storage map is not enclosed in parentheses, but eachI SQL> -- threshold clause associated with a particular area is enclosed SQL> -- in parentheses. SQL> --) SQL> CREATE STORAGE MAP M1 FOR SPECIES( cont> THRESHOLDS ARE (30, 50, 80) cont> ENABLE COMPRESSION# cont> PLACEMENT VIA INDEX I1 cont> NOLOGGING1 cont> COMMENT IS 'Storage Map for Species' cont> STORE cont> IN AREA1 cont> (THRESHOLD (10), cont> PARTITION AREA1,1 cont> COMMENT IS 'Partition is AREA1'); SQL> --* SQL> CREATE STORAGE MAP M2 FOR SIGHTING cont> THRESHOLD IS (40) cont> STORE cont> RANDOMLY ACROSS (( cont> AREA1 (THRESHOLD OF (10), cont> PARTITION AREA1),2 cont> AREA2 (THRESHOLDS ARE (30, 50, 98), cont> PARTITION AREA2),& cont> AREA3 (PARTITION AREA3) cont> ); SQL> --- SQL> CREATE STORAGE MAP M3 FOR FIELD_NOTES# cont> THRESHOLDS OF (50,70,90)9 cont> STORE COLUMNS (WEATHER, TIDE, SIGHTING_TIME)9 cont> VERTICAL PARTITION WEATHER_TIDE_SIGHTINGTIME/ cont> USING (SPECIES_ NUMBER, NOTES_NUMBER) cont> IN AREA10 cont> (THRESHOLDS OF (20, 80, 90) )) cont> WITH LIMIT OF (30, 88) cont> IN AREA2) cont> WITH LIMIT OF (40, 89) cont> IN AREA3) cont> WITH LIMIT OF (50, 90)! cont> OTHERWISE IN AREA40 cont> (THRESHOLDS ARE (20, 30, 40))> cont> STORE COLUMNS (NOTES, NOTES_NUMBER, SPECIES_NUMBER)8 cont> VERTICAL PARTITION NOTES_NOTESNUM_SPECIESNUM" cont> USING (SPECIES_NUMBER) cont> IN AREA50 cont> (THRESHOLDS OF (20, 80, 90) )% cont> WITH LIMIT OF (30) cont> IN AREA6% cont> WITH LIMIT OF (40) cont> IN AREA7% cont> WITH LIMIT OF (50)! cont> OTHERWISE IN AREA81 cont> (THRESHOLDS ARE (20, 30, 40)); @ Example 6: Creating a storage map for a table containing dataD SQL> -- Create table, insert data, and then create a storage map. S QL> --7 SQL> CREATE TABLE MAP_TEST2 (a INTEGER, b CHAR(10));: SQL> INSERT INTO MAP_TEST2 (a, b) VALUES (2, 'Second'); 1 row inserted6 SQL> CREATE STORAGE MAP MAP_TEST2_MAP FOR MAP_TEST2! cont> STORE IN RDB$SYSTEM;< SQL> INSERT INTO MAP_TEST2 (a, b) VALUES (22, 'Second2'); 1 row inserted SQL> COMMIT;& SQL> SELECT *,DBKEY FROM MAP_TEST2;5 A B DBKEY5 2 Second 90:809:05 22  Second2 90:809:1 2 rows selected SQL>( SQL> -- Now alter the storage map and0 SQL> -- place it in a different storage area. SQL>' SQL> ALTER STORAGE MAP MAP_TEST2_MAP! cont> STORE IN TEST_AREA2; SQL> COMMIT;& SQL> SELECT *,DBKEY FROM MAP_TEST2;5 A B DBKEY5 2 Second 91:11:05 22 Second2 91:11:1 2 rows selected SQL> 6 Example 7: Invalid attempts to create a storage map. SQL> -- Create table, insert data, and then8 SQL> -- create a storage map with invalid attributes. SQL>7 SQL> CREATE TABLE MAP_TEST3 (a INTEGER, b CHAR(10));6 SQL> CREATE INDEX MAP_TEST3_INDEX ON MAP_TEST3 (a);9 SQL> INSERT INTO MAP_TEST3 (a, b) VALUES (3, 'Third'); 1 row inserted SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP FOR MAP_TEST3I cont> STORE IN TEST_AREA1; -- Must be the default ar ea.0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E-NOCMPLXMAP, can not use complex map for non-empty table SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP for MAP_TEST3J cont> PLACEMENT VIA INDEX MAP_TEST3_INDEX -- Can't use placement.! cont> STORE IN RDB$SYSTEM;0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E-NOCMPLXMAP, can not use com plex map for non-empty table SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP FOR MAP_TEST3K cont> DISABLE COMPRESSION -- Can't change compression.! cont> STORE IN RDB$SYSTEM;0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E-NOCMPLXMAP, can not use complex map for non-empty table SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP for MAP_TEST3K cont> THRESHOLDS ARE (50, 60, 70) -- Can 't change thresholds.! cont> STORE IN RDB$SYSTEM;0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E-NOCMPLXMAP, can not use complex map for non-empty table SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP FOR MAP_TEST3S cont> STORE ACROSS (RDB$SYSTEM, TEST_AREA2);-- Can't use more than one area.0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E -NOCMPLXMAP, can not use complex map for non-empty table SQL>6 SQL> CREATE STORAGE MAP MAP_TEST3_MAP for MAP_TEST3Q cont> STORE COLUMNS (a) in RDB$SYSTEM -- Can't vertically partition.- cont> STORE COLUMNS (b) in TEST_AREA2;0 %RDB-E-NO_META_UPDATE, metadata update failed8 -RDMS-F-RELNOTEMPTY, table "MAP_TEST3" has data in itB -RDMS-E-NOCMPLXMAP, can not use complex map for non-empty table D Example 8: Using the RMU Extract command to display WITH LIMIT OF  expressions> The WITH LIMIT OF clauses of the STORE clause are converted? to Boolean expressions that are used by Oracle Rdb to directA inserted data to the correct storage area. You can use the RMU@ Extract command to display these Boolean expressions. Use the> Item=STORAGE_MAP and Option=FULL qualifiers as shown in the following example. $ RMU/EXTRACT- _$ /ITEM=STORAGE_MAP-B _$ /OPTION=(MATCH:EMPLOYEES_MAP%,NOHEADER,FULL,FILENAME_ONLY) - _$ DB$:MF_PERSONNEL set verify; set language ENGLISH;# set default date format 'SQL92'; set quoting rules 'SQL92';& set date format DATE 001, TIME 001;& attach 'filename MF_PERSONNEL.RDB';# create storage map EMPLOYEES_MAP for EMPLOYEES comment is4 ' employees partitioned by "00200" "00400"') placement via index EMPLOYEES_HASH store using (EMPLOYEE_ID) -- Partition:- -- (EMPLOYEE_ID <= '00200')  in EMPIDS_LOW* with limit of ('00200') -- Partition:- -- (EMPLOYEE_ID <= '00400') in EMPIDS_MID* with limit of ('00400')( otherwise in EMPIDS_OVER; commit work;! Example 9: SQL Mapping RoutineC This example shows the SQL mapping routine created by the CREATEB STORAGE MAP statement that matches the WITH LIMIT OF clause for the storage map. SQL> create table EMPLOYEES  (' cont> EMPLOYEE_ID CHAR (5),( cont> LAST_NAME CHAR (14),( cont> FIRST_NAME CHAR (10),' cont> MIDDLE_INITIAL CHAR (1),( cont> ADDRESS_DATA_1 CHAR (25),( cont> ADDRESS_DATA_2 CHAR (25),( cont> CITY CHAR (20),' cont> STATE CHAR (2),' cont> POSTAL_CODE CHAR (5),' cont> SEX CHAR (1),' cont> BIRTHDAY DATE VMS,( cont> STATUS_CODE CHAR (1)); SQL>, SQL> create storage map EMPLOYEES_MAP cont> for EMPLOYEES cont> comment is> cont> ' employees partitioned by "00200" "00400"' cont> store( cont> using (EMPLOYEE_ID)& cont> in EMPIDS_LOW4 cont> with limit of ('00200')& cont> in EMPIDS_MID4 cont> with limit of ('00400')2 cont> otherwise in EMPIDS_OVER; SQL> SQL> commit work; SQL> SQL> show system modules;1 Modules in database with filename MF_PERSONNEL RDB$STORAGE_MAPS SQL> SQL> show system functions;3 Functions in database with filename MF_PERSONNEL EMPLOYEES_MAP SQL>+ SQL> show system function EMPLOYEES_MAP;) Information for function EMPLOYEES_MAP Function ID is: -2 Source: return case0 when (:EMPLOYEE_ID <= '00200') then 10 when (:EMPLOYEE_ID <= '00 400') then 2 else 3 end case;C Comment: Return value for select partition - range 1 .. 3$ Module name is: RDB$STORAGE_MAPS Module ID is: -1 Number of parameters is: 1B Parameter Name Data Type Domain or TypeB -------------- --------- --------------* INTEGER# Function result datatype* Return value is passed by value* EMPLOYEE_ID  CHAR(5)" Parameter position is 1! Parameter is IN (read)+ Parameter is passed by referenceB Example 10: Using Storage Area Attributes in a LIST Storage MapD The following example shows the use of storage area attributes inC a LIST storage map. The storage area attributes must immediately; follow the storage area name (as in table storage maps). SQL> create database& cont> filename 'DB$:MULTIMEDIA' cont>, cont> creat e storage area PHOTO_AREA1+ cont> filename 'DB$:PHOTO_AREA1'$ cont> page format UNIFORM cont>, cont> create storage area PHOTO_AREA2+ cont> filename 'DB$:PHOTO_AREA2'$ cont> page format UNIFORM cont>* cont> create storage area TEXT_AREA) cont> filename 'DB$:TEXT_AREA'$ cont> page format UNIFORM cont>+ cont> create storage area AUDIO_AREA* cont> filename 'DB$:AUDIO_AREA'$ cont> p age format UNIFORM cont>* cont> create storage area DATA_AREA) cont> filename 'DB$:DATA_AREA'$ cont> page format UNIFORM cont> ; SQL> SQL> create table EMPLOYEES" cont> (name char(30), cont> dob date,! cont> ident integer,? cont> photograph list of byte varying (4096) as binary,< cont> resume list of byte varying (132) as text,; cont> review list of byte varying (80) as text,>  cont> voiceprint list of byte varying (4096) as binary cont> ); SQL>( SQL> create storage map EMPLOYEES_MAP cont> for EMPLOYEES cont> enable compression cont> store in DATA_AREA; SQL>$ SQL> create storage map LISTS_MAP cont> store lists cont> in AUDIO_AREA6 cont> (thresholds are (89, 99, 100)6 cont> ,comment is 'The voice clips'0 cont> ,partition AUDIO_STUFF)/ cont>  for (employees.voiceprint) cont> in TEXT_AREA, cont> (thresholds is (99)3 cont> ,partition TEXT_DOCUMENTS)= cont> for (employees.resume, employees.review) cont> in (PHOTO_AREA1; cont> (comment is 'Happy Smiling Faces?'+ cont> ,threshold is (99): cont> ,partition PHOTOGRAPHIC_IMAGES_1)! cont> ,PHOTO_AREA2; cont> (commen t is 'Happy Smiling Faces?'+ cont> ,threshold is (99): cont> ,partition PHOTOGRAPHIC_IMAGES_2) cont> )/ cont> for (employees.photograph)" cont> fill randomly cont> in RDB$SYSTEM: cont> (partition SYSTEM_LARGE_OBJECTS); SQL># SQL> show storage map LISTS_MAP; LISTS_MAP For Lists& Store clause: STORE lists in AUDIO_AREA0  (thresholds are (89, 99, 100)0 ,comment is 'The voice clips'* ,partition AUDIO_STUFF)) for (employees.voiceprint) in TEXT_AREA& (thresholds is (99)- ,partition TEXT_DOCUMENTS)7 for (employees.resume, employees.review) in (PHOTO_AREA15 (comment is 'Happy Smiling Faces?'% ,threshold is (99)4 ,partition PHOTOGRAPH IC_IMAGES_1) ,PHOTO_AREA25 (comment is 'Happy Smiling Faces?'% ,threshold is (99)4 ,partition PHOTOGRAPHIC_IMAGES_2) )) for (employees.photograph) fill randomly in RDB$SYSTEM3 (partition SYSTEM_LARGE_OBJECTS)( Partition information for lists map: Vertical Partition: VRP_P000 Partition: (1) AUDIO_STUFF Fill Randomly  Storage Area: AUDIO_AREA( Thresholds are (89, 99, 100)" Comment: The voice clips" Partition: (2) TEXT_DOCUMENTS Fill Randomly Storage Area: TEXT_AREA) Thresholds are (99, 100, 100)) Partition: (3) PHOTOGRAPHIC_IMAGES_1 Fill Randomly Storage Area: PHOTO_AREA1) Thresholds are (99, 100, 100)' Comment: Happy Smiling Faces?) Partition: (3) PHOTOGRAPHIC_IMAGES_2 Storage Area: PHOTO_AREA2)  Thresholds are (99, 100, 100)' Comment: Happy Smiling Faces?( Partition: (4) SYSTEM_LARGE_OBJECTS Fill Randomly Storage Area: RDB$SYSTEM SQL> SQL> commit; 2 SYNONYM@ Creates an alternate name or synonym for an existing databaseC object. The object may be a domain, function, module, procedure,- sequence, another synonym, table, or view.= Once defined, the synonym can be used in any query or dataC definition language statement in place of the referenced object.B However, the SHOW commands do not accept synonyms. Use the SHOW; SYNONYM statement to determine if the name is a synonym. 3 Environment, You can use the CREATE SYNONYM statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format, CREATE -+-------------- -+-+-----------+---+, +-> OR REPLACE -+ +-> PUBLIC -+ |, +------------------ <--------------------+6 +-> SYNONYM FOR -+----------------+-+6 +-> object-type -+ |6 +---------------------- <--------------------------+B +-> -+-----------------------------------------+->@ +-> COMMENT IS -+-> ' ' -++? +--------- / <-----------+ object-type =   -+-> DOMAIN ----+-> +-> FUNCTION --+ +-> MODULE ----+ +-> PROCEDURE -+ +-> SEQUENCE --+ +-> SYNONYM ---+ +-> TABLE -----+ +-> VIEW ------+ 3 Arguments 4 COMMENT_IS_'quoted-string'C This optional clause can be used to add several lines of comment> to the synonym object. The comment is displayed by the SHOW SYNONYM statement. 4 FOR_object-name; The name of the database object for which the synonym isC required. This name must exis t for an object in the database. IfC the optional object type is omitted, then Oracle Rdb will search- the database for an object with this name. 4 object-type Syntax options: DOMAIN FUNCTION MODULE PROCEDURE SEQUENCE SYNONYM TABLE VIEW> These optional object types can be used when the referenced? object name is not unique within the database. For instance,B Oracle Rdb allows a domain and a table to both be called MONEY.C Therefore, to create a synonym for the table MONEY, you must use: the FOR TABLE clause so that it is uniquely identified. 4 OR_REPLACEB Instructs SQL to replace any synonym of this name if it exists.A If it does not exist, a new synonym is created. This shorthand> allows replacement of an existing synonym while maintainingB all the dependencies established by query and DDL usage of this synonym. 4 PUBLIC> This optional clause is provide  d for compatibility with the= Oracle database server. It is currently not used by Oracle? Rdb. Its presence or absence may be used by future releases.> Oracle Corporation recommends you use the PUBLIC keyword in applications. 4 synonym-name? The name of the synonym you want to create. The synonym name? must be unique within all domains, tables, views, functions,D procedures, modules, sequences, and synonyms within the database.$ You may qualify it with an alias.  3 Examples% Example 1: Using the Default Alias* SQL> CREATE SYNONYM emps FOR employees;5 Example 2: Using an Explicit Alias for the Synonym. SQL> CREATE SYNONYM db1.emps FOR employees;? Example 3: Using an Explicit Alias for the Referenced Object. SQL> CREATE SYNONYM emps FOR db1.employees;( Example 4: Using the Alias Explicitly2 SQL> CREATE SYNONYM db1.emps FOR db1.employees;" Example 5: Using the Table Type+ SQL> CREATE SYNONYM cash FOR  table moneyD cont> COMMENT IS 'use a different name to avoid confusion with') cont> / 'the domain MONEY';% Example 6: Using Multiple Synonyms, SQL> CREATE TABLE t_employees_0001 (...);6 SQL> CREATE SYNONYM employees FOR t_employees_0001;* SQL> CREATE SYNONYM emps FOR employees; 2 TABLEC Creates a temporary or persistent base table definition. A tableD definition consists of a list of definitions of columns that make up a row in the table.@  Persistent base tables are tables whose metadata and data are@ stored in the database beyond an SQL session. The data can be0 shared by all users attached to the database.B Temporary tables are tables whose data is automatically deletedB when an SQL session or module ends. The tables only materializeA when you refer to them in an SQL session and the data is local> to an SQL session. You can also specify whether the data is> preserved or deleted at the end of a transaction with in theD session; the default is to delete the data. The data in temporaryD tables is private to the user. There are three types of temporary tables: o Global temporary tables o Local temporary tables= o Declared local temporary tables (see the DECLARE LOCAL_1 TEMPORARY_TABLE for additional information)= The metadata for a global temporary table is stored in the> database and persists beyond the SQL session. Different SQL? sessions can share the same m  etadata. The data stored in theA table cannot be shared between SQL sessions. However, the dataB can be shared between modules in a single SQL session. The data* does not persist beyond an SQL session.< The metadata for a local temporary table is stored in the> database and persists beyond the SQL session. Different SQL? sessions can share the same metadata. The data stored in theC table cannot be shared between different modules in a single SQLD session or between SQL se  ssions. The data does not persist beyond an SQL session or module.B Because temporary tables are used only to hold the user's data,D which is not shared among users, no locks are needed and the data. can be modified in a read-only transaction.A See the Oracle Rdb Guide to Database Design and Definition for( more information on temporary tables.> Information tables are special read-only tables that can beB used to retrieve database attributes that are not stored in theC existing relational tables. Information tables allow interestingA database information, which is currently stored in an internal1 format, to be displayed as a relational table.D When you define a table, you can also define table constraints. AB constraint specifies a condition that restricts the values thatA can be stored in a table. Constraints can specify that columns contain: - Only certain values - Primary key values - Unique values - Valu es that cannot be null> There are several ways to specify a table definition in the CREATE TABLE statement:> o Directly by naming the table, its columns and associatedC data types, default values (optional), constraint definitions) (optional), and formatting clauses.> You can define constraints on persistent base tables and# global temporary tables only.A o Indirectly by providing a path name for a repository recordA definition that specifies th e table name, columns, and data types.D o Indirectly by providing another table as a model in inheriting6 the columns, datatypes and NOT NULL constraints.C SQL allows you to specify the default character data type or the< national character data type when defining table columns. 3 Environment* You can use the CREATE TABLE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format9 CREATE -+---------------------------+-> TABLE --------+9 +-> INFORMATION ------------+ |9 +-> GLOBAL -+-> TEMPORARY --+ |9 +-> LOCAL --+ |9 +---------------------- <------------------------------+E ++-> FROM -+-------------------+-----------------------+E | +-> ALIAS --+ |E +-> -+-------------------------------+-> table-body -+E +-> STORED NAME IS stored-name -+ |E +---------------------<------------------------------------------+) +-+--------------------------------+->' +-+--> create-table-attributes -++& +---------------<-------------+ create-table-attributes = 4 ---+-> COMMENT IS --+-> 'quoted-string' -+------+->2 | +-------- / ----- ----+ |2 +-> COMPRESSION IS -+-> ENABLED ---+---------+2 | +-> DISABLED --+ |2 +-> DISABLE --+-> cre-enable-disable --------+2 +-> ENABLE ---+ |2 +-> LOGGING ---------------------------------+2 +-> NOLOGGING -------------------------------+2 +-> ON COMMIT -+-> DELETE ----+-> ROWS ------+# +-> PRESERVE --+ table-body = C -+-> (column-constraint-list) --------------------------------- +->A | |A +-> LIKE --+------------------------------++@ +--> (column-constraint-list) -+  cre-enable-disable = . -+-> ALL CONSTRAINTS ---------------------+->, +-> CONSTRAINT --------+, +-> PRIMARY KEY -------------------------+, +-> UNIQUE ( -+- +-> ) ----+" +------- , <-----+  col-definition =  -->  --+ +---------------+; +---> column-type ---+--------------------------+-+--+; | +->DEFAULT value-expr | | |; | +->column-identity --------+ | |; +---> COMPUTED BY value-expr ---------------------+ |; +-------------------------<--------------------------+. +-+--------------------+----------------+. +-> col-constraint --+ |. +--------------------------<------------+@ ++- -----------------------+-----+-----------------------+->> +-> comment-is-clause --+ +-> sql-and-dtr-clause -+    column-constraint-list = ) --+--+-> col-definition -------+-----+->' | +-> table-constraint -----+ |' +---------------- , <--------------+ column-identity = G --> IDENTITY --+--------------------------------------------------+-->D +- ( --+----------------------+-> ) --+<  +-> , --+ column-type= 8 --+-> data-type -----------------------------------+-->5 +-> -------------------------------+5 +-> references-clause ---------------------------+5 +-> AUTOMATIC --+-----------+--> AS value-expr --+ +-> INSERT -+ +-> UPDATE -+ data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+--------- ! ------+A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+ |A +-> FLOAT ----------------+ |A +-> NUMBER -+----------------------------------+-------------+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE " VARYING --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT ---+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) + |A | +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION -------------------------- # --------------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+ |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+--------$ --+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ----% --+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac ----& ----------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+  col-constraint= ) ---+---------------------------------++) +-> CONSTRAINT -+|) +------------------------------------+% +-> PRIMARY KEY -----------------+% +-> UNIQUE ----------------------+% +-> NOT NULL --------------------+% +-> NULL ------------------------+% +-> CHECK (predicate) -----------+% +-> references-clause -----' ------+% +------------>-------------------+% +-------------<------------------+) +----+----------------------------+-->& +--> constraint-attributes --+ references-clause = & REFERENCES -+& +-----------------<----------------+1 +-+--------------------->-------------------+->/ +-> ( -+> +-> ) -+( +----------- , <------------+  sql-and-dtr-clause = A -+-> QUERY HEADER IS -+> +-------------------+->? | +------ / <--------+ |? +-> EDIT STRING IS -------------------------+? | |? +-> QUERY NAME FOR -+-> DTR --------+-> IS -+? | +-> DATATRIEVE -+ |? +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+* +-> DATATRIEVE -+ literal = --+-> num) eric-literal ----+---> +-> string-literal -----+ +-> date-time-literal --+ +-> interval-literal ---+ +-> dbkey-literal ------+ table-constraint = . ---+---------------->------------------+----+. +-> CONSTRAINT ---+ |. +------------------------------------------+. +--> table-constraint-clause --------------+. +------------------------------------------+1 +---+---------------------------+-------------># +-> constraint-attributes --+*  table-constraint-clause = 5 -+----------------------------------------------+-->2 +-> PRIMARY KEY -> ( -+-> -+> ) -+2 | +------- , <-------+ |2 +-> UNIQUE -> ( -+> +-> ) -------+2 | +------- , <-----+ |2 +-> CHECK (predicate) -------------------------+2 +-> FOREIGN KEY -> ( -+> +-> ) + |2 +------- , <-----+ | |2 +-----------------------<---------------+ ---+ |2 +-> references-clause ------------->---------+  constraint-attributes = B -+-> DEFERRABLE -------------+------------------------------+-+->@ | +-> INITIALLY +-> IMMEDIATE --++ |@ | +-> DEFERRED ---+ |@ +-> NOT DEFERRABLE ---------+-------------------------+------+@ | +-> INITIALLY IMMEDIATE --+ |@ +-> INITIALLY IMMEDIATE ----+-------------------+------------+@ | , +-> DEFERRABLE -----+ |@ | +-> NOT DEFERRABLE -+ |@ +-> INITIALLY DEFERRED -----+-------------------+------------+3 +-> DEFERRABLE -----+ 3 Arguments 4 ALIAS_aliasD Specifies a name for an attach to a particular database. SQL addsA the table definition to the database referred to by the alias.C If you do not specify an alias, SQL adds the table definition toC the- default database. See the User_Supplied_Names HELP topic for5 more information on default databases and aliases. 4 AUTOMATICSyntax options: AUTOMATIC AS value-expr$ AUTOMATIC INSERT AS value-expr$ AUTOMATIC UPDATE AS value-expr< These AUTOMATIC column clauses allow you to store specialD information when data is inserted into a row or a row is updated.? For example, you can log application-specific information toB audit activity or provide essen . tial values, such as time stamps& or unique identifiers for the data.C The assignment of values to these types of columns is managed byA Oracle Rdb. The AUTOMATIC INSERT clause can be used to provide@ a complex default for the column when the row is inserted; itA cannot be changed by an UPDATE statement. The AUTOMATIC UPDATEB clause can be used to provide an updated value during an UPDATEA statement. The unqualified AUTOMATIC clause specifies that theC value expression sh / ould be applied during both INSERT and UPDATEA statements. The column type is derived from the AS value-expr;C using CAST allows a specific data type to be specified. However,0 this is not required and is rarely necessary.= You can define an AUTOMATIC INSERT column to automaticallyC receive data during an insert operation. The data is stored likeC any other column, but the column is read-only. Because AUTOMATICB columns are treated as read-only columns, they cannot appear 0 in@ the column list for an insert operation nor be modified by anD update operation. AUTOMATIC UPDATE columns can have an associated< default value that will be used when the row is inserted. 4 char-data-typeA A valid SQL character data type. See the Data_Types HELP topic0 for more information on character data types. 4 character-set-name A valid character set name. 4 CHECK_predicate= Specifies a predicate that column values inserted into the@ 1 table must satisfy. See the Predicates HELP topic for details on specifying predicates.D Predicates in CHECK column constraints can refer directly only to- the column with which they are associated. 4 col-constraint? A constraint that applies to values stored in the associated column.@ SQL allows column constraints and table constraints. The fiveA types of column constraints are PRIMARY KEY, UNIQUE, NOT NULL,B CHECK, and FOREIGN KEY constraints. The FOREIGN2 KEY constraints* are created with the REFERENCES clause.C You can define a column constraint on persistent base tables and global temporary tables only. 4 col-definitionC The definition for a column in the table. SQL gives you two ways! to specify column definitions:C o By directly specifying a data type to associate with a column nameA o By naming a domain that indirectly specifies a data type to" associate with a column name@ Either wa3 y also allows options for specifying default values,. column constraints, and formatting clauses. 4 column-nameD The name of a column you want to create in the table. You need toD specify a column name whether you directly specify a data type inD the column definition or indirectly specify a data type by naming% a domain in the column definition. 4 COMPUTED_BYD Specifies that the value of this column is calculated from values- in other columns and constant exp4 ressions.C If your column definition refers to a column name within a valueC expression, that named column must already be defined within theD same CREATE TABLE statement. See the Value_Expressions HELP topic( for information on value expressions.? Any column that you refer to in the definition of a computedC column cannot be deleted from that table unless you first delete the computed column.9 SQL does not allow the following for computed columns: o UNIQUE5 constraints o REFERENCES clauses o PRIMARY KEY constraints o DEFAULT clause o IDENTITY clause" o Default value for DATATRIEVEC For example, if the FICA_RATE for an employee is 6.10 percent ofA the employee's starting salary and the group insurance rate isD 0.7 percent, you can define FICA_RATE and GROUP_RATE columns like this:# SQL> CREATE TABLE payroll_detail cont> (salary_code CHAR(1),& cont> starting_salary SMALLINT(2), cont> 6 fica_amt2 cont> COMPUTED BY (starting_salary * 0.061), cont> group_rate3 cont> COMPUTED BY (starting_salary * 0.007));? When you use this type of definition, you only have to storeB values in the salary_code and starting_salary columns. The FICAC and group insurance deduction columns are computed automatically8 when the columns fica_amt or group_rate are selected. 4 COMPRESSION_IS Syntax options:3 COMPRESSION IS ENABLED | COMPRESSION IS DISABLED 7 B Specifies whether run-length compression is enabled or disabled6 for rows inserted into the base or temporary table.A In some cases, the data inserted into a table may not compress? and so incur only overhead in the row. This overhead is used> by Rdb to describe the sequence of uncompressible data. Use= COMPRESSION IS DISABLED to prevent Rdb from attempting the compression of such data.D Any storage map which specifies the ENABLE COMPRESSION or DISABLE> COMPRESSION8 clause will override this setting in the table.= The COMPRESSION IS clause is not permitted for INFORMATION tables.) The default is COMPRESSION IS ENABLED. 4 constraint-attributesD Although the constraint attribute syntax provides 11 permutationsB as required by the SQL99 standard, they equate to the following three options:( o INITIALLY IMMEDIATE NOT DEFERRABLEA Specifies that evaluation of the constraint must take place? when the INSERT, DEL 9 ETE, or UPDATE statement executes. IfC you are using the SQL99, SQL92, MIA, ORACLE LEVEL1, or ORACLE* LEVEL2 dialect, this is the default.$ o INITIALLY IMMEDIATE DEFERRABLEA Specifies that evaluation of the constraint may be deferredD (using the SET CONSTRAINT ALL statement or the SET TRANSACTION> statement with the EVALUATING clause), but by default it@ is evaluated after the INSERT, DELETE, or UPDATE statement> executes. See the SET_ALL_CONSTRAINT : S statement for more information.# o INITIALLY DEFERRED DEFERRABLE@ Specifies that evaluation of the constraint can take placeB at any later time. Unless otherwise specified, evaluation ofB the constraint takes place as the COMMIT statement executes.? You can use the SET ALL CONSTRAINTS statement to have allC constraints evaluated earlier. See the description of the SET5 ALL CONSTRAINTS statement for more information.> If you are using the; default SQLV40 dialect, this is theC default constraint attribute. When using this dialect, OracleC Rdb displays a deprecated feature message for all constraints< defined without specification of one of the constraint attributes. 4 CONSTRAINTA Specifies a name for a column or table constraint. The name is" used for a variety of purposes:A o The RDB$INTEG_FAIL error message specifies the name when anB INSERT, UPDATE, or DELETE statement violat< es the constraint.@ o The ALTER TABLE table-name DROP CONSTRAINT constraint-name@ statement specifies the name to delete a table constraint.? o The SHOW TABLE statements display the names of column and table constraints.> o The EVALUATING clause of the SET TRANSACTION and DECLARE8 TRANSACTION statements specifies constraint names.B o The ENABLE and DISABLE clauses of the ALTER and CREATE TABLE* statements specify constraint names.@ o The ALTER CO= NSTRAINT statement specifies constraint names.# o The DROP CONSTRAINT statement@ The CONSTRAINT clause is optional. If you omit the constraint@ name, SQL creates a name. However, Oracle Rdb recommends that@ you always name column and table constraints. If you supply a@ constraint name with the CONSTRAINT clause, it must be uniqueB in the database or in the schema if you are using a multischema database. 4 data-type= A valid SQL data type. Specifying an explicit> data type toC associate with a column is an alternative to specifying a domainC name. See the Data_Types HELP topic for more information on data types. 4 date-time-data-types@ A data type that specifies a date, time, or interval. See theB Data_Types HELP topic for more information about date-time data types. 4 DEFAULT_value-exprD Provides a default value for a column if the row that is inserted, does not include a value for that column.9 You c ? an use any value expression including subqueries,@ conditional, character, date/time, and numeric expressions asC default values. See Value Expressions for more information about value expressions.D For more information about NULL, see the NULL_Keyword HELP topic.? The value expressions described in Value Expressions include@ DBKEY and aggregate functions. However, the DEFAULT clause is? not a valid location for referencing a DBKEY or an aggregate> function. If you at@ tempt to reference either, you receive a compile-time error.? If you do not specify a default value, a column inherits theA default value from the domain. If you do not specify a defaultA value for either the column or domain, SQL assigns NULL as the default value. 4 domain-nameA The name of a domain created in a CREATE DOMAIN statement. SQLC gives the column the data type specified in the domain. For more; information on domains, see the CREATE DOMAIN stateA ment.? For most purposes, you should specify a domain instead of an explicit data type.C o Domains ensure that all columns in multiple tables that serveD the same purpose have the same data type. For example, severalA tables in the sample personnel database refer to the domain ID_DOM.A o A domain lets you change the data type for all columns that@ refer to it in one operation by changing the domain itself% with an ALTER DOMAIN statement.> B For example, if you want to change the data type for the? column EMPLOYEE_ID from CHAR(5) to CHAR(6), you need onlyC alter the data type for the domain ID_DOM. You do not have toB alter the data type for the column EMPLOYEE_ID in the tablesD DEGREES, EMPLOYEES, JOB_HISTORY, or SALARY_HISTORY, nor do youC have to alter the column MANAGER_ID in the DEPARTMENTS table.D However, you might not want to use domains when you create tables if:< o Your applicaC tion must be compatible with Oracle RDBMS.B o You are creating intermediate result tables that do not need the advantages of domains. 4 enable-disable-clause= Allows you to enable or disable all constraints, specifiedD constraints, a primary key, or a unique column name, as describedB in the following list. By default, table and column constraints5 added during a create table operation are enabled. o DISABLE ALL CONSTRAINTSC All table and column conD straints for this table are disabled.D No error is raised if no constraints are defined on the table. o ENABLE ALL CONSTRAINTS? All and column constraints for this table are enabled. NoA error is raised if no constraints are defined on the table.( o DISABLE CONSTRAINT constraint-nameD The named constraint is disabled. The named constraint must be1 a table or column constraint for the table.' o ENABLE CONSTRAINT constraint-nameC The nameE d constraint is enabled. The named constraint must be1 a table or column constraint for the table. o DISABLE PRIMARY KEY0 The primary key for the table is disabled. o ENABLE PRIMARY KEY/ The primary key for the table is enabled." o DISABLE UNIQUE (column-name)D The matching UNIQUE constraint is disabled. The columns listed# must be columns in the table.! o ENABLE UNIQUE (column-name)C The matching UNIQUE constraint is enabled.F The columns listed# must be columns in the table. 4 FOREIGN_KEY@ The name of a column or columns that you want to declare as aA foreign key in the table you are defining (referencing table).9 You cannot declare a computed column as a foreign key. 4 FROM_pathname< Specifies the repository path name of a repository recordC definition. SQL creates the table using the definition from this@ record and gives the table the name of the record definition.A G You can create a table using the FROM path-name clause only ifA the record definition in the repository was originally createdA using the repository Common Dictionary Operator (CDO) utility.C For instance, you cannot create a table using the FROM path-nameC clause if the record definition was created in the repository as part of an SQL session.D If the repository record contains a nested record definition, you% cannot create a table based on it.> Creating a table ba H sed on a repository record definition isC useful when many applications share the same definition. ChangesA to the common definition can be automatically reflected in all applications that use it.& NOTE: Changes by other users or applications to the record> definition in the repository affect the table definition= once the database is integrated to match the repository@ with an INTEGRATE DATABASE . . . ALTER FILES statement. If I ? those changes include deleting records or fields on whichB tables or table columns are based, any data in the dependent< table or table column is lost after the next INTEGRATE4 DATABASE . . . ALTER FILES statement executes.@ You can use the FROM clause only if the database was attached@ specifying PATHNAME. You can specify either a full repository0 path name or a relative repository path name.> You cannot define constraints or any other table definition? c J lauses, such as DATATRIEVE formatting clauses, when you use> the FROM path-name form of the CREATE TABLE statement. This= restriction does not prevent you from using an ALTER TABLE statement to add them later.C You cannot use the FROM path-name clause when embedding a CREATE6 TABLE statement within a CREATE DATABASE statement. 4 IDENTITYB Specifies that the column is to be a special read-only identityD column. INSERT will evaluate this column and store a unique vK alueA for each row inserted. Only one column of a table may have theC IDENTITY attribute. Rdb creates a sequence with the same name as the current table.? See ALTER SEQUENCE and CREATE SEQUENCE for more information. 4 increment-by@ An integer literal value that specifies the increment for the= sequence created for the IDENTITY column. A negative valueA creates a descending sequence, and a positive value creates anC ascending sequence. A value of zero is not L permitted. If omitted3 the default is 1, that is an ascending sequence. 4 INFORMATION? Specifies that the table definition is an information table.A Information tables are reserved for use by Oracle Corporation. 4 LIKE_other-table-name; Allows a database administrator to copy the metadata for8 an existing table and create a new table with similarD characteristics. An optional column list can be used to add extraB columns and contraints to this table. TheM referenced table must9 exist in the same database as the table being created. Syntax options: LOGGING | NOLOGGING? The LOGGING clause specifies that the CREATE TABLE statement@ should be logged in the recovery-unit journal file (.ruj) and# after-image journal file (.aij).A The NOLOGGING clause specifies that the CREATE TABLE statementD should not be logged in the recovery-unit journal file (.ruj) and# after-image journal file (.aij).% The LOGGING claN use is the default. 4 NOT_NULL> Restricts values in the column to values that are not null. 4 ON_COMMIT Syntax options:2 ON COMMIT PRESERVE ROWS | ON COMMIT DELETE ROWS@ Specifies whether data is preserved or deleted after a COMMIT7 statement for global or local temporary tables only.; The default, if not specified, is ON COMMIT DELETE ROWS. 4 PRIMARY_KEYD A primary key constraint defines one or more columns whose values@ make a row in aO table different from all others. SQL requires> that values in a primary key column be unique and not null;A therefore, you need not specify the UNIQUE and NOT NULL column' constraints for primary key columns.? You cannot specify the primary key constraint for a computed column.B When used as a table constraint this clause must be followed by@ a list of column names. When used as a column constraint this3 clause applies to the named column of the table. 4 refer P ences-clause@ Specifies the name of the column or columns that are a unique: key or primary key or in the referenced table. When theD REFERENCES clause is used as a table constraint, the column namesC specified in the FOREIGN KEY clause become a foreign key for the referencing table.? When used as the column type clause, specifies that the typeB of the column be inherited from the PRIMARY KEY or UNIQUE index; referenced. Both the data type and domain are inherited. Q #4 REFERENCES_referenced_table_name? Specifies the name of the table that contains the unique keyA or primary key referenced by the referencing table. To declareA a constraint that refers to a unique or primary key in anotherB table, you must have the SQL REFERENCES or CREATE privileges to the referenced table. 4 referenced-column-name< For a column constraint, the name of the column that is a@ unique key or primary key in the referenced table. You cannotA R use a computed column as a referenced column name. For a tableC constraint, the referenced column name is the name of the columnD or columns that are a unique key or primary key in the referencedD table. If you omit the referenced-column-name clause, the primaryC key is selected by default. The number of columns and their data types must match. 4 sql-and-dtr-clause" Optional SQL formatting clause.C If you specify a formatting clause for a column that is based onS C a domain that also specifies a formatting clause, the formattingA clause in the table definition overrides the one in the domain definition. 4 start-withA An integer literal value that specifies the starting value for? the sequence created for the IDENTITY column. If omitted the default is 1. 4 STORED_NAME_ISB Specifies a name that Oracle Rdb uses to access a table createdB in a multischema database. The stored name allows you to access@ multiscT hema definitions using interfaces, such as Oracle RMU,D the Oracle Rdb management utility, that do not recognize multiple@ schemas in one database. You cannot specify a stored name forB a table in a database that does not allow multiple schemas. ForD more details about stored names, see the User_Supplied_Names HELP topic. 4 table-constraint; A constraint definition that applies to the whole table.@ SQL allows column constraints and table constraints. The fourA tU ypes of table constraints are PRIMARY KEY, UNIQUE, CHECK, and FOREIGN KEY constraints.A A column must be defined in a table before you can specify the+ column in a table constraint definition.B You can define a table constraint on persistent base tables and global temporary tables only. 4 table-nameB The name of the table definition you want to create. Use a nameC that is unique among all table, sequence, view and synonym namesC in the database, or in the V schema if you are using a multischemaA database. Use any valid SQL name. (See the User_Supplied_Names; HELP topic for more information on user-supplied names.) 4 temporary_tables Syntax options:? CREATE GLOBAL TEMPORARY TABLE | CREATE LOCAL TEMPORARY TABLEB Specifies that the table definition is either a global or local temporary table. 4 UNIQUEA Specifies that values in the associated column must be unique.B You can use either the UNIQUE or PR W IMARY KEY keywords to define3 one or more columns as a unique key for a table.D You cannot specify the UNIQUE constraint for a computed column or@ for a column defined with the LIST OF BYTE VARYING data type. 3 Examples? Example 1: Creating new tables with primary and foreign keys@ In this example, the CREATE TABLE statement is used to createA the EMPLOYEES_2, SALARY_HISTORY_2, and WORK_STATUS_2 tables inC the personnel database. It specifies column definitions bas X ed on. domain definitions for the entire database.? The FOREIGN KEY constraint specified in the SALARY_HISTORY_2? table must match the PRIMARY KEY constraint specified in the EMPLOYEES_2 table.; Note also that the CHECK constraint specified is a tableB constraint because it is separated by commas from the column toD which it refers. In this case, a column constraint on EMPLOYEE_IDB would have the same effect because it refers only to the single column EMPLOYEE_ID.Y ; Because the dialect is SQL99, the default for constraint% evaluation time is NOT DEFERRABLE. SQL> -- *** Set Dialect *** SQL> -- SQL> SET DIALECT 'SQL99'; SQL> -- SQL> -- *** Create tables *** SQL> --" SQL> CREATE TABLE WORK_STATUS_2 cont> (+ cont> STATUS_CODE STATUS_CODE_DOM/ cont> CONSTRAINT WS2_STATUS_CODE_PRIMARY cont> PRIMARY KEY,, cont> STATUS_NAME STATUS_NAME_DOM,+ cont> STATUS_TYPE STATUS_DESC_DOM Z cont> ); SQL> -- SQL> CREATE TABLE EMPLOYEES_2 cont> (" cont> EMPLOYEE_ID ID_DOM. cont> CONSTRAINT E2_EMPLOYEE_ID_PRIMARY cont> PRIMARY KEY,* cont> LAST_NAME LAST_NAME_DOM,+ cont> FIRST_NAME FIRST_NAME_DOM,/ cont> MIDDLE_INITIAL MIDDLE_INITIAL_DOM,/ cont> ADDRESS_DATA_1 ADDRESS_DATA_1_DOM,/ cont> ADDRESS_DATA_2 ADDRESS_DATA_2_DOM,% cont> CITY CITY_DOM,& cont> STATE STATE_DOM, [ , cont> POSTAL_CODE POSTAL_CODE_DOM,# cont> SEX SEX_DOM/ cont> CONSTRAINT EMPLOYEE_SEX_VALUES cont> CHECK (< cont> SEX IN ('M', 'F') OR SEX IS NULL cont> ),% cont> BIRTHDAY DATE_DOM,+ cont> STATUS_CODE STATUS_CODE_DOM. cont> CONSTRAINT E2_STATUS_CODE_FOREIGN4 cont> REFERENCES WORK_STATUS_2 (STATUS_CODE),4 cont> CONSTRAINT EMP_STATUS_CODE_VALUES_2 \ cont> CHECK (: cont> STATUS_CODE IN ('0', '1', '2')2 cont> OR STATUS_CODE IS NULL cont> ) cont> ); SQL> --% SQL> CREATE TABLE SALARY_HISTORY_2 cont> (" cont> EMPLOYEE_ID ID_DOM0 cont> CONSTRAINT SH2_EMPLOYEES_ID_FOREIGN2 cont> REFERENCES EMPLOYEES_2 (EMPLOYEE_ID),' cont> SALARY_AMOUNT SALARY_DOM,% cont> SALARY_START DATE_DOM,$ cont> SALARY_END ] DATE_DOM cont> ); SQL>7 Example 2: Creating a table with many SQL data typesC The following example is an excerpt from the sample program sql_A all_datatypes created during installation of Oracle Rdb in theC Samples directory. For a variety of languages, sql_all_datatypesC illustrates how you declare program variables to match a variety@ of data types, and how you can specify those variables in SQL? statements when you store and retrieve column values or null^ values.B This example shows the CREATE TABLE statement from the sql_all_ datatypes program., EXEC SQL CREATE TABLE ALL_DATATYPES_TABLE (, CHAR_COL CHAR(10),, SMALLINT_COL SMALLINT,0 SMALLINT_SCALED_COL SMALLINT (3),+ INTEGER_COL INTEGER,/ INTEGER_SCALED_COL INTEGER (2),, QUADWORD_COL QUADWORD,0 QUADWORD_SCALED_COL QUADWORD (5),( _ REAL_COL REAL,4 DOUBLE_PREC_COL DOUBLE PRECISION,( DATE_COL DATE,. VARCHAR_COL VARCHAR(40) );3 Example 3: Specifying default values for columns> The following example illustrates the use of default valuesB for columns. Each salesperson enters his or her own daily sales* information into the DAILY_SALES table. SQL> -- SQL> CREATE TABLE DAILY_SALES cont> --@ cont> - ` - The column SALESPERSON is based on LAST_NAME_DOM and@ cont> -- the default value is the user name of the person who# cont> -- enters the information:1 cont> (SALESPERSON LAST_NAME_DOM DEFAULT USER, cont> --( cont> -- Typical work day is 8 hours:+ cont> HOURS_WORKED SMALLINT DEFAULT 8,# cont> HOURS_OVERTIME SMALLINT,! cont> GROSS_SALES INTEGER ); SQL> --7 SQL> -- Insert daily sales information accepting the; SQL> -- default values for SALESPERSON and HOa URS_WORKED: SQL> -- SQL> INSERT INTO DAILY_SALES' cont> (HOURS_OVERTIME, GROSS_SALES ) cont> VALUES cont> (1, 2499.00); 1 row inserted" SQL> SELECT * FROM DAILY_SALES;@ SALESPERSON HOURS_WORKED HOURS_OVERTIME GROSS_SALES@ KILPATRICK 8 1 2499 1 row selected? Example 4: Violating a constraint indirectly with the DELETE statementD Constraints prevent INSERT statements from adding rows to a table> b that do not satisfy conditions specified in the constraint.< Constraints also prevent DELETE or UPDATE statements fromC deleting or changing values in a table if the deletion or change@ violates the constraint on another table in the database. The, following example illustrates that point:G SQL> -- TEST has no constraints defined for it, but it is subject toG SQL> -- restrictions nonetheless because of the constraint specified SQL> -- in TEST2: SQL> CREATE TABLE TESTc  cont> (COL1 REAL); SQL> SQL> CREATE TABLE TEST2 cont> (COL1 REAL, cont> CHECK (COL1 IN# cont> (SELECT COL1 FROM TEST)) cont> ); SQL> COMMIT; SQL>$ SQL> INSERT INTO TEST VALUES (1); 1 row inserted% SQL> INSERT INTO TEST2 VALUES (1); 1 row inserted SQL> COMMIT;H SQL> -- This DELETE statement will fail because it will cause COL1 inK SQL> -- TEST2 to contain a value without the same value in COL1 of TEST:( SQL> DELETE FROM TEST Wd HERE COL1 = 1; 1 row deleted SQL> COMMIT;N %RDB-E-INTEG_FAIL, violation of constraint TEST2_CHECK1 caused operation to fail1 Example 5: Evaluating constraints at verb time? Deferrable constraints are not evaluated until a transactionA issues a COMMIT statement. You can specify that constraints beB evaluated more frequently with the EVALUATING clause of the SET TRANSACTION statement. SQL> create table TEST cont> (col1 integer, cont> col2e integer cont> constraint C2 cont> unique cont> deferrable cont> ); SQL>4 SQL> insert into TEST (col1, col2) values (1, 2); 1 row inserted SQL> commit; SQL> SQL> /*; ***> This INSERT will violate the constraint as shown by ***> the error during COMMIT ***> */4 SQL> insert into TEST (col1, col2) values (1, 2); 1 row inserted SQL> commit;I %RDB-E-INTEG_FAIL, violation of constraint C2 caused operatf ion to failH -RDB-F-ON_DB, on database USER_DISK:[DOC.DATABASES]MF_PERSONNEL.RDB;1 SQL> /*. ***> The COMMIT failed, so we will ROLLBACK ***> */ SQL> rollback; SQL> SQL> /*> ***> You can change the evalution time using the EVALUATING! ***> clause of SET TRANSACTION ***> */> SQL> set transaction read write evaluating C2 at verb time;4 SQL> insert into TEST (col1, col2) values (1, 2);I %RDB-E-INTEG_FAIL, violation of constraint C2 caused operation to fail g H -RDB-F-ON_DB, on database USER_DISK:[DOC.DATABASES]MF_PERSONNEL.RDB;1 SQL> rollback; 2 TRIGGER@ Creates triggers for a specified table. A trigger defines theD actions to occur before or after the table is updated (by a writeA operation such as an INSERT, DELETE, or UPDATE statement). The? trigger is associated with a single table, takes effect at aC specific time for a particular type of update, and causes one orC more triggered actions to be performed. If the trh igger specifiesC multiple actions, each action is performed in the order in which, it appears within the trigger definition.8 With triggers, you can define useful actions such as: o Cascading deletes@ Deleting a row from one table causes additional rows to beC deleted from other tables that are related to the first table by key values. o Cascading updates> Updating a row in one table causes additional rows to beA updated in other tables i that are related to the first tableB by key values. These updates are commonly limited to the key fields themselves. o Summation updates> Updating a row from one table causes a value in a row ofB another table to be updated by being increased or decreased. o Hidden deletesA Causing rows to be deleted from a table by moving them to a@ parallel table that is not otherwise used by the database.& NOTEB Co j mbinations of table-specific constraints and appropriately< defined triggers, by themselves, are not sufficient to= guarantee that database integrity is preserved when the; database is updated. If integrity is to be preserved,= table-specific constraints and triggers must be used in= conjunction with a common set of update procedures thatA ensure completely reproducible and consistent retrieval and update strategies.B The CREATE TRIGGER statement adk ds the trigger definition to the physical database.@ A triggered action consists of an optional predicate and someB triggered statements. If specified, the predicate must evaluateA to true for the triggered statements in the action to execute.@ Each triggered statement is executed in the order in which it. appears within the triggered action clause." The triggered statement can be: o A DELETE statement o An UPDATE statement o An INSERT statement l o A CALL statement o A SIGNAL statement o A TRACE statement o An ERROR statement 3 Environment, You can use the CREATE TRIGGER statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format* CREATE TRIGGER --> ------+* +---------------------------------------+* +-+-------------- m ---------------------+-+* +-> STORED NAME IS ---+ |* +------------------<--------------------+> ++-> BEFORE -+-+-> INSERT --------------------------------+-+> +-> AFTER --+ +-> DELETE --------------------------------+ |> +-> UPDATE --+--------------------------+--+ |> +--> OF -+> ++ |> +--- , <---------+ |> +----------------------------<------------------------------+F +-> ON n +-----------------------++-> triggered-action -+>E +-> referencing-clause -++----------<----------+  referencing-clause = : REFERENCING -++-> OLD AS --> -++->8 |+-> NEW AS --> -+|8 +------------------<---------------------+  triggered-action = @ --+---------------------+-> ( -+> triggered-statement -+-> ) -+@ +-> WHEN (predicate) -+ +----------- , <------o --+ |@ +----------- ; <--------+ |@ +---------------------------<------------------------------+@ +-+------------------------+-------------------------------> +-> FOR EACH ROW --------+ +-> FOR EACH STATEMENT --+ triggered-statement =  --+-> call-statement ---+--> +-> delete-statement -+ +-> ERROR ------------+ +-> insert-statement -+ +-> signal-statement -+ +-> trace-statement --+ +-> update-statemenp t -+ 3 Arguments 4 call-statement> Specifies the stored procedure to invoke. You can only callD procedures with IN parameters. Operations on the triggering table? are not permitted due to possible side effects and recursive calls. 4 column-nameD The name of a column within the specified table to be checked forD deletion, modification, or insertion. Use this argument only with UPDATE triggers. 4 delete-statement? Specifies the row oq f a table that you want to delete. If you> specify CURRENT OF cursor-name with the WHERE clause of theD DELETE statement, you receive an error message because the cursor2 is not visible to the CREATE TRIGGER statement. 4 ERROR" Provides the following message:= RDMS-E-TRIG_ERROR, Trigger 'trigger_name' forced an error.D A triggered ERROR statement cancels the DELETE, UPDATE, or INSERT& statement that invoked the trigger. 4 FOR_EACH Syntax options:$r FOR EACH ROW | FOR EACH STATEMENT? Specifies whether the triggered action is evaluated once perB triggering statement, or for each row of the subject table that+ is affected by the triggering statement.? If you specify FOR EACH STATEMENT, then the triggered actionB is evaluated only once, and row values are not available to the triggered action.0 The FOR EACH STATEMENT clause is the default. 4 insert-statement< Specifies the new row or rows you want to as dd to a table. 4 old-correlation-nameC A temporary name used to refer to the row values as they existedA before an UPDATE operation occurred. If you do not specify theC FOR EACH ROW clause, this correlation name cannot be referred to in the triggered statement. 4 new-correlation-name= A temporary name used to refer to the new row values to beA applied by the UPDATE operation. If you do not specify the FORB EACH ROW clause, this correlation name cannot bt e referred to in the triggered statement. 4 referencing-clauseB Lets you specify whether you want to refer to the row values asB they existed before an UPDATE operation occurred or the new rowD values after they are applied by the UPDATE operation. Do not use0 this clause with INSERT or DELETE operations.B You can specify each option (OLD AS old-correlation-name or NEW@ AS new-correlation-name) only once in the referencing clause. 4 signal-statementA S u pecifies that the signaled SQLSTATE status parameter is to be? passed back to the application or SQL interface and that theA current routine and all calling routines are to be terminated.D This provides a more complete error mechanism than is provided by the ERROR clause. 4 STORED_NAME_ISD Specifies a name that Oracle Rdb uses to access a trigger createdB in a multischema database. The stored name allows you to access@ multischema definitions using interfaces, such v as Oracle RMU,D the Oracle Rdb management utility, that do not recognize multipleB schemas in one database. You cannot specify a stored name for aB trigger in a database that does not allow multiple schemas. For@ more information on stored names, see the User_Supplied_Names HELP topic. 4 table-name; The name of the table for which this trigger is defined. 4 trace-statementD Allows applications to add triggers to log information when trace logging is actiw ve. 4 triggered-actionD Consists of an optional predicate, some triggered statements, andA an optional frequency clause. If specified, the predicate mustA evaluate to true for the triggered statements in the triggeredD action clause to execute. Each triggered statement is executed inD the order in which it appears within the triggered action clause. 4 triggered-statement6 Updates the database or generates an error message. 4 update-statement? Spe x cifies the row of a table that you want to modify. If you> specify CURRENT OF cursor-name with the WHERE clause of theD UPDATE statement, you receive an error message because the cursor2 is not visible to the CREATE TRIGGER statement. 4 WHEN_predicateA Describes the optional condition that must be satisfied beforeC the associated triggered statements are executed. This predicate. cannot refer to any host language variable.; To avoid ambiguity between columns and exy ternal function= callouts, use parentheses around the predicate in the WHEN clause. 3 Examples1 Example 1: Defining a cascading delete trigger> The following SQL procedure shows a trigger from the sample@ personnel database that deletes rows in several tables beforeB deleting a row in the EMPLOYEES table. Each associated employee? row (from the tables that have foreign keys referring to the< primary key in the employee row) is deleted. The employee< identificz ation number being deleted (00164) belongs to anC employee who is also a manager; therefore, the MANAGER_ID column? in the DEPARTMENTS table is set to null, as specified by the trigger.# SQL> SET TRANSACTION READ WRITE; SQL> --9 SQL> -- Display the EMPLOYEE_ID_CASCADE_DELETE trigger" SQL> -- in the sample database: SQL> --/ SQL> SHOW TRIGGER EMPLOYEE_ID_CASCADE_DELETE" EMPLOYEE_ID_CASCADE_DELETE Source: EMPLOYEE_ID_CASCADE_DELETE$ BEFO { RE DELETE ON EMPLOYEES6 (DELETE FROM DEGREES D WHERE D.EMPLOYEE_ID =! EMPLOYEES.EMPLOYEE_ID) FOR EACH ROW< (DELETE FROM JOB_HISTORY JH WHERE JH.EMPLOYEE_ID =! EMPLOYEES.EMPLOYEE_ID) FOR EACH ROW? (DELETE FROM SALARY_HISTORY SH WHERE SH.EMPLOYEE_ID =! EMPLOYEES.EMPLOYEE_ID) FOR EACH ROW> ! Also, if an employee is terminated and that employee< ! is the manager of a department, | set the manager_id# ! null for that department.8 (UPDATE DEPARTMENTS D SET D.MANAGER_ID = NULL6 WHERE D.MANAGER_ID = EMPLOYEES.EMPLOYEE_ID) FOR EACH ROW SQL> --5 SQL> -- The EMPLOYEES table has a value of '00164'% SQL> -- in the EMPLOYEE_ID column: SQL> --@ SQL> SELECT * FROM EMPLOYEES E WHERE E.EMPLOYEE_ID = '00164';> EMPLOYEE_ID LAST_NAME FIRST_NAME MIDDLE_INITIAL= ADDRESS_DATA_1 ADDRESS_DATA_2 } CITY? STATE POSTAL_CODE SEX BIRTHDAY STATUS_CODE1 00164 Toliver Alvin AA 146 Parnell Place Chocorua5 NH 03817 M 28-Mar-1947 1 1 row selected SQL> -- SQL> --6 SQL> -- The DEGREES table has two values of '00164'% SQL> -- in the EMPLOYEE_ID column: SQL> --> SQL> SELECT * FROM DEGREES D WHERE D.EMPLOYEE_ID = '00164';C EMPLOYEE_ID COLLEGE_CODE YEAR_ ~ GIVEN DEGREE DEGREE_FIELDC 00164 PRDU 1973 MA Applied MathA 00164 PRDU 1982 PhD Statistics 2 rows selected SQL> -- SQL> --< SQL> -- The JOB_HISTORY table has the value of '00164' in2 SQL> -- several rows in the EMPLOYEE_ID column: SQL> --D SQL> SELECT * FROM JOB_HISTORY JH WHERE JH.EMPLOYEE_ID = '00164';H EMPLOYEE_ID JOB_CODE JOB_START JOB_END DEPARTMENT_CODE SUPERVISOR_ID= 00164 DMGR 21-Sep-1981 NULL MBMN 00228= 00164 SPGM 5-Jul-1980 20-Sep-1981 MCBM 00164 2 rows selected SQL> -- SQL> --: SQL> -- The SALARY_HISTORY table has a value of '00164'5 SQL> -- in several rows in the EMPLOYEE_ID column: SQL> --G SQL> SELECT * FROM SALARY_HISTORY SH WHERE SH.EMPLOYEE_ID = '00164';; EMPLOYEE_ID SALARY_AMOUNT SALARY_START SALARY_END< 00164 $26,291.00 5-J ul-1980 2-Mar-19815 00164 $51,712.00 14-Jan-1983 NULL< 00164 $26,291.00 2-Mar-1981 21-Sep-1981< 00164 $50,000.00 21-Sep-1981 14-Jan-1983 4 rows selected SQL> -- SQL> --7 SQL> -- The DEPARTMENTS table has a value of '00164'$ SQL> -- in the MANAGER_ID column: SQL> --A SQL> SELECT * FROM DEPARTMENTS D WHERE D.MANAGER_ID = '00164';A DEPARTMENT_CODE DEPARTMENT_NAME MANAGER_ID& BUDGET_P ROJECTED BUDGET_ACTUAL< MBMN Board Manufacturing North 00164& NULL NULL 1 row selected SQL> -- SQL> --G SQL> -- Test the trigger by deleting the row with a value of '00164'> SQL> -- in the EMPLOYEE_ID column from the EMPLOYEES table: SQL> --> SQL> DELETE FROM EMPLOYEES E WHERE E.EMPLOYEE_ID = '00164'; 1 row deleted SQL> --D SQL> -- The row with a value of '00164' in the EMPLOYEE_ID column0 SQL> -- was del eted from the EMPLOYEES table: SQL> --@ SQL> SELECT * FROM EMPLOYEES E WHERE E.EMPLOYEE_ID = '00164'; 0 rows selected SQL> --E SQL> -- The rows with a value of '00164' in the EMPLOYEE_ID column/ SQL> -- were deleted from the DEGREES table: SQL> --> SQL> SELECT * FROM DEGREES D WHERE D.EMPLOYEE_ID = '00164'; 0 rows selected SQL> --> SQL> -- The rows with a value of '00164' in the EMPLOYEE_ID: SQL> -- column were deleted from the JOB_HISTORY table: SQL> -- D SQL> SELECT * FROM JOB_HISTORY JH WHERE JH.EMPLOYEE_ID = '00164'; 0 rows selected SQL> --> SQL> -- The rows with a value of '00164' in the EMPLOYEE_ID= SQL> -- column were deleted from the SALARY_HISTORY table: SQL> --G SQL> SELECT * FROM SALARY_HISTORY SH WHERE SH.EMPLOYEE_ID = '00164'; 0 rows selected SQL> --H SQL> -- The value of '00164' in the MANAGER_ID column was set to null$ SQL> -- in the DEPARTMENTS table: SQL> --E SQL> SELECT * FROM DEPARTMENT S D WHERE D.DEPARTMENT_CODE = 'MBMN';A DEPARTMENT_CODE DEPARTMENT_NAME MANAGER_ID& BUDGET_PROJECTED BUDGET_ACTUAL; MBMN Board Manufacturing North NULL& NULL NULL 1 row selected SQL> -- SQL> ROLLBACK;8 Example 2: Defining a trigger that performs an updateA Before the STATUS_CODE column in WORK_STATUS table is updated,> the STATUS_CODE_CASCADE_UPDATE trigger in the following SQLD proce dure updates the associated rows in the EMPLOYEES table. TheB REFERENCING clause specifies OLD_WORK_STATUS as the correlationA name for the values in the WORK_STATUS table before the UPDATE= statement executes, and NEW_WORK_STATUS as the correlation@ name for the values in the WORK_STATUS table after the UPDATE statement executes.< SQL> -- Display the STATUS_CODE_CASCADE_UPDATE trigger in SQL> -- the sample database: SQL> --/ SQL> SHOW TRIGGER STATUS_CODE_CASCADE_UPD ATE" STATUS_CODE_CASCADE_UPDATE Source: STATUS_CODE_CASCADE_UPDATEE BEFORE UPDATE OF STATUS_CODE ON WORK_STATUS? REFERENCING OLD AS OLD_WORK_STATUS? NEW AS NEW_WORK_STATUS- (UPDATE EMPLOYEES EJ SET E.STATUS_CODE = NEW_WORK_STATUS.STATUS_CODEM WHERE E.STATUS_CODE = OLD_WORK_STATUS.STATUS_CODE)) FOR EACH ROW SQL> --K SQL> -- Change the STATUS_CODE column with a value of 2 to a value of 3: SQL> --H SQL> UPDATE WORK_STATUS WS SET STATUS_CODE="3" WHERE STATUS_CODE="2"; 1 row updated SQL> --L SQL> -- The trigger changes any STATUS_CODE column in the EMPLOYEES tableD SQL> -- with a value of 2 to a value of 3. Therefore, no rows areN SQL> -- selected for the first query that follows, but several are selected SQL> -- for the second query: SQL> --< SQL> SELECT * FROM EMPLOYEES E WHERE E.STATUS_CODE = "2"; 0 rows selected SQL> --< SQL> SELECT * FROM EMPLOYEES E WHERE E.STATUS_CODE = "3";> EMPLOYEE_ID LAST_NAME FIRST_NAME MIDDLE_INITIAL= ADDRESS_DATA_1 ADDRESS_DATA_2 CITY? STATE POSTAL_CODE SEX BIRTHDAY STATUS_CODE1 00165 Smith Terry DA 120 Tenby Dr. Chocorua5 NH 03817  M 15-May-1954 34 00178 Goldstone Neal NULLB 194 Lyons Av, Colebrook5 NH 03576 M 25-Apr-1952 3 . . .1 00358 Lapointe Jo Ann CA 70 Tenby Dr. Chocorua5 NH 03817 F 24-Feb-1931 3 12 rows selected SQL> -- SQL> ROLLBACK;= Example 3: Defining a trigg er that updates a sales summaryA The following example defines a trigger that updates a monthly- sales total after each daily sale is made. SQL> --; SQL> -- Create the table to keep track of monthly sales:" SQL> CREATE TABLE MONTHLY_SALES! cont> ( SALES_AMOUNT INTEGER); SQL> --> SQL> -- Create the table to keep track of sales made today: SQL> CREATE TABLE DAILY_SALES! cont> ( SALES_AMOUNT INTEGER); SQL> --P SQL> -- Assume that $250.00 of sales have bee n made during the current month:! SQL> INSERT INTO MONTHLY_SALES% cont> (SALES_AMOUNT) VALUES (250); 1 row inserted SQL> --A SQL> -- After adding a new value to the SALES_AMOUNT column in= SQL> -- DAILY_SALES table, SQL updates the SALES column inC SQL> -- the MONTHLY_SALES table with the amount of the new sale:5 SQL> CREATE TRIGGER UPDATE_SALES_TOTAL_ON_NEW_SALE$ cont> AFTER INSERT ON DAILY_SALES" cont> (UPDATE MONTHLY_SALES MN cont> SET M.SALES_AMOUN T = M.SALES_AMOUNT + DAILY_SALES.SALES_AMOUNT) cont> FOR EACH ROW; SQL> --F SQL> -- The following statement records a new $5.00 sale for today: SQL> INSERT INTO DAILY_SALES# cont> (SALES_AMOUNT) VALUES (5); 1 row inserted SQL> --I SQL> -- The value for the SALES_AMOUNT column of the DAILY_SALES tableC SQL> -- is $5.00 and the value of the SALES_AMOUNT column of the* SQL> -- MONTHLY_SALES table is $255.00:" SQL> SELECT * FROM DAILY_SALES; SALES_AMOUNT  5 1 row selected SQL> --$ SQL> SELECT * FROM MONTHLY_SALES; SALES_AMOUNT 255 1 row selected SQL> --K SQL> -- When a new $9.00 sale is made, the values in the two rows of theK SQL> -- SALES_AMOUNT column of the DAILY_SALES table are $5.00 and $9.00H SQL> -- and the value of the SALES_AMOUNT column of the MONTHLY_SALES SQL> -- table is $264.00: SQL> INSERT INTO DAILY_SALES# cont> (SALES_AMOUNT) VALUES (9); 1 row inserted  SQL> --" SQL> SELECT * FROM DAILY_SALES; SALES_AMOUNT 5 9 2 rows selected SQL> --$ SQL> SELECT * FROM MONTHLY_SALES; SALES_AMOUNT 264 1 row selected SQL> -- SQL> ROLLBACK; SQL> --@ Example 4: Defining a trigger that sets column values to null< Before the STATUS_CODE column in the WORK_STATUS table isB deleted, this trigger causes the associated WORK_STATUS columns, in the EMPLOYEES table to be se t to null.5 SQL> CREATE TRIGGER STATUS_CODE_ON_DELETE_SET_NULL& cont> BEFORE DELETE ON WORK_STATUS8 cont> (UPDATE EMPLOYEES E SET E.STATUS_CODE = NULL: cont> WHERE E.STATUS_CODE = WORK_STATUS.STATUS_CODE) cont> FOR EACH ROW; SQL> --H SQL> -- Delete any row in the WORK_STATUS table where the STATUS_CODE# SQL> -- column has a value of 1:> SQL> DELETE FROM WORK_STATUS WS WHERE WS.STATUS_CODE = "1"; 1 row deleted SQL> --I SQL> -- This trigger sets the S TATUS_CODE column value to null in many' SQL> -- rows in the EMPLOYEES table:> SQL> SELECT * FROM EMPLOYEES E WHERE E.STATUS_CODE IS NULL;> EMPLOYEE_ID LAST_NAME FIRST_NAME MIDDLE_INITIAL= ADDRESS_DATA_1 ADDRESS_DATA_2 CITY? STATE POSTAL_CODE SEX BIRTHDAY STATUS_CODE1 00416 Ames Louie A> 61 Broad st. NULL Alton8 NH 03809 M 13-Apr-194 1 NULL1 00374 Andriola Leslie QB 111 Boston Post Rd. NULL Salisbury8 NH 03268 M 19-Mar-1955 NULL . . .1 00200 Ziemke Al FD 121 Putnam Hill Rd. NULL Winnisquam< NH 03289 M 27-Oct-1928 NULL 88 rows selected SQL> ROLLBACK;@ Example 5: Defining a trigger that prevents deletio n of a row that exists in two tablesB Suppose that a user wants to delete only those rows in the JOB_B HISTORY table that do not also exist in the JOBS table. This isB difficult to do with constraints because a row can exist in oneB table with a key number that does not exist in the other table.A The following statement creates a trigger that causes an error@ when the user tries to delete a row that exists in table JOB_ HISTORY.# SQL> CREATE TRIGGER DELETE_GUARD% cont> BEFORE DELETE ON JOB_HISTORY4 cont> WHEN EXISTS (SELECT JOBS.JOB_CODE FROM JOBS2 cont> WHERE JOBS.JOB_CODE=JOB_HISTORY.JOB_CODE) cont> (ERROR) FOR EACH ROW; SQL> --< SQL> -- Now attempt a deletion that violates the trigger. SQL> --8 SQL> DELETE FROM JOB_HISTORY WHERE JOB_CODE = 'DMGR';C %RDB-E-TRIG_INV_UPD, invalid update; encountered error condition defined for trigger; -RDMS-E-TRIG_ERROR, trigger DELETE_GUARD forced an error@ -RDB-F-ON_DB, on database D ISK1:[DEPT3.SQL]MF_PERSONNEL.RDB;1= Example 6: Defining a trigger that saves audit information5 SQL> -- Create new table to record changes made to SQL> -- EMPLOYEES table SQL> CREATE TABLE AUDIT_TRAIL cont> (LOG DATE VMS, cont> PERSON CHAR(31), cont> TBL_NAME CHAR(10), cont> OPER CHAR(1)); SQL> COMMIT;- SQL> -- Create a trigger so that each time, SQL> -- an INSERT operation is performed,7 SQL> -- a record is stored in the AUDIT_TRAIL table.#  SQL> CREATE TRIGGER EMPS_TRIGGER cont> AFTER INSERT cont> ON EMPLOYEES! cont> (INSERT INTO AUDIT_TRAIL# cont> VALUES (CURRENT_TIMESTAMP,1 cont> CURRENT_USER, 'EMPLOYEES', 'I')) cont> FOR EACH STATEMENT;: SQL> -- The AUDIT_TRAIL table currently has no records." SQL> SELECT * FROM AUDIT_TRAIL; 0 rows selected) SQL> -- Insert a record into EMPLOYEES SQL> INSERT INTO EMPLOYEES! cont> (EMPLOYEE_ID, LAST_NAME)$ cont> VALUES ('00964', 'FRENCH'); 1 row inserted8 SQL> -- See if trigger updated the AUDIT_TRAIL table." SQL> SELECT * FROM AUDIT_TRAIL;Q LOG PERSON TBL_NAME OPERN 17-JUN-2003 15:04:31.43 STEWART EMPLOYEES I 1 row selected- Example 7: Using TRACE as a trigger action SQL> set flags 'TRACE';4 SQL> create table M_TABLE (a integer, b integer); SQL> SQL> create trigger T_A$ cont> after insert on M_TABLE G cont> (trace 'in a trigger: ' || cast(M_TABLE.a as varchar(10))) cont> for each row; SQL>2 SQL> insert into M_TABLE (a, b) values (1, 10); ~Xt: in a trigger: 1 1 row inserted SQL>. Example 8: Using SIGNAL as a trigger action4 SQL> create table M_TABLE (a integer, b integer); SQL> SQL> create trigger T_A% cont> after insert on M_TABLE2* cont> when (M_TABLE2.a is not null)2 cont> (signal '12345' ('in a trigger: 'F c ont> || cast(M_TABLE2.a as varchar(10)))) cont> for each row; SQL>3 SQL> insert into M_TABLE2 (a, b) values (1, 10);B %RDB-E-SIGNAL_SQLSTATE, routine "T_A" signaled SQLSTATE "12345" -RDB-I-TEXT, in a trigger: 1 SQL>, Example 9: Using CALL as a trigger action SQL> create module M_MODULE cont> language SQL cont>% cont> procedure M_K (in :a int);H cont> trace 'called from a trigger: ' || cast(:a as varchar(10));  cont> cont> end module; SQL>4 SQL> create table M_TABLE (a integer, b integer); SQL> SQL> create trigger T_A$ cont> after insert on M_TABLE# cont> (call M_K (M_TABLE.a)) cont> for each row; SQL>2 SQL> insert into M_TABLE (a, b) values (1, 10); ~Xt: called from a trigger: 1 1 row inserted SQL> 2 USERB Creates a special security profile entry to identify a database> user. That user can be granted roles, which in turn provi de access to database objects. 3 Environment) You can use the CREATE USER statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 FormatE CREATE USER --+---> ----> IDENTIFIED EXTERNALLY --+-----+E +---> PUBLIC ----------------------------------+ |E +-------------- ----------------------------------------------------+E +-------------+-------------------------------+-------------------->0 +---> create-user-opts ---------+ create-user-opts = 5 -+-> ACCOUNT --+->LOCK ---+---------------------+-->2 | +->UNLOCK -+ |2 +-> COMMENT IS -+-> '' --+-------------+2 | +------- / <-----+ |2 +-> NO PROFILE -------------------------------+2 +-> PROFILE --- -----------------+  3 Arguments 4 ACCOUNT_lock-option Syntax options: ACCOUNT LOCK | ACCOUNT UNLOCKA The ACCOUNT LOCK clause disables access to the database by the@ user for whom the CREATE USER statement is being applied. TheA ACCOUNT UNLOCK clause allows that user access to the database., The ACCOUNT UNLOCK clause is the default. 4 COMMENT_IS_'string'> Adds a comment about the user. SQL displays the text of the? comment when it e xecutes a SHOW USERS statement. Enclose theD comment in single quotation marks (') and separate multiple lines& in a comment with a slash mark (/). 4 IDENTIFIED_EXTERNALLY< Indicates that the user will be authenticated through the operating system. 4 PROFILE Syntax options: PROFILE | NOPROFILE; Identifies a new profile for assignment to the user. TheB specified profile name must be the name of an existing profile.B NOPROFILE is the default  behavior and indicates that no special) restrictions are applied to this user. 4 PUBLIC< Explicitly creates a PUBLIC security profile entry in the database. 4 usernameC The name of the user to add to the database. This must match the( name of an existing OpenVMS username. 3 Examples9 Example 1: Creating a New User and Locking Her Account0 SQL> CREATE USER munroy IDENTIFIED EXTERNALLY cont> ACCOUNT LOCK0 cont> COMMENT IS 'User munroy s tarts job on'/0 cont> 'May 1, 2003. Unlock when she starts';( Example 2: Adding a profile to a user> This example creates a new profile that defines the DEFAULTD transaction and then assigns a profile while creating a new user.D The next time the user attaches to the database the START DEFAULTD TRANSACTION statement will use the defined profile instead of the standard READ ONLY default.% SQL> create profile READ_COMMITTEDO cont> default transaction read write isolat ion level read committed wait 30;# SQL> show profile READ_COMMITTED READ_COMMITTED/ Default transaction read write wait 30) Isolation level read committedF SQL> create user JAIN identified externally profile READ_COMMITTED; SQL> show user JAIN; JAIN Identified externally Account is unlocked Profile: READ_COMMITTED0 No roles have been granted to this user 2 VIEW@ Creates a view definition. A view is a logical structure that? refers to rows stored in other tables. Data in a view is not? physically stored in the database. You can include in a viewD definition combinations of rows and columns from other tables andD view definitions in the schema. You define a view by specifying a select expression, that:D o Names the criteria for selecting the tables, rows, and columns for the view2 o Specifies a set of columns from those tables= When the CREATE VIEW st atement executes, SQL adds the viewB definition to the physical database. If you declared the schemaC with the PATHNAME argument, the definition is also stored in the repository. 3 Environment) You can use the CREATE VIEW statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format7 CREATE VIEW --> -------------------------+7 +--------------------------------------------------+7 ++-----------------------------------+-------------+7 +-> STORED NAME IS ---+ |7 +----------------------------------------------------+7 ++------------------------>------------------------+-+7 +-> ( -+-> -+--------------+-+-> ) -+ |7 | +----------------+ | | |7 | ++-+------------------------+-+-+ | |7  | | +-> sql-and-dtr-clause --+ | | |7 | +-------------<--------------+ | |7 +----------------- , <--------------+ |7 +----------------------------------------------------+4 +-> AS select-expr ---+------------------------+-->1 +-> check-option-clause -+  select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ sql-and-dtr-clause = A -+-> QUERY HEADER IS -+> +-------------------+->? | +------ / <--------+ |? +-> EDIT STRING IS -------------------------+? |  |? +-> QUERY NAME FOR -+-> DTR --------+-> IS -+? | +-> DATATRIEVE -+ |? +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+* +-> DATATRIEVE -+  check-option-clause = < WITH CHECK OPTION --+----------------------------------+-->9 +-> CONSTRAINT +  3 Arguments 4 check-option-clauseB  A constraint that places restrictions on update operations madeD to a view. The check option clause ensures that any rows that areA inserted or updated in a view conform to the definition of theD view. Do not specify the WITH CHECK OPTION clause with views that are read-only. 4 column-nameB A list of names for the columns of the view. If you omit column> names, SQL assigns the names from the columns in the source# tables in the select expression.B However, you  must specify names for all the columns of the view in the following cases:C o The select expression generates columns with duplicate names.D o The select expression uses statistical functions or arithmeticB expressions to create new columns that are not in the source tables. 4 CONSTRAINTC Specify a name for the WITH CHECK OPTION constraint. If you omitD the name, SQL creates a name. However, Oracle Rdb recommends thatA you always name constraints. If you supply a name for the WITHB CHECK OPTION constraint, the name must be unique in the schema.? The name for the WITH CHECK OPTION constraint is used by the> INTEG_FAIL error message when an INSERT or UPDATE statement violates the constraint. 4 select-exprA A select expression that defines which columns and rows of theC specified tables SQL includes in the view. The select expressionA for a nonmultischema database can name only tables in the same< schema as the view. A select expression for a multischema? database can name a table in any schema in the database; theD schema need not be in the same catalog as the view being created.@ See the Select_Expressions HELP topic for more information on select expressions. 4 sql-and-dtr-clause: Optional SQL and DATATRIEVE formatting clauses. See theD DATATRIEVE HELP topic for more information on formatting clauses. 4 STORED_NAME_ISA Specifies a name that Oracle Rdb uses to access a view createdB in a multischema database. The stored name allows you to access@ multischema definitions using interfaces, such as Oracle RMU,D the Oracle Rdb management utility, that do not recognize multiple@ schemas in one database. You cannot specify a stored name forA a view in a database that does not allow multiple schemas. ForD more details about stored names, see the User_Supplied_Names HELP topic. 4 view-nameB Name of the view definition you w ant to create. When choosing a name, follow these rules:A o Use a name that is unique among all view and table names in the schema.D o Use any valid SQL name (see the User_Supplied_Names HELP topic for more information). 3 Examples5 Example 1: Defining a view based on a single tableD This example shows a view definition that uses three columns from a single table, EMPLOYEES. SQL> CREATE VIEW EMP_NAME cont> AS SELECT cont>  FIRST_NAME," cont> MIDDLE_INITIAL, cont> LAST_NAME cont> FROM EMPLOYEES; SQL> --; SQL> -- Now display the rows from the view just created. SQL> SELECT * FROM EMP_NAME;+ FIRST_NAME MIDDLE_INITIAL LAST_NAME) Alvin A Toliver' Terry D Smith . . .B Example 2: Defining a view that does not allow you to insert or; update rows tha t do not conform to the view's definitionC This example shows a view definition using the WITH CHECK OPTION clause. SQL> CREATE VIEW ADMN_VIEW, cont> AS SELECT * FROM JOB_HISTORY. cont> WHERE DEPARTMENT_CODE = 'ADMN'= cont> WITH CHECK OPTION CONSTRAINT ADMN_VIEW_CONST;0 SQL> -- You cannot insert a row that does not* SQL> -- conform to the view definition. SQL> --A SQL> INSERT INTO ADMN_VIEW (DEPARTMENT_CODE) VALUES ('MBMN');> %RDB-E-IN TEG-FAIL, violation of constraint ADMN_VIEW_CONST- caused operation to fail6 Example 3: Defining a view based on multiple tables8 You can also define a view using more than one table." SQL> CREATE VIEW CURRENT_SALARY cont> AS SELECT cont> E.LAST_NAME, cont> E.FIRST_NAME, cont> E.EMPLOYEE_ID, cont> SH.SALARY_START, cont> SH.SALARY_AMOUNT cont> FROM. cont> SALARY_HISTORY SH, EMPLOYEES E cont> WH ERE. cont> SH.EMPLOYEE_ID = E.EMPLOYEE_ID cont> AND1 cont> SH.SALARY_END IS NULL ;D This example defines a view from the EMPLOYEES and SALARY_HISTORY, tables. It uses the select expression to:C o Choose the columns derived from each table. Because no columnC names are specified before the select expression, the columns/ inherit the names from the source tables.= o Join the tables and limit the view to current salaries.  5 Example 4: Defining a view with local column names SQL> CREATE VIEW EMP_JOB cont> ( CURRENT_ID, cont> CURRENT_NAME, cont> CURRENT_JOB, cont> SUPERVISOR ) cont> AS SELECT cont> E.EMPLOYEE_ID, cont> E.LAST_NAME, cont> J.JOB_TITLE, cont> JH.SUPERVISOR_ID cont> FROM cont> EMPLOYEES E, cont> JOB_HISTORY JH, cont> JOBS J cont> WHERE. cont>  E.EMPLOYEE_ID = JH.EMPLOYEE_ID cont> AND( cont> JH.JOB_CODE = J.JOB_CODE cont> AND) cont> JH.JOB_END IS NULL ; This view definition:8 o Specifies local names for the columns in the view.A o Joins the EMPLOYEES and JOB_HISTORY tables. This join linksC rows in the EMPLOYEES table to rows in the JOB_HISTORY table.D o Joins the JOB_HISTORY and JOBS tables. This join lets the view. contain job titles instead of job codes.C  o Uses the JH.JOB_END IS NULL expression. This clause specifies? that only the current JOB_HISTORY rows, where the JOB_END5 column is null, should be included in the view.< The following query uses the view defined in the previous example: EXEC SQL DECLARE X CURSOR FORD SELECT CURRENT_ID, CURRENT_NAME, CURRENT_JOB, SUPERVISOR FROM EMP_JOB END-EXEC EXEC SQL OPEN X END-EXEC PERFORM WHILE SQLCODE NOT = 0 EXEC SQL FETCH X0 INTO :ID, :NAME, :JOB, :SUPER END-EXEC END PERFORM EXEC SQL CLOSE X END-EXEC6 Example 5: Defining a view with a calculated column= This example shows a view definition that derives a column< through a calculation based on a column in an base table. SQL> CREATE VIEW SS_DEDUCTION cont> ( IDENT, cont> SALARY, cont> SS_AMOUNT  ) cont> AS SELECT cont> E.EMPLOYEE_ID,! cont> SH.SALARY_AMOUNT,( cont> SH.SALARY_AMOUNT * 0.065 cont> FROM. cont> SALARY_HISTORY SH, EMPLOYEES E cont> WHERE. cont> SH.EMPLOYEE_ID = E.EMPLOYEE_ID cont> AND) cont> SH.SALARY_END IS NULL ;A Each time the view column SS_AMOUNT is selected, it computes a@ new value from the SALARY_AMOUNT column of the SALARY_HISTORY table. 7 Example 6:  Defining a view dependent on another view> This example creates a view, DEPENDENT_VIEW, that refers to@ the CURRENT_JOB view in its definition to include current job; information for employees in the engineering department." SQL> CREATE VIEW DEPENDENT_VIEW' cont> AS SELECT * FROM CURRENT_JOB1 cont> WHERE DEPARTMENT_CODE = 'ENG'; ww% 1 DECLARE 2 ALIASC Specifies the name and the source of the database definitions toD be us ed for module compilation, and makes the named alias part ofB the implicit environment of an application. You can name either? a file or a repository path name to be used for the database definitions. 3 Environment+ You can use the DECLARE ALIAS statement:: o Embedded in host language programs to be precompiled o In a context file5 o As part of the DECLARE section in an SQL moduleD The alias that you declare must be different from any other alias s pecified in the module. 3 Format DECLARE -+------------------+-+ +-> scope-options -+ | +-----------------------------+, +-+------------+- ALIAS FOR COMPILETIME -+, +-> -+ |, +-------------------------<---------------+, +-+-> FILENAME --> 'attach-spec ' -+------+, +-> PATHNAME --> ----+ |, +------------------------<----------------+, +-+------------------------------------+--+, +-> lit-or-def-user-authenticatio n --+ |, +------------------------<----------------+# +-+----------------------------+-+# +-> RUNTIME runtime-options -+ |# +-------------------------<------+7 +-+-+--------------------------------------------+-+->5 | +-> database-options ------------------------+ |5 | +-> attach-options --------------------------+ |5 | +-> DEFAULT CHARACTER SET support-char-set --+ |5 | +-> NATIONAL CHARACTER SET support-char-set -+ |5 | +-> DISPLAY CHARACTER SET support-char-set --+ | 5 +----------------------- <-----------------------+! lit-or-def-user-authentication = E --> USER -+-> '' -+--+--------------------------------+-->B +-> DEFAULT -----+ +--> USING -+-> '' --+-+@ +-> DEFAULT ------+  scope-options =  -+-> LOCAL --------------+--> +-> GLOBAL -------------+ +-> EXTERNAL -----------+  attach-spec = * --+----------------+-> ----->  +-> -+ node-spec = + -+-> -+-------------------+-+->) | +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  runtime-options = - -+-> FILENAME --+-> '' +-+--->) | +-> ---+ |) +-> PATHNAME --+-> --+--+) | +-> --+ | ) +-> runtime-string ------------------+  runtime-string = C -+> ' -+> FILENAME -+-+---------------------+> ' +->A | +> PATHNAME ----+ +> literal-user-auth -+ |A +> parameter -------------------------------------------------+  database-options = % --+--> ELN ---------------------+-->" +--> NSDS --------------------+" +--> rdb-options -------------+" +--> VIDA --------------------+" +--> VIDA V1 -----------------+" +--> VIDA V2 -----------------+" +--> VIDA V2N ----------------+" +--> NOVIDA ------------------+" +--> DBIV1 -------------------+" +--> DBIV31 ------------------+" +--> DBIV70 ------------------+  rdb-options =  -+-> RDBVMS --+--> +-> RDB030 --+ +-> RDB031 --+ +-> RDB040 --+ +-> RDB041 --+ +-> RDB042 --+ +-> RDB050 --+ +-> RDB051 --+ +-> RDB060 --+ +-> RDB061 --+ +-> RDB070 --+ +-> RDB071 --+ attach-op tions = H -+-> DBKEY -+-> SCOPE IS -+-> ATTACH -------+-----------------------+->F +-> ROWID -+ +-> TRANSACTION --+ |F +-> MULTISCHEMA IS -+-> ON --+-------------------------------------+F | +-> OFF -+ |F +-> PRESTARTED TRANSACTIONS ARE -+-> ON --+------------------------+F | +-> OFF -+ |F +-+-------+-> RESTRICTED ACCESS ------------------------ -----------+ +-> NO -+ 3 Arguments 4 alias_ALIASA Specifies a name for the attach to the database. Specifying an; alias lets your program refer to more than one database.; You do not have to specify an alias in the DECLARE ALIAS9 statement. The default alias in interactive SQL and inD precompiled programs is RDB$DBHANDLE. In the SQL module language,A the default is the alias specified in the module header. Using? the default alias (either by specif ying it explicitly in the> DECLARE ALIAS statement or by omitting any alias) makes theA database part of the default environment. Specifying a defaultD database means that statements that refer to the default database do not need to use an alias.> If a default alias was already declared and you specify the? default alias in the alias clause (or specify any alias thatB was already declared), you receive an error when you precompile; the program or process it with the SQL  module processor. 4 database-optionsA By default, SQL uses only the database options used to compileB a program as valid options for that program. If you want to useC the program with other supported databases, you can override theB default options by specifying database options in the ATTACH or DECLARE ALIAS statement.> For more information on database options, see the Database_ Options HELP topic. 4 DBKEY_SCOPE Syntax options:5 DBKEY SCO PE IS ATTACH | DBKEY SCOPE IS TRANSACTIOND Controls when the database key of a deleted row can be used again by SQL.? o The default DBKEY SCOPE IS TRANSACTION means that SQL canB reuse the database key of a deleted table row (to refer to aA newly inserted row) as soon as the transaction that deletedA the original row completes with a COMMIT statement. (If theD user who deleted the original row enters a ROLLBACK statement,@ then the database key for that row cannot be used again by SQL.)? During the connection of the user who entered the DECLARE< ALIAS statement, the DBKEY SCOPE IS TRANSACTION clauseA specifies that a database key is guaranteed to refer to the4 same row only within a particular transaction.D o The DBKEY SCOPE IS ATTACH clause means that SQL cannot use theA database key again (to refer to a newly inserted row) untilA all users who have attached with DBKEY SCOPE IS ATTACH have! detached from the database.= It only requires one process to attach with DBKEY SCOPE: IS ATTACH to force all database users to assume this characteristic.D o Oracle Corporation recommends using DBKEY SCOPE IS TRANSACTION? to prevent excessive consumption of storage area space byD overhead space needed to support DBKEY SCOPE IS ATTACH, and to9 prevent performance problems when storing new rows.? During the connection of the user who entered  the DECLAREA ALIAS statement, the DBKEY SCOPE IS ATTACH clause specifies@ that a database key is guaranteed to refer to the same row0 until the user detaches from the database.1 See the DBKEY HELP topic for more information. 4 DEFAULT_CHARACTER_SET> Specifies the default character set of the alias at compileC time. For a list of allowable character set names, see Supported Character Sets. )4 DISPLAY_CHARACTER_SET_support-char-setD Specifies t he character set encoding and characteristics expected, of text strings returned from Oracle Rdb. 4 FILENAMEC A quoted string containing full or partial information needed to access a database.C For an Oracle Rdb database, an attach specification contains the' file specification of the .rdb file.> When you use the FILENAME argument, any changes you make to? database definitions are entered only to the database system= file, not to the repository. If you spe cify FILENAME, yourB application attaches to the database with that file name at run time. If you specify FILENAME:D - During compilation, your application attaches to the specified@ database and reads metadata from the database definitions.= - At run time, your application attaches to the specified database.D For information regarding node-spec and file-spec, see Oracle Rdb Attach Specifications. 4 FOR_COMPILETIMED Optional keyword prov ided for upward compatibility: DECLARE ALIASD specifies the compile-time environment by default. Specifies thatB the alias declared is the source of the database definition for# program compiling and execution. !4 lit-or-def-user-authentication; Specifies the user name and password to enable access to, databases, particularly remote databases.> You can use this clause to explicitly provide user name and7 password information in the DECLARE ALIAS statement. 4  literal-user-authB Specifies the user name and password for the specified databaseA to be accessed at run time. For more information about when to- use this clause, see the ATTACH statement. 4 MULTISCHEMA_IS Syntax options:) MULTISCHEMA IS ON | MULTISCHEMA IS OFFB The MULTISCHEMA IS ON clause enables multischema naming for theA duration of the database attach. The MULTISCHEMA IS OFF clause? disables multischema naming for the duration of the database5  attach. Multischema naming is disabled by default. 4 NATIONAL_CHARACTER_SET? Specifies the national character set of the alias at compileC time. For a list of allowable character set names, see Supported Character Sets. 4 PATHNAME= A full or relative repository path name that specifies the@ source of the database definitions. When you use the PATHNAME= argument, any changes you make to database definitions are? entered in both the repository and the da tabase system file.D Oracle Rdb recommends using the PATHNAME argument if you have theD repository on your system and you plan to use any data definition statements. If you specify PATHNAME:: o During compilation, your application attaches to the@ repository database definition and reads metadata from the? dictionary definitions. SQL extracts the file name of theB Oracle Rdb database from the dictionary and saves it for use at run time.: o At run time, your application attaches to the Oracle= Rdb database file name extracted from the dictionary at compilation. 4 PRESTARTED_TRANSACTIONS_ARE Syntax options:C PRESTARTED TRANSACTIONS ARE ON | PRESTARTED TRANSACTIONS ARE OFF> Specifies whether Oracle Rdb enables or disables prestarted transactions.> Use the PRESTARTED TRANSACTIONS ARE OFF clause only if your< application uses a server process that is attached to theA database for long periods o f time and causes the snapshot fileB to grow excessively. If you use the PRESTARTED TRANSACTIONS ARE@ OFF clause, Oracle Rdb may require additional I/O as each SETC TRANSACTION statement must reserve a transaction sequence number (TSN).? For most applications, Oracle Rdb recommends that you enableB prestarted transactions. The default is PRESTARTED TRANSACTIONSB ARE ON. If you use the PRESTARTED TRANSACTIONS ARE ON clause or@ do not specify the PRESTARTED TRANSACTIONS cl ause, the COMMIT@ or ROLLBACK statement for the previous read/write transaction> automatically reserves the TSN for the next transaction and reduces I/O.B You can use ALTER DATABASE . . . PRESTARTED TRANSACTIONS clause@ to establish a default setting for all applications using theC database. You can also define the RDMS$BIND_PRESTART_TXN logicalA name to define the default setting for prestarted transactions? outside of an application. The PRESTARTED TRANSACTION clause= overrides this logical name and database setting. For moreA information, see the Oracle Rdb7 Guide to Database Performance and Tuning. 4 RESTRICTED_ACCESS Syntax options:+ RESTRICTED ACCESS | NO RESTRICTED ACCESSB Restricts access to the database. This allows you to access theC database but locks out all other users until you disconnect fromC the database. Setting restricted access to the database requires DBADM privileges.8 The default is NO RESTR ICTED ACCESS if not specified. 4 ROWID_SCOPE Syntax options:5 ROWID SCOPE IS ATTACH | ROWID SCOPE IS TRANSACTION@ The ROWID keyword is a synonym for the DBKEY keyword. See the- DBKEY_SCOPE argument for more information. 4 RUNTIMED Specifies the source of the database definitions when the program is run. 4 runtime-stringD A quoted string or parameter that specifies the file name or pathC name of the database to be accessed at run time, and  optionally,C the user name and password of the user accessing the database at run time. 4 scope-options LOCAL | GLOBAL | EXTERNALB Specifies the scope of the alias declaration in precompiled SQL or SQL module language.% The scope-option declarations are:@ o LOCAL declares an alias that is local to procedures in theD module in which it is declared, or local to dynamic statements5 prepared in the module in which it is declared.? SQL attach es to a database with LOCAL scope only when youC execute a procedure in the same module without a session. The@ alias of a database with LOCAL scope pertains only to that module.D If the execution of a procedure in another module has attachedA to the implicit environment and that procedure subsequentlyC calls another procedure that references a local database, SQLB attempts to attach to that local database. If no transaction< is active, SQL adds the local database to the implicitB environment for this module. If a transaction is active, SQL returns an error message.; o GLOBAL declares an alias definition that is global to; procedures in the application. GLOBAL is the default.D o EXTERNAL declares an external reference to a global alias that# is defined in another module.> In single-image applications, the distinction between alias? definitions and alias references is often unimportant. It is? only necessary that each alias have at least one definition.? For this reason, Oracle Rdb has treated all alias references9 (declared with the EXTERNAL keyword) the same as aliasA definitions (declared with the GLOBAL keyword or the default.)= For compatibility with previous versions, this remains the default.< However, applications that share aliases between multiple= images require a distinction between alias definitions andB alias references. All definitions of any aliases shared betweenB multiple OpenVMS images must be defined in one image, generally? the shareable image against which you link the other images.? Oracle Rdb recommends that you distinquish alias definitionsC from alias references in any new source code. Use the GLOBAL (or@ default) scope keyword for alias definitions and the EXTERNAL= keyword for alias references. If you share aliases betweenC multiple OpenVMS images, use the NOEXTERNAL_GLOBALS command lineD qua lifier to override the default and cause SQL to properly treat" alias references as references.D If you use the EXTERNAL_GLOBAL command line qualifier, SQL treatsA aliases declared with the EXTERNAL keyword as GLOBAL. That is,A SQL initializes alias references as well as alias definitions.? If you use the NOEXTERNAL_GLOBAL command line qualifier, SQL= treats aliases declared with the EXTERNAL keyword as aliasD references and does not initialize them. It initializes all oth er aliases.0 The EXTERNAL_GLOBAL qualifier is the default.A The [NO]INITIALIZE_HANDLES command line qualifiers also affectC the initialization of aliases, but they are recommended only for! use in versions prior to V7.0.B See the SQL Module Language and SQL Precompiler help topics for6 more information about the command line qualifiers. 4 USER Syntax options: username | DEFAULTD Specifies the operating system user name that the database system  uses for privilege checking.B You can specify a character string literal for the user name orB you can specify the DEFAULT keyword. The DEFAULT keyword allowsA you to avoid placing the user name in a program's source code.D If you specify the DEFAULT keyword, you pass the user name to theD program by using a command line qualifier when you compile an SQLA module or precompiled program. You use the USERNAME qualifier. 4 USING- Syntax options: USING 'password ' | DEFAULTC Specifies the user's password for the user name specified in the USER clause.A You can specify a character string literal for the PASSWORD orB you can specify the DEFAULT keyword. The DEFAULT keyword allowsA you to avoid placing the user name in a program's source code.C If you specify the DEFAULT keyword, you pass the password to theD program by using a command line qualifier when you compile an SQLA module or precompiled program. You use the PASSWORD q ualifier. 3 Examples@ Example 1: Specifying a database and an alias in embedded SQL; This statement declares the database defined by the file@ specification personnel. The precompiler uses this definitionB when compiling the program and SQL uses the file personnel when@ the program runs. This name may be a logical name or the name% portion of the file personnel.rdb. EXEC SQL9 DECLARE PERS_ALIAS ALIAS FOR FILENAME personnel END-EXEC: Example 2 : Specifying a database with restricted accessD This statement is the same as Example 1, but specifies restricted access to the database. EXEC SQL9 DECLARE PERS_ALIAS ALIAS FOR FILENAME personnel RESTRICTED ACCESS END-EXEC4 Example 3: Specifying the DECLARE ALIAS statement@ This portion of an application program declares the databases@ MIA1 and MIA_CHAR_SET. The precompiler uses the MIA1 databaseD when compiling the program and SQL uses the M IA_CHAR_SET database when the program runs. EXEC SQL DECLARE ALIAS" COMPILETIME FILENAME MIA1- RUNTIME FILENAME MIA_CHAR_SET/ DEFAULT CHARACTER SET DEC_KANJI- NATIONAL CHARACTER SET KANJI;8 Example 4: Specifying the DEFAULT user authentication@ The following example shows how to use the DEFAULT clause for+ user name and password in an SQL module:" MODULE TEST_DECLARE DIALECT  SQL99 LANGUAGE C PARAMETER COLONS" ALIAS RDB$DBHANDLE: -------------------------------------------------------: -----------------------declarations--------------------6 DECLARE ALIAS COMPILETIME FILENAME mf_personnel! USER DEFAULT" USING DEFAULT RUNTIME :run_time_spec . . .B You pass the compile-time user name and password to the program@ by using command li ne qualifiers. For example, to compile the* program use the following command line:4 $ SQLMOD TESTDEC /USER=heleng /PASS= helenspasswd= At run time, the host language program can prompt the run-? time user to specify only the file specification or the file@ specification and the user name and password at run time. The7 host language program can build the run time string.? For example, if the host language program uses only the fileA specification, the value of the var iable passed to the program can be the following: FILENAME "mf_personnel"A If the host language program uses the file specification, user= name and password, the value of the variable passed to the program can be the following:< FILENAME "mf_personnel 'USER heleng' USING 'mypassword' "> You must enclose the string in quotation marks; whether you@ use single (') or double quotation marks (") depends upon the programming language.= If you use the following  DECLARE ALIAS statement, the host@ language program can only prompt the run-time user to specify the file name.6 DECLARE ALIAS COMPILETIME FILENAME mf_personnel! USER DEFAULT" USING DEFAULT RUNTIME FILENAME :foo 2 CURSOR Declares a cursor.< With cursors, the conditions that define the result table? are specified by the select expression in the DECLARE CURSORC statement. SQL creates the result table when it e xecutes an OPENA statement. The result table for a cursor exists until a CLOSE,D COMMIT, or ROLLBACK statement executes, the program stops, or youA exit from interactive SQL. However, the result table can existB across transactions if you define a holdable cursor. A holdable@ cursor can remain open and retain its position when a new SQL transaction begins.? Host language programs require cursors because programs mustA perform operations one row or element at a time, and  thereforeD may execute statements more than once to process an entire result table or list.= The scope of a cursor describes the portion of a module orB program where the cursor is valid. The extent of a cursor tellsA how long it is valid. All cursors in SQL have the scope of the entire module.> You can create three classes of cursors, depending on which$ DECLARE CURSOR statement you use:D o The DECLARE CURSOR statement is executed immediately. A cursorD that you create with this statement, sometimes called a staticD cursor, exists only within the scope and extent of its module.A Both the cursor name and SELECT statement are known to your" application at compile time.C o The dynamic DECLARE CURSOR statement is executed immediately.> The cursor name is known at compile time, and the SELECTA statement is determined at run time. You must supply a name? for the SELECT statement that is generated at run time. A ? dynamic cursor exists within the scope of its module, but? its extent is the entire run of the program or image. ForA information about the dynamic DECLARE CURSOR statement, see+ the DECLARE Dynamic_CURSOR statement.; o The extended dynamic DECLARE CURSOR statement must beB precompiled or used as part of a procedure in an SQL module.@ You must supply parameters for the cursor name and for theD identifier of a prepared SELECT statement that is gene rated atB run time. An extended dynamic cursor exists within the scope@ and extent of the entire module. For information about the@ extended dynamic DECLARE CURSOR statement, see the DECLARE( Extended_Dynamic_CURSOR statement.: Within each class, you can create two types of cursors:< o Table cursors are a method that SQL provides to access= individual rows of a result table. (A result table is a? temporary collection of columns and rows from one or more  tables or views.); o List cursors are a method that SQL provides to access$ individual elements in a list.B A list is an ordered collection of elements, or segments, ofD the data type LIST OF BYTE VARYING. For more information aboutA the LIST OF BYTE VARYING data type, see the Data_Types HELP topic.A List cursors enable users to scan through a very large dataD structure from within a language that does not provide support? for obje cts of such size. Because lists exist as a set of@ elements within a row of a table, a list cursor must referA to a table cursor because the table cursor provides the row context.C Cursors are further divided according to the modes of operations8 that they can perform. Table cursors have four modes:A o Update cursors are the default table cursor. Rows are first@ read and locked for SHARED READ or PROTECTED READ and thenA later, when an UPDATE is perform ed, the rows are locked for> EXCLUSIVE access. If the table is reserved for EXCLUSIVE9 access, the subsequent update lock is not required.B o Read-only cursors can be used to access row information from= a result table whenever you do not intend to update the@ database. For example, you could use a read-only cursor to3 fetch row and column information for display.D o Insert-only cursors position themselves on a row that has just= been inserted so tha t you can load lists into that row.@ o Update-only cursors are used whenever you intend to modify@ many rows in the result table. When the UPDATE ONLY option> is used, SQL uses a more aggressive lock mode that locks> the rows for EXCLUSIVE access when first read. This modeC avoids a lock promotion from SHARED READ or PROTECTED READ toC EXCLUSIVE access. It may, therefore, avoid deadlocks normally, encountered during the lock promotion.  List cursor s have two modes:D o Read-only cursors are the default list cursor. They enable youA to read existing lists. By adding the SCROLL keyword to theC read-only list cursor clause, you enable Oracle Rdb to scroll? forward and backward through the list segments as needed.@ o Insert-only cursors enable you to insert data into a list.= The following table lists the classes, types, and modes of cursors that SQL provides.1 Table 1-2 Classes, Types, and Modes of  Cursors; Dynamic Extended Dynamic: DECLARE CURSOR DECLARE CURSOR DECLARE CURSOR8 Table List Table List Table List; Insert- Insert- Insert- Insert- Insert- Insert-8 only only only only only only9 Read- Read- Read- Read- Read- Read-8 only only only only only only1 Update- Update- Update-. only only only? For example, you must declare an insert-only table cursor toA insert data into a table. If the table includes lists, use the> table cursor to position on the correct row, and declare an? insert-only list cursor to load the lists into that row. ForC details about using cursors to load data into your database, see the INSERT statement.C To process the rows of a result table formed by a DECLARE CURSORD statement, you must use the OPEN stat ement to position the cursorA before the first row. Subsequent FETCH statements retrieve theD values of each row for display on the terminal or processing in aC program. (You must close the cursor before you attempt to reopenC it.)You can similarly process the elements of a list by using anA OPEN statement to position the cursor before the first elementD in the list and repeating FETCH statements to retrieve successive elements. 3 Environment, You can use the DECLA RE CURSOR statement: o In interactive SQL: o Embedded in host language programs to be precompiled5 o As part of the DECLARE section in an SQL module o In a context file 3 Format, DECLARE --------------------+, +-----------------------------------------+? +-+-+----------------+--> TABLE CURSOR ---+----------------+-+? | +-> INSERT ONLY -+ +-> with-clause -+ |? | +-> READ ONLY ---+ | ? | +-> UPDATE ONLY -+ |? | +--------------------------------------------------------+9 | +-> FOR -> select-expr --+----------------------+--+9 | +-> for-update-clause -+ |9 | +---------------------------------------------+B | +-+--------------------+----------------------------+-->? | +-> optimize-clause -+ |? ++---------------++---------+-+-> LIST CURSOR FOR SELEC T + |? +> READ ONLY ---++> SCROLL + | | |? +> INSERT ONLY --------------+ | |? +--------------------------------------------------------+ |? +> WHERE CURRENT OF -----+  with-clause = 8 ---> WITH --> HOLD -+-------------------------------+->6 +-> PRESERVE --+-> ON COMMIT ---+6 +-> ON ROLLBACK -+6  +-> ALL ---------+6 +-> NONE --------+  select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+  for-update-clause = . --> FOR UPDATE -+-------------------------+->, +-+-> OF -+-+* +-------- , <---------+  optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> US ING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  3 Arguments 4 cursor-nameC Specifies the name of the cursor you want to declare. Use a nameC t hat is unique among all the cursor names in the module. Use anyC valid SQL name. See the User_Supplied_Names HELP topic. for more& information on user-supplied names.A You can use a parameter to specify the cursor name at run timeC in an extended dynamic DECLARE CURSOR statement. See the DECLARE@ Extended_Dynamic_CURSOR statement for more information on the- extended dynamic DECLARE CURSOR statement. 4 FOR_select_exprC A select expression that defines which column s and rows of which@ tables SQL includes in the cursor. See the Select_Expressions9 HELP topic for more information on select expressions. 4 FOR_UPDATE_OFC Specifies the columns in a cursor that you or your program mightA later modify with an UPDATE statement. The column names in the@ FOR UPDATE clause must belong to a table or view named in the FROM clause.B You do not have to specify the FOR UPDATE clause of the DECLARED CURSOR statement to later modify rows using the UPDATE statement:= o If you do specify a FOR UPDATE clause and later specifyD columns in the UPDATE statement that are not in the FOR UPDATE@ clause, SQL issues a warning message and proceeds with the update modifications.? o If you do not specify a FOR UPDATE clause, you can updateC any column using the UPDATE statement. SQL does not issue any messages.A The FOR UPDATE OF clause in a SELECT statement provides UPDATE: ONLY CURSOR sem antics by locking all the rows selected. 4 INSERT_ONLY? Specifies that a new list or a new row is created or opened.B If you specify a list cursor but do not specify the INSERT ONLY; clause, SQL declares a read-only list cursor by default.C If you specify a table cursor but do not specify the INSERT ONLY4 clause, SQL declares an update cursor by default.D When you specify an insert-only cursor, all the value expressions= in the select list must be read/write. Wh en you declare anB insert-only table cursor to insert lists, you must specify both9 table column and list column names in the FROM clause.A For more information about how to use insert-only cursors, see the INSERT statement. 4 LIST_CURSORD Specifies a cursor that is used to manipulate columns of the data type LIST OF BYTE VARYING. 4 OPTIMIZE_AS_query_name= Assigns a name to the query. You must define the SET FLAGSA 'STRATEGY' statement to see the a ccess methods used to produce the results of the query. 4 OPTIMIZE_FOR< The OPTIMIZE FOR clause specifies the preferred optimizer@ strategy for statements that specify a select expression. The# following options are available: o FAST FIRSTB A query optimized for FAST FIRST returns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optim ization. A good candidate for FAST FIRST> optimization is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST optimization.C If optimization strategy is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records in D the query, and performs updates or writes a report, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization.A The following examples illustrate the DECLARE CURSOR syntax0 for setting a preferred optimization mode:% SQL> DECLARE TEMP1 TABLE CURSOR cont> FOR cont> SELECT * cont> FROM EMPLOYEES, cont> WHERE EMPLOYEE_ID > '00400'% cont> OPTIMIZE FOR FAST FIRST; SQL> --% SQL> DECLARE TEMP2 TABLE CURSOR cont> FOR+ cont> SELECT LAST_NAME, FIRST_NAME cont> FROM EMPLOYEES% cont> ORDER BY LAST_NAME% cont> OPTIMIZE FOR TOTAL TIME; o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly: valuable for tables that use the strict partitioning functionality. 4 OPTIMIZE_USING_outline_name@ Explicitly names the query outline to be used with the select C expression even if the outline IDs for the select expression and! for the outline are different.D See the CREATE OUTLINE statement for more information on creating an outline. 4 OPTIMIZE_WITHB Selects one of three optimization controls: DEFAULT (as used by@ previous versions of Oracle Rdb), AGGRESSIVE (assumes smaller= numbers of rows will be selected), and SAMPLED (which uses= literals in the query to perform preliminary estimation on indices). 4  preserve-clause Syntax options: PRESERVE ON COMMIT PRESERVE ON ROLLBACK PRESERVE ALL PRESERVE NONE( Specifies when a cursor remains open. o PRESERVE ON COMMIT@ On commit, all cursors close except those defined with theC WITH HOLD PRESERVE ON COMMIT syntax. On rollback, all cursorsB close including those defined with the WITH HOLD PRESERVE ON COMMIT syntax.A This is the same as specifying the WITH HOLD clause without  any preserve options. o PRESERVE ON ROLLBACKB On rollback, all cursors close except those defined with theC WITH HOLD PRESERVE ON ROLLBACK syntax. On commit, all cursorsB close including those defined with the WITH HOLD PRESERVE ON ROLLBACK syntax. o PRESERVE ALL? All cursors remain open after commit or rollback. Cursors> close with the CLOSE statement or when the session ends. o PRESERVE NONE: All cursors close after a  CLOSE, COMMIT, or ROLLBACK> statement, when the program stops, or when you exit from interactive SQL.@ This is the same as not specifying the WITH HOLD clause at all. 4 READ_ONLY@ Specifies that the cursor is not used to update the database. 4 SCROLL> Specifies that Oracle Rdb can read the items in a list fromA either direction (up or down) or at random. The SCROLL keyword; must be used if the following fetch options are desired: o  NEXT o PRIOR o FIRST o LAST o RELATIVE o ABSOLUTED If SCROLL is not specified, the default for FETCH is NEXT. SCROLL& is only supported for LIST cursors. 4 TABLE_CURSORC Specifies that the cursor you want to declare is a table cursor,B rather than a list cursor. If you do not specify a cursor type,* SQL declares a table cursor by default. 4 UPDATE_ONLY< Specifies that the cursor is used to update the database.@ Use an  update-only cursor when you plan to update most of the> rows you are fetching. The update-only cursor causes Oracle@ Rdb to apply more restrictive locking during the initial readA operation, so that locks do not need to be upgraded later fromA READ to exclusive WRITE. This reduces the total number of lock7 requests per query, and may help to avoid deadlocks.C Use update-only table cursors to modify table rows. SQL does not" allow update-only list cursors. 4 WHERE_CUR RENT_OF? Specifies the table cursor that provides the row context forB the list cursor. The table cursor named must be defined using a DECLARE CURSOR statement. 4 WITH_HOLDB Indicates that the cursor remain open and maintain its position@ after the transaction ends. This is called a holdable cursor. 3 Examples9 Example 1: Declaring a table cursor in interactive SQLA The following example declares a cursor named SALARY_INFO. The> result table for SALA RY_INFO contains the names and current4 salaries of employees and is sorted by last name. SQL> --& SQL> DECLARE SALARY_INFO CURSOR FOR< cont> SELECT E.FIRST_NAME, E.LAST_NAME, S.SALARY_AMOUNT/ cont> FROM EMPLOYEES E, SALARY_HISTORY S/ cont> WHERE E.EMPLOYEE_ID = S.EMPLOYEE_ID cont> AND& cont> S.SALARY_END IS NULL cont> ORDER BY" cont> E.LAST_NAME ASC; SQL> --7 SQL> -- Use an OPEN statement to open the cursor and2 SQL > -- position it before the first row of the SQL> -- result table: SQL> OPEN SALARY_INFO; SQL> --7 SQL> -- Finally, use two FETCH statements to see the( SQL> -- first two rows of the cursor: SQL> FETCH SALARY_INFO;3 E.FIRST_NAME E.LAST_NAME S.SALARY_AMOUNT3 Louie Ames $26,743.00 SQL> FETCH SALARY_INFO;3 E.FIRST_NAME E.LAST_NAME S.SALARY_AMOUNT3 Leslie Andriola $50,424.005 Example 2: Declar ing a table cursor in a C programD This simple program uses embedded DECLARE CURSOR, OPEN, and FETCH@ statements to retrieve and print the names and departments of managers. #include  void main () { int SQLCODE; char FNAME[15]; char LNAME[15]; char DNAME[31]; /* Declare the cursor: */ exec sql! DECLARE MANAGER CURSOR FOR> SELECT E.FIRST_NAME, E.LAST_NAME, D.DEPARTMENT_NAME* FROM EMPLOYEES E, DEPARTMENTS D / WHERE E.EMPLOYEE_ID = D.MANAGER_ID ; /* Open the cursor: */ exec sql OPEN MANAGER;8 /* Start a loop to process the rows of the cursor: */ for (;;) {) /* Retrieve the rows of the cursor7 and put the value in host language variables: */ exec sql5 FETCH MANAGER INTO :FNAME, :LNAME, :DNAME; if (SQLCODE != 0) break;/ /* Print the values in the variables: */2 printf ("%s %s %s\n", FNAME, LNAME, D NAME); } /* Close the cursor: */ exec sql CLOSE MANAGER; }C Example 3: Using table and list cursors to retrieve list data in interactive SQL< The following example declares a table and list cursor to retrieve list information:6 SQL> DECLARE TBLCURSOR INSERT ONLY TABLE CURSOR FOR1 cont> SELECT EMPLOYEE_ID, RESUME FROM RESUMES;I SQL> DECLARE LSTCURSOR INSERT ONLY LIST CURSOR FOR SELECT RESUME WHERE CURRENT OF TBLCURSOR; SQL> OPEN T BLCURSOR;D SQL> INSERT INTO CURSOR TBLCURSOR (EMPLOYEE_ID) VALUES ('00164'); 1 row inserted SQL> OPEN LSTCURSOR;M SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('This is the resume for 00164');; SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('Boston, MA');C SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('Oracle Corporation'); SQL> CLOSE LSTCURSOR; SQL> CLOSE TBLCURSOR; SQL> COMMIT;9 SQL> DECLARE TBLCURSOR2 CURSOR FOR SELECT EMPLOYEE_ID, cont> RESUME FROM RESUMES;> S QL> DECLARE LSTCURSOR2 LIST CURSOR FOR SELECT RESUME WHERE CURRENT OF TBLCURSOR2; SQL> OPEN TBLCURSOR2; SQL> FETCH TBLCURSOR2; 00164 SQL> OPEN LSTCURSOR2; SQL> FETCH LSTCURSOR2; RESUME This is the resume for 00164 SQL> FETCH LSTCURSOR2; RESUME Boston, MA SQL> FETCH LSTCURSOR2; RESUME Oracle Corporation SQL> FETCH LSTCURSOR2; RESUME@ %RDB-E-STREAM_EOF, attempt to fetch past end of record stream SQL> CLOSE LSTCURSOR2;  SQL> SELECT * FROM RESUMES; EMPLOYEE_ID RESUME% 00164 1:701:2 1 row selected SQL> CLOSE TBLCURSOR2; SQL> COMMIT;: Example 4: Using the scroll attribute for a list cursorB The following example declares a table and read-only scrollableA list cursor to retrieve list information by scrolling back and& forth between segments of the list: SQL> DECLARE CURSOR_ONE cont> TABLE CURSOR FOR4 cont> (SELECT EMPLOYEE_ID,RESUME  FROM RESUMES); SQL> -- SQL> DECLARE CURSOR_TWO cont> READ ONLY cont> SCROLL cont> LIST CURSOR cont> FOR SELECT RESUME( cont> WHERE CURRENT OF CURSOR_ONE; ) Example 5: Declaring a holdable cursor@ SQL> -- Declare a holdable cursor that remains open on COMMIT SQL> -- SQL> DECLARE curs1 CURSOR) cont> WITH HOLD PRESERVE ON COMMIT1 cont> FOR SELECT e.first_name, e.last_name! cont> FROM employees e& cont>  ORDER BY e.last_name; SQL> OPEN curs1; SQL> FETCH curs1; FIRST_NAME LAST_NAME Louie Ames SQL> FETCH curs1; FIRST_NAME LAST_NAME Leslie Andriola SQL> COMMIT; SQL> FETCH curs1; FIRST_NAME LAST_NAME Joseph Babbin SQL> FETCH curs1; FIRST_NAME LAST_NAME Dean Bartlett SQL> ROLLBACK; SQL> FETCH curs1;/ %SQL-F-CURNOTOPE, Cursor CURS1 is not opened SQL> --C SQL> -- Declare another hol dable cursor that remains open always SQL> -- SQL> DECLARE curs2 CURSOR# cont> WITH HOLD PRESERVE ALL1 cont> FOR SELECT e.first_name, e.last_name! cont> FROM employees e& cont> ORDER BY e.last_name; SQL> OPEN curs2; SQL> FETCH curs2; FIRST_NAME LAST_NAME Louie Ames SQL> FETCH curs2; FIRST_NAME LAST_NAME Leslie Andriola SQL> COMMIT; SQL> FETCH curs2; FIRST_NAME LAST_NAME Joseph  Babbin SQL> FETCH curs2; FIRST_NAME LAST_NAME Dean Bartlett SQL> ROLLBACK; SQL> FETCH curs2; FIRST_NAME LAST_NAME Wes Bartlett 2 Dynamic_CURSORB Declares a cursor where the SELECT statement is supplied at run time in a parameter.< Refer to the DECLARE CURSOR for a detailed description of? statement elements that apply to both dynamic and nondynamic DECLARE CURSOR statements. 3 Environment4 You can use t he dynamic DECLARE CURSOR statement:: o Embedded in host language programs to be precompiled? o As part of the DECLARE statement section in an SQL module 3 Format. DECLARE ----------------------+. +-------------------------------------------+< +-+-+----------------+-> TABLE CURSOR -+----------------+-+< | +-> INSERT ONLY -+ +-> with-clause -+ |< | +-> READ ONLY ---+ |< | +-> UPDATE ONLY -+  |< | +-----------------------------------------------------+= | +-> FOR -> ------------------------+-->: ++--------------++----------++-> LIST CURSOR ------+ |: +-> READ ONLY -++> SCROLL -+| | |: +-> INSERT ONLY ------------+ | |: +-------------------------------------------------+ |: +-> FOR -> -------------------------+  with-clause = 8 ---> WITH --> HOLD -+-- -----------------------------+->6 +-> PRESERVE --+-> ON COMMIT ---+6 +-> ON ROLLBACK -+6 +-> ALL ---------+6 +-> NONE --------+  3 Arguments 4 cursor-nameA The name of the cursor you want to declare. Use a name that isA unique among all the cursor names in the module. Use any valid= SQL name. See the User_Supplied_Names HELP topic for more  information on identifiers. 4 FOR_statement_name= A name that identifies a prepared SELECT statement that is generated at run time. 4 INSERT_ONLY? Specifies that a new list or a new row is created or opened. 4 LIST_CURSORC Specifies that you are declaring a cursor to access the elements in a list. 4 preserve-clause Syntax options: PRESERVE ON COMMIT PRESERVE ON ROLLBACK PRESERVE ALL PRESERVE NONE( Specifies when a cursor remains open. o PRESERVE ON COMMIT@ On commit, all cursors close except those defined with theC WITH HOLD PRESERVE ON COMMIT syntax. On rollback, all cursorsB close including those defined with the WITH HOLD PRESERVE ON COMMIT syntax.A This is the same as specifying the WITH HOLD clause without any preserve options. o PRESERVE ON ROLLBACKB On rollback, all cursors close except those defined with theC WI TH HOLD PRESERVE ON ROLLBACK syntax. On commit, all cursorsB close including those defined with the WITH HOLD PRESERVE ON ROLLBACK syntax. o PRESERVE ALL? All cursors remain open after commit or rollback. Cursors> close with the CLOSE statement or when the session ends. o PRESERVE NONE: All cursors close after a CLOSE, COMMIT, or ROLLBACK> statement, when the program stops, or when you exit from interactive SQL.@ This is the same as not specifying the WITH HOLD clause at all. 4 READ_ONLY@ Specifies that the cursor is not used to update the database. 4 SCROLL> Specifies that Oracle Rdb can read the items in a list from. either direction (up or down) or at random. 4 TABLE_CURSORD Specifies that you are declaring a cursor to access the rows in a table. 4 UPDATE_ONLY< Specifies that the cursor is used to update the database. 4 WITH_HOLDB Indicates t hat the cursor remain open and maintain its position@ after the transaction ends. This is called a holdable cursor. 3 Examples4 Example 1: Using a parameter for a statement name . . .L * This program prepares a statement for dynamic execution from the stringI * passed to it, and uses a dynamic cursor to fetch a row from a table. * */ #include  #include  struct SQLDA_STRUCT { char SQLDAID[8];  int SQLDABC; short SQLN; short SQLD; struct { short SQLTYPE; short SQLLEN; char *SQLDATA; short *SQLIND;! short SQLNAME_LEN; char SQLNAME[30]; } SQLVAR[]; } *SQLDA; main() { /* * General purpose locals */ int i; long sqlcode; char command_string[256]; /*!  * Allocate SQLDA structures. */ SQLDA = malloc(500); SQLDA->SQLN = 20;. /* Get the SELECT statement at run time. */, printf("\n Enter a SELECT statement.\n");= printf("\n Do not end the statement with a semicolon.\n"); gets(command_string);& /* Prepare the SELECT statement. */1 PREP_STMT( &sqlcode, &command_string, SQLDA ); if (sqlcode != 0) goto err; /* Open the cursor. */ OPEN_CURSOR( &sqlcode ); if (sqlcode != 0) goto  err; /* Allocate memory. */$ for (i=0; i < SQLDA->SQLD; i++) {D SQLDA->SQLVAR[i].SQLDATA = malloc( SQLDA->SQLVAR[i].SQLLEN );. SQLDA->SQLVAR[i].SQLIND = malloc( 2 ); } /* Fetch a row. */# FETCH_CURSOR( &sqlcode, SQLDA ); if (sqlcode != 0) goto err;H /* Use the SQLDA to determine the data type of each column in the rowJ and print the column. For simplicity, test for only two data types. CHAR and INT. */$ for (i=0; i < SQLDA-> SQLD; i++) {* switch (SQLDA->SQLVAR[i].SQLTYPE) {* case SQLDA_CHAR; /* Character */4 printf( "%s", SQLDA->SQLVAR[i].SQLDATA ); break;* case SQLDA_INTEGER: /* Integer */4 printf( "%d", SQLDA->SQLVAR[i].SQLDATA ); break; default:8 printf( "Some other datatype encountered\n"); } } /* Close the cursor. */ CLOSE_CURSOR( &sqlcode ); ROLLBACK(&sqlcode ); return; .  . . }> Example 2: SQL module file that the preceding program calls8 -- This program uses dynamic cursors to fetch a row. -- --! MODULE C_MOD_DYN_CURS LANGUAGE C AUTHORIZATION RDB$DBHANDLE' DECLARE ALIAS FOR FILENAME personnelD -- Declare the dynamic cursor. Use a statement name to identify a -- prepared SELECT statement.' DECLARE CURSOR1 CURSOR FOR STMT_NAME@ -- Prepare the statement from a statement entered at  run timeA -- and specify that SQL write information about the number and2 -- data type of select list items to the SQLDA. PROCEDURE PREP_STMT SQLCODE! COMMAND_STRING CHAR (256) SQLDA;F PREPARE STMT_NAME SELECT LIST INTO SQLDA FROM COMMAND_STRING; PROCEDURE OPEN_CURSOR SQLCODE; OPEN CURSOR1; PROCEDURE FETCH_CURSOR SQLCODE SQLDA;, FETCH CURSOR1 USING DESCRIPTOR SQLDA; PROCEDURE CLOSE_CURSOR  SQLCODE; CLOSE CURSOR1; PROCEDURE ROLLBACK SQLCODE; ROLLBACK; 2 Extended_Dynamic_CURSORC Declares an extended dynamic cursor. An extended dynamic DECLAREC CURSOR statement is a DECLARE CURSOR statement in which both theB cursor name and the SELECT statement are supplied in parameters at run time.A See the DECLARE CURSOR for a detailed description of statementD elements that apply to both dynamic and nondynamic DECLARE CURS OR statements. 3 Environment= You can use the extended dynamic DECLARE CURSOR statement:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 3 Format1 DECLARE ---------------+1 +----------------------------------------------+< ++---+----------------+-> TABLE CURSOR -+----------------++< | +-> INSERT ONLY -+ +-> with-clause -+|< | +-> READ ONLY ---+ |< | +-> UPDATE ONLY -+ |< | +------------------------------------------------------+@ | +--> FOR ---> ------------+------->8 +-+--------------++----------++-> LIST CURSOR FOR -+ |8 +-> READ ONLY -++> SCROLL -+| | |8 +-> INSERT ONLY ------------+ | |8 +--------------------------------------------------+ |8 +-> ------------------------+ !  with-clause = 8 ---> WITH --> HOLD -+-------------------------------+->6 +-> PRESERVE --+-> ON COMMIT ---+6 +-> ON ROLLBACK -+6 +-> ALL ---------+6 +-> NONE --------+  3 Arguments 4 cursor-name-parameter= Contains the name of the cursor you want to declare. Use a> character string parameter to hold the cursor name that the program" supplies at run time. 4 FOR_statement_id_parameterB A parameter that contains an integer that identifies a preparedC SELECT statement. Use an integer parameter to hold the statementB identifier that SQL generates and assigns to the parameter when$ SQL executes a PREPARE statement. 4 INSERT_ONLY? Specifies that a new list or a new row is created or opened. 4 LIST_CURSOR_FORC Specifies that you are declaring a cursor to access the elements in a li# st. 4 preserve-clause Syntax options: PRESERVE ON COMMIT PRESERVE ON ROLLBACK PRESERVE ALL PRESERVE NONE( Specifies when a cursor remains open. o PRESERVE ON COMMIT@ On commit, all cursors close except those defined with theC WITH HOLD PRESERVE ON COMMIT syntax. On rollback, all cursorsB close including those defined with the WITH HOLD PRESERVE ON COMMIT syntax.A This is the same as specifying the WITH HOLD c$ lause without any preserve options. o PRESERVE ON ROLLBACKB On rollback, all cursors close except those defined with theC WITH HOLD PRESERVE ON ROLLBACK syntax. On commit, all cursorsB close including those defined with the WITH HOLD PRESERVE ON ROLLBACK syntax. o PRESERVE ALL? All cursors remain open after commit or rollback. Cursors> close with the CLOSE statement or when the session ends. o PRESERVE NONE: All cursors % close after a close, commit, or rollback> statement, when the program stops, or when you exit from interactive SQL.@ This is the same as not specifying the WITH HOLD clause at all. 4 READ_ONLY@ Specifies that the cursor is not used to update the database. 4 SCROLL> Specifies that Oracle Rdb can read the items in a list from. either direction (up or down) or at random. 4 TABLE_CURSOR_FORD Specifies that you are declaring a cursor t& o access the rows in a table. 4 UPDATE_ONLY< Specifies that the cursor is used to update the database. 4 WITH_HOLDB Indicates that the cursor remain open and maintain its position@ after the transaction ends. This is called a holdable cursor. 3 Example= Example 1: Using parameters for statement and cursor namesD The following example shows two procedures from the online sampleC program SQL$MULTI_STMT_DYN.SQLADA. These procedures show the use0 o' f parameters for statement and cursor names. . . .O -- This procedure prepares a statement for dynamic execution from the stringH -- passed to it. This procedure can prepare any number of statementsI -- because the statement is passed to it as the parameter, cur_procid. procedure PREPARE_SQL is5 CUR_CURSOR : string(1..31) := (others => ' ');! CUR_PROCID : integer := 0;5 CUR_STMT : string(1..1024) := (others => ' '); beginO -- Allocate s ( eparate SQLDAs for parameter markers (sqlda_in) and select listO -- items (sqlda_out). Assign the value of the constant MAXPARMS (set in theL -- declarations section) to the SQLN field of both SQLDA structures. SQLN5 -- specifies to SQL the maximum size of the SQLDA. sqlda_in := new sqlda_record; sqlda_in.sqln := maxparms;! sqlda_out := new sqlda_record; sqlda_out.sqln := maxparms;D -- Assign the SQL statement that was constructed in the procedure- -- CONSTRUCT_ ) SQL to the variable cur_stmt. cur_stmt := sql_stmt;N -- Use the PREPARE...SELECT LIST statement to prepare the dynamic statementK -- and write information about any select list items in it to sqlda_out.M -- It prepares a statement for dynamic execution from the string passed toK -- it. It also writes information about the number and data type of anyG -- select list items in the statement to an SQLDA (specifically, the! -- sqlda_out SQLDA specified). --O -- Note * that the PREPARE statement could have prepared the statement withoutP -- writing to an SQLDA. Instead, a separate DESCRIBE...SELECT LIST statementM -- would have written information about any select list items to an SQLDA.K EXEC SQL PREPARE :cur_procid SELECT LIST INTO :sqlda_out FROM :cur_stmt; case sqlca.sqlcode is when sql_success => null;) when others => raise syntax_error; end case;I -- Use the DESCRIBE...MARKERS statement to write information about any + M -- parameter markers in the dynamic statement to sqlda_in. This statementF -- writes information to an SQLDA (specifically, the sqlda_in SQLDAK -- specified) about the number and data type of any parameter markers inK -- the prepared dynamic statement. Note that SELECT statements may also -- have parameter markers.7 EXEC SQL DESCRIBE :cur_procid MARKERS INTO sqlda_in; case sqlca.sqlcode is when sql_success => null;) when others => raise syntax_error; , end case;J -- If the operation is "Read," create a unique name for the cursor nameI -- so that the program can pass the cursor name to the dynamic DECLARE -- CURSOR statement. if cur_op(1) = 'R' then cur_cursor(1) := 'C';B cur_cursor(2..name_strlng) := cur_name(1..name_strlng - 1);! -- Declare the dynamic cursor.; EXEC SQL DECLARE :cur_cursor CURSOR FOR :cur_procid; case sqlca.sqlcode is$ when sql_success => null;- whe- n others => raise syntax_error; end case; end if;* number_of_procs := number_of_procs + 1;/ sqlda_in_array(number_of_procs) := sqlda_in;1 sqlda_out_array(number_of_procs) := sqlda_out;0 procedure_names(number_of_procs) := cur_name;0 procedure_ids(number_of_procs) := cur_procid; if cur_op(1) = 'R' then3 cursor_names(number_of_procs) := cur_cursor; end if; exception when syntax_error =>A sql_get_error_text(get_error_buffer,get_err. or_length);D put_line(get_error_buffer(1..integer(get_error_length)));- put("Press RETURN to continue. ");2 get_line(terminal,release_screen,last); new_line; end PREPARE_SQL; . . .( begin -- procedure body DISPLAY_DATAC -- Before displaying any data, allocate buffers to hold the data -- returned by SQL. -- allocate_buffers;A -- Allocate and assign SQLDAs for the requested SQL procedure. -- sqlda_i / n := new sqlda_record;* sqlda_in := sqlda_in_array(stmt_index);! sqlda_out := new sqlda_record;, sqlda_out := sqlda_out_array(stmt_index);* cur_cursor := cursor_names(stmt_index);C -- Open the previously declared cursor. The statement specifiesJ -- an SQLDA (specifically, sqlda_in) as the source of addresses for any9 -- parameter markers in the cursor's SELECT statement. --7 EXEC SQL OPEN :cur_cursor USING DESCRIPTOR sqlda_in; case sqlca.sqlcode is when sq0 l_success => null;- when others => raise unexpected_error; end case;J -- Fetch the first row from the result table. This statement fetches aI -- row from the opened cursor and writes it to the addresses specified, -- in an SQLDA (specifically, sqlda_out). --9 EXEC SQL FETCH :cur_cursor USING DESCRIPTOR sqlda_out; case sqlca.sqlcode is5 -- Check to see if the result table has any rows. when sql_success => null; when stream_eof =>) p1 ut_line("No records found."); new_line;- when others => raise unexpected_error; end case;K -- Set up a loop to display the first row, then fetch and display second -- and subsequent rows. rowcount := 0;# while sqlca.sqlcode = 0 loop$ rowcount := rowcount + 1;- -- Execute the DISPLAY_ROW procedure. display_row;D -- To only display 5 rows, exit the loop if the loop counter6 -- equals MAXROW (coded as 52 in this program).3 if rowcount = maxrows then exit; end if;< -- Fetch another row, exit the loop if no more rows.A EXEC SQL FETCH :cur_cursor USING DESCRIPTOR sqlda_out; case sqlca.sqlcode is( when sql_success => null;' when stream_eof => exit;5 when others => raise unexpected_error; end case; end loop; -- Close the cursor. EXEC SQL CLOSE :cur_cursor; case sqlca.sqlcode is 3 when sql_success => null;- when others => raise unexpected_error; end case; exception when unexpected_error =>A sql_get_error_text(get_error_buffer,get_error_length); EXEC SQL ROLLBACK;8 put_line("This condition was not expected.");D put_line(get_error_buffer(1..integer(get_error_length)));- put("Press RETURN to continue. ");2 get_line(terminal,release_screen,last);2 -- Stop and let the user look bef4 ore returning. skip;- put_line("Press RETURN to proceed. ");. get_line(terminal,release_screen,last); end DISPLAY_DATA; 2 FUNCTION> Declares an external function interface for use in database definition statements.A The DECLARE FUNCTION statement is documented under the DECLAREB Routine. For complete information on declaring a procedure, see" the DECLARE ROUTINE Help topic. 2 PROCEDURE@ Declares a procedure interface for use in datab5 ase definition statements.B The DECLARE PROCEDURE statement is documented under the DECLAREB Routine. For complete information on declaring a procedure, see" the DECLARE ROUTINE Help topic. 2 Routine> Declares a routine interface for use in database definition= statements. A routine is either a function or a procedure.D The declared routine acts as a template for calls to the functionC or procedure in DDL statements such as CREATE TABLE, CREATE VIEW> and CREAT6 E MODULE. The template allows Rdb to validate that? the routine is correctly named, is passed the correct number@ of parameters and that those parameters are passed compatible= arguments. For functions the returned data type is used toC calculate data types for COMPUTED BY, AUTOMATIC and other stored value expressions. 3 Environment- You can use the DECLARE Routine statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 7 3 FormatA DECLARE --+-> FUNCTION ---+-> ------------------+A +-> PROCEDURE --+ |A +----------------------------- <-----------------------------+A +-+--------------------------------+-------------------------+A +-> STORED NAME IS -+ |A +--------------------------- <-------------------------------+A +-> ( -+-----------------------+-> ) ------------------------+A 8 ++-> parameter-list --+-+ |A +-------- , <--------+ |A +--------------------------- <-------------------------------+E +-+-------------------+--> --+------------------+---------------->4 +-> returns-clause -+ +-> LANGUAGE SQL --+  parameter-list = D -+----------+-+-------------------+-+-> data-type -----+----------+D +-> IN ----+ +> + +-> -+ |D +-> OUT --9 -+ |D +-> INOUT -+ |D +-----------------------------------------------------------------+D +-+---------------------------+--+---------------------+----------+D +-> DEFAULT value-expr -----+ +-> mechanism-clause -+ |D +------------------------------<---------------------------------+F ++---------------------------------+------------------------------->& +-> COMMENT IS -+-> 'st: ring' ---+-+$ +------ / <-----+ mechanism-clause = ! ----> BY --+-> DESCRIPTOR -+---> +-> LENGTH -----+ +-> REFERENCE --+ +-> VALUE ------+  returns-clause = @ ---> RETURNS -+> result-data-type -++---------------------+-->= +> ----++-> mechanism-clause -+ 3 Arguments 4 DEFAULT_value-expr? Specifies the default value of a parameter for a function orC pro ; cedure defined with mode IN. If you omit this parameter or ifD the CALL statement argument list or function invocation specifies? the DEFAULT keyword, then the value-expr specified with thisC clause is used. The parameter uses NULL as the default if you do- not specify a value expression explicitly. 4 FUNCTION" Declares a function definition.@ A function optionally accepts a list of IN parameters, always@ returns a value, and is referenced by name as an element of< a value expression. 4 LANGUAGE_SQL- Names the language that calls the routine. 4 mechanism-clause= Defines the passing mechanism for an external routine. The3 following list describes the passing mechanisms. o BY DESCRIPTORB Allows passing character data with any parameter access modeC to routines compiled by language compilers that implement the OpenVMS calling standard. o BY LENGTH@ The LENGTH passing mechanism is = the same as the DESCRIPTOR passing mechanism. o BY REFERENCE= Allows passing data with any parameter access mode as a# reference to the actual data.@ This is the default passing mechanism for parameters. This@ is also the default passing mechanism for a function value returning character data. o BY VALUE@ Allows passing data with the IN parameter access mode to a@ routine as a value and allows functions to return a value.@ > This is the default passing mechanism for a function value" returning noncharacter data. 4 parameter-list= The optional parameters of the routine. For each parameter@ you can specify a parameter access mode (IN, OUT, and INOUT),= a parameter name, a data type, and a passing mechanism (by, DESCRIPTOR, LENGTH, REFERENCE, or VALUE).A The parameter access mode (IN, OUT, and INOUT) is optional and? specifies how the parameter is accessed (whether it is read,A w ? ritten, or both). IN signifies read only, OUT signifies writeA only, and INOUT signifies read and write. The parameter access mode defaults to IN.: Only the IN parameter access mode may be specified withC parameters to a function. Any of the parameter access modes (IN,C OUT, and INOUT) may be specified with parameters to a procedure.B The parameter name is prefixed with a colon (:). The parameter5 name must be unique within the routine parameters.@ The data type i@ s required and describes the type of parameter2 using either an SQL data type or a domain name.B You cannot declare a parameter as the LIST OF BYTE VARYING data type. 4 PROCEDURE# Declares a procedure definition.= A procedure optionally accepts a list of IN, OUT, or INOUT= parameters, and is referenced by name in a CALL statement. 4 RETURNS@ Describes a function (returned) value. You can specify a dataB type and a passing mechanism (BY DESCRIPTOR, LEA NGTH, REFERENCE,A or VALUE). The function value is, by definition, an OUT access mode value.@ The data type is required and describes the type of parameter2 using either an SQL data type or a domain name.B You cannot declare a function value as the LIST OF BYTE VARYING data type. 4 routine-nameB The name of the external routine. The name must be unique amongB external and stored routines in the schema and can be qualified> with an alias or, in a multischemB a database, a schema name. 4 STORED_NAME_ISC The name that Oracle Rdb uses to access the routine when definedB in a multischema database. The stored name allows you to accessA multischema definitions using interfaces that do not recognize@ multiple schemas in one database. You cannot specify a stored@ name for a routine in a database that does not allow multiple? schemas. For more information about stored names, see Stored Names. 3 Examples= Example 1C : Definining a domain and referencing an external function+ SQL> create domain MONEY as integer (2); SQL>% SQL> create function INTEREST_PAID cont> (in :amt MONEY) cont> returns MONEY; cont> external cont> language C' cont> parameter style GENERAL; SQL> SQL> alter domain MONEY cont> add0 cont> check (INTEREST_PAID (value) > 0) cont> not deferrable;C Once the ALTER DOMAIN is completed, neither the fD unction nor theD domain can be defined before the other. Here is a fragment of the? result of executing the output from the RMU Extract command. SQL> create domain MONEY cont> INTEGER (2). cont> check((INTEREST_PAID(value) > 0)) cont> not deferrable;G %SQL-F-RTNNOTDEF, function or procedure INTEREST_PAID is not defined SQL> SQL> commit work;' SQL> create function INTEREST_PAID ( cont> in :AMT cont> MONEY cont> bE y reference) cont> returns cont> MONEY by value cont> language SQL; cont> external cont> language C( cont> parameter style GENERAL cont> deterministic! cont> called on null input cont> ;O %SQL-F-NO_SUCH_FIELD, Domain MONEY does not exist in this database or schema SQL> commit work;A This problem is avoided for RMU Extract by adding the FORWARD_' REFERENCES item to the command line:M $ RMU/EXTRAF CT/ITEM=(ALL,FORWARD_REFERENCES) databasename/OUTPUT=script.SQL@ The script now contains a forward declaration of the function= INTEREST_PAID so that execution of the script can succeed.( SQL> declare function INTEREST_PAID ( cont> in :AMT cont> INTEGER (2)) cont> returns cont> INTEGER (2) cont> ; SQL> SQL> create domain MONEY cont> INTEGER (2). cont> check((INTEREST_PAID(value) > 0)) cont> not deferraG ble; SQL> SQL> commit work;' SQL> create function INTEREST_PAID ( cont> in :AMT cont> MONEY cont> by reference) cont> returns cont> MONEY by value cont> language SQL; cont> external cont> language C( cont> parameter style GENERAL cont> deterministic! cont> called on null input cont> ; SQL> commit work; 2 LOCAL_TEMPORARY_TABLE/ Explicitly declares a local H temporary table.B The metadata for a declared local temporary table is not stored? in the database and cannot be shared by other modules. These. tables are sometimes called scratch tables.< The data stored in the table cannot be shared between SQL= sessions or modules in a single session. Unlike persistentB base tables, the metadata and data do not persist beyond an SQL session.@ In addition to declared local temporary tables, there are two# other types of temporI ary tables: o Global temporary tables o Local temporary tables? See the CREATE TABLE statement for additional information on% global and local temporary tables. 3 Environment; You can use the DECLARE LOCAL TEMPORARY TABLE statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed o In a stored module 3 FormatA DECLARE LOCAL TEMPORARY TABLE -+-----------------+> MODULE . -+A J +-> alias-name . -+ |A +--------------------------------------------------------------+@ +-> --> dec-local-table-body -------------------+@ +-------------------------------------------------------------+A +---+----+--> COMPRESSION IS -+-> ENABLED --+-------+-----+---->< | | +-> DISABLED -+ | |< | +--> ON COMMIT -+-> DELETE ----+--> ROWS --+ |< | +-> PRESERVE --+ |< +--K -------------------------<-------------------------+ dec_local_table_body ? -+-> (dec_local_col_list) ---------------------------------+->= | |= +-> LIKE --+--------------------------++< +--> (dec_local_col_list) -+  dec-local-col-list =  --+-> --+ | +-----------------+> | +-+-> data-type ----++---------------------------+-+--+->< | | + L -> ++-> DEFAULT default-value --+ | |< | +--> COMPUTED BY value-expr -----------------------+ |< +-----------------------, <-----------------------------+ data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+---------------+A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+M |A +-> FLOAT ----------------+ |A +-> NUMBER -+----------------------------------+-------------+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE VARYING --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT --N -+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) + |A | +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION ----------------------------------------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++----------------O ----------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+ |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --P ------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -------------------------------Q ----------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac --------------------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+  frac = " --+---------------------------+-> +R --> ( ) -+  interval-qualifier = ; --+-> YEAR ---> prec --+-------------+-----------------+->9 | +-> TO MONTH -+ |9 +-> MONTH --> prec ----------------------------------+9 +-> DAY ----> prec --+-------------------------------+9 | +-> TO -+-> HOUR ---------------+9 | +-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> HOUR --->S prec --+-------------------------------+9 | +-> TO -+-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> MINUTE -> prec --+-------------------------------+9 | +-> TO SECOND ------> frac -----+9 +-> SECOND -> seconds-prec --------------------------+  prec = " --+---------------------------+-> +--> ( ) -+  seconds-prec = . --+--------------------------------T ------+-->+ +-> ( ---+ |+ +-------------------------+ |+ ++--------------------------+-> ) --+# +> , --+  3 Arguments 4 dec-local-col-definitionC The definition for a column in the table. SQL gives you two ways! to specify column definitions:C o By directly specifying a data type to associate with a column nameA o By naming a domain that indirectly specifies a data typeU to" associate with a column name9 See the CREATE TABLE for more information about columnB definitions. See the Data_Types HELP topic for more information about data types. 4 COMPRESSION_IS Syntax options:3 COMPRESSION IS ENABLED | COMPRESSION IS DISABLEDB Specifies whether run-length compression is enabled or disabled= for rows inserted into the declared local temporary table.D In some cases, the data inserted into a local temporary table mayD V not compress and so incur only overhead in the row. This overheadB is used by Rdb to describe the sequence of uncompressible data.A Use COMPRESSION IS DISABLED to prevent Rdb from attempting the compression of such data.) The default is COMPRESSION IS ENABLED. 4 ON_COMMIT Syntax options:2 ON COMMIT PRESERVE ROWS | ON COMMIT DELETE ROWS@ Specifies whether data is preserved or deleted after a COMMIT1 statement for declared local temporary tables.; The dW efault, if not specified, is ON COMMIT DELETE ROWS. 4 table-name@ The name of the table you want to declare. You can optionallyC precede the table-name with an alias-name and a period (.). YouD must, however, precede the table-name with the keyword MODULE and3 a period (.), for example, MODULE.EMPL_PAYROLL. 3 ExamplesB Example 1: Declaring and using a declared local temporary table in interactive SQL> SQL> DECLARE LOCAL TEMPORARY TABLE MODULE.PAYCHECK_ X DECL_INT$ cont> (EMPLOYEE_ID ID_DOM,$ cont> LAST_NAME CHAR(14),& cont> HOURS_WORKED INTEGER,) cont> HOURLY_SAL INTEGER(2),) cont> WEEKLY_PAY INTEGER(2))( cont> ON COMMIT PRESERVE ROWS; SQL> --, SQL> INSERT INTO MODULE.PAYCHECK_DECL_INTP cont> (EMPLOYEE_ID, LAST_NAME, HOURS_WORKED, HOURLY_SAL, WEEKLY_PAY)E cont> SELECT P.EMPLOYEE_ID, E.LAST_NAME, P.HOURS_WORKED,E cont> P.HOURLY_SAL Y , P.HOURS_WORKED * P.HOURLY_SAL1 cont> FROM EMPLOYEES E, PAYROLL P= cont> WHERE E.EMPLOYEE_ID = P.EMPLOYEE_ID@ cont> AND P.WEEK_DATE = DATE '1995-08-01'; 100 rows inserted? SQL> SELECT * FROM MODULE.PAYCHECK_DECL_INT LIMIT TO 2 ROWS;Q EMPLOYEE_ID LAST_NAME HOURS_WORKED HOURLY_SAL WEEKLY_PAYQ 00165 Smith 40 30.50 1220.00Q 00166 Dietrich Z 40 36.00 1440.00 2 rows selectedC Example 2: Creating a stored module that contains the following:@ o A declared local temporary table, MODULE.PAYCHECK_DECL_TAB9 o A procedure, PAYCHECK_INS_DECL, that inserts weekly= salary records into the declared local temporary table, MODULE.PAYCHECK_DECL_TAB< o A procedure, LOW_HOURS_DECL, that counts the number of. employees with less than 40 hours workedB The following examp [ le also demonstrates that you can access the> declared local temporary table only from within the module.C SQL> -- Create the module containing a declared temporary table. SQL> --' SQL> CREATE MODULE PAYCHECK_DECL_MOD cont> LANGUAGE SQLA cont> DECLARE LOCAL TEMPORARY TABLE MODULE.PAYCHECK_DECL_TAB& cont> (EMPLOYEE_ID ID_DOM,' cont> LAST_NAME CHAR(14) ,? cont> HOURS_WORKED INTEGER, HOURLY_SAL INTEGER(2),+ cont> WEEKLY_PA \ Y INTEGER(2))* cont> ON COMMIT PRESERVE ROWS cont> --0 cont> -- Create the procedure to insert rows. cont> --' cont> PROCEDURE PAYCHECK_INS_DECL; cont> BEGIN1 cont> INSERT INTO MODULE.PAYCHECK_DECL_TABP cont> (EMPLOYEE_ID, LAST_NAME, HOURS_WORKED, HOURLY_SAL, WEEKLY_PAY)E cont> SELECT P.EMPLOYEE_ID, E.LAST_NAME, P.HOURS_WORKED,E cont> P.HOURLY_SAL, P.HOURS_WORKED * P.HOURLY_SAL5 cont> FR] OM EMPLOYEES E, PAYROLL P= cont> WHERE E.EMPLOYEE_ID = P.EMPLOYEE_ID@ cont> AND P.WEEK_DATE = DATE '1995-08-01'; cont> END; cont> --8 cont> -- Create the procedure to count the low hours. cont> --3 cont> PROCEDURE LOW_HOURS_DECL (:cnt INTEGER); cont> BEGIND cont> SELECT COUNT(*) INTO :cnt FROM MODULE.PAYCHECK_DECL_TAB, cont> WHERE HOURS_WORKED < 40; cont> END; cont> END MODULE; SQL> --1 S^ QL> -- Call the procedure to insert the rows. SQL> --! SQL> CALL PAYCHECK_INS_DECL(); SQL> --J SQL> -- Declare a variable and call the procedure to count records with SQL> -- low hours. SQL> --$ SQL> DECLARE :low_hr_cnt integer;) SQL> CALL LOW_HOURS_DECL(:low_hr_cnt); LOW_HR_CNT 2 SQL> --L SQL> -- Because the table is a declared local temporary table, you cannotE SQL> -- access it from outside the stored module that contains it. S _ QL> --/ SQL> SELECT * FROM MODULE.PAYCHECK_DECL_TAB;O %SQL-F-RELNOTDCL, Table PAYCHECK_DECL_TAB has not been declared in module or environmentA Example 3: Disabling Compression for a Declard Local Temporary Table? The following example shows a declared local temporary tableD that will not benefit from compression. The clause COMPRESSION ISD DISABLED is used to reduce the CPU overhead for the table as wellD as preventing a possible row size increase because of compr` ession notations.5 SQL> declare local temporary table module.scratch0( cont> (averages double precision)$ cont> compression is DISABLED$ cont> on commit PRESERVE rows cont> ; SQL># SQL> insert into module.scratch0? cont> select avg (char_length (a)) from module.scratch1; 1 row inserted SQL>& SQL> select * from module.scratch0; AVERAGES 2.100000000000000E+001 2 MODULED Specifies characteristics, sua ch as character sets, quoting rules,6 and the default date format for a nonstored module. 3 Environment, You can use the DECLARE MODULE statement:: o Embedded in host language programs to be precompiled o In a context file" This command is not executable. 3 Format< DECLARE MODULE --+------------------------+-+< +-> DIALECT environment -+ |< +---------------------------------------------------------+< +-+------ b ---------------+-+-----------------------------+-+< +-> char-set-options -+ +---> CATALOG -+ |< +---------------------------------------------------------+< +-+------------------------++----------------------------++< +-> SCHEMA ++-> AUTHORIZATION -+|< +---------------------------------------------------------+H +-+--------------------------------+-+----------------------------+--->D +-> PRAGMA (module-pragma-list) -+ +-> module-language-options -+c  environment =  --+--> SQL99 -----+-> +--> SQL92 -----+ +--> SQL89 -----+ +--> SQLV40 ----+ +--> MIA -------+  char-set-options = * --+----------------> -------------+-----+* +--> NAMES ARE names-char-set --+ |* +----------------- <--------------------+9 ++-+---------------> ------------------------------+-+->7 | +--> LITERAL CHARACTER SET support-char-set ----+ |7 | +--> NATIONAL CHARACTER SET support-char-set ---+ |7 | +--> DEFAULT CHAd RACTER SET support-char-set ----+ |7 | +--> IDENTIFIER CHARACTER SET names-char-set ---+ |7 | +--> DISPLAY CHARACTER SET names-char-set ------+ |7 +---------------------------<-----------------------+  module-pragma-list = 9 -----------------> IDENT string-literal -----------> module-language-options = ; -+-+---> ALIAS ------------------------+-+-->8 | +---> CHARACTER LENGTH -+-> CHARACTERS -+--------+ |8 | | +-> OCTETS e -----+ | |8 | +---> DEFAULT DATE FORMAT --+--> SQL99 -+--------+ |8 | | +--> SQL92 -+ | |8 | | +--> VMS ---+ | |8 | +---> KEYWORD RULES environment -----------------+ |8 | +---> PARAMETER COLONS --------------------------+ |8 | +---> QUOTING RULES environment -----------------+ |8 | +---> RIGHTS --+--> INVOKER ---+-----------------+ |8 | | +--> RESTRICT --+ | |8 | +---> VIEW UPDATE f RULES environment -------------+ |8 | +---> QUIET COMMIT -+-> ON ---+------------------+ |8 | | +-> OFF --+ | |8 | +---> COMPOUND TRANSACTIONS -+-> INTERNAL -+----+ |8 | +-> EXTERNAL -+ |8 +--------------------------- <-----------------------+ 3 Arguments 4 ALIAS_alias_nameD Specifies the module alias. If you do not specify a module alias,D the default alias is the authorization identifier for tg he module.@ When the FIPS flagger is enabled, the ALIAS clause (by itselfC or used with the AUTHORIZATION clause) is flagged as nonstandard syntax.@ If the application needs to refer to only one database acrossB multiple modules, it is good practice to use the same alias forB the default database in all modules that will be linked to make up an executable image. 4 AUTHORIZATION@ Specifies the authorization identifier for the module. If you? do not specify a h schema clause, the authorization identifier specifies the default schema.9 To comply with the ANSI/ISO 1989 standard, specify theA AUTHORIZATION clause without the schema name. Specify both the> AUTHORIZATION clause and the schema name to comply with the ANSI/ISO SQL standard.? When you attach to a multischema database, the authorizationD identifier for each schema is the user name of the user compiling@ the module. This authorization identifier defines the defaultB i alias and schema. You can use the SCHEMA clause and the DECLARE, ALIAS statement to override the defaults.< If you attach to a single-schema database or specify that@ MULTISCHEMA IS OFF in your ATTACH or DECLARE ALIAS statementsD and you specify both an AUTHORIZATION clause and an ALIAS clause,@ the authorization identifier is ignored by SQL unless you use@ the RIGHTS RESTRICT clause. The RIGHTS RESTRICT clause causesB SQL to use the authorization identifier specified in the j module/ AUTHORIZATION clause for privilege checking.B If procedures in the SQL module always qualify table names with? an authorization identifier, the AUTHORIZATION clause has no. effect on SQL statements in the procedures.7 When the FIPS flagger is enabled, the omission of an> AUTHORIZATION clause is flagged as nonstandard ANSI syntax. 4 CATALOG_catalog_nameD Specifies the default catalog for the module. Catalogs are groupsD of schemas within a multischema dk atabase. If you omit the catalog@ name when specifying an object in a multischema database, SQL? uses the default catalog name RDB$CATALOG. Databases created> without the multischema attribute do not have catalogs. YouB can use the SET CATALOG statement to change the current default. catalog name in dynamic or interactive SQL. 4 CHARACTER_LENGTH Syntax options:8 CHARACTER LENGTH CHARACTERS | CHARACTER LENGTH OCTETS? Specifies whether the length of character strl ing parameters,D columns, and domains are interpreted as characters or octets. The default is octets. 4 DEFAULT_CHARACTER_SETD Specifies the character set for parameters that are not qualifiedD by a character set. The default is DEC_MCS. This clause overrides; the character set specified in the NAMES ARE clause. SeeA Supported Character Sets for a list of the allowable character sets. 4 DEFAULT_DATE_FORMAT Syntax options:. DEFAULT DATE FORMAT { S m QL99 | SQL92 | VMS }; Controls the default interpretation for the data type of= the CURRENT_TIMESTAMP built in function and column or CAST= expressions with the DATE data type. The DATE and CURRENT_> TIMESTAMP data types can be either VMS or ANSI/ISO Standard format.= If you specify VMS, both data types are interpreted as VMSA format. The VMS format DATE and CURRENT_TIMESTAMP contain YEAR TO SECOND fields.D If you specify SQL99 or SQL92, both data types are inten rpreted asB SQL standard format. The SQL format DATE contains only the YEAR TO DAY fields. The default is VMS.C Use the DEFAULT DATE FORMAT clause, rather than the SQLOPTIONS =D ANSI_DATE qualifier because the qualifier will be deprecated in a future release. 4 DIALECT# Controls the following settings:A o Whether the length of character string parameters, columns,9 and domains are interpreted as characters or octets> o Whether double quotatio on marks are interpreted as string' literals or delimited identifiers0 o Whether or not identifiers can be keywords o Which views are read-onlyB o Whether columns with the DATE or CURRENT_TIMESTAMP data type, are interpreted as VMS or SQL99 formatD The DIALECT clause lets you specify the settings with one clause,? instead of specifying each setting individually. Because theB module processor processes the module clauses sequentially, the@ DIALECT clause p can override the settings of clauses specified< before it or be overridden by clauses specified after it.> The following statements are specific to the SQL99 dialect:A o The default constraint evaluation time setting changes from# DEFERRABLE to NOT DEFERRABLE.C o Conversions between character data types when storing data orB retrieving data will raise exceptions or warnings in certain situations.> o You can specify DECIMAL or NUMERIC for formal parameteq rs? in SQL modules, and declare host language parameters withD packed decimal or signed numeric storage format. SQL generates= an error message if you attempt to exceed the precision specified.C o The USER keyword specifies the current active user name for a request.C o A warning is generated when a NULL value is eliminated from a SET function.D o The WITH CHECK OPTION clause on views returns a discrete error0 code from an integrity cr onstraint failure.C o An exception is generated with non-null terminated C strings.; See the SET_DIALECT statement for more information about dialects. '4 DISPLAY_CHARACTER_SET_names-char-setD Specifies the character set encoding and characteristics expected8 of text strings returned back to SQL from Oracle Rdb. 4 IDENTIFIER_CHARACTER_SET= Specifies the character set used for database object namesB such as table names and column names. This clause oves rrides theB character set specified in the NAMES ARE clause. See the OracleB Rdb SQL Reference Manual for a list of allowable character sets and option values.= The specified character set must contain ASCII characters. 4 KEYWORD_RULES> Controls whether or not identifiers can be keywords. If youB specify SQL99, SQL92, SQL89, or MIA, you cannot use keywords asB identifiers, unless you enclose them in double quotation marks.B If you specify SQLV40, you can use keywt ords as identifiers. The default is SQLV40.C Use the KEYWORD RULES clause, rather than the SQLOPTIONS = ANSI_C IDENTIFIER qualifier because the qualifier will be deprecated in a future release. 4 LITERAL_CHARACTER_SETB Specifies the character set for literals that are not qualified> by a character set or national character set. If you do not= specify a character set in this clause or in the NAMES ARE< clause, the default is DEC_MCS. This clause overrides theD u character set for unqualified literals specified in the NAMES AREC clause. See Supported Character Sets for a list of the allowable character sets. 4 MODULE_module_nameD An optional name for the nonstored module. If you do not supply a/ module name, the default name is SQL_MODULE.@ Use any valid OpenVMS name. (See the User_Supplied_Names HELPC topic for more information on user-supplied names.) However, theD name must be unique among the modules that are linkedv together to form an executable image. 4 NAMES_ARE@ Specifies the character set used for the default, identifier,@ and literal character sets for the module. Also specifies theD character string parameters that are not qualified by a characterC set or national character set. If you do not specify a character set, the default is DEC_MCS.B You must ensure that the character set specified in this clause@ matches the character set of all the databases attached to byw C any particular connection and must contain ASCII characters. SeeB the Oracle Rdb SQL Reference Manual for a list of the allowable character sets. 4 NATIONAL_CHARACTER_SET< Specifies the character set for literals qualified by theB national character set. See Supported Character Sets for a list# of the allowable character sets. 4 PARAMETER_COLONS> If you use the PARAMETER COLONS clause, all parameter namesC must begin with a colon (:). This is valid i x n context files forC module language only. This rule applies to both declarations andD references of module language procedure parameters. If you do not= use this clause, no parameter name can begin with a colon.? The current default behavior is no colons are used. However,D this default is deprecated syntax. In the future, required colonsC will be the default because it allows processing of ANSI/ISO SQL standard modules.> Use the PARAMETER COLONS clause, rather than y the SQLOPTIONS< = ANSI_PARAMETERS qualifier because the qualifier will be" deprecated in a future release. 4 QUOTING_RULESD Controls whether double quotation marks are interpreted as string@ literals or delimited identifiers. If you specify SQLV40, SQLD interprets double quotation marks as literals. All other dialectsA interpret double quotation marks as delimited identifiers. The default is SQLV40.C Use the QUOTING RULES clause, rather than the SQLOPTIONS = ANSIz _B QUOTING qualifier because the qualifier will be deprecated in a future release. 4 RIGHTS Syntax options:# RIGHTS INVOKER | RIGHTS RESTRICT? Specifies whether or not a module must be executed by a userB whose authorization identifier matches the module authorization identifier.? If you specify RESTRICT, SQL bases privilege checking on the> default authorization identifier. The default authorization= identifier is the authorization identifier of t { he user whoB compiles a module, unless you specify a different authorization> identifier using an AUTHORIZATION clause in the module. The= RESTRICT option causes SQL to compare the user name of the> person who executes a module with the default authorization; identifier and prevents any user other than one with the> correct authorization identifier from invoking that module.@ All applications that use multischema restrict the invoker by default.9 If you specify INVOKE| R, SQL bases the privilege on the? authorization identifier of the user running the module. The default is INVOKER.< Use the RIGHTS clause, rather than the SQLOPTIONS = ANSI_C AUTHORIZATION qualifier because the qualifier will be deprecated in a future release. 4 SCHEMA_schema_name@ Specifies the default schema name for the module. The default> schema is the schema to which SQL statements refer if those? statements do not qualify table names and other schema } names< with an authorization identifier. If you do not specify a? default schema name for a module, you must specify a default authorization identifier.= Using the SCHEMA clause, separate modules can each declareC different schemas as default schemas. This can be convenient forA an application that needs to refer to more than one schema. ByC putting SQL statements that refer to a schema in the appropriateA module's procedures, you can minimize tedious qualification of~ , schema element names in those statements.A When you specify SCHEMA schema-name AUTHORIZATION auth-id, youB specify the schema name and the schema authorization identifierD for the module. The schema authorization identifier is considered< the owner and creator of the schema and everything in it. 4 VIEW_UPDATE_RULES@ Specifies whether or not the SQL module processor applies theA ANSI/ISO SQL standard for updatable views to all views created during compilation.  = If you specify SQL99, SQL92, SQL89, or MIA, the SQL moduleC processor applies that ANSI/ISO SQL standard for updatable viewsD to all views created during compilation. Views that do not comply? with the specified ANSI/ISO SQL standard for updatable views cannot be updated.C The specified ANSI/ISO standard for updatable views requires the: following conditions to be met in the SELECT statement:, o The DISTINCT keyword is not specified.B o Only column names can  appear in the select list. Each columnB name can appear only once. Functions and expressions such asD max(column_name) or column_name +1 cannot appear in the select list.B o The FROM clause refers to only one table. This table must beA either a base table or a derived table that can be updated.3 o The WHERE clause does not contain a subquery.+ o The GROUP BY clause is not specified.) o The HAVING clause is not specified.B If you specify SQLV40 , SQL does not apply the ANSI/ISO standardB for updatable views. Instead, SQL considers views that meet the( following conditions to be updatable:, o The DISTINCT keyword is not specified.B o The FROM clause refers to only one table. This table must beA either a base table or a derived table that can be updated.3 o The WHERE clause does not contain a subquery.+ o The GROUP BY clause is not specified.) o The HAVING clause is not specified. 3 Example @ Example 1: Declaring a module specifying character strings of different character sets> Assuming that the character sets for the database match theA character sets specified in the program, the following exampleB shows a simple SQL precompiled C program that retrieves one row from the COLOURS table.M /* This SQL precompiled program does some simple tests of character length * and character sets. */ #include stdio #include descrip main() { J /* Specify CHARACTER LENGTH CHARACTERS in the DECLARE MODULE statement.K * In addition, specify the NAMES, NATIONAL, and DEFAULT character sets. */& EXEC SQL DECLARE MODULE CCC_COLOURS NAMES ARE DEC_KANJI( NATIONAL CHARACTER SET KANJI SCHEMA RDB$SCHEMA$ AUTHORIZATION SQL_SAMPLE' CHARACTER LENGTH CHARACTERS+ DEFAULT CHARACTER SET DEC_KANJI ALIAS RDB$DBHANDLE;N /* If you do not specify ch aracter sets in the DECLARE ALIAS statement, SQL; * uses the character sets of the compile-time database. */0 EXEC SQL DECLARE ALIAS FILENAME MIA_CHAR_SET; int SQLCODE;P /* Because the default character set is DEC_KANJI, you do not need to qualifyK * the variable dec_kanji_p with the character set, but you must declare * char in lowercase. */ char dec_kanji_p[31];I /* When you declare a parameter with lowercase char, SQL considers theF * char acter set unspecified and allocates single-octet characters. */ char english_p[31];N /* When you specify the character set, SQL allocates single- or multi-octet3 * characters, depending upon the character set. */- char CHARACTER SET DEC_MCS french_p[31];/ char CHARACTER SET KANJI japanese_p[31]; . . ./ /* Select one row from the COLOURS table. */5 EXEC SQL SELECT ENGLISH, FRENCH, JAPANESE, ROMAJI,: KATAKANA, H INDI, GREEK, ARABIC, RUSSIANB INTO :english_p, :french_p, :japanese_p, :dec_kanji_p,> :katakana_p, :devanagari_p, :isolatingreek_p,7 :isolatinarabic_p, :isolatincyrillic_p( FROM COLOURS LIMIT TO 1 ROW; if (SQLCODE != 0) SQL$SIGNAL();' printf ("\nENGLISH: %s", english_p);% printf ("\nFRENCH: %s", french_p);) printf ("\nJAPANESE: %s", japanese_p);( printf ("\nROMAJI: %s", dec_kanji_p);) printf ("\nKA TAKANA: %s", katakana_p);( printf ("\nHINDI: %s", devanagari_p);+ printf ("\nGREEK: %s", isolatingreek_p);- printf ("\nARABIC: %s", isolatinarabic_p);0 printf ("\nRUSSIAN: %s", isolatincyrillic_p); EXEC SQL ROLLBACK; } 2 STATEMENTB Documents a statement name later used in a PREPARE statement inA dynamic SQL. SQL does not require DECLARE STATEMENT statementsD and does not generate any code when it precompiles them. They are entirely optional. 3  Environment= You can issue the DECLARE STATEMENT statement only in host' language programs to be precompiled. 3 Format- DECLARE --+-> +-> STATEMENT! +------- , <--------+ 3 Arguments 4 statement-nameD Specifies the name of a statement later referred to in one of the) following embedded dynamic statements: o PREPARE o DECLARE CURSOR o DESCRIBE 3 Example: Example 1: Declaring a statement na me in a PL/I programC This example shows a program line that declares a statement nameA DYNAMIC_STATEMENT. Later lines in the example show how DECLARE@ CURSOR, PREPARE, and DESCRIBE statements refer to it. BecauseA you do not have to declare a statement explicitly, the DECLARE* STATEMENT statement is always optional.0 EXEC SQL DECLARE DYNAMIC_STATEMENT STATEMENT;- /* Declare the SQL Communications Area. */ EXEC SQL INCLUDE SQLCA;) /* Declare the SQL Descriptor Area. */ EXEC SQL INCLUDE SQLDA;5 /* The program declares the host language variable+ STATEMENT_STRING and stores in it the* character string containing a SELECT. statement to be executed dynamically. */ . . .9 EXEC SQL DECLARE CURSOR1 CURSOR FOR DYNAMIC_STATEMENT;; EXEC SQL PREPARE OBJECT_STATEMENT FROM STATEMENT_STRING;1 EXEC SQL DESCRIBE OBJECT_STATEMENT INTO SQLDA;) /* The program sets up pointers in the, SQLDATA field of the SQLDA to the data. area (host language variables or dynamic. memory, for example) to receive the data from the cursor. */ . . . EXEC SQL OPEN CURSOR1; DO WHILE (SQLCODE = 0);9 EXEC SQL FETCH CURSOR1 USING DESCRIPTOR SQLDA;% /* The program prints or otherwise* processes rows of the result tables. */ . .  . END; EXEC SQL CLOSE CURSOR1; 2 TABLEC Explicitly declares a table or view definition in a program. ForD tables named in a DECLARE TABLE statement, SQL does not check theB schema to compare the definition with the explicit declaration.. An explicit table declaration is useful to:? o Document the definition in the source code of the program; o Allow references to tables that do not exist when SQL) precompiles the program, including:7 - Tables created in other modules of the program# - Tables created dynamicallyB o Improve precompiler performance because SQL does not need to; attach to the schema to retrieve the table definition< o Make it easier to check that the declaration correctly> corresponds to a host structure the program uses to hold" values from or for the table> o Declare only a subset of columns contained in the schemaC definition of the table if the program nee ds to use only some of the columns 3 Environment+ You can use the DECLARE TABLE statement:: o Embedded in host language programs to be precompiled o In a context file5 o As part of the DECLARE section in an SQL module 3 Format* DECLARE --+-> -+-> TABLE --+* +-> --+ |* +-------------------------------------+1 +-> ( -++-> declare-col-definition -++-> ) -->) |+-> table-constraint -------+| ) +---------- , <---------------+ declare-col-definition = @ --> --> data-type -++------------------------++->> |+-> col-constraint ------+|> |+-> sql-and-dtr-clause --+|> +----------- <-------------+ data-type = D -+-> char-data-types -----------------------------------------+-->A +-> TINYINT --------------+-----+------------+---------------+ A +-> SMALLINT -------------+ +-> ( ) -+ |A +-> INTEGER --------------+ |A +-> BIGINT ---------------+ |A +-> FLOAT ----------------+ |A +-> NUMBER -+----------------------------------+-------------+A | +-> ( -+->

-+-+----------+-> ) + |A | +-> * ---+ +-> , -+ |A +-> LIST OF BYTE VARYING  --+------------+--+--------------+--+A | +-> ( ) -+ +-> AS BINARY -+ |A | +-> AS TEXT ---+ |A +-> DECIMAL -++------------------------------+---------------+A +-> NUMERIC -++-> ( --> +----------+-> ) + |A | +-> , -+ |A +-> REAL ----------------------------------------------------+A +-> DOUBLE PRECISION ---------------------------------- ------+A +-> date-time-data-types ------------------------------------+  char-data-types = M -+-> CHAR -------------++------------++--------------------------------+-+->K +-> CHARACTER --------++-> ( ) -++-> CHARACTER SET char-set-name -+ |K +-> CHAR VARYING -----+ |K +-> CHARACTER VARYING + |K +-> VARCHAR --+> ( ) ---+--------------------------------+----------+K  +-> VARCHAR2 -+ +-> CHARACTER SET char-set-name -+ |K +-> LONG VARCHAR ------------------------------------------------------+K +-> NCHAR --------------+-+------------+--------------------------------+K +-> NATIONAL CHAR ------+ +-> ( ) -+ |K +-> NATIONAL CHARACTER -+ |K +-> NCHAR VARYING --------------+-+------------+------------------------+K +-> NATIONAL CHAR VARYING ------+ +->  ( ) -+ |K +-> NATIONAL CHARACTER VARYING -+ |K +-> RAW -> ( ) -----------------------------------------------------+K +-> LONG -+--------+----------------------------------------------------+ +-> RAW -+ date-time-data-types = . --+-> DATE -+----------+-----------------+-->+ | +-> ANSI -+ |+ | +-> VMS ---+ |+ +-> TIME ---> frac ------------ --------++ +-> TIMESTAMP --> frac ----------------++ +-> INTERVAL ---> interval-qualifier --+  frac = " --+---------------------------+-> +--> ( ) -+  interval-qualifier = ; --+-> YEAR ---> prec --+-------------+-----------------+->9 | +-> TO MONTH -+ |9 +-> MONTH --> prec ----------------------------------+9 +-> DAY ----> prec --+-------------------------------+9 | +-> TO -+-> HOUR ---------------+9 | +-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> HOUR ---> prec --+-------------------------------+9 | +-> TO -+-> MINUTE -------------+9 | +-> SECOND -> frac -----+9 +-> MINUTE -> prec --+-------------------------------+9 | +-> TO SECOND ------> frac -----+9 +-> SECOND -> seconds-prec ------------------------ --+  prec = " --+---------------------------+-> +--> ( ) -+  seconds-prec = . --+--------------------------------------+-->+ +-> ( ---+ |+ +-------------------------+ |+ ++--------------------------+-> ) --+# +> , --+  col-constraint= ) ----+--------------------------------+-+) +> CONSTRAINT -+ |) +---------------<---------- ----------+% +-> PRIMARY KEY -----------------+% +-> UNIQUE ----------------------+% +-> NOT NULL --------------------+% +-> NULL ------------------------+% +-> CHECK (predicate) -----------+% +-> references-clause -----------+% +--------------->----------------+% +---------------<----------------+) +----+----------------------------+-->& +--> constraint-attributes --+ constraint-attributes = B -+-> DEFERRABLE -------------+--------------------- ---------+-+->@ | +-> INITIALLY +-> IMMEDIATE --++ |@ | +-> DEFERRED ---+ |@ +-> NOT DEFERRABLE ---------+-------------------------+------+@ | +-> INITIALLY IMMEDIATE --+ |@ +-> INITIALLY IMMEDIATE ----+-------------------+------------+@ | +-> DEFERRABLE -----+ |@ | +-> NOT DEFERRABLE -+ |@ +-> INITIALLY DEFERRED --- --+-------------------+------------+3 +-> DEFERRABLE -----+ sql-and-dtr-clause = A -+-> QUERY HEADER IS -+> +-------------------+->? | +------ / <--------+ |? +-> EDIT STRING IS -------------------------+? | |? +-> QUERY NAME FOR -+-> DTR --------+-> IS -+? | +-> DATATRIEVE -+  |? +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+* +-> DATATRIEVE -+  table-constraint = . ---+-----------------------------------+----+. +-> CONSTRAINT ---+ |. +------------------------------------------+. +--> table-constraint-clause --------------+. +------------------------------------------+1 +---+---------------------------+-------------># +-> constraint-attributes --+  t able-constraint-clause = 5 -+----------------------------------------------+-->2 +-> PRIMARY KEY -> ( -+> +-> ) --+2 | +------- , <-----+ |2 +-> UNIQUE -> ( -+> +-> ) -------+2 | +------- , <-----+ |2 +-> CHECK (predicate) -------------------------+2 +-> FOREIGN KEY -> ( -+> +-> ) + |2 +------- , <-----+ | |2 +--------------------<---------------------+ |2  +-> references-clause ---------->------------+  3 Arguments 4 character-set-name? A valid character set name. See the Oracle Rdb SQL Reference1 Manual for more information on character sets. 4 col-constraint? A column constraint. See the CREATE TABLE statement for more( information about column constraints. 4 column-name- The name of the column you want to define. 4 data-type@ The data type of the column you want to define. S ee the Data_7 Types HELP topic for more information on data types. 4 date-time-data-typesB Data types for dates, times, and intervals. See the Data_Types; HELP topic for more information on date-time data types. 4 declare-col-definitionB The definition for a column in the table. The column definition9 must correspond to the table definition in the schema.C See the CREATE TABLE statement for more information about column definitions.? However, yo u cannot refer to domain names in a DECLARE TABLEA statement. For tables whose definitions refer to domain names,C you must substitute the data type and size of the domain for the domain name. 4 fracC Precision specifications for date-time data types. See the Data_) Types HELP topic for more information. 4 interval-qualifierC Precision specifications for date-time data types. See the Data_) Types HELP topic for more information. 4 precC  Precision specifications for date-time data types. See the Data_) Types HELP topic for more information. 4 references-clause7 See the CREATE TABLE statement for more information. 4 seconds-precC Precision specifications for date-time data types. See the Data_) Types HELP topic for more information. 4 sql-and-dtr-clauseD Optional SQL and DATATRIEVE formatting clause. See the DATATRIEVE< HELP topic for more information about formatting clauses.  4 table-name8 The name of the table definition you want to declare. 4 view-name7 The name of the view definition you want to declare. 4 table-constraint? A constraint definition that applies to the whole table. SeeC the CREATE TABLE statement for more information about specifying table constraints. 3 Examples> Example 1: Declaring the table EMPLOYEES in a COBOL program EXEC SQL DECLARE EMPLOYEES TABLE1 (EMPLOYEE_ID CHAR (5)1 CONSTRAINT EMP_EMPLOYEE_ID_NOT_NULL NOT NULL,3 LAST_NAME CHAR (14),3 FIRST_NAME CHAR (10),2 MIDDLE_INITIAL CHAR (1),3 ADDRESS_DATA_1 CHAR (25),3 ADDRESS_DATA_2 CHAR (25),3 CITY CHAR (20),2 STATE CHAR (2),2 POSTAL_CODE CHAR (5),2 SEX CHAR (1),' CONSTRAINT EMP_SEX_VALUES CHECK (9 SEX IN ('M', 'F') OR SEX IS NULL ),/ BIRTHDAY DATE ,1 STATUS_CODE CHAR (1)/ CONSTRAINT EMP_STATUS_CODE_VALUES CHECK (7 STATUS_CODE IN ('0', '1', '2')/ OR STATUS_COD E IS NULL ) ) END_EXEC 2 TRANSACTION= Specifies the characteristics for a default transaction. AA transaction is a group of statements whose changes can be made& permanent or undone only as a unit.A A transaction ends with a COMMIT or ROLLBACK statement. If youB end the transaction with the COMMIT statement, all changes madeC to the database by the statements are made permanent. If you endA the transaction with the ROLLBACK s tatement, the statements do not take effect.C The characteristics specified in a DECLARE TRANSACTION statement; affect all transactions (except those started by the SET> TRANSACTION or START TRANSACTION statement) until you issue= another DECLARE TRANSACTION statement. The characteristics@ specified in a SET TRANSACTION or START TRANSACTION statement affect only that transaction.@ A DECLARE TRANSACTION statement does not start a transaction.B The declarations made in a DECLARE TRANSACTION statement do notC take effect until SQL starts a new transaction. SQL starts a newB transaction with the first executable data manipulation or data@ definition statement following a DECLARE TRANSACTION, COMMIT,C or ROLLBACK statement. In the latter case (following a COMMIT orC ROLLBACK statement), SQL applies the transaction characteristicsC you declared for the transaction that just ended to the next one you start.D In addition to the DECLARE TRANSACTION statement, you can specify; the characteristics of a transaction in one of two ways:= o If you specify the SET TRANSACTION or START TRANSACTION> statement, the declarations in the statement take effect3 immediately and SQL starts a new transaction.; o You can retrieve and update data without declaring or? setting a transaction explicitly. If you omit the DECLAREC TRANSACTION, SET TRANSACTION or START TRANSACTION statements,B SQL automatica lly starts a transaction (using the read/writeA option) with the first executable data manipulation or dataD definition statement following a COMMIT or ROLLBACK statement.C See the Oracle Rdb SQL Reference Manual for examples of when youA would want to use the DECLARE TRANSACTION statement instead of6 the SET TRANSACTION or START TRANSACTION statement.< You can specify many options with the DECLARE TRANSACTION statement, including:< o A transaction mode (READ O NLY/READ WRITE/BATCH UPDATE)5 o A lock specification clause (RESERVING options) o A wait mode (WAIT/NOWAIT) o An isolation level2 o A constraint evaluation specification clauseB o Multiple sets of all the preceding options for each database- involved in the transaction (ON clause) 3 Environment1 You can use the DECLARE TRANSACTION statement: o In interactive SQL: o Embedded in host language programs to be precompiled o In a conte xt file5 o As part of the DECLARE section in an SQL module? o As part of the module header in a CREATE MODULE statement> o In dynamic SQL as a statement to be dynamically executed@ In host language programs, you can have only a single DECLAREA TRANSACTION statement in each separately compiled source file.@ See the Oracle Rdb SQL Reference Manual for more information.@ The DECLARE TRANSACTION statement is an extension to standardB SQL syntax. If your program mus t adhere to standard SQL syntax,C you can isolate a DECLARE TRANSACTION statement by putting it inA a context file. For more information on context files, see the' Oracle Rdb Guide to SQL Programming. 3 Format* DECLARE TRANSACTION --+---------------+->( +-> tx-options -+( +-> db-txns ----+ tx-options = 3 --+-+----------------------------------------+-+->1 | +-> NAME 'quoted-string' ----------------+ |1 | +-> EVA LUATING -+- evaluating-clause --+-+ |1 | | +-------> , <----------+ | |1 | +-> RESERVING --+-> reserving-clause --+-+ |1 | | +-------- , <----------+ | |1 | +-> isolation-level ---------------------+ |1 | +-> transaction-mode --------------------+ |1 | +-> wait-option -------------------------+ |1 +----------------+-------+-------------------+ +-- , <-+ evaluating-clause = B -+-------------+-> -> AT -+-> VERB TIME ---+-->? +-> -+ +-> COMMIT TIME -+  reserving-clause = I -+-+-> ------------------------------------------------+-+-+I | +-> -+-------------------------------------------+-+ | |I | +-> PARTITION --> ( -+-> -+-> ) -+ | |I | +------ , <-----+ | |I +----------------------------------- , <---------------------------- + |I +---------------------------------------------------------------------+I +-> FOR -+--------------+--+-> READ ------------+--------------------->3 +-> EXCLUSIVE -+ +-> WRITE -----------+3 +-> PROTECTED -+ +-> DATA DEFINITION -+ +-> SHARED ----+  isolation-level = 3 ---> ISOLATION LEVEL --+-> READ COMMITTED ----+-->0 +-> REPEATABLE READ ---+0 +-> SERIALIZABLE ------+ transaction-mod e =  --+-> READ ONLY ----+-> +-> READ WRITE ---+ +-> BATCH UPDATE -+ wait-option =( --+-> WAIT -+---------------------+-+->& | +-> --+ |& +-> NOWAIT -----------------------+ db-txns = F --+--------------------------------------------------------------+-->C ++-> ON -+-> -+-> USING --> ( +-> tx-options --+-> ) -++B | +---- , <----+ +-> DEFAULTS ----+ |B +-------------------------- AND <--------- -------------------+  3 ArgumentsB The DECLARE TRANSACTION arguments are the same as the arguments= for the SET TRANSACTION statement. See the SET_TRANSACTION> statement for more information about the arguments for both statements. 3 DefaultsD The DECLARE TRANSACTION defaults are the same as the defaults forC the SET TRANSACTION statement. See the SET_TRANSACTION statement for complete information.9 In general, you should not rely on default transact ion@ characteristics. Use explicit DECLARE TRANSACTION statements,= specifying read/write, read-only, or batch-update options;= a list of tables in the RESERVING clause; and a share mode? and lock type for each table. The more specific you are in aB DECLARE TRANSACTION statement, the more efficient your database operations will be.A When a transaction starts using characteristics specified in aA DECLARE TRANSACTION statement, any transaction characteristics@ unspeci fied in the DECLARE TRANSACTION statement take the SQLD defaults. This is true even if the characteristics unspecified inB DECLARE TRANSACTION were specified in an earlier SET or DECLARE TRANSACTION statement. 3 ExamplesB Example 1: Illustrating DECLARE and SET TRANSACTION differences; In the following example, the first executable statementD following the DECLARE TRANSACTION statement starts a transaction.? In contrast, the subsequent SET TRANSACTION statement itsel f starts a transaction.. SQL> DECLARE TRANSACTION READ WRITE NOWAIT; SQL> --> SQL> -- Notice the "no transaction is in progress" message: SQL> -- SQL> SHOW TRANSACTION Transaction information:- Statement constraint evaluation is off On the default alias Transaction characteristics: Nowait Read Write3 Transaction information returned by base system: no transaction is in progress - session ID number is 80 SQL>  --7 SQL> -- The first executable statement following the@ SQL> -- DECLARE TRANSACTION statement starts the transaction.B SQL> -- In this case, SELECT is the first executable statement. SQL> --- SQL> SELECT LAST_NAME FROM CURRENT_SALARY; LAST_NAME Toliver Smith Dietrich . . . SQL> --G SQL> -- Note the transaction inherits the read/write characteristics: SQL> -- specified in the DECLARE TRANSACTION statement: SQL> -- SQL > SHOW TRANSACTION; Transaction information:- Statement constraint evaluation is off On the default alias Transaction characteristics: Nowait Read Write3 Transaction information returned by base system:* a read-write transaction is in progress& - updates have not been performed/ - transaction sequence number (TSN) is 416= - snapshot space for TSNs less than 416 can be reclaimed - session ID number is 80 SQL> --  SQL> ROLLBACK; SQL> --E SQL> -- Again, notice the "no transaction is in progress" message: SQL> -- SQL> SHOW TRANSACTION; Transaction information:- Statement constraint evaluation is off On the default alias Transaction characteristics: Nowait Read Write3 Transaction information returned by base system: no transaction is in progress8 - transaction sequence number (TSN) 416 is reserved= - snapshot space for TSNs l ess than 416 can be reclaimed - session ID number is 80 SQL> --D SQL> -- Unlike DECLARE TRANSACTION, the SET TRANSACTION statement, SQL> -- immediately starts a transaction: SQL> --' SQL> SET TRANSACTION READ ONLY WAIT; SQL> --8 SQL> -- Note the transaction characteristics show the% SQL> -- read-only characteristics: SQL> -- SQL> SHOW TRANSACTION; Transaction information:- Statement constraint evaluation is off On the default alias T ransaction characteristics: Wait Read only3 Transaction information returned by base system:( a snapshot transaction is in progressH - all transaction sequence numbers (TSNs) less than 416 are visible - TSN 416 is invisible: - all TSNs greater than or equal to 417 are invisible - session ID number is 80@ Example 2: Using a DECLARE TRANSACTION statement in a context fileA The following example shows a context file, test_declares.sql ,D that contains declarations for precompiling source file test.sco:( DECLARE ALIAS FOR FILENAME personnel;! DECLARE TRANSACTION READ WRITE3 RESERVING EMPLOYEES FOR PROTECTED WRITE,5 JOB_HISTORY FOR PROTECTED WRITE,1 DEPARTMENTS FOR SHARED READ,* JOBS FOR SHARED READ;? The section in the Oracle Rdb Guide to SQL Programming about= program transportability explains when you may need an SQLB context fil e to support a program that includes SQL statements. A Example 3: Explicitly setting the isolation level in a DECLARE TRANSACTION statement? In this example, you declare the default characteristics for@ a read/write transaction, which includes changing the defaultC ISOLATION LEVEL SERIALIZABLE to ISOLATION LEVEL REPEATABLE READ.G SQL> DECLARE TRANSACTION READ WRITE ISOLATION LEVEL REPEATABLE READ;# Example 4: Reserving a Partition: SQL> -- Determine the ordin al position of the EMPLOYEES SQL> -- partitions.@ SQL> SELECT RDB$MAP_NAME, RDB$AREA_NAME, RDB$ORDINAL_POSITION# cont> FROM RDB$STORAGE_MAP_AREAS, cont> WHERE RDB$MAP_NAME='EMPLOYEES_MAP';3 RDB$MAP_NAME RDB$AREA_NAME RDB$ORDINAL_POSITION0 EMPLOYEES_MAP EMPIDS_LOW 10 EMPLOYEES_MAP EMPIDS_MID 21 EMPLOYEES_MAP EMPIDS_OVER  3 3 rows selected SQL> --1 SQL> -- Reserve EMPIDS_MID and EMPIDS_OVER for SQL> -- exclusive write. SQL> -- SQL> DECLARE TRANSACTION, cont> RESERVING EMPLOYEES PARTITION (2,3) cont> FOR EXCLUSIVE WRITE; 2 VariableA Declares variables that you can use in interactive and dynamicC SQL for invoking stored procedures and for testing procedures inA modules or embedded SQL programs. For information on declaringD variables in compound state ments, see the Compound_Statement HELP topic. 3 Environment% You can use the DECLARE statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 3 Format5 DECLARE -+-> : +--+---------------+-+5 +-------- , <--------+ +--> CONSTANT --+ |5 +--> UPDATABLE -+ |5 +--------------------------------------------------+5 +-+-> data-type ----+-+--------------------+-------> - +-> + +-> default-clause -+  default-clause = 3 --+-> DEFAULT --+--+--> date-time-literal -+----->- +-> = ------+ +--> interval-literal -+- +--> numeric-literal --+- +--> string-literal ---+- +--> : -+ 3 Arguments 4 CONSTANT Syntax options: CONSTANT | UPDATABLE> CONSTANT changes the variable into a declared constant thatA cannot be updat ed. If you specify CONSTANT, you must also haveC specified the DEFAULT clause to ensure the variable has a value.> CONSTANT also indicates that the variable cannot be used asA the target of an assignment or be passed as an expression to a& procedure's INOUT or OUT parameter.C UPDATABLE is the default and allows the variable to be modified.@ An update of a variable can occur due to a SET assignment, anB INTO assignment (as part of an INSERT ... RETURNING, UPDATE ...D RETUR NING, or SELECT statement), or as a procedure's OUT or INOUT! parameter on a CALL statement. 4 data-typeB Specifies the data type assigned to the variable. See the Data_7 Types HELP topic for more information on data types. 4 default-clauseA You can only use references to simple literal values and other# declared variables as a default. 4 domain-nameA Specifies the domain name assigned to the variable. The domainC supplies the data type and, for interactive SQL, the edit string of the variable.A See the User_Supplied_Names HELP topic for more information on domain names. 4 variable-name Specifies the local variable. 3 Example4 Example 1: Declaring variables in interactive SQL SQL> DECLARE :X INTEGER; SQL> DECLARE :Y CHAR(10); SQL> SQL> BEGIN cont> SET :X = 100; cont> SET :Y = 'Active'; cont> END; SQL> PRINT :X, :Y ; X Y 100  Active SQL> SHOW VARIABLES;* X INTEGER+ Y CHAR(10)@ Example 2: Using the values of SQLSTATE in an interactive SQL scriptD The following simple script uses the named SQLSTATE variable with: the SIGNAL statement to make the script easier to read. @SYS$LIBRARY:SQLSTATE set verify; begin8 signal :SQLSTATE_DATA_ASSIGN ('Error in assignment'); end;3 When executed the output appears as shown b elow. SQL> begin> cont> signal :SQLSTATE_DATA_ASSIGN ('Error in assignment'); cont> end;H %RDB-E-SIGNAL_SQLSTATE, routine "(unnamed)" signaled SQLSTATE "22005"# -RDB-I-TEXT, Error in assignment SQL> ww?f 1 DELETE& Deletes a row from a table or view. 2 Environment$ You can use the DELETE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL modul e> o In dynamic SQL as a statement to be dynamically executed 2 Format@ DELETE FROM --+-> ---+-+-----------------------+-+@ +-> ----+ +-> -+ |@ +-------------------------------------------------------------+A ++--------------------------------------------------------+---->< +-> WHERE -+-> predicate --+---------------------------+-+< | +> optimize-clause ---------+ |< +-> CURRENT O F -----------------+  optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B |  | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  2 Arguments 3 correlation_name< Specifies a name that identifies the table or view in theA predicate of the DELETE statement. See the User_Supplied_Names; HELP topic for more information about correlation names.  3 CURRENT_OFD If the WHERE clause uses CURRENT OF cursor-name, SQL deletes only3 the row on which the named cursor is positioned.A The cursor must have been named previously in a DECLARE CURSOR? statement, must be open, and must be positioned on a row. In? addition, the FROM clause of the SELECT statement within theC DECLARE CURSOR statement must refer to the table or view that is& the target of the DELETE statement. 3 OPTIMIZE_AS Assigns a name to the que ry. 3 OPTIMIZE_FOR< The OPTIMIZE FOR clause specifies the preferred optimizer@ strategy for statements that specify a select expression. The# following options are available: o FAST FIRSTB A query optimized for FAST FIRST returns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optimization. A good candidate for FAST FIRST> optimiza tion is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST optimization.C If optimization strategy is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records inD the query, and performs updates or writes a repo rt, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization. o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly: valuable for tables that use the strict partitioning functionality. 3 OPTIMIZE_USING? Names the query outline to be used with the DELETE statement? even if the outline ID for the query and for the outline are different.< A query outline is an overall pla n for how a query can be? implemented. See the CREATE OUTLINE statement for additional information. 3 OPTIMIZE_WITHB Selects one of three optimization controls: DEFAULT (as used by@ previous versions of Oracle Rdb), AGGRESSIVE (assumes smaller= numbers of rows will be selected), and SAMPLED (which uses= literals in the query to perform preliminary estimation on indices). 3 predicate@ If the WHERE clause includes a predicate, all the rows of theD tar get table for which the predicate is true are deleted. See the< Predicates HELP topic for more information on predicates. 3 table-name@ Specifies the name of the target table from which you want to delete a row. 3 view-nameA Specifies the name of the view from which you want to delete a row. 3 WHERE> Specifies the rows of the target table or view that will beA deleted. If you omit the WHERE clause, SQL deletes all rows ofD the target table or view. You can specify either a predicate or a# cursor name in the WHERE clause. 2 Examples8 Example 1: Deleting all information about an employee? To delete all the information about an employee, you need toD delete rows from several tables within a single transaction. ThisD program fragment deletes the rows from all the result tables thatB contain information about an employee. Note that all the DELETEC operations are included in one transaction so that no employee' s& records are only partially deleted.4 DISPLAY "Enter the ID number of employee".7 DISPLAY "whose records you want to delete: " WITH NO ADVANCING. ACCEPT EMP-ID. EXEC SQL) DECLARE TRANSACTION READ WRITE8 RESERVING EMPLOYEES FOR PROTECTED WRITE,8 JOB_HISTORY FOR PROTECTED WRITE,8 SALARY_HISTORY FOR PROTECTED WRITE,7 DEGREES FOR PROTECTED WRIT E END-EXEC EXEC SQL" DELETE FROM EMPLOYEES E( WHERE E.EMPLOYEE_ID = :EMP-ID END-EXEC IF SQLCODE < 0 THEN3 EXEC SQL ROLLBACK END-EXEC GO TO ERROR-PAR END-IF EXEC SQL% DELETE FROM JOB_HISTORY JH) WHERE JH.EMPLOYEE_ID = :EMP-ID END-EXEC IF SQLCODE < 0 THEN3 EXEC SQL ROLLBACK END-EXEC GO TO ERROR-PAR END-IF EXEC SQL(  DELETE FROM SALARY_HISTORY SH) WHERE SH.EMPLOYEE_ID = :EMP-ID END-EXEC IF SQLCODE < 0 THEN3 EXEC SQL ROLLBACK END-EXEC GO TO ERROR-PAR END-IF EXEC SQL DELETE FROM DEGREES D( WHERE D.EMPLOYEE_ID = :EMP-ID END-EXEC IF SQLCODE < 0 THEN3 EXEC SQL ROLLBACK END-EXEC GO TO ERROR-PAR END-IF1 Example 2: Deleting selected rows from a tableD The followi ng statement deletes all rows from the EMPLOYEES table@ where the employee SALARY_AMOUNT is greater than $75,000. TheD EMPLOYEES and SALARY_HISTORY tables are both in the database with the alias PERS./ SQL> ATTACH 'ALIAS PERS FILENAME personnel';$ SQL> DELETE FROM PERS.EMPLOYEES E cont> WHERE EXISTS ( SELECT *4 cont> FROM PERS.SALARY_HISTORY S< cont> WHERE S.EMPLOYEE_ID = E.EMPLOYEE_ID6 cont> AND S.SALARY_AMOUNT > 75000  cont> ) ; 7 rows deletedC Example 3: Deleting rows from a table specifying an outline nameA The following example shows the syntax used to define the DEL_ EMP_75000 outline:$ SQL> CREATE OUTLINE DEL_EMP_75000 cont> FROM% cont> (DELETE FROM EMPLOYEES E% cont> WHERE EXISTS ( SELECT */ cont> FROM SALARY_HISTORY S< cont> WHERE S.EMPLOYEE_ID = E.EMPLOYEE_ID6 cont> AND S.SALARY_AM OUNT > 75000 cont> );; The following query specifies the DEL_EMP_75000 outline: SQL> DELETE FROM EMPLOYEES E cont> WHERE EXISTS ( SELECT */ cont> FROM SALARY_HISTORY S< cont> WHERE S.EMPLOYEE_ID = E.EMPLOYEE_ID6 cont> AND S.SALARY_AMOUNT > 75000 cont> )& cont> OPTIMIZE USING DEL_EMP_75000;! ~S: Outline DEL_EMP_75000 used . . . 7 rows deleted ww P 1 DESCRIBE; Writes information about a prepared statement to the SQL Descriptor Area (SQLDA).A The DESCRIBE statement is a dynamic SQL statement. Dynamic SQL? lets programs accept or generate SQL statements at run time,A in contrast to SQL statements that are part of the source code> for precompiled programs or SQL module language procedures.A Unlike precompiled SQL or SQL module language statements, suchB dynamically executed SQL statements are not part of a program'sD source code but are generated while the program runs. Dynamic SQLC is useful when you cannot predict the type of SQL statement your program needs to process.A The SQLDA is a collection of host language variables used onlyA in dynamic SQL programs. To use the SQLDA, host languages mustD support pointer variables that provide indirect access to storageB by storing the address of data instead of directly storing data@ in the host language variable. The languages supported by theB SQL precompiler that also support pointer variables are Ada, C,C and PL/I. Any other language that supports pointer variables canB use the SQLDA, but must call SQL module procedures that containB SQL statements instead of embedding the SQL statements directlyC in source code. The SQLDA provides information about dynamic SQLC statements to the program and information about memory allocated by the program to SQL.@ The DESCRIBE statement is how S QL writes information that theB program uses to the SQLDA. Specifically, the DESCRIBE statementC stores in the SQLDA the number and data types of any select list6 items or parameter markers in a prepared statement.? The Oracle Rdb SQL Reference Manual describes in more detail> the specific fields of the SQLDA and how programs use it to? communicate about select list items and parameter markers in prepared statements. 2 Environment& You can use the DESCRIBE statem ent:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format2 DESCRIBE -+-> ------------+----+2 +-> ----+ |2 +---------------------- <----------------------+8 +--+----------------+-----> INTO --> +-> SELECT LIST -+ +-> OUTPUT ------+ +-> MARKERS -----+ +-> INPUT -------+  2 Arguments 3 INPUTA Spe cifies that the DESCRIBE statement writes information aboutD input parameter markers to the SQLDA. The MARKERS or INPUT clauseA specifies that the DESCRIBE statement writes information aboutB the number and data types of any input parameter markers in the# prepared statement to the SQLDA.A Input parameter markers in a prepared statement serve the sameA purpose as host language variables in nondynamic, embedded SQL@ statements. The program can use that information in the SQL DA> to allocate storage. The program must supply values in thatD allocated storage. SQL substitutes these values for the parameter? markers when it dynamically executes the prepared statement. 3 INTO_descriptor_nameB Specifies the name of a structure declared in the host languageC program as an SQLDA to which SQL writes information about select4 list items, or input or output parameter markers.B Precompiled programs can use the embedded SQL statement INCLUDE: SQL DA to automatically insert a declaration of an SQLDA> structure, called SQLDA, in the program when it precompiles> the program. Programs that use the SQL module language must@ explicitly declare an SQLDA. Either precompiled or SQL moduleA language programs can explicitly declare additional SQLDAs butB must declare them with unique names. For sample declarations of= SQLDA structures, see the Oracle Rdb SQL Reference Manual. 3 MARKERSA Specifies that the DESCRIBE stateme nt writes information aboutD input parameter markers to the SQLDA. The MARKERS or INPUT clauseA specifies that the DESCRIBE statement writes information aboutB the number and data types of any input parameter markers in the# prepared statement to the SQLDA.A Input parameter markers in a prepared statement serve the sameA purpose as host language variables in nondynamic, embedded SQL@ statements. The program can use that information in the SQLDA> to allocate storage. The program must supply values in thatD allocated storage. SQL substitutes these values for the parameter? markers when it dynamically executes the prepared statement. 3 OUTPUTA Specifies that the DESCRIBE statement writes information about? returned values in a prepared statement to the SQLDA. If youC use this clause, the DESCRIBE statement writes information aboutC the number and data types of any returned values in the prepared? statement to the SQLDA. The program u ses that information toB allocate storage for the returned values. The storage allocated4 by the program then receives the returned values.D The following statements or clauses return values to the DESCRIBE statement:- o Select list items in a SELECT statement@ o The following statements within multistatement procedures:# - Singleton SELECT statementE - INSERT . . . RETURNING and UPDATE . . . RETURNING statements! - SET assignment statement 2 o CALL statement (invoking a stored procedure)( o Dynamic singleton SELECT statement* The default is SELECT LIST (or OUTPUT). 3 SELECT_LISTA Specifies that the DESCRIBE statement writes information about? returned values in a prepared statement to the SQLDA. If youC use this clause, the DESCRIBE statement writes information aboutC the number and data types of any returned values in the prepared? statement to the SQLDA. The program uses that information to B allocate storage for the returned values. The storage allocated4 by the program then receives the returned values.D The following statements or clauses return values to the DESCRIBE statement:- o Select list items in a SELECT statement@ o The following statements within multistatement procedures:# - Singleton SELECT statementE - INSERT . . . RETURNING and UPDATE . . . RETURNING statements! - SET assignment statement2 o CALL statement ( invoking a stored procedure)( o Dynamic singleton SELECT statement* The default is SELECT LIST (or OUTPUT). 3 statement-name= Specifies the name of a prepared statement. If the PREPARE? statement for the dynamically executed statement specifies a> parameter, use the same parameter in the DESCRIBE statement) instead of an explicit statement name.@ You can supply either a parameter or a compile-time statement> name. Specifying a parameter lets SQL supply iden tifiers to@ programs at run time. Use an integer parameter to contain the= statement identifier returned by SQL or a character string? parameter to contain the name of the statement that you passC to SQL. See the PREPARE statement and the DECLARE Dynamic_CURSOR statement for more details. 3 statement-id-parameterA The name of a prepared statement. If the PREPARE statement forD the dynamically executed statement specifies a parameter, use theB same parameter in t he DESCRIBE statement instead of an explicit statement name.@ You can supply either a parameter or a compile-time statement> name. Specifying a parameter lets SQL supply identifiers to@ programs at run time. Use an integer parameter to contain the= statement identifier returned by SQL or a character string? parameter to contain the name of the statement that you passC to SQL. See the PREPARE statement and the DECLARE Dynamic_CURSOR statement for more details. 2 E xamples> Example 1: Using the DESCRIBE . . . OUTPUT statement with a prepared SELECT statement@ This PL/I program illustrates using the DESCRIBE . . . OUTPUT? statement to write information to the SQLDA about the selectD list items of a prepared SELECT statement. There are no parameter8 markers in this particular prepared SELECT statement.B After issuing the DESCRIBE statement, the program stores in theC SQLDA the addresses of host language variables that will receive C values from columns of the result table during FETCH statements.; To shorten the example, this PL/I program is simplified:A o The program includes the SELECT statement to be dynamicallyA executed as part of the source code directly in the PREPARE> statement. A program with such coded SQL statements doesB not need to use dynamic SQL at all, but can simply embed the@ SELECT statement in a DECLARE CURSOR statement. (A programB that must process SQL statem ents generated as it executes is/ the only type that requires dynamic SQL.)B o The program declares host language variables for select listA items without checking the SQLDA for a description of thoseA items. Typically, an application needs to look in the SQLDA@ to determine the number and data type of select list items@ generated by a prepared SELECT statement before allocating storage.A o The program does not use the DESCRIBE . . . INPUT statement = to determine if there are any parameter markers in this= dynamically executed SELECT statement. In this example,> because the SELECT statement is coded in the program, it? is clear that there is no need for a DESCRIBE . . . INPUT> statement. However, if the SELECT statement is generatedA at run time, the program may have to determine there if areC parameter markers by issuing a DESCRIBE . . . INPUT statement> and looking at the value of the SQLD f ield in the SQLDA.( CURSOR_EX : PROCEDURE OPTIONS (MAIN); /*< * Illustrate the DESCRIBE...SELECT LIST statement using a * dynamic SELECT statement: *4 * Use a dynamic SELECT statement as the basis for3 * a cursor that displays a join of the EMPLOYEES- * and SALARY_HISTORY tables on the screen. */$ declare sys$putmsg external entry* (any, any value, any value, any value);) /* Declare SQL Communications Area: */ EXEC SQL INCLUDE SQLCA;% /* Decl are SQL Descriptor Area: */ EXEC SQL INCLUDE SQLDA; /* Declare the alias: */2 EXEC SQL DECLARE ALIAS FILENAME 'SQL$DATABASE'; /*0 * Branch to ERR_HANDLER if the SQLCODE field% * of the SQLCA is greater than 0: *// EXEC SQL WHENEVER SQLERROR GOTO ERR_HANDLER; /*. * Declare a cursor named EMP that uses the$ * prepared statement DYN_SELECT: */. EXEC SQL DECLARE EMP CURSOR FOR DYN_SELECT;) /* Declare a host structure to receive& * th e results of FETCH statements: */ DCL 1 P_REC,# 2 EMPLOYEE_ID CHAR(5),$ 2 FIRST_NAME CHAR(10),$ 2 LAST_NAME CHAR(14),, 2 SALARY_AMOUNT FIXED BINARY(31);' /* Allocate memory for the SQLDA and& * set the value of its SQLN field: */ SQLSIZE = 10;! ALLOCATE SQLDA SET (SQLDAPTR); SQLN = 10;" /* Prepare the SELECT statement$ * for dynamic execution directly * from a statement string: */# EXEC SQ L PREPARE DYN_SELECT FROM! 'SELECT E.EMPLOYEE_ID, E.FIRST_NAME, E.LAST_NAME," S.SALARY_AMOUNT. FROM EMPLOYEES E, SALARY_HISTORY S2 WHERE E.EMPLOYEE_ID = S.EMPLOYEE_ID AND' S.SALARY_END IS NULL';! /* Write information about the! * columns of the result table# * of DYN_SELECT into the SQLDA: */2 EXEC SQL DESCRIBE DYN_SELECT OUTPUT INTO SQLDA; /*/ * Assign t he addresses of the host language3 * variables that will receive the values of the& * fetched row to the SQLDATA field * of the SQLDA: */$ SQLDATA(1) = ADDR( EMPLOYEE_ID );" SQLDATA(2) = ADDR( FIRST_NAME);" SQLDATA(3) = ADDR( LAST_NAME );% SQLDATA(4) = ADDR( SALARY_AMOUNT); /* Open the cursor: */ EXEC SQL OPEN EMP;. /* Fetch the first row of the result table.) * SQL uses the addresses in the SQLDA) * to store values from the table into"  * the host language variables. */- EXEC SQL FETCH EMP USING DESCRIPTOR SQLDA;C PUT EDIT ('Current Salaries of Employees: ') (SKIP, A, SKIP(2));$ /* While the SQLCODE field of the) * SQLCA is not 100 (NOT_FOUND error): */ DO WHILE (SQLCA.SQLCODE = 0);E /* Display the values from the host language variables: */ PUT SKIP EDIT> (EMPLOYEE_ID, ' ', FIRST_NAME, ' ', LAST_NAME, ' ', SALARY_AMOUNT)$ (A, A, A, A, A, A , F(9));7 /* Fetch another row of the result table: */5 EXEC SQL FETCH EMP USING DESCRIPTOR SQLDA; END; /* Close the cursor: */ EXEC SQL CLOSE EMP; RETURN; ERR_HANDLER: PUT EDITM ('Unexpected error, SQLCODE is: ', SQLCA.SQLCODE) (skip, a, f(9));8 CALL SYS$PUTMSG(RDB$MESSAGE_VECTOR, 0, 0, 0);/ EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK; RETURN; END CURSOR_EX; 0 See also Example 2 in DECLARE Dynamic_CURSOR. wwP 1 DISCONNECTA Detaches from declared databases and releases the aliases thatC you specified in the declarations. The DISCONNECT statement alsoA ends the specified transactions and undoes all the changes you' made since those transactions began. 2 Environment( You can use the DISCONNECT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format) DISCONNECT ---+-> -+->' +-> ALL ---------------+' +-> CURRENT -----------+' +-> DEFAULT -----------+  connection-name = " -+--> ' ' -------+----> +--> ---------+ +--> --+  2 Arguments 3 ALL$ Specifies all active connec tions. 3 connection-name< Specifies a name for the association between the group ofB databases being attached (the environment) and the database and- queries that reference them (the session).8 You can specify the connection name as the following:9 o A string literal enclosed in single quotation marks& o A parameter (in module language)% o A variable (in precompiled SQL) 3 CURRENT$ Specifies the current connection. 3 DEFAULT$ Speci fies the default connection. 2 Examples? Example 1: Using the DISCONNECT statement in interactive SQLB This example in interactive SQL illustrates that the DISCONNECT@ statement lets you attach a database with the same alias as aA previously attached database (in this example the alias is the@ default). Use the SHOW DATABASE statement to see the database settings.! SQL> ATTACH 'FILENAME mypers'; SQL> --! SQL> ATTACH 'FILENAME mypers';( This alias has al ready been declared.7 Would you like to override this declaration (No)? noO %SQL-F-DEFDBDEC, A database has already been declared with the default alias SQL> DISCONNECT DEFAULT;! SQL> ATTACH 'FILENAME mypers';? Example 2: Using the DISCONNECT statement in precompiled SQLD This example is taken from the sample program sql_connections.sc.8 To use connections in a program, you must specify the< SQLOPTIONS=(CONNECT) qualifier on the precompiler commandA line. This exam ple shows an EXEC SQL DISCONNECT statement that@ specifies the string literal 'al' for the connection-name andC EXEC SQL DISCONNECT statements that specify the keywords ALL and DEFAULT. #include  #include  #include  char employee_id1[6]; char last_name1[16]; char employee_id2[16]; char degree[14]; char employee_id3[16]; char supervisor[6]; char employee_id4[6]; char last_name4[15]; v oid sys$putmsg(); EXEC SQL INCLUDE SQLCA;6 EXEC SQL declare alias filename personnel;6 EXEC SQL declare alias_1 alias filename personnel;6 EXEC SQL declare alias_2 alias filename personnel;6 EXEC SQL declare alias_3 alias filename personnel; main() {G printf("\n\n\n******* Disconnect from default ***************\n");! EXEC SQL disconnect default;C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0); printf("\n\n\n");< printf("********* Establish CONNECTION 1 **********\n");C EXEC SQL connect to 'alias alias_1 filename personnel' as 'a1';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);6 printf("********* Insert a record **********\n");C EXEC SQL insert into alias_1.employees (employee_id, last_name) values ('00301','FELDMAN');C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);: printf("********* Retrieve the record **********\n");> EXEC SQL select employee_id, last_name into :employee_id1,C :last_name1 from alias_1.employees where employee_id = '00301';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0); printf("\n\n\n");/ printf ("Employee_id = %s\n",employee_id1);- printf ("Last_name = %s\n",last_name1); printf("\n\n\n");< printf("********* Establish CONNECTION 2 **********\n");C EXEC SQL connect to 'alias alias_2 filename personnel' as 'a2';C if (SQLCA.SQLCODE != 0) S YS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);6 printf("********* Insert a record **********\n");D EXEC SQL insert into alias_2.degrees (employee_id, degree_field) values ('00901','MASTERS');C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);: printf("********* Retrieve the record **********\n");A EXEC SQL select employee_id, degree_field into :employee_id2,= :degree from alias_2.degrees where employee_id = '00901';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG( &RDB$MESSAGE_VECTOR,0,0,0); printf("\n\n\n");/ printf("Employee-id = %s\n",employee_id2);) printf("Degree = %s\n",degree); printf("\n\n\n");< printf("********* Establish CONNECTION 3 **********\n");C EXEC SQL connect to 'alias alias_3 filename personnel' as 'a3';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);6 printf("********* Insert a record **********\n");I EXEC SQL insert into alias_3.job_history (employee_id, supervisor_id ) values ('01501','Brown');C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);: printf("********* Retrieve the record **********\n");B EXEC SQL select employee_id, supervisor_id into :employee_id3,E :supervisor from alias_3.job_history where employee_id = '01501';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0); printf("\n\n\n");/ printf("Employee-id = %s\n",employee_id3);. printf("Supervisor = %s\n ",supervisor); pr intf("\n\n\n");B printf("********* Establish CONNECTION DEFAULT **********\n");" EXEC SQL set connect default ;C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);C printf("********* Retrieve record with id 00164 **********\n");> EXEC SQL select employee_id, last_name into :employee_id4,; :last_name4 from employees where employee_id = '00164';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0); printf("\n\n\n");/ printf("Employee _id = %s\n",employee_id4);- printf("Last_name = %s\n",last_name4); printf("\n\n\n");F printf("**** DISCONNECT, RECONNECT & TRY TO FIND RECORD *****\n");! strcpy(employee_id1," ");( strcpy(last_name1," "); EXEC SQL disconnect 'a1';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);C EXEC SQL connect to 'alias alias_1 filename personnel' as 'a1';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);: printf ("********* Retrieve the record **********\n");> EXEC SQL select employee_id, last_name into :employee_id1,C :last_name1 from alias_1.employees where employee_id = '00301';C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0);G printf("************** SHOULD DISPLAY NO RECORD **************\n"); printf("\n\n\n");. printf("employee_id = %s\n",employee_id1);, printf("last_name = %s\n",last_name1); printf("\n\n\n");L printf("*************** DISCO NNECT ALL CONNECTIONS ***************\n"); EXEC SQL disconnect all;C if (SQLCA.SQLCODE != 0) SYS$PUTMSG(&RDB$MESSAGE_VECTOR,0,0,0); EXEC SQL rollback; } wwa1 DROP 2 CATALOG@ Deletes the specified catalog definition. You must delete all@ schemas and definitions contained in a catalog before you canD delete that catalog. If other definitions exist that refer to the% named catalog, the deletion fails.D The DROP CATALOG statement  lists all schemas and definitions thatC it is going to delete. You can roll back the statement if you do( not want to delete these definitions. 3 Environment* You can use the DROP CATALOG statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format5 DROP CATALOG -+-+---------------+-+->3  | +-> CASCADE ----+ |3 | +-> RESTRICT --+ |3 | +-> IF EXISTS --+ |3 +----------<--------+ catalog-name = . -+------> --------------+->, | |, +-> " -> . ->" -+  3 Arguments 4 alias.name-of-catalog> Specifies a name for the attachment to the database. Always< q ualify the catalog name with an alias if your program or> interactive SQL statements refer to more than one database.A Separate the name of the catalog from the alias with a period,< and enclose the qualified name in double quotation marks.> You must issue a SET QUOTING RULES statement before you can( qualify a catalog name with an alias. 4 CATALOG Syntax options: CASCADE | RESTRICTC Performs a restricted delete by default. If you prefer to delete@ all d efinitions contained in the catalog, you can specify the" DROP CATALOG CASCADE statement. 4 catalog-name% Specifies the module catalog name. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 3 Example Example 1: Deleting a catalogD The following statement deletes the catalog DEPT1 associated with the alias PERSONNEL_ALIAS:? SQL> ATTACH 'ALIAS PERSONNEL_ALIAS FI LENAME CORPORATE_DATA';" SQL> SET QUOTING RULES 'SQL99';/ SQL> CREATE CATALOG "PERSONNEL_ALIAS.DEPT1"; SQL> SHOW CATALOG;' Catalogs in database PERSONNEL_ALIAS' "PERSONNEL_ALIAS.ADMINISTRATION"% "PERSONNEL_ALIAS.RDB$CATALOG"" "PERSONNEL_ALIAS.DEPT1"- SQL> DROP CATALOG "PERSONNEL_ALIAS.DEPT1"; SQL> SHOW CATALOG;' Catalogs in database PERSONNEL_ALIAS' "PERSONNEL_ALIAS.ADMINISTRATION"$ "PERSONNEL_ALIAS.RDB$CATALOG"3 SQL> DROP CATALOG "PERSONNEL_ALIAS.RDB$CATALOG";H %SQL-F-NODROPSYSCAT, Catalog "PERSONNEL_ALIAS.RDB$CATALOG" may not be dropped SQL> 2 COLLATING_SEQUENCE( Deletes the named collating sequence.> You cannot delete a collating sequence if it is used by the- database or by any domain in the database. 3 Environment5 You can use the DROP COLLATING SEQUENCE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a p rocedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatB DROP COLLATING SEQUENCE --> -+---------------+->@ +-> IF EXISTS --+ 3 Arguments 4 collation-nameC Specifies the collation-name argument you used when creating theA collating sequence in the CREATE COLLATING SEQUENCE statement. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 3 ExamplesB Example 1: Creating, then deleting, a French collating sequence? The following example creates a collating sequence using the> predefined collating sequence FRENCH. It then uses the SHOW= COLLATING SEQUENCE statement to show the defined collating sequence.< The example next deletes the collating sequence using theA DROP COLLATING SEQUENCE statement. The SHOW COLLATING SEQUENCE @ statement shows that the collating sequence no longer exists.$ SQL> ATTACH 'FILENAME personnel';0 SQL> CREATE COLLATING SEQUENCE FRENCH FRENCH; SQL> -- SQL> SHOW COLLATING SEQUENCE? User collating sequences in database with filename personnel FRENCH SQL> --' SQL> DROP COLLATING SEQUENCE FRENCH; SQL> -- SQL> SHOW COLLATING SEQUENCE? User collating sequences in database with filename personnel No collating sequences foundC Example 2: Dele ting a collating sequence used to define a domain or databaseA The following example shows that you cannot delete a collatingB sequence if a domain or database is defined using the collating sequence:2 SQL> CREATE COLLATING SEQUENCE SPANISH SPANISH;1 SQL> CREATE DOMAIN LAST_NAME_SPANISH CHAR (14)' cont> COLLATING SEQUENCE IS SPANISH; SQL> --% SQL> SHOW DOMAIN LAST_NAME_SPANISH+ LAST_NAME_SPANISH CHAR(14) Collating sequence: SPANISH SQL > -- SQL> SHOW COLLATING SEQUENCE? User collating sequences in database with filename personnel SPANISH SQL> --? SQL> -- You cannot delete the collating sequence because theI SQL> -- domain LAST_NAME_SPANISH, defined using SPANISH, still exists: SQL> --( SQL> DROP COLLATING SEQUENCE SPANISH;0 %RDB-E-NO_META_UPDATE, metadata update failedF -RDMS-F-COLUSEDFLD, the collating sequence named SPANISH is used in field LAST_NAME_SPANISH SQL> -- SQL> -- D elete the domain: SQL> --& SQL> DROP DOMAIN LAST_NAME_SPANISH; SQL> --5 SQL> -- Now you can delete the collating sequence: SQL> --( SQL> DROP COLLATING SEQUENCE SPANISH; SQL> -- SQL> SHOW COLLATING SEQUENCE? User collating sequences in database with filename personnel No collating sequences found 2 CONSTRAINT! Deletes the named constraints. 3 Environment- You can use the DROP CONSTRAINT statement: o In interactive SQL: o Em bedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format; DROP CONSTRAINT --> -+---------------+->9 +-> IF EXISTS --+ 3 Arguments 4 constraint-name@ Specifies the name of the constraint that you want to delete. 4 IF_EXISTSB Prevents SQL command language from displaying error mes sages if8 the referenced object does not exist in the database. 3 Example# Example 1: Deleting a constraint? The following statement deletes the SEX_NOT_NULL constraint.% SQL> DROP CONSTRAINT SEX_NOT_NULL; 2 DATABASE Deletes a database.> When this statement executes in Oracle Rdb, SQL deletes all? the database root and storage area files associated with the database.= If you specify a repository path name in the DROP DATABASEA statement or  specify an alias for a database attached with theD PATHNAME argument, SQL also deletes the repository directory that% contains the database definitions.' CAUTION? Use the DROP DATABASE statement with care. You cannot useA the ROLLBACK statement to cancel a DROP DATABASE statement.@ When you use this statement, SQL deletes the database root< and storage area files, which include all data and all definitions. 3 Environ ment+ You can use the DROP DATABASE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatB DROP DATABASE --------------------------------------------------+B +-------------------------- <----------------------------------+E +-> ALIAS ---------------------------------------------+-->B +-> FILENAME 'db-a ttach-spec' ------+-+----------------------+-+@ +-> PATHNAME -----------+ +-> literal-user-auth -+  db-attach-spec = ( --+----------------+-> ---> +-> -+ node-spec = + -+-> -+-------------------+-+->) | +-> + |) +------------------ :: <--------------+ access-string = & -+-> " " --+->$ +-> " " ---+  literal-user- auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  3 Arguments 4 ALIAS_aliasB Specifies the alias for an attached database. The DROP DATABASEC statement deletes the database and all database root and storage( area files associated with the alias.D If the database was declared with the PATHNAME argument, the DROP@ DATABASE statement also deletes the repository directory that% contains the  database definitions. 4 FILENAMEC Specifies a quoted string containing full or partial informationD needed to access a database. An attach specification contains the' file specification of the .rdb file.; The DROP DATABASE statement deletes the database and all? database system files associated with the database root fileC specification. If you use a partial file specification, SQL usesB the standard defaults. The DROP DATABASE statement deletes only@ the dat abase files, whether or not there is also a repository- directory containing database definitions. 4 literal-user-auth@ Specifies the user name and password for access to databases, particularly remote database.B This literal lets you explicitly provide user name and password. information in the DROP DATABASE statement. 4 PATHNAME< Specifies a full or relative repository path name for theB repository directory where the database definitions are stored.@  Use a path name instead of a file specification to delete theA repository database definitions from the repository along with> the database root and storage area files. See also the DROP PATHNAME statement. 4 USER_usernameB Defines a character string literal that specifies the operating? system user name that the database system uses for privilege checking. 4 USING_password? Defines a character string literal that specifies the user's; password for th e user name specified in the USER clause. 3 Examples! Example 1: Deleting files only@ The following statement deletes the database system files forC the database associated with the database personnel.rdb. If thisB database also had definitions stored in a repository directory,C this DROP DATABASE statement would not delete those definitions.) SQL> DROP DATABASE FILENAME personnel;7 Example 2: Deleting files and repository definitions; To delete database  files and repository definitions, you; must specify a repository path name in the DROP DATABASE= statement. This statement deletes the repository directory@ CDD$TOP.ACCOUNTING.PERSONNEL in addition to all database root- and storage area files associated with it.< SQL> DROP DATABASE PATHNAME CDD$TOP.ACCOUNTING.PERSONNEL; 2 DOMAIN? Deletes a domain definition. If you attached to the database< using the PATHNAME qualifier, SQL also deletes the domain" definition fr om the repository. 3 Environment) You can use the DROP DOMAIN statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format5 DROP DOMAIN --> --+---------------+-->2 +-> IF EXISTS --+  3 Arguments 4 domain-name7 Specifies the name of the domain  you want to delete. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 3 Examples: Example 1: Deleting a domain not referred to by columns SQL> --A SQL> -- The following CREATE DOMAIN statement creates a domain+ SQL> -- that is not used by any columns: SQL> --& SQL> CREATE DOMAIN ABCD IS CHAR(4); SQL> --> SQL> -- The SHOW DOMAINS statement shows domain ABCD at the SQL> -- top of the list: SQL> -- SQL> SHOW DOMAINS3 User domains in database with filename personnel* ABCD CHAR(4)+ ADDRESS_DATA_1_DOM CHAR(25)+ ADDRESS_DATA_2_DOM CHAR(20) . . . SQL> --! SQL> -- Now delete the domain: SQL> -- SQL> DROP DOMAIN ABCD; SQL> --4 SQL> -- The SHOW DOMAINS statement shows that the( SQL> -- domain ABCD has been deleted: SQL> -- SQL> SH OW DOMAINS3 User domains in database with filename personnel+ ADDRESS_DATA_1_DOM CHAR(25)+ ADDRESS_DATA_2_DOM CHAR(20) . . .6 Example 2: Deleting a domain referred to by columns? The following example deletes a domain definition. Because aA column refers to the domain definition and a constraint refersD to the column, you must first alter the table before deleting the domain. SQL> --@ SQL> -- Attempt to dele  te the domain SEX_DOM. Error messages< SQL> -- indicate that the table EMPLOYEES uses the domain5 SQL> -- SEX_DOM, so SEX_DOM cannot yet be deleted: SQL> -- SQL> DROP DOMAIN SEX_DOM;0 %RDB-E-NO_META_UPDATE, metadata update failed> -RDMS-F-RELEXI, field SEX_DOM is used in relation EMPLOYEES8 -RDMS-F-FLDNOTDEL, field SEX_DOM has not been deleted SQL> --? SQL> -- Looking at the EMPLOYEES table shows that SEX is the: SQL> -- column that depends on the domain SEX_DOM. T  ryE SQL> -- to delete the column SEX; error messages indicate that the? SQL> -- constraint EMP_SEX_VALUES depends on the column SEX: SQL> --. SQL> ALTER TABLE EMPLOYEES DROP COLUMN SEX;0 %RDB-E-NO_META_UPDATE, metadata update failedI -RDMS-F-FLDINCON, field SEX is referenced in constraint EMP_SEX_VALUES4 -RDMS-F-RELFLDNOD, field SEX has not been deleted from relation EMPLOYEES SQL> --0 SQL> -- Delete the constraint EMP_SEX_VALUES: SQL> --= SQL> ALTER TABLE EM  PLOYEES DROP CONSTRAINT EMP_SEX_VALUES; SQL> --B SQL> -- Because EMP_SEX_VALUES was the only constraint or index> SQL> -- that depended on the column SEX, you can now delete SQL> -- the column SEX: SQL> --. SQL> ALTER TABLE EMPLOYEES DROP COLUMN SEX; SQL> --G SQL> -- The column SEX in the table EMPLOYEES was the only column inG SQL> -- the database that depended on the domain SEX_DOM, so you can) SQL> -- now delete the domain SEX_DOM: SQL> -- SQL> DROP DOM AIN SEX_DOM; SQL> 2 FUNCTION= For information on deleting an external or stored function/ definition, see the DROP Routine Help topic. 2 INDEX? Deletes the specified index definition. If you attach to theD database using the PATHNAME qualifier, SQL also deletes the index" definition from the repository. 3 Environment( You can use the DROP INDEX statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format7 DROP INDEX ---> --+-+---------------+-+->5 | +-> RESTRICT --+ |5 | +-> CASCADE --+ |5 | +-> IF EXISTS --+ |5 +----------<--------+ 3 Arguments 4 CASCADEB Specifies that you want SQL to modify any storage map that uses9 this index to be a NO PLACEMENT VIA INDEX storage map. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 index-nameA Specifies the name of the index definition you want to delete. 4 RESTRICTD Prevents the removal of an index if it is referenced by any otherA object within an Oracle Rdb database. RESTRICT is the default. 3 Examples9 Example 1: Deleting an index from the default database$ SQL> ATTACH 'FILENAME personnel';$ SQL> DROP INDEX DEG_COLLEGE_CODE; SQL> COMMIT;< Example 2: Deleting an index from one of several attached databases$ SQL> ATTACH 'FILENAME personnel';0 SQL> ATTACH 'ALIAS MF FILENAME mf_personnel';4 SQL> ATTACH 'ALIAS CORP FILENAME corporate_data';" SQL> SET QUOTING RULES 'SQL99';C SQL> DROP INDEX "CORP.ADMINISTRATION".PERSONNEL.EMP_EMPLOYEE_ID; SQL> COMMIT; 2 MODUL! E0 Deletes a module from an Oracle Rdb database. 3 Environment) You can use the DROP MODULE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format7 DROP MODULE --> -+-+---------------+-+->5 | +-> RESTRICT --+ |5 | +-> CASCADE " --+ |5 | +-> IF EXISTS --+ |5 +----------<--------+ 3 Arguments 4 CASCADE= Specifies that you want SQL to invalidate all objects that> refer to routines in the module and then delete that moduleC definition. This is known as a cascading delete. If you delete aD module referenced by a stored routine with a routine or language-B semantic dependency, SQL also marks the affected stored routine as # invalid. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 module-name% Identifies the name of the module. 4 RESTRICT? Prevents the removal of a stored routine definition when theD function or procedure is referenced by any other object within an0 Oracle Rdb database. RESTRICT is the default. 3 Examples; Example 1: Removing a module from an Oracle Rdb datab $ ase$ SQL> DROP MODULE employee_salary;: Example 2: Observing the DROP MODULE ... CASCASE actionA This example demonstrates that dependencies may exists between> the module being dropped and other database objects such asB routines and triggers. The script uses SET FLAGS with the WARN_@ INVALID option so that the database administrator is informed> of any affected objects. In this case a rollback is used to? undo the DROP MODULE ... CASCADE as the affects might damage% the application environment.% SQL> start transaction read write; SQL>" SQL> create module FIRST_MODULE! cont> function GET_TIME () cont> returns TIME (2);% cont> return CURRENT_TIME (2); cont> end module; SQL># SQL> create module SECOND_MODULE9 cont> procedure PRINT_TRACE (in :arg varchar(40)); cont> begin* cont> trace GET_TIME(), ': ', :arg; cont> end; cont> end module; SQL>! SQL> create table SAMPLE_TA& BLE cont> (ident integer, cont> descr char(100));+ SQL> create trigger SAMPLE_TABLE_TRIGGER) cont> after insert on SAMPLE_TABLE9 cont> (trace GET_TIME(), ': ', SAMPLE_TABLE.descr) cont> for each row; SQL> SQL> commit; SQL>! SQL> set flags 'warn_invalid';* SQL> drop module FIRST_MODULE restrict;0 %RDB-E-NO_META_UPDATE, metadata update failed_ -RDMS-E-OBJ_INUSE, object "GET_TIME" is referenced by SAMPLE_TABLE_TRIGGER. (usage: Tri' gger)@ -RDMS-E-MODNOTDEL, module "FIRST_MODULE" has not been deleted) SQL> drop module FIRST_MODULE cascade;5 ~Xw: Trigger "SAMPLE_TABLE_TRIGGER" marked invalid, ~Xw: Routine "PRINT_TRACE" marked invalid SQL> SQL> rollback; 2 OUTLINE Deletes a query outline. 3 Environment* You can use the DROP OUTLINE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module( > o In dynamic SQL as a statement to be dynamically executed@ The DROP OUTLINE statement allows the user to specify that an8 existing outline should be removed from the database. 3 Format6 DROP OUTLINE ---> -+---------------+->4 +-> IF EXISTS --+ 3 Arguments 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 outli) ne-name8 Specifies the name of the outline you want to delete. 3 Examples! Example 1. Deleting an outline SQL> DROP OUTLINE MY_OUTLINE; 2 PATHNAME= Deletes the repository definitions. It does not delete the physical database files. 3 Environment+ You can use the DROP PATHNAME statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL* as a statement to be dynamically executed 3 Format$ DROP PATHNAME ---> ---> 3 Arguments 4 path-nameA Specifies the repository path name for the schema definitions.> Specify either a full path name or a relative path name. If? you use a relative path name, the current default repositoryB directory must be defined to include all the path name segments' that precede the relative path name. 3 ExamplesC Example 1: Deleting a path + name with the DROP PATHNAME statement@ The following example deletes CDD$TOP.SQL.DEPT3, a repository= directory, and all its descendants. It does not delete theD database system files or data that corresponds to that path name.* SQL> DROP PATHNAME "CDD$TOP.SQL.DEPT3"; 2 PROCEDURE> For information on deleting an external or stored procedure/ definition, see the DROP Routine Help topic. 2 PROFILE Drops a profile definition. 3 Environment* You can u, se the DROP PROFILE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 FormatO DROP -+-> PROFILE --> ----------------+--+-+---------------+-+->M +-> DEFAULT PROFILE -+----------------------+-+ | +-> CASCADE ----+ |M +-> ALIAS aliasname ---+ | +-> RESTRI- CT ---+ |M | +-> IF EXISTS --+ |M +-------<-----------+ 3 Arguments 4 ALIAS_aliasnameD When attached to multiple databases, the aliasname is required to7 direct the DROP command to the appropriate database. 4 CASCADEB This option causes all user definitions to be altered to remove! the reference to this profile. 4 DEFAULT_PROFILE1 D. rops the special profile RDB$DEFAULT_PROFILE. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICT= If the profile is used by a user in the database, the DROP4 PROFILE statement will fail. This is the default. 3 Examples? Example 1: Using Delimited Identification Mixed-Case Profile Names& SQL> DROP PROFILE Decision_Support;0 %RDB-E-NO_META_UPDATE, meta/ data update failedN -RDMS-E-PRFNEXISTS, a quota does not exist with the name "DECISION_SUPPORT" SQL> SET DIALECT 'SQL99';( SQL> DROP PROFILE "Decision_Support"; SQL> COMMIT;B Example 2: Using CASCADE to remove assigned profiles from usersC This example demonstrates that there may be dependencies between@ profiles and user objects. The CASCADE action will remove the/ profile from all users to which is assigned.' SQL> create profile DECISION_SUPPORT: cont> c0 omment is 'restrictions for read-only users'* cont> default transaction read only3 cont> transaction modes (read only, shared); SQL>& SQL> show profile DECISION_SUPPORT; DECISION_SUPPORT3 Comment: restrictions for read-only users- Transaction modes (read only, shared)% Default transaction read only SQL> SQL> create user FREEMAN" cont> identified externally& cont> profile DECISION_SUPPORT; SQL> SQL> show user 1 FREEMAN; FREEMAN Identified externally Account is unlocked! Profile: DECISION_SUPPORT/ No roles have been granted to this user SQL>/ SQL> drop profile DECISION_SUPPORT restrict;0 %RDB-E-NO_META_UPDATE, metadata update failedM -RDMS-E-PRFINUSE, entry "DECISION_SUPPORT" is referenced by user "FREEMAN" SQL>. SQL> drop profile DECISION_SUPPORT cascade; SQL> SQL> show user FREEMAN; FREEMAN Identified externa2 lly Account is unlocked/ No roles have been granted to this user SQL> SQL> commit; 2 ROLE@ Drops a role previously created with the CREATE ROLE or GRANT statement. 3 Environment' You can use the DROP ROLE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 3 Format7 DROP ROLE ---> -+-+-----------------+-+-->4 | +---> CASCADE --+ |4 | +---> RESTRICT --+ |4 | +---> IF EXISTS --+ |4 +------------<--------+ 3 Arguments 4 CASCADE= Drops the specified role from the database and deletes all? references to this role that exist in other roles and access control lists (ACLs). 4 IF_EXISTS4 B Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICT@ Drops the specified role. If there are any references to thisC role in another role or ACL, then the DROP ROLE statement fails.& The RESTRICT clause is the default. 4 role-name= An existing role-name in the database (such as one createdA with the CREATE ROLE statement). You cannot specify one of the predefined roles. 5 3 Examples/ Example 1: Dropping a Role from the Database SQL> SHOW ROLES;3 Roles in database with filename mf_personnel.rdb DOCUMENTATION) SQL> DROP ROLE DOCUMENTATION RESTRICT; SQL> SHOW ROLES;3 Roles in database with filename mf_personnel.rdb No Roles Found 2 RoutineC Deletes a routine definition, external or stored, from an OracleC Rdb database. External routine refers to both external functions@ and external procedures. Stored r6 outine refers to both stored# functions and stored procedures. 3 Environment? You can use the DROP FUNCTION and DROP PROCEDURE statements: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 FormatA DROP -+-> FUNCTION --+-> -+-+---------------+-+->? +-> PROCEDURE -+ | +-> RESTRICT7 ---+ |? | +-> CASCADE ----+ |? | +-> RESRICT ----+ |? | +-> IF EXISTS --+ |? +----------<--------+ 3 Arguments 4 CASCADEB Deletes the routine definition even when there are dependencies@ on the specified routine. Any referencing routines are marked invalid. 4 IF_EXISTSB Prevents SQL comm8 and language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICTC Prevents the removal of an external or stored routine definition? when the routine is referenced by any other object within an Oracle Rdb database. RESTRICT is the default. 4 routine-nameC Identifies the name of the external or stored routine definition in the Oracle Rdb database. 3 Examples> Example 1: Deleting an external f9 unction definition from an Oracle Rdb databaseA If you want to alter an external function definition, you must@ first delete it and then create it again with the changes you@ plan. This example shows how to delete the COSINE_F function.( SQL> DROP FUNCTION cosine_f RESTRICT; 5 Example 2: Deleting a routine from a stored moduleA The DROP FUNCTION and DROP PROCEDURE statements can be used toC drop routines from a stored module. If the routine is referenced> by : other objects then the CASCADE option may be required to! successfully drop the routine.A See also the DROP FUNCTION and DROP PROCEDURE clauses of ALTER5 MODULE which can be used to perform the same task.? This example removes a function from the stored module TIME_% ROUTINES that is no longer in use. SQL> set dialect 'sql99';& SQL> create database filename junk; SQL># SQL> create module TIME_ROUTINES cont>! cont> function GET_TIME () cont> ; returns TIME (2);% cont> return CURRENT_TIME (2); cont>/ cont> function DAY_OF_WEEK (in :dt date)! cont> returns VARCHAR(10);3 cont> return case EXTRACT (weekday from :dt)) cont> when 1 then 'Monday'* cont> when 2 then 'Tuesday', cont> when 3 then 'Wednesday'+ cont> when 4 then 'Thursday') cont> when 5 then 'Friday'+ cont> when 6 then 'Saturday') cont> when < 7 then 'Sunday' cont> else '***' cont> end; cont> cont> end module; SQL>" SQL> show module TIME_ROUTINES;' Information for module TIME_ROUTINES Header: TIME_ROUTINES No description found Module ID is: 1% Routines in module TIME_ROUTINES: DAY_OF_WEEK GET_TIME' SQL> drop function GET_TIME cascade;" SQL> show module TIME_ROUTINES;' Information for module TIME_ROUTINES Header: = TIME_ROUTINES No description found Module ID is: 1% Routines in module TIME_ROUTINES: DAY_OF_WEEK SQL> 2 SCHEMA= Deletes a schema and all the definitions that it contains. 3 Environment) You can use the DROP SCHEMA statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 For> mat4 DROP SCHEMA -+-+---------------+-+-->1 | +-> CASCADE ---+ |1 | +-> RESTRICT --+ |1 | +-> IF EXISTS --+ |1 +----------<--------+ 3 Arguments 4 CASCADE= Deletes all other definitions (views, constraints, tables,C sequences, indexes, and triggers) that refer to the named schema> and then deletes that schema definition. This is known as? a cascading delete.B If you specify the CASCADE keyword, SQL deletes all definitions6 contained by the schema before deleting the schema.@ If you do not specify the CASCADE keyword, the schema must be empty. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICTC Returns an error message if other definitions refer to the named? schema. The DROP SCHEMA RESTRIC@ T statement will not delete aD schema until you have deleted all other definitions that refer toD the named schema. The DROP SCHEMA statement specifies an implicit RESTRICT by default. 4 schema-nameC Specifies the schema name. You must qualify the schema name with> catalog and alias names if the schema is not in the defaultA catalog and database. For more information about schema names,* see the User_Supplied_Names HELP topic. 3 Examples6 Example 1: Dele A ting a schema with implicit RESTRICTA In the following example, the user must delete the definitionsA that refer to the schema RECRUITING before deleting the schema itself.A After setting the default schema to RECRUITING and the defaultB catalog to ADMINISTRATION, the user can qualify each definition! name with only the alias CORP.4 SQL> ATTACH 'ALIAS CORP FILENAME CORPORATE_DATA';, SQL> SET CATALOG '"CORP.ADMINISTRATION"';6 SQL> SET SCHEMA '"CORP.ADMINISTRATION". B RECRUITING';" SQL> SET QUOTING RULES 'SQL92';& SQL> DROP SCHEMA "CORP.RECRUITING";0 %RDB-E-NO_META_UPDATE, metadata update failed: -RDMS-E-SCHEMAINUSE, schema RECRUITING currently in use% SQL> DROP TABLE "CORP.CANDIDATES";# SQL> DROP TABLE "CORP.COLLEGES";0 %RDB-E-NO_META_UPDATE, metadata update failedQ -RDMS-F-CONEXI, relation COLLEGES is referenced in constraint DEGREES_FOREIGN3< -RDMS-F-RELNOTDEL, relation COLLEGES has not been deleted" SQL> DROP TABLE "CORP.DEGREES C ";0 %RDB-E-NO_META_UPDATE, metadata update failed< -RDMS-F-TRGEXI, relation DEGREES is referenced in trigger EMPLOYEE_ID_CASCADE_DELETE" SQL> DROP TABLE "CORP.RESUMES";0 %RDB-E-NO_META_UPDATE, metadata update failed< -RDMS-F-TRGEXI, relation RESUMES is referenced in trigger EMPLOYEE_ID_CASCADE_DELETE; -RDMS-F-RELNOTDEL, relation RESUMES has not been deleted SQL> --G SQL> -- The trigger is part of another schema, PERSONNEL. Since thisI SQL> -- is not the default D schema, the user qualifies the trigger name! SQL> -- with schema and names. SQL> --O SQL> DROP TRIGGER "CORP.ADMINSTRATION".PERSONNEL.EMPLOYEE_ID_CASCADE_DELETE;0 SQL> DROP CONSTRAINT "CORP.DEGREES_FOREIGN3";0 %RDB-E-NO_META_UPDATE, metadata update failedK -RDMS-F-CONDELVIAREL, constraint DEGREES_FOREIGN3 can only be deleted by( changing or deleting relation DEGREES" SQL> DROP TABLE "CORP.DEGREES";" SQL> DROP TABLE "CORP.RESUMES";# SQL> DROP TABLE "CORP.COLLEGES";&E SQL> DROP SCHEMA "CORP.RECRUITING";, Example 2: Deleting a schema with CASCADEC In the following example, SQL deletes the definitions that refer< to the schema ACCOUNTING, then deletes the schema itself:. SQL> DROP SCHEMA "CORP.ACCOUNTING" CASCADE;H Domain "CORP.ADMINISTRATION".ACCOUNTING.BUDGET is also being dropped.F Domain "CORP.ADMINISTRATION".ACCOUNTING.CODE is also being dropped. SQL> 2 SEQUENCE Drops a specified sequence. 3 Environment+ YF ou can use the DROP SEQUENCE statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format9 DROP SEQUENCE --+-+---------------+-+-->6 | +--> CASCADE --+ |6 | +--> RESTRICT --+ |6 | +--> IF EXISTG S -+ |6 +-----------<-------+ 3 Arguments 4 CASCADE? The CASCADE clause specifies that you want SQL to invalidate= all objects that refer to the sequence and then delete the@ sequence definition. If you delete a sequence referenced by a@ stored routine or trigger with a routine or language-semanticD dependency, SQL also marks the affected stored routine or trigger as invalid. 4 IF_EXISTSB Prevents SQL command languaH ge from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICTD The RESTRICT clause prevents the removal of a sequence definition; (the DROP SEQUENCE statement fails) when the sequence isA referenced by any other object within the Oracle Rdb database.& The RESTRICT clause is the default. 4 sequence-nameB An existing sequence name in the database. To specify lowercaseB characters or characters not in the SQL repertoirI e, enclose the/ sequence name in single quotation marks ('). 3 Examples! Example 1: Dropping a Sequence SQL> SHOW SEQUENCE;7 Sequences in database with filename mf_personnel.rdb EMPID SQL> DROP SEQUENCE EMPID; SQL> SHOW SEQUENCE;7 Sequences in database with filename mf_personnel.rdb No Sequences Found SQL> 2 STORAGE_MAP0 Deletes the specified storage map definition. 3 Environment. You can use the DROP STORAGE MAP statemJ ent: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format5 DROP STORAGE MAP --> --+--------------+->3 +-> IF EXISTS -+   3 Arguments 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in tK he database. 4 map-name< Specifies the name of the storage map you want to delete. 3 Examples7 Example 1: Deleting a storage map in interactive SQLB This example deletes a storage map. You cannot delete a storage1 map that refers to a table that contains data.' SQL> ATTACH 'FILENAME mf_personnel';) SQL> DROP STORAGE MAP WORK_STATUS_MAP;0 %RDB-E-NO_META_UPDATE, metadata update failed; -RDMS-F-RELNOTEMPTY, relation WORK_STATUS has data in it SQL> L DELETE FROM WORK_STATUS; 3 rows deleted) SQL> DROP STORAGE MAP WORK_STATUS_MAP; SQL> 2 SYNONYM Drops a synonym definition. 3 Environment* You can use the DROP SYNONYM statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 FormatF DROP -+-----------+-> SYNONYM M -+-+---------------+-+->D +-> PUBLIC -+ | +-> CASCADE ---+ |D | +-> RESTRICT ---+ |D | +-> IF EXISTS --+ |D +---------<---------+ 3 Arguments 4 CASCADED Specifies that you want SQL to delete the synonym definition evenB if other database objects reference this name. This might later@ cause errors whenN executing queries. Stored functions, storedC procedures, and triggers that reference this name will be marked as invalid. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 PUBLIC> This optional clause is provided for compatibility with the= Oracle database server. It is currently not used by Oracle? Rdb. Its presence or absence may be used by future releases.> Oracle CoO rporation recommends you use the PUBLIC keyword in applications. 4 RESTRICT@ Specifies that you want SQL to abort the DROP statement if itA detects any database object referencing this name. This is the default. 4 synonym-name4 The name of an existing synonym you want to drop. 3 Example Example 1: Dropping a Synonym. SQL> DROP PUBLIC SYNONYM employees CASCADE; 2 TABLE* Deletes the specified table definition.; If you use the PAP THNAME qualifier when you attach to the< database, the DROP TABLE statement also deletes the table" definition from the repository. 3 Environment( You can use the DROP TABLE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format2 DROP TABLE -+-+----------------+-+->0 Q | +-> CASCADE ---+ |0 | +-> RESTRICT ---+ |0 | +-> IF EXISTS ---+ |0 +----------<---------+ 3 Arguments 4 CASCADE> Specifies that you want SQL to delete all other definitions> (constraints, indexes, modules, storage maps, triggers, and< views) that refer to the named table and then delete that= table definition. This is known as a cascading delete. ForB stored routines or triggers witR h a routine or language-semanticC dependency, SQL also marks the affected routines and triggers as invalid. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICT= Specifies that you want SQL to delete only the named table> definition. If constraints, modules, triggers, or views areA defined that refer to the named table, SQL does not delete the@ table. If there areS indexes or storage maps that refer to theB named table, SQL deletes the table and storage map and does not issue an error. 4 table-nameA Specifies the name of the table definition you want to delete. 3 Examples8 Example 1: Deleting a table from an attached database/ SQL> ATTACH 'ALIAS PERS FILENAME personnel'; SQL> DROP TABLE PERS.DEGREES; SQL> COMMIT;@ Example 2: Deleting a table and definitions that reference it from the default database)T SQL> ATTACH 'FILENAME corporate_data';> SQL> DROP TABLE ADMINISTRATION.PERSONNEL.EMPLOYEES CASCADE;C View ADMINISTRATION.PERSONNEL.REVIEW_DATE is also being dropped.D View ADMINISTRATION.PERSONNEL.CURRENT_INFO is also being dropped.F View ADMINISTRATION.PERSONNEL.CURRENT_SALARY is also being dropped.C View ADMINISTRATION.PERSONNEL.CURRENT_JOB is also being dropped.O Constraint ADMINISTRATION.RECRUITING.DEGREES_FOREIGN2 is also being dropped.L Constraint ADMINISTRATION.PERSO U NNEL.EMPLOYEES_PRIMARY_EMPLOYEE_ID is also being dropped.L Constraint ADMINISTRATION.PERSONNEL.EMP_SEX_VALUES is also being dropped.L Constraint ADMINISTRATION.PERSONNEL.HOURLY_HISTORY_FOREIGN1 is also being dropped.I Constraint ADMINISTRATION.PERSONNEL.JOB_HISTORY_FOREIGN1 is also being dropped.O Constraint ADMINISTRATION.RECRUITING.RESUMES_FOREIGN2 is also being dropped.L Constraint ADMINISTRATION.PERSONNEL.SALARY_HISTORY_FOREIGN1 is also being dropped.P Const V raint ADMINISTRATION.PERSONNEL.STATUS_CODE_VALUES is also being dropped.F Index ADMINISTRATION.PERSONNEL.EMP_LAST_NAME is also being dropped.H Index ADMINISTRATION.PERSONNEL.EMP_EMPLOYEE_ID is also being dropped.L Trigger ADMINISTRATION.PERSONNEL.EMPLOYEE_ID_CASCADE_DELETE is also being dropped.L Trigger ADMINISTRATION.PERSONNEL.STATUS_CODE_CASCADE_UPDATE is also being dropped. 2 TRIGGERB Deletes a trigger definition from the physical database and, if@ the database W was attached with PATHNAME, from the repository. 3 Environment* You can use the DROP TRIGGER statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format7 DROP TRIGGER ---> --+---------------+->5 +--> IF EXISTS -+ 3 Arguments 4 IF_EXISTSB PreX vents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 trigger-name3 Specifies the name of the trigger to be deleted. 3 Examples= Example 1: Deleting the EMPLOYEE_ID_CASCADE_DELETE trigger$ SQL> ATTACH 'FILENAME personnel'; SQL> SHOW TRIGGERS4 User triggers in database with filename PERSONNEL# COLLEGE_CODE_CASCADE_UPDATE" EMPLOYEE_ID_CASCADE_DELETE" STATUS_CODE_CASCADE_UPY DATE0 SQL> DROP TRIGGER EMPLOYEE_ID_CASCADE_DELETE; SQL> SHOW TRIGGERS5 User trigggers in database with filename PERSONNEL# COLLEGE_CODE_CASCADE_UPDATE" STATUS_CODE_CASCADE_UPDATE SQL> 2 USERA Removes the entry (such as one created with the CREATE USER orB GRANT statement) for a user name or special user class from the database. 3 Environment" You can use the DROP statement: o In interactive SQL( o Embedded in host language Z programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 3 Format6 DROP USER -----> --+-+---------------+-+->4 | +-> CASCADE --+ |4 | +-> RESTRICT --+ |4 | +-> IF EXISTS --+ |4 +----------<--------+ 3 Arguments 4 CASCADE@ The CAS[ CADE clause drops the specified user from the databaseC and deletes all references to this user that exist in the accessD control lists (ACLs), modules, and schemas. If the PUBLIC user is> dropped, ACLs are not processed to remove the PUBLIC entry. 4 RESTRICT= The RESTRICT clause drops the specified user. If there areA any references to this user in another ACL, then the DROP USER statement fails.& The RESTRICT clause is the default. 4 username) An \ existing user name in the database. 3 Example Example 1: Dropping a User SQL> SHOW USER3 Users in database with filename mf_personnel.rdb JSMITH NSTUART SQL> DROP USER JSMITH; SQL> SHOW USER3 Users in database with filename mf_personnel.rdb NSTUART SQL> 2 VIEW< Deletes the specified view definition. When the DROP VIEW? statement executes, SQL deletes the view definition from the= database. If you attach to th] e database using the PATHNAME; qualifier, SQL also deletes the view definition from the repository. 3 Environment' You can use the DROP VIEW statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format0 DROP VIEW --+-+---------------+-+->. | +-> CASCADE ---+ |. ^ | +-> RESTRICT --+ |. | +-> IF EXISTS --+ |. +----------<--------+ 3 Arguments 4 CASCADEC Specifies that you want SQL to delete all other view definitions9 that refer to the named view and then delete that viewA definition. This is known as a cascading delete. If you deleteB a view referenced by a stored routine or trigger with a routine? or language-semantic dependency, SQL also marks the affecte_ d$ routines and triggers as invalid. 4 IF_EXISTSB Prevents SQL command language from displaying error messages if8 the referenced object does not exist in the database. 4 RESTRICT< Specifies that you want SQL to delete only the named viewC definition. If there are other views, triggers, or routines that? refer to the named view, the deletion fails. RESTRICT is the default. 4 view-name@ Specifies the name of the view definition you want to del` ete. 3 Examples( Example 1: Deleting a view definitionB The following example deletes the view definition CURRENT_INFO: SQL> DROP VIEW CURRENT_INFO; SQL> COMMIT;2 Example 2: Deleting a view with dependent views@ This example shows that SQL will not automatically delete anyA views that refer to the view named in the DROP VIEW statement.C You must use the CASCADE keyword to delete a view with dependent views. SQL> DROP VIEW CURRENT_JOB;0 %RDB- a E-NO_META_UPDATE, metadata update failedJ -RDMS-F-VIEWINVIEW, view CURRENT_JOB is referenced by view CURRENT_INFO< -RDMS-F-VIEWNOTDEL, view CURRENT_JOB has not been deleted& SQL> DROP VIEW CURRENT_JOB CASCADE;+ View CURRENT_INFO is also being dropped. SQL> COMMIT;2 Example 3: Adding new definitions to a databaseC When updating metadata definitions using a predefined SQL scriptB it sometimes required to remove objects that may not be present= in all databases being b maintained. Adding a DROP VIEW, for3 instance, will result in an error as shown here. SQL> drop view CURRENT_INFO;L %SQL-F-RELNOTDEF, Table CURRENT_INFO is not defined in database or schema SQL> create view CURRENT_INFO cont> ...etc...C By using the IF EXISTS clause the error message is supressed and@ makes for a less confusing execution of the maintance script.) SQL> drop view CURRENT_INFO if exists; SQL> create view CURRENT_INFO cont> ...etc... wc wV1 EDIT> Calls an editor that lets you modify the SQL statements you$ issued within a terminal session.5 SQL supports a variety editors, some of which are: o EDTC o DEC Text Processing Utility (DECTPU) editors on OpenVMS, such as EVE@ o Language-Sensitive Editor (LSE) on OpenVMS, which is basedA on DECTPU and provides templates that guide you in entering& syntactically correct statementsB To invoke an editor other than thd e default, you must define the SQL$EDIT logical name.C You can use the editor you choose with your usual initializationC file to modify your previous SQL statements, construct your nextA statement or group of statements, or include a file with other statements. 2 Environment< You can issue the EDIT statement only in interactive SQL. 2 Format EDIT --+--------------+--> +-> --+ +-> * ---------+ 2 Arguments 3 *_(e wildcard)> Specifies a wildcard character. If you use the * (asterisk)D wildcard character, SQL includes in the editing buffer the number? of statements specified in the last SET EDIT KEEP statement.A If you do not use the SET EDIT KEEP statement, EDIT * puts the? last 20 statements in your editing buffer. If you omit the *A (asterisk) wildcard character, SQL includes the last statement issued in the editing buffer. 3 number@ Specifies the number of previous f statements you want to edit,B up to the number specified in the last SET EDIT KEEP statement.? If you specify zero as the number, then SQL does not include? any statements in the editing buffer. If you omit the numberB argument, SQL includes the last statement issued in the editing buffer. 2 Examples/ Example 1: Correcting a misspelled statement 1. Make a mistake:& SQL> SELECT JOB_TITLE FROM JOSB;; %SQL-F-RELNOTDEF, Table JOSB is not defined in schemg a SQL> 2. Invoke the editor: SQL> EDITA 3. When in the editor, change JOSB to JOBS. See the manual forA the editor you are using for detailed editing instructions.C 4. Exit from the editor. SQL automatically executes the contents of the editing buffer. * EXIT! SELECT JOB_TITLE FROM JOBS; Associate Programmer Clerk Assistant Clerk Department Manager Dept. Supervisor . h . . wwV1 END_DECLAREC Delimits the end of a host language variable declaration section in a precompiled program. 2 EnvironmentB You can use the END DECLARE statement embedded in host language programs to be precompiled. 2 Format. EXEC SQL --> BEGIN DECLARE SECTION --> ; ---+. +-------------------------------------------+0 +-+-> -+-+0 +---------<-------------------------------+ |0 +i ---------------------------------------------++ +-> EXEC SQL --> END DECLARE SECTION --> ;  2 Arguments 3 BEGIN_DECLARE_SECTIONB Delimits the beginning of a host language variable declaration. 3 END_DECLARE_SECTION; Delimits the end of host language variable declarations. 3 ;_(semicolon); Terminates the BEGIN DECLARE and END DECLARE statements.D Which terminator you use depends on the language in which you areB embedding the host languagej variable. The following table shows which terminator to use:/ Required SQL Terminator* END. BEGIN DECLARE DECLARE0 Host Language Statement Statement/ COBOL END-EXEC END-EXEC+ FORTRAN None required None/ required/ Ada, C, Pascal, or ; (semicolon) ; (semi-- PL/I colonk ) %3 host_language_variable_declaration> Specifies a variable declaration embedded within a program.A See the User_Supplied_Names HELP topic for more information on& host language variable definitions. 2 Examples9 Example 1: Declaring a host language variable within a BEGIN . . . END DECLARE block> The following example shows portions of a PL/I program. The@ first part of the example declares the host language variableA LNAME within the BEGIN DECLARl E and END DECLARE statements. TheA semicolon is necessary as a terminator because the language is PL/I.D The second part of the example shows a singleton SELECT statement? that specifies a one-row result table. The statement assigns@ the value in the row to the previously declared host language variable LNAME. EXEC SQL BEGIN DECLARE SECTION; DECLARE LNAME char(20); EXEC SQL END DECLARE SECTION; . . . EXEC SQL SELECT FIRST_NAMEm INTO :LNAME FROM EMPLOYEES" WHERE EMPLOYEE_ID = "00164"; wwV 1 Execute_@B In SQL, the at sign (@) means execute. When you type @ and theC name of an indirect command file, SQL executes the statements inA that file as if you typed them one-at-a-time at the SQL promptA (SQL>). The command file must be a text file that contains SQL statements.C The default file extension for an indirect command file is .SQL.B You can use the S n ET VERIFY statement to display the commands in the file as they execute.? SQL recognizes a special SQL command file called SQLINI.SQL,A which contains SQL statements to be issued before SQL displays? the SQL prompt (SQL>). If this file exists, SQL executes the? commands in the file first, before displaying the prompt andC accepting your input. If you define the logical name to point toC a general initialization file, SQL uses this file. Otherwise, it9 looks for SQLINI.o SQL in the current default directory. 2 EnvironmentD You can issue the execute (@) statement only in interactive SQL. 2 Format @  2 Arguments 3 file-spec> Specifies the name of an indirect command file. You can useC either a full file specification, a file name, or a logical name? on OpenVMS. If you use a file name, SQL looks in the currentC default directory for a file by that name. The file must contain valid SQL statemep nts. 2 ExamplesB Example 1: Storing interactive SQL statements in a startup fileB You can use an indirect command file to specify characteristicsD of your SQL terminal session. This example assumes that SQLINI isC defined as a logical name that points to the file setup.sql. The. file contains the following SQL statements: SET VERIFY;B SET EDIT KEEP 5; -- This line will be displayed on the terminal9 SQL executes the file when you invoke interactive SQL. $q SQL$G SQL> SET EDIT KEEP 5; -- This line will be displayed on the terminal SQL>A When it executes, setup.sql turns on the indirect command file? display and limits the number of statements saved by SQL for editing to five. / Example 2: Executing frequently used queries> The file EMPADDR.SQL contains the following SQL statements:A -- This command file generates information for a mailing list. -- ATTACH 'FILENAME personnel'; SET OUTPUT MAILLISTr .DOC1 SELECT FIRST_NAME, MIDDLE_INITIAL, LAST_NAME,C ADDRESS_DATA_1, ADDRESS_DATA_2, CITY, STATE, POSTAL_CODE FROM EMPLOYEES; --6 -- Execute the file by using the following command: -- @EMPADDR8 Example 3: Using a logical name to run a command fileD If you define COUNT to be a logical name, you can use the commandD @COUNT to execute the statements in the file, even if the file isD located in a directory other than the default directory. The file3 s COUNT.SQL contains the following SQL statements:* -- This command file counts the rows in, -- each table of the personnel database. -- SET NOVERIFY;C SELECT 'Count of Employees -------> ', COUNT (*) FROM EMPLOYEES;> SELECT 'Count of Jobs ------------> ', COUNT (*) FROM JOBS;A SELECT 'Count of Degrees ---------> ', COUNT (*) FROM DEGREES;H SELECT 'Count of Salary_History --> ', COUNT (*) FROM SALARY_HISTORY;E SELECT 'Count of Job_History -----> ', COUNT (*) FROM Jt OB_HISTORY;E SELECT 'Count of Work_Status -----> ', COUNT (*) FROM WORK_STATUS;E SELECT 'Count of Departments -----> ', COUNT (*) FROM DEPARTMENTS;B SELECT 'Count of Colleges --------> ', COUNT (*) FROM COLLEGES;> The following example shows how to execute the file and the output: $ SQL SQL> @COUNT;. Count of Employees -------> 100 1 row selected. Count of Jobs ------------> 15 1 row selected. Count of Degrees ---------u > 166 1 row selected . . . ww~ 1 EXECUTE8 Dynamically executes a previously prepared statement.@ The EXECUTE statement is a dynamic SQL statement. Dynamic SQL? lets programs accept or generate SQL statements at run time,A in contrast to SQL statements that are part of the source code> for precompiled programs or SQL module language procedures.A Unlike precompiled SQL or SQL module language statements, suchD d v ynamically executed SQL statements are not necessarily part of aC program's source code, but can be generated while the program isB running. Dynamic SQL is useful when you cannot predict the type6 of SQL statement your program will need to process.B If a program needs to dynamically execute a statement more than@ once, the statement should be prepared first with the PREPARE? statement and executed each time with the EXECUTE statement.C SQL does not parse and compile prepared sw tatements every time it8 dynamically executes them with the EXECUTE statement. 2 Environment% You can use the EXECUTE statement:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format+ EXECUTE --+-> --------+-++ +-> + |+ +----------------------------------------+8 +-+-------------------------------------------------+-+8 +-> INTO --+-> DESCRIPTOR ----------+-+ |8 +-+-+-> ------------+-+-+ |8 | +-> --+ | |8 | +-> ------------+ | |8 +-------------- , <--------------+ |8 +--------------------------------<--------------------+: +-+-------------------------------------------------+--->6 +-> USING -+-> DESCRIPTOR ----------+-+4 +-+-+-> ------------+-+-+2 | +-y > --+ |2 | +-> ------------+ |2 +-------------- , <--------------+ 2 Arguments 3 INTO_DESCRIPTORA Specifies an SQLDA descriptor that contains addresses and data5 types that specify output parameters or variables.C The descriptor must be a structure declared in the host languageB program as an SQLDA. If the program is precompiled and uses theB embedded SQL statement INCLUDE SQLDA, the name of the z structure> is simply SQLDA. Programs can use multiple SQLDAs, but must7 explicitly declare them with names other than SQLDA.D Programs can always use the INTO DESCRIPTOR clause of the EXECUTE@ statement whether or not the statement string contains output? parameter markers, as long as the value of the SQLD field inC the SQLDA corresponds to the number of output parameter markers.? SQL updates the SQLD field with the correct number of outputA parameter markers when it pro{ cesses the DESCRIBE statement for the statement string. 3 INTO_clause Syntax options:< INTO parameter | INTO qualified-parameter | INTO variable< Specifies output parameters or variables whose values are. returned by a successful EXECUTE statement.A When you specify a list of parameters or variables, the number> of parameters in the list must be the same as the number ofC output parameter markers in the statement string of the prepared> statement. If SQL | determines that a statement string had no< output parameter markers, the INTO clause is not allowed. 3 statement-nameD Specifies the name of a prepared statement. You can supply either= a parameter or a compile-time statement name. Specifying aA parameter lets SQL supply identifiers to programs at run time.? Use an integer parameter to contain the statement identifierA returned by SQL or a character string parameter to contain the. name of the statement that you pa} ss to SQL.B If the PREPARE statement for the dynamically executed statement@ specifies a parameter, use that same parameter in the EXECUTE3 statement instead of an explicit statement name. 3 statement-id-parameterD Specifies the name of a prepared statement. You can supply either= a parameter or a compile-time statement name. Specifying aA parameter lets SQL supply identifiers to programs at run time.? Use an integer parameter to contain the statement identifierA ~ returned by SQL or a character string parameter to contain the. name of the statement that you pass to SQL.B If the PREPARE statement for the dynamically executed statementB specifies the same parameter, use that parameter in the EXECUTEB statement instead of an explicit statement name. If an SQLCA isC used to capture completion conditions and row count information,D an SQLCA must be used with the PREPARE statement. See the PREPARE" statement for more information. 3  USING_DESCRIPTORA Specifies an SQLDA descriptor that contains addresses and data* types of input parameters or variables.C The descriptor must be a structure declared in the host languageB program as an SQLDA. If the program is precompiled and uses theB embedded SQL statement INCLUDE SQLDA, the name of the structure> is simply SQLDA. Programs can use multiple SQLDAs, but must7 explicitly declare them with names other than SQLDA.= Programs can always use the USING DES CRIPTOR clause of theA EXECUTE statement whether or not the statement string contains< input parameter markers, as long as the value of the SQLDB field in the SQLDA corresponds to the number of input parameterA markers. SQL updates the SQLD field with the correct number ofC input parameter markers when it processes the DESCRIBE statement for the statement string. 3 USING_clause Syntax options:? USING parameter | USING qualified-parameter | USING variableC Specifies input parameters or variables whose values SQL uses to> replace parameter markers in the prepared statement string.A When you specify a list of parameters or variables, the number> of parameters in the list must be the same as the number ofB input parameter markers in the statement string of the preparedD statement. If SQL determines that a statement string had no input6 parameter markers, the USING clause is not allowed. 2 ExampleB Example 1: Executing an INSERT statement with parameter markers? These fragments from the online sample C program sql_dynamicC illustrate using an EXECUTE statement in an SQL module procedure4 to execute a dynamically generated SQL statement.@ The program accepts input of any valid SQL statement from the@ terminal and calls the subunit shown in the following program excerpt: . . . /*Q **---------------------------------------------------------------------------- ** Begin Main routineQ **---------------------------------------------------------------------------- */Q int sql_dynamic (psql_stmt, input_sqlda, output_sqlda, stmt_id, is_select) char *psql_stmt; sqlda *input_sqlda; sqlda *output_sqlda; long *stmt_id; int *is_select; {H sqlda sqlda_in, sqlda_out; /* Declare the SQLDA structures. */ int rowcount, status; int param;O /* Declare arrays for storage of origin al data types and allocate memory. */ mem_ptr output_save; mem_ptr input_save;Q /* * If a NULL SQLDA is passed, then a new statement is being prepared. */= if ((*input_sqlda == NULL) && (*output_sqlda == NULL)) {! new_statement = TRUE; /*M * Allocate separate SQLDAs for input parameter markers (SQLDA_IN)R * and output list items (SQLDA_OUT). Assign the value of the constantU * MAXPAR MS to the SQLN field of both SQLDA structures. SQLN specifies to0 * SQL the maximum size of the SQLDA. */H if ((sqlda_in = (sqlda) calloc (1, sizeof (sqlda_rec))) == 0) {N printf ("\n\n*** Error allocating memory for sqlda_in: Abort"); return (-1); }5 else /* set # of possible parameters */* sqlda_in->sqln = MAXPARAMS;I if ((sqlda_out = (sqlda) calloc (1, s izeof (sqlda_rec))) == 0) {O printf ("\n\n*** Error allocating memory for sqlda_out: Abort"); return (-1); } } else9 /* Set # of possible select list items. */+ sqlda_out->sqln = MAXPARAMS;7 /* copy name SQLDA2 to identify the SQLDA */7 strncpy(&sqlda_in->sqldaid[0],"SQLDA2 ",8);8 strncpy(&sqlda_out->sqldaid[0],"SQLDA2 ",8); /*D * Call an SQL module language procedure, prepare_stmt andH * describe_stmt that contains a PREPARE and DESCRIBE...OUTPUTM * statement to prepare the dynamic statement and write information< * about any select list items in it to SQLDA_OUT. */S *stmt_id = 0; /* If <> 0 the BADPREPARE error results in the PREPARE.*/5 PREPARE_STMT (&SQLCA, stmt_id, psql_stmt);- if (SQLCA.SQLCODE != sql_success) {M printf ("\n\nDSQL-E-PREPARE, Error %d encountered in PREPARE",* SQLCA.SQLCODE);' display_error_message(); return (-1); }8 DESCRIBE_SELECT (&SQLCA, stmt_id, sqlda_out);- if (SQLCA.SQLCODE != sql_success) {M printf ("\n\nDSQL-E-PREPARE, Error %d encountered in PREPARE",* SQLCA.SQLCODE);' display_e rror_message(); return (-1); } /*R * Call an SQL module language procedure, describe_parm, that contains aP * DESCRIBE...INPUT statement to write information about any parameter: * markers in the dynamic statement to sqlda_in. */5 DESCRIBE_PARM (&SQLCA, stmt_id, sqlda_in);- if (SQLCA.SQLCODE != sql_success) {M printf ("\n\n*** Error %d returned from d escribe_parm: Abort",' SQLCA.SQLCODE);' display_error_message(); return (-1); }N /* Save the value of the SQLCA.SQLERRD[1] field so that program canG * determine if the statement is a SELECT statement or not.H * If the value is 1, the statement is a SELECT statement.*/, *is_select = SQLCA.SQLERRD[1]; . . . /*N  * Check to see if the prepared dynamic statement contains any parameterM * markers by looking at the SQLD field of sqlda_in. SQLD contains theJ * number of parameter markers in the prepared statement. If SQLD isR * positive, the prepared statement contains parameter markers. The programM * executes a local procedure, get_in_params, that prompts the user forR * values, allocates storage for those values, and updates the SQLDATA field * of sqlda_in: */ if (sqlda_in->sqld > 0)B if ((status = get_in_params(sqlda_in,input_save)) != 0) {E printf ("\nError returned from GET_IN_PARAMS. Abort"); return (-1); }O /* Check to see if the prepared dynamic statement is a SELECT by lookingA * at the value in is_select, which stores the value of theK * SQLCA.SQLERRD[1] field. If that value is equal to 1, the preparedL * statement is a SE LECT statement. The program allocates storage forQ * rows for SQL module language procedures to open and fetch from a cursor,/ * and displays the rows on the terminal: */ if (*is_select) {M if (new_statement == TRUE) /* Allocate buffers for output. */ {8 /* assign a unique name for the cursor */; sprintf(cursor_name,"%2d",++cursor_counter);? if ((status = allocate_buffers(sq lda_out)) != 0) . . . /*Q * If the SQLCA.SQLERRD[1] field is not 1, then the prepared statement is not aQ * SELECT statement and only needs to be executed. Call an SQL module languageJ * procedure to execute the statement, using information about parameterE * markers stored in sqlda_in by the local procedure get_in_params: */ {4 EXECUTE_STMT (&SQLCA, stmt_id, sqlda_in);, if (SQLCA.SQLCODE != sql_success)  . . .= The SQL module language procedures called by the preceding fragment: . . .R ------------------------------------------------------------------------------- -- Procedure SectionR -------------------------------------------------------------------------------O -- This procedure prepares a statement for dynamic execution from the stringQ -- passed to it. It also writes information about the number and data type ofH --  any select list items in the statement to an SQLDA2 (specifically,K -- the sqlda_out SQLDA2 passed to the procedure by the calling program). -- PROCEDURE PREPARE_STMT SQLCA :DYN_STMT_ID INTEGER# :STMT CHAR(1024);' PREPARE :DYN_STMT_ID FROM :STMT;B -- This procedure writes information to an SQLDA (specifically,H -- the sqlda_in SQLDA passed to the procedure by the calling program)D -- about the number and data type of any para meter markers in theG -- prepared dynamic statement. Note that SELECT statements may also -- have parameter markers. PROCEDURE DESCRIBE_SELECT SQLCA :DYN_STMT_ID INTEGER SQLDA;/ DESCRIBE :DYN_STMT_ID OUTPUT INTO SQLDA; PROCEDURE DESCRIBE_PARM SQLCA :DYN_STMT_ID INTEGER SQLDA;. DESCRIBE :DYN_STMT_ID INPUT INTO SQLDA;A -- This procedure dynamically executes a non-SELECT statement.E -- SELECT statement s are processed by DECLARE CURSOR, OPEN CURSOR, -- and FETCH statements. --> -- The EXECUTE statement specifies an SQLDA2 (specifically,I -- the sqlda_in SQLDA2 passed to the procedure by the calling program)I -- as the source of addresses for any parameter markers in the dynamic -- statement. --< -- The EXECUTE statement with the USING DESCRIPTOR clauseG -- also handles statement strings that contain no parameter markers.C -- If a statement string contains no  parameter markers, SQL sets+ -- the SQLD field of the SQLDA2 to zero. PROCEDURE EXECUTE_STMT SQLCA :DYN_STMT_ID INTEGER SQLDA;3 EXECUTE :DYN_STMT_ID USING DESCRIPTOR SQLDA; . . . ww~1 EXECUTE_IMMEDIATEA Dynamically prepares, executes, and releases an SQL statement.> The EXECUTE IMMEDIATE statement is a dynamic SQL statement.A Dynamic SQL lets programs accept or generate SQL statements atA run time, in contrast to precompiled statements, which must beA embedded in the program before it is compiled. Unlike embedded? statements, such dynamically executed SQL statements are notD necessarily part of the program's source code, but can be created? while the program is running. Dynamic SQL is useful when youB cannot predict the type of SQL statement your program will need to process.D The EXECUTE IMMEDIATE statement cannot contain parameter markers.> However,  if the statement meets those restrictions and will? be dynamically executed only once, use the EXECUTE IMMEDIATE7 statement instead of PREPARE and EXECUTE statements. 2 Environment/ You can use the EXECUTE IMMEDIATE statement:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format1 EXECUTE IMMEDIATE --+-> '' +->/ +-> --------+  2 Arguments  3 statement-string: Specifies the SQL statement to be prepared and executed@ dynamically. You either specify the statement string directlyD in a character string literal enclosed in single quotation marks,8 or in a parameter that contains the statement string.> Whether specified directly or by a parameter, the statement: string must be a character string that is a dynamicallyB executable SQL statement The form for the statement is the same? as in embedded SQL, exc ept that you do not need to begin the string with EXEC SQL. 3 parameter: Specifies the SQL statement to be prepared and executed@ dynamically. You either specify the statement string directlyD in a character string literal enclosed in single quotation marks,8 or in a parameter that contains the statement string.> Whether specified directly or by a parameter, the statement: string must be a character string that is a dynamically; executable SQL statement other than the SELECT statement@ (the PREPARE lists the SQL statements that can be dynamicallyC executed). The form for the statement is the same as in embeddedA SQL, except that you do not need to begin the string with EXEC/ SQL or end it with any statement terminator. 2 Example< Example 1: Executing an INSERT statement with the EXECUTE IMMEDIATE statement= This COBOL program illustrates using the EXECUTE IMMEDIATE? statement to prepare and execute a dynamic INSERT state ment.B Compare this example with the example for the EXECUTE statementC (see the EXECUTE), which uses an INSERT statement with parameter; markers and displays the result of the insert operation. IDENTIFICATION DIVISION.+ PROGRAM-ID. EXECUTE_IMMEDIATE_EXAMPLE. *B * Illustrate EXECUTE_IMMEDIATE with a dynamic INSERT statement. * DATA DIVISION. WORKING-STORAGE SECTION.! * Variable for DECLARE SCHEMA: 01 FILESPEC PIC X(20).! * Variables t o hold values for * storage in EMPLOYEES: 01 EMP_ID PIC X(5). 01 FNAME PIC X(10). 01 MID_INIT PIC X(1). 01 LNAME PIC X(14). 01 ADDR_1 PIC X(25). 01 ADDR_2 PIC X(25). 01 CITY PIC X(20). 01 STATE PIC X(2). 01 P_CODE PIC X(5). 01 SEX PIC X(1).( 01 BDATE PIC S9(11)V9(7) COMP. 01 S_CODE PIC X(1).' * Indicator variables for retrieving) * the entire row, including c olumns we" * do not assign values to, from * the EMPLOYEES table:" 01 EMP_ID_IND PIC S9(4) COMP." 01 FNAME_IND PIC S9(4) COMP." 01 MID_INIT_IND PIC S9(4) COMP." 01 LNAME_IND PIC S9(4) COMP." 01 ADDR_1_IND PIC S9(4) COMP." 01 ADDR_2_IND PIC S9(4) COMP." 01 CITY_IND PIC S9(4) COMP." 01 STATE_IND PIC S9(4) COMP." 01 P_CODE_IND PIC S9(4) COMP." 01 SEX_IND PIC S9(4) COMP." 01 BDATE_IND PIC S9(4) COMP." 01 S_CODE_IND PIC S9(4) COMP.  * Buffer for error handling: 01 BUFFER PIC X(300).+ 01 LEN PIC S9(4) USAGE IS COMP.; * 01 disp_sqlcode pic s9(9) sign leading separate.8 * Load definition for SQL Communication Area (SQLCA):* EXEC SQL INCLUDE SQLCA END-EXEC.G ******************************************************************** *7 * P R O C E D U R E D I V I S I O N *G ********************************************************************  PROCEDURE DIVISION. START-UP. * Assign value to FILESPEC:* MOVE "SQL$DATABASE" TO FILESPEC * Declare the schema:= EXEC SQL DECLARE SCHEMA RUNTIME FILENAME :FILESPEC END-EXEC5 * Use an EXECUTE IMMEDIATE statement2 * to execute an INSERT statement:) EXEC SQL EXECUTE IMMEDIATE% "INSERT INTO EMPLOYEES; - "(EMPLOYEE_ID,FIRST_NAME,LAST_NAME,CITY)= - "VA LUES ('99999','Les','Warton','Hudson')" END-EXEC PERFORM CHECK. PERFORM FETCHES.2 EXEC SQL EXECUTE IMMEDIATE 'ROLLBACK' END-EXEC. PERFORM CHECK.5 DISPLAY "Rolled back changes. All done.". CLEAR-IT-EXIT. EXIT PROGRAM. FETCHES.. DISPLAY "Here's the row we stored:"% EXEC SQL PREPARE STMT FROM@ 'SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = "99999"' END -EXEC6 EXEC SQL DECLARE C CURSOR FOR STMT END-EXEC# EXEC SQL OPEN C END-EXEC( * Clear values in host language' * variables in case new values# * from the table are null: MOVE SPACES TO EMP_ID MOVE SPACES TO FNAME" MOVE SPACES TO MID_INIT MOVE SPACES TO LNAME MOVE SPACES TO ADDR_1 MOVE SPACES TO ADDR_2 MOVE SPACES TO CITY MOVE SPACES TO STATE  MOVE SPACES TO P_CODE MOVE SPACES TO SEX MOVE ZERO TO BDATE MOVE SPACES TO S_CODE EXEC SQL FETCH C INTO& :EMP_ID:EMP_ID_IND,$ :LNAME:LNAME_IND,$ :FNAME:FNAME_IND,* :MID_INIT:MID_INIT_IND,& :ADDR_1:ADDR_1_IND,& :ADDR_2:ADDR_2_IND," :CITY:CITY_IND,$ :STATE:STATE_IND,& :P_CODE:P_COD E_IND, :SEX:SEX_IND,$ :BDATE:BDATE_IND,% :S_CODE:S_CODE_IND END-EXEC DISPLAY EMP_ID," ", FNAME," ", MID_INIT," ", LNAME," ", ADDR_1," ", ADDR_2," ", CITY," ", STATE," ", P_CODE," ", SEX," ", BDATE," ",  S_CODE. PERFORM CHECK.% EXEC SQL CLOSE C END-EXEC. CHECK.3 IF SQLCODE NOT = 100 AND SQLCODE NOT = 07 DISPLAY "Error: SQLCODE = ", SQLCODE. CALL "SQL$GET_ERROR_TEXT" USING( BY DESCRIPTOR BUFFER,# BY REFERENCE LEN$ DISPLAY BUFFER(1:LEN) END-IF. wwǦ1 EXITD Stops an interactive SQL session and returns you to the operating @ system prompt. By default, the EXIT statement commits changes made during the session. 2 Environment< You can issue the EXIT statement in interactive SQL only. 2 Format --+-> EXIT ------+--> +-> --+ wwǦ 1 EXPORT> Makes a copy of a database in an intermediate form. Use the> IMPORT statement to rebuild an Oracle Rdb database from the? interchange file (.rbr file extension) created by the EXPORT statement.A  You use the EXPORT statement with the IMPORT statement to make@ changes to Oracle Rdb databases that cannot be made any otherD way. The EXPORT statement unloads a database to an .rbr file. TheD IMPORT statement creates the database again with the changes thatA are both allowed and not allowed through ALTER statements. See- the IMPORT statement for more information. 2 Environment< You can use the EXPORT statement in interactive SQL only. 2 FormatJ EXPORT DATABA SE -+-> ALIAS -------------------------------------+J +-> FILENAME -+-+----------------------+---+J +-> PATHNAME -+ +-> literal-user-auth -+ |J +----------------------<------------------------------------------------+@ +-> INTO -+------------------------------------+-->= +- WITH -+-> EXTENSIONS -----------+= +-> NO EXTENSIONS ----------+=  +-> DATA -----------------+= +-> NO DATA ---------------+= +-> FORWARD_REFERENCES ----+= +-> NO FORWARD_REFERENCES --+ literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING '' -+  2 Arguments 3 ALIAS_alias? Specifies the source database files to be written to an .rbr file.C o The ALIAS argument specifies the alias of an already attached= database. If the database you want to export is already@ attached, specifying ALIAS avoids the overhead of a second@ attachment to the database and the locking that attachment entails.D o The FILENAME and PATHNAME arguments both identify the database> root file associated with the database. If you specify aB repository path name, the path name indirectly specifies the? database root fi le. Because the EXPORT statement does not@ change any definitions in the repository the effect of the2 PATHNAME and FILENAME arguments is the same. 3 FILENAME_file_spec? Specifies the source database files to be written to an .rbr file.C o The ALIAS argument specifies the alias of an already attached= database. If the database you want to export is already@ attached, specifying ALIAS avoids the overhead of a second@ attachment to the database a nd the locking that attachment entails.D o The FILENAME and PATHNAME arguments both identify the database> root file associated with the database. If you specify aB repository path name, the path name indirectly specifies the? database root file. Because the EXPORT statement does not@ change any definitions in the repository the effect of the2 PATHNAME and FILENAME arguments is the same. 3 PATHNAME_pathname? Specifies the source database files t o be written to an .rbr file.C o The ALIAS argument specifies the alias of an already attached= database. If the database you want to export is already@ attached, specifying ALIAS avoids the overhead of a second@ attachment to the database and the locking that attachment entails.D o The FILENAME and PATHNAME arguments both identify the database> root file associated with the database. If you specify aB repository path name, the path name indirect ly specifies the? database root file. Because the EXPORT statement does notA change any definitions in the repository, the effect of the2 PATHNAME and FILENAME arguments is the same. 3 FORWARD_REFERENCESSyntax options:- FORWARD_REFERENCES | NO FORWARD_REFERENCESA The EXPORT statement analyzes all dependencies in the database@ to determine which functions and procedures are referenced by@ other definitions. Since IMPORT defines each object type in aA strict order, it is possible that some definitions may be used> prior to their definition. For instance, tables are defined@ before modules, but the table might call an SQL function from? a module. The FORWARD_REFERENCES option requests that EXPORTD save descriptions of these routines first in the interchange file@ so that IMPORT can declare them prior to their usage. See the. DECLARE Routine statement for more details.@ FORWARD_REFERENCES is the default. If the interchange file is@ to be used by a version prior to Oracle Rdb V7.1.0.4 then the> NO FORWARD_REFERENCES option should be used to exclude this information. 3 INTO_file_spec< Specifies the name for the .rbr file the EXPORT statementC creates. Optionally, the file specification can include a device and directory specification. 3 literal-user-auth@ Specifies the user name and password for access to databases, particularly remote database.B This literal lets y ou explicitly provide user name and password' information in the EXPORT statement. 3 USER_usernameB Defines a character string literal that specifies the operating? system user name that the database system uses for privilege checking. 3 USING_password? Defines a character string literal that specifies the user's; password for the user name specified in the USER clause. 3 WITH_[NO]_DATAB Specifies whether the .rbr file created by the EXPORT sta tementC includes the data and metadata contained in the database, or the+ metadata only. The default is WITH DATA.A When you specify the WITH NO DATA option, the EXPORT statementB copies metadata, but not the data, from a source database to anD .rbr file. Use the IMPORT statement to generate an empty database> whose metadata is identical to that of the source database.& NOTE; The WITH NO DATA option is not compatible with OracleA  CDD/Repository databases (CDD$DATABASE.RDB). If you attempt@ to export a CDD$DATABASE.RDB database, SQL issues an error? message stating that the WITH NO DATA option is not valid* for Oracle CDD/Repository databases. 3 WITH_[NO]_EXTENSIONS? Specifies whether or not the .rbr file created by the EXPORT> statement includes extensions that are compatible only withA Oracle Rdb Version 3.0 or higher database systems. The default is WITH EXTENSIONS.@ Whe n you specify the WITH NO EXTENSIONS option, the resulting? interchange (.rbr) file contains only the definitions of theD domains, the tables, and indexes. Indexes are converted to sorted@ indexes and are minus storage maps. The following conversions take place for domains:= o TINYINT data types are converted to SMALLINT data types@ o DATE ANSI, TIMESTAMP, and TIME data types are converted to DATE VMS data types= In addition, all null values are converted to the columns'B missing value or default to a data type specific missing value.B For example, null numeric values are replaced by zeros and null+ character values are replaced by blanks.@ When you specify the WITH NO EXTENSIONS option, many featuresA of Oracle Rdb databases are not exported. For example, storageA areas, storage maps, triggers, collating sequences, functions,D modules, and outlines are not backed up when you specify the WITH NO EXTENSIONS argument.&  NOTEA The WITH NO EXTENSIONS option is not compatible with OracleA CDD/Repository databases (CDD$DATABASE.RDB). If you attempt@ to export a CDD$DATABASE.RDB database, SQL issues an error? message stating that the WITH NO EXTENSIONS option is not0 valid for Oracle CDD/Repository databases. wwǦ1 FETCH< Advances a cursor to the next row of its result table and< retrieves the values from that row. When used w ith a list? cursor, the FETCH statement places the cursor on a specified? position within a list and retrieves a portion of that list.A When embedded in precompiled host language programs, the FETCHC statement assigns the values from the row to host parameters. InA interactive SQL, the FETCH statement displays the value of the row on the terminal screen. 2 Environment# You can use the FETCH statement:B o In interactive SQL (except for the USING DESCRIPTION cla use): o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format@ FETCH -+---------------->-----------------+-+- ++@ +> fetch-orientation-clause FROM --+ +> --+|@ +--------------------------<----------------------------+? ++------------------->---------------------------+----->9 +--> INTO -+-+-> ------------+-+-+--+6 | | +-> --+ | |6 | | +-> -------------+ | |6 | +--------- , <------------------+ |6 +--> USING DESCRIPTOR -----+  fetch-orientation-clause = = -----+--> NEXT --------------------------------------+--->9 +--> PRIOR --------------------------------------+9 +--> FIRST --------------------------------------+9 +--> LAST ---------------------------------------+9 +--> RELATIVE ----> simple-valu e-expression -----+9 +--> ABSOLUTE ----> simple-value-expression -----+  2 Arguments 3 cursor-nameC Specifies the name of the cursor from which you want to retrieveA a row. Use a parameter if the cursor referred to by the cursor> name was declared at run time with a dynamic DECLARE CURSOR? statement. Specify the parameter used for the cursor name in( the dynamic DECLARE CURSOR statement.D You can use a parameter to refer to the cursor name only wh en the1 FETCH statement is accessing a dynamic cursor. 3 fetch_FROMD Specifies the specific segment of the list cursor to fetch. TheseC options are available only if you specified the SCROLL option in1 the DECLARE CURSOR statement. The choices are: o NEXT> Fetches the next segment of the list cursor. This is the default. o PRIORC Fetches the segment immediately before the current segment of the list cursor. o FIRST3  Fetches the first segment of the list cursor. o LAST2 Fetches the last segment of the list cursor.& o RELATIVE simple-value-expressionC Fetches the segment of the list cursor indicated by the valueB expression. For example, relative -4 would fetch the segment9 that is four segments prior to the current segment.& o ABSOLUTE simple-value-expressionC Fetches the segment of the list cursor indicated by the value@ expression. For example, a bsolute 4 would fetch the fourth! segment of the list cursor. 3 INTO Syntax options:< INTO parameter | INTO qualified-parameter | INTO variable= Specifies a list of parameters, qualified parameters (host@ structures), or variables to receive the values SQL retrieves; from the row of the cursor's result table. The number of> parameters or variables in the list must be the same as theC number of values in the row. (If any of the parameters is a hostC str ucture, SQL counts the number of parameters in that structureD when it compares the number of host parameters in the INTO clause) with the number of values in the row.)@ The data types of parameters and variables must be compatibleA with the values of the corresponding column of the cursor row. 3 parameterC Specifies the name of the cursor from which you want to retrieveA a row. Use a parameter if the cursor referred to by the cursor> name was declared at run time with a dynamic DECLARE CURSOR? statement. Specify the parameter used for the cursor name in( the dynamic DECLARE CURSOR statement.D You can use a parameter to refer to the cursor name only when the1 FETCH statement is accessing a dynamic cursor. 3 simple-value-expression@ Specifies either a positive or negative integer, or a numeric. module language or host language parameter. 3 USING_DESCRIPTORC Specifies the name of a descriptor that corresponds to an S QLDA.A If you use the INCLUDE statement to insert the SQLDA into your0 program, the descriptor name is simply SQLDA.C An SQLDA is a collection of host language variables used only inB dynamic SQL. In a FETCH statement, the SQLDA points to a numberB of parameters SQL uses to store values from the row. The number= of parameters must match the number of columns in the row.B The data types of parameters must be compatible with the values1 of the corresponding column of the  cursor row. 2 Examples@ Example 1: Using a FETCH statement embedded in a PL/I program@ This program fragment uses embedded DECLARE CURSOR, OPEN, andC FETCH statements to retrieve and print the names and departmentsB of managers. The FETCH statement fetches the rows of the result> table and stores them in the parameters :FNAME, :LNAME, and :DNAME. /* Declare the parameters: */ BEGIN DECLARE SECTION DCL ID CHAR(3); DCL FNAME CHAR(10);  DCL LNAME CHAR(14); END DECLARE SECTION /* Declare the cursor: */& EXEC SQL DECLARE MANAGER CURSOR FOR> SELECT E.FIRST_NAME, E.LAST_NAME, D.DEPARTMENT_NAME2 FROM EMPLOYEES E, DEPARTMENTS D7 WHERE E.EMPLOYEE_ID = D.MANAGER_ID ; /* Open the cursor: */ EXEC SQL OPEN MANAGER;8 /* Start a loop to process the rows of the cursor: */ DO WHILE (SQLCODE = 0);- /* Retrieve the rows of the cursor.  and put the value in parameters: */> EXEC SQL FETCH MANAGER INTO :FNAME, :LNAME, :DNAME;4 /* Print the values in the parameters: */ . . . END; /* Close the cursor: */ EXEC SQL CLOSE MANAGER;> Example 2: Using a FETCH statement to display segments in a column of data type LIST= This interactive example uses a table cursor to retrieve a< row that contains a list  from the RESUMES table. The OPENB statement positions the cursor on the first segment of the listA in the RESUME column, and subsequent FETCH statements retrieve$ successive segments of that list.@ SQL> DECLARE TBLCURSOR2 CURSOR FOR SELECT EMPLOYEE_ID, RESUME cont> FROM RESUMES;8 SQL> DECLARE LSTCURSOR2 LIST CURSOR FOR SELECT RESUME% cont> WHERE CURRENT OF TBLCURSOR2; SQL> OPEN TBLCURSOR2; SQL> FETCH TBLCURSOR2; 00164 SQL> OPEN LSTCURSOR2; SQL> FETCH LS TCURSOR2; RESUME This is the resume for 00164 SQL> FETCH LSTCURSOR2; RESUME Boston, MA SQL> FETCH LSTCURSOR2; RESUME Oracle Corporation SQL> FETCH LSTCURSOR2; RESUME@ %RDB-E-STREAM_EOF, attempt to fetch past end of record stream SQL> CLOSE LSTCURSOR2; SQL> SELECT * FROM RESUMES; EMPLOYEE_ID RESUME$ 00164 72:2:3 1 row selected SQL> CLOSE TBLCURSOR2; SQL> COMMIT;? Example 3: Using a scroll able list cursor to fetch list dataD This C program demonstrates the use of scrollable list cursors toD read list data from the sample personnel database using the FETCHC statement. The list data being read is from the RESUME column ofB the RESUMES table in personnel. Note that the RESUME is divided% into three segments in this order:C 1. A line including the employee's name: "This is the resume for Alvin Toliver"; 2. A line stating where the employee lives: "Bost on, MA"C 3. A line stating where the employee works: "Oracle Corporation" #include stdio #include descripF /* Declare parameters for error handling by including the SQLCA. */ EXEC SQL INCLUDE SQLCA; /* Error-handling section. */ dump_error( ) { short errbuflen;" char errbuf[ 1024 ];1 struct dsc$descriptor_s errbufdsc;) errbufdsc.dsc$b_class = DSC$K_CLASS_S;) errbufdsc.dsc$b_dtype = DSC$K_DTYPE_T;!  errbufdsc.dsc$w_length = 1024;% errbufdsc.dsc$a_pointer = &errbuf; if (SQLCA.SQLCODE != 0) {5 printf( "SQLCODE = %d\n", SQLCA.SQLCODE );7 SQL$GET_ERROR_TEXT( &errbufdsc, &errbuflen ); errbuf[ errbuflen ] = 0;! printf("%s\n", &errbuf ); } } main() {* /* Attach to the personnel database. */- EXEC SQL DECLARE ALIAS FILENAME personnel; /* Declare variables. */ short two_s; long two_l; char blob[8]; char emp_id[6]; char seg2[ 81 ]; /* Declare a table cursor. */7 exec sql declare resumes_cursor table cursor forK select employee_id, resume from resumes where employee_id = '00164';O /* Declare a read-only scrollable list cursor to fetch the RESUME column. */O exec sql declare resume_list_cursor read only scrollable list cursor for5 select resume where current of resumes_cursor; /* Open the table cursor. */$ exec sql open resumes_cursor; dump_error();R /* Place the first value in the table cursor (00164) into the emp_id parameter,2 and the resume data into the blob parameter. */9 exec sql fetch resumes_cursor into :emp_id, :blob; dump_error();) /* Open the scrollable list cursor. */$ exec sql open resume_list_cursor; dump_error();N /* Begin to use the FETCH statement to read desired lines from the resume.L If an attempt is made to retrie ve a segment that is out of range, the' program prints an error message. */: exec sql fetch last from resume_list_cursor into :seg2;6 printf("FETCH LAST segment returned: %s\n", seg2 ); dump_error();: exec sql fetch next from resume_list_cursor into :seg2;6 printf("FETCH NEXT segment returned: %s\n", seg2 ); dump_error();; exec sql fetch first from resume_list_cursor into :seg2;7 printf("FETCH FIRST segment returned: %s\n", seg2 ); dump_error();:  exec sql fetch next from resume_list_cursor into :seg2;6 printf("FETCH NEXT segment returned: %s\n", seg2 ); dump_error();: exec sql fetch next from resume_list_cursor into :seg2;6 printf("FETCH NEXT segment returned: %s\n", seg2 ); dump_error();A exec sql fetch relative -2 from resume_list_cursor into :seg2;= printf("FETCH RELATIVE -2 segment returned: %s\n", seg2 ); dump_error();; exec sql fetch first from resume_list_cursor into :seg2;7 printf("FETCH FIRST segment returned: %s\n", seg2 ); dump_error();@ exec sql fetch relative 2 from resume_list_cursor into :seg2;< printf("FETCH RELATIVE 2 segment returned: %s\n", seg2 ); dump_error();: exec sql fetch last from resume_list_cursor into :seg2;6 printf("FETCH LAST segment returned: %s\n", seg2 ); dump_error();; exec sql fetch prior from resume_list_cursor into :seg2;7 printf("FETCH PRIOR segment returned: %s\n", seg2 ); dump_error();@ exec sql fetch ABSOLUTE 1 from resume_list_cursor into :seg2;< printf("FETCH ABSOLUTE 1 segment returned: %s\n", seg2 ); dump_error();@ exec sql fetch relative 2 from resume_list_cursor into :seg2;< printf("FETCH RELATIVE 2 segment returned: %s\n", seg2 ); dump_error(); two_s = 2;E exec sql fetch ABSOLUTE :two_s from resume_list_cursor into :seg2;A printf("FETCH ABSOLUTE :two_s segment returned: %s\n", seg2 ); dump_error(); two_l = 2;E exec sql fetch ABSOLUTE :two_l from resum e_list_cursor into :seg2;A printf("FETCH ABSOLUTE :two_1 segment returned: %s\n", seg2 ); dump_error();I exec sql fetch RELATIVE :two_l from resume_list_cursor into :seg2;E printf("FETCH RELATIVE :two_1 segment returned: %s\n", seg2 ); dump_error(); exec sql rollback; }; The following example shows the output from the program:2 FETCH LAST segment returned: Oracle Corporation2 FETCH NEXT segment returned: Oracle Corporation SQLCODE = 1 009 %SQL-W-NOTFOUND, No rows were found for this statementE FETCH FIRST segment returned: This is the resume for Alvin Toliver* FETCH NEXT segment returned: Boston, MA2 FETCH NEXT segment returned: Oracle CorporationK FETCH RELATIVE -2 segment returned: This is the resume for Alvin ToliverE FETCH FIRST segment returned: This is the resume for Alvin Toliver8 FETCH RELATIVE 2 segment returned: Oracle Corporation2 FETCH LAST segment returned: Oracle Corporation+ FETCH PRIOR segment returned: Boston, MAJ FETCH ABSOLUTE 1 segment returned: This is the resume for Alvin Toliver8 FETCH RELATIVE 2 segment returned: Oracle Corporation5 FETCH ABSOLUTE :two_s segment returned: Boston, MA5 FETCH ABSOLUTE :two_1 segment returned: Boston, MA5 FETCH RELATIVE :two_1 segment returned: Boston, MA SQLCODE = -1I %RDB-F-SEGSTR_EOF, attempt to fetch past the end of a segmented stringM -RDMS-E-FETRELATIVE, fetch relative (2) causes reference out of range 1..3  wwΑ1 FOR_Control@ Executes an SQL statement for each row of a query expression. 2 EnvironmentC You can use the FOR control statement in a compound statement of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format for-statement = B -+----------------- -------+-> FOR --------------+B +--> : + |B +---------------------------------<----------------------------+B +--> AS -+----------------+-+--------------------------------+-+B +-> EACH ROW OF -+ +-> for-statement-table-cursor --+ |B +----------------------------------<---------------------------+B +--> select-expression --> DO --+-> compound-use-statement --+-+B +--------------< -------------+ |B +-----------------------------------<--------------------------+& +--> END FOR -+------------------+->$ +-> + for-statement-table-cursor = E ---+-----------------+--+-----------+-> CURSOR FOR -->& +-> READ ONLY ----+ +-> TABLE --+ +-> UPDATE ONLY --+  2 Arguments 3 AS_EACH_ROW_OF_cursor2 Creates a result table with a specified cursor.? The optional naming of a cursor lets you use  positioned dataC manipulation language statements in the DO clause of a FOR loop. 3 AS_EACH_ROW_OF_select_expr! Creates a simple result table.A After SQL creates the result table from the select expression,@ the DO clause executes a set of SQL statements (compound-use-( statement) for each result table row. 3 beginning-label:' Assigns a name to the FOR statement.> A named FOR loop is called a labeled FOR loop statement. If; you include an ending l abel, it must be identical to itsB corresponding beginning label. A beginning label must be unique8 within the procedure in which the label is contained. 3 DO@ Executes a block of SQL statements for each row of the select expression result table. 3 END_FOR< Marks the end of a FOR loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique within the- procedure in wh ich the label is contained.9 The optional end-label argument makes the FOR loops of? multistatement procedures easier to read, especially in very complex procedure blocks. 3 FOR_variable_name? Specifies a name for a record consisting of a field for eachD named column of the FOR loop select expression. Each field in theC record contains the data represented by each column name in each- row of the select expression result table.D The variable name lets you re ference a field in the compound-use-> statement argument, for example: variable-name.column-name. 2 ExamplesD Example 1: Using the FOR statement within an SQL module procedure SQL> set flags 'trace'; SQL> SQL> create module REPORTS cont> /*< ***> This procedure counts the employees of a given state< ***> who have had a decrease in their salary during their ***> employment ***> */" cont> procedure COUNT_DECREASED cont> (in :state CHAR(2)* cont> ,inout :n_decreased INTEGER); cont> begin cont> set :n_decreased = 0; cont> cont> EMP_LOOP: cont> for :empfor cont> as each row of# cont> select employee_id5 cont> from EMPLOYEES where state = :state cont> do cont> begin8 cont> declare :last_salary INTEGER (2) default 0; cont> cont> HISTORY_LOOP: cont> for :salfor cont> as each row of) cont> select salary_amount) c ont> from SALARY_HISTORY= cont> where employee_id = :empfor.employee_id+ cont> order by salary_start cont> do8 cont> if :salfor.salary_amount < :last_salary cont> then9 cont> set :n_decreased = :n_decreased + 1;L cont> trace :empfor.employee_id, ': ', :salfor.salary_amount;( cont> leave HISTORY_LOOP; cont> end if; cont>: cont> set :last_salary = :sal for.salary_amount; cont> end for; cont> end; cont> end for; cont> end; cont> cont> end module; SQL> SQL> declare :n integer;( SQL> call COUNT_DECREASED ('NH', :n); ~Xt: 00200: 40789.00 ~Xt: 00248: 46000.00 ~Xt: 00471: 52000.00 N 3 SQL> SQL> rollback; ww1 FOR_Counted_ControlD Executes a block of SQL statements while the FOR loop variable isD incremented (or decre mented) from a user-specified starting value$ to a user-specified ending value. 2 Environment> You can use the FOR counted control statement in a compound+ statement of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format counted-for-statement = B -+------------------------+-> FOR --------------+B +--> : + |B +---------------------------------<----------------------------+B +--> IN -+-------------+-> value-expr --> TO --> value-expr ---+B +-> REVERSE --+ |B +--------------------------------------------------------------+B +-+--------------------+-> DO -+-> compound-use-statement --+--+B +-> STEP value-expr -+ +------------ <--------------+  |B +-----------------------------------<--------------------------+C +--> END FOR -+------------------+------------------------------>$ +-> + 2 Arguments #3 AS_EACH_ROW_OF_select-expression! Creates a simple result table.A After SQL creates the result table from the select expression,@ the DO clause executes a set of SQL statements (compound-use-? statement) for each result table row. See Select_ExpressionsA in the Oracle Rdb SQL Reference Manual for more information on select expressions. 3 beginning-label:B Assigns a name to the FOR statement. A named FOR loop is called@ a labeled FOR loop statement. If you include an ending label,? it must be identical to its corresponding beginning label. AC beginning label must be unique within the procedure in which the label is contained. 3 compound-use-statement@ Identifies the SQL statements allowed in a compound statementD block . See Compound_Stmt for a complete description of a compound statement. 3 DO_compound-use-statementD Executes a block of SQL statements once for each execution of the@ loop as defined by the starting and ending value expressions. 3 END_FOR Syntax:! END FOR | END FOR ending-label< Marks the end of a FOR loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique w ithin theD procedure in which the label is contained. The optional end-labelC argument makes the FOR loops of multistatement procedures easier8 to read, especially in very complex procedure blocks. 3 FOR_variable_name@ Specifies a variable to hold a value that is incremented eachD time the FOR loop is executed. The variable is decremented if theD REVERSE keyword is specified. The starting value for the variable@ is the first value expression. Execution of the FOR loop endsA when the variable has been incremented (or decremented) to the4 value specified with the second value expression.< Marks the end of a FOR loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique within theD procedure in which the label is contained. The optional end-labelC argument makes the FOR loops of multistatement procedures easier8 to read, especially in very complex pro cedure blocks. 3 IN_value-expression-option Syntax options:! IN value-expr TO value-expr) IN REVERSE value-expr TO value-expr; Specifies how often the compound-use-statement should beD executed. When the REVERSE keyword is not specified, the variableB contained in the FOR variable-name is incremented at the end of@ each execution of the FOR loop body. When the REVERSE keywordC is specified, the variable contained in the FOR variable-name isA dec remented at the end of each execution of the FOR loop body.< Both value expressions are evaluated once before the loopA executes. The TO value-expression is evaluated first to ensure= that references to the FOR loop variable do not cause side effects. 3 select_expressionD See Select_Expressions in the Oracle Rdb SQL Reference Manual for0 a complete description of select expressions. 3 STEP_value-exprC Controls the size of the increment between loop inter ations. The; step size is specified using a numeric value expression.) If omitted the default step size is 1. SQL> begin cont> declare :i integer;! cont> for :i in 1 to 20 step 5 cont> do cont> trace :i; cont> end for; cont> end; ~Xt: 1 ~Xt: 6 ~Xt: 11 ~Xt: 16& NOTE? Even if the loop control variable is an INTERVAL type the> STEP must be numeric type. In addition the value must beB  greater than zero - use the REVERSE keyword to decrement the loop control variable. 3 value-expr Syntax:! IN value-expr TO value-expr) IN REVERSE value-expr TO value-expr; Specifies how often the compound-use-statement should beD executed. When the REVERSE keyword is not specified, the variableB contained in the FOR variable-name is incremented at the end of@ each execution of the FOR loop body. When the REVERSE keywordC is specified, the varia ble contained in the FOR variable-name isA decremented at the end of each execution of the FOR loop body.< Both value expressions are evaluated once before the loopA executes. The TO value-expression is evaluated first to ensure= that references to the FOR loop variable do not cause side effects. 2 Examples" Example 1: Using a Reverse Loop SQL> SET FLAGS 'TRACE'; SQL> BEGIN$ cont> DECLARE :LOOP_VAR INTEGER;) cont> FOR :LOOP_VAR IN REVERSE 1 TO 5  cont> DO cont> TRACE :LOOP_VAR; cont> END FOR; cont> END; ~Xt: 5 ~Xt: 4 ~Xt: 3 ~Xt: 2 ~Xt: 19 Example 2: Using an INTERVAL type as the loop variable SQL> begin" cont> declare :i interval year;: cont> for :i in (interval'1' year) to (interval'4'year) cont> do cont> trace :i; cont> end for; cont> end; ~Xt: 01 ~Xt: 02 ~Xt: 03 ~Xt: 04? Example 3: Using a complex expression as the STEP expression SQL> begin" cont> declare :i interval year;5 cont> declare :k interval year = interval'18'year; cont> declare :j integer = 2; cont>7 cont> for :i in (interval'1' year) to :k/2 step :j*2 cont> do cont> trace :i; cont> end for; cont> end; ~Xt: 01 ~Xt: 05 ~Xt: 09 ww1 GET_DIAGNOSTICS= Extracts diagnostic information about the execution of the5 previous SQL statement or SQL routine environme nt.@ The GET DIAGNOSTICS statement captures diagnostic information: from an Oracle Rdb maintained data structure called theB diagnostics area. In the ANSI/ISO SQL standard, the diagnostics? area consists of two components: a single header area and anC array of detail areas. Oracle Rdb extracts information only from@ the header component and the first element of the detail area (Exception 1): o Header areaB Contains status information about rows and transacti ons, forC example, the number of rows affected by an INSERT, UPDATE, orA DELETE statement or the type of transaction that is active.A See the statement-item-name argument for a complete list ofC the status information you can retrieve from the header area. o Detail area (Exception 1)D Contains diagnostic information that corresponds to the status> that would be reported in the SQLSTATE or SQLCODE status? parameter. The EXCEPTION . . . RETURNED_ SQLSTATE argument? retrieves the SQLSTATE status information from the detailC area. The EXCEPTION . . . RETURNED_SQLCODE argument retrieves: the SQLCODE status information from the detail area. 2 Environment< You can use the GET DIAGNOSTICS statement only within the4 compound statement of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled< o As part of a multistatement procedure in an SQL module > o In dynamic SQL as a statement to be dynamically executed 2 Format= GET DIAGNOSTICS -------------------------------------------+= +----------------------------------------------------------+H +-+-+-+-> +---> = statement-item-name -----+-------------+>G | | +-> -+ | |G | +---------------- , <------------------------------+ |G +-> EXCEPTION --> 1 -+-+-> +> = statement-info-clause ++F | +-> -+ |F +-------------------- , <--------------------+  statement-item-name = * ----+-> ACCESS_MODE -----------------+-->' +-> CALLING_ROUTINE -------------+' +-> CONNECTION_NAME -------------+' +-> CURRENT_ROW -----------------+' +-> DATABASE_HANDLE -------------+' +-> GLOBAL_TRANSACTION ----------+' +-> HOT_STANDBY_MODE ------------+' +-> IMAGE_NAME - ----------------+' +-> ISOLATION_LEVEL -------------+' +-> LIMIT_CPU_TIME --------------+' +-> LIMIT_ELAPSED_TIME ----------+' +-> LIMIT_ROWS_FETCHED ----------+' +-> ROW_COUNT -------------------+' +-> SERVER_IDENTIFICATION -------+' +-> TRACE_ENABLED ---------------+' +-> TRANSACTION_ACTIVE ----------+' +-> TRANSACTION_CHANGE_ALLOWED --+' +-> TRANSACTION_SEQUENCE --------+' +-> TRANSACTION_TIMESTAMP -------+   ' +' -> TRANSACTIONS_COMMITTED -----+' +-> TRANSACTIONS_ROLLED_BACK ----+                  statement-info-clause =  -+-> RETURNED_SQLSTATE --+---> +-> RETURNED_SQLCODE ---+  2 Arguments 3 IMAGE_NAME= Requests that the activating image name be returned to the? caller. The image name includes the node name from which the@ attach was started. This might be a node different to that on* which the O racle Rdb server is running.B The data is returned to the caller as a VARCHAR (255) value and@ should be assigned to either a VARCHAR or CHAR data type that$ supports the ASCII character set. 3 EXCEPTION@ Returns the exception condition following the execution of an@ SQL statement (other than GET DIAGNOSTICS). Either SQLCODE or SQLSTATE can be returned. 3 parameter? Retrieves information about the statement execution recorded; in the diagnostics area and stores it in a simple target+ specification (a parameter or variable). 3 RETURNED_SQLCODE= Requests the SQLCODE be returned to the target variable or: parameter. The data type of the returned information isB INTEGER. Oracle Rdb only returns success (0) and warning status@ (positive value) for SQLCODE. Any error status will cause theA compound statement, or stored routine to return to the calling application. 3 RETURNED_SQLSTATE> Requests the SQLSTATE be returned to the target variable orC parameter. The data type of the returned information is CHAR(5).C Oracle Rdb only returns success ('00000') and warning status forC SQLSTATE. Any error status will cause the compound statement, or7 stored routine to return to the calling application. 3 statement-item-name@ Specifies the kind of diagnostic information you can retrieve@ about a previously executed SQL statement. You can gather the following diagnostic data:> o ACCESS_MODE returns the character string READ ONLY, READ@ WRITE, or BATCH UPDATE to indicate the type of transactionB that is active. These character strings are of the CHAR dataA type. The argument also returns NONE when no transaction isD active. See the SET_TRANSACTION statement for a description of transaction access modes.? o CALLING_ROUTINE returns a string of data type CHAR(31) ofB the name of the calling routine. If there is no name for the+ calling routine, spaces are returned.: o CONNECTION_NAME returns the current connection name.= o DATABASE_HANDLE returns the current database handle (or stream) identifier.B o CURRENT_ROW returns the integer value for the number of rowsD that have been fetched by the innermost FOR control statement.> o GLOBAL_TRANSACTION returns an integer of 1 when a global: transaction is active and an integer of 0 otherwise.B o ISOLATION_LEVEL returns the ch aracter string READ COMMITTED,@ REPEATABLE READ, or SERIALIZABLE to indicate the isolation< level of a transaction. These character strings are of@ the CHAR data type. The argument also returns NONE when noD transaction is active. See the SET_TRANSACTION statement for a* description of transaction isolation levels.? o LIMIT_CPU_TIME returns an INTEGER value for the session's6 execution CPU time limit in seconds. If zero (0)8 is returned it is eq uivalent to no CPU time limit.: This value is established by either the logical nameD RDMS$BIND_QG_EXEC_CPU_TIMEOUT or the SET QUERY EXECUTION LIMIT CPU TIME statement.C o LIMIT_ELAPSED_TIME returns an INTEGER value for the session's= execution elapsed time limit in seconds. If zero (0) isD returned it is equivalent to no elapsed time limit. This valueB is established by either the logical name RDMS$BIND_QG_EXEC_C ELAPSED_TIMEOUT or the SET QUERY EXE CUTION LIMIT ELAPSED TIME statement.A o LIMIT_ROWS_FETCHED returns a BIGINT value for the session's@ row limit. If zero (0) is returned, it is equivalent to no> row limit. This value is established by the logical name RDMS$BIND_QG_REC_LIMIT.B o ROW_COUNT returns an integer for the number of rows affected> by an INSERT, searched UPDATE, searched DELETE, or a FOR cursor loop statement.? o TRACE_ENABLED returns an INTEGER value to indicate if th e? TRACE flag has been enabled using the statement SET FLAGS? 'TRACE', or by either of the logical names RDMS$SET_FLAGS@ or RDMS$DEBUG_FLAGS. A zero (0) is returned if the flag is@ disabled, otherwise a one (1) is returned to indicate that tracing is enabled.C o TRANSACTION_ACTIVE returns an integer of 1 when a transaction. is active and an integer of 0 otherwise.D o TRANSACTIONS_COMMITTED returns an integer value for the numberD of transacti ons that have been committed during the processing$ of a multistatement procedure.? o TRANSACTIONS_ROLLED_BACK returns an integer value for theB number of transactions that have been rolled back during the/ processing of a multistatement procedure. o TRANSACTION_CHANGE_ALLOWEDA There are many situations where the SQL language programmerC would like to start or end a transaction but does not know ifB a transaction statement (SET TRANSACTION, START  TRANSACTION,A COMMIT or ROLLBACK) is currently permitted. The transaction: statements are not permitted in the following cases:D o During a multi-database or global transaction. In this caseA the transaction must be coordinated by the client, not a server-based procedure.? o When a BEGIN ATOMIC compound statement is in the outer scope.< o When a FOR cursor loop is active in an outer scope.A The TRANSACTION_CHANGE_ALLOWED c lause allows the programmerD to detect these restricted locations and conditionally executeA a COMMIT, ROLLBACK, START TRANSACTION or SET TRANSACTION as needed.A The result data type is INTEGER. If transaction changes areD permitted then a value one (1) will be assigned. Otherwise the result will be zero (0). o HOT_STANDBY_MODE> This option returns a text string that indicates if thisA database is participating in a Hot Standby configura tion asC master (returns 'MASTER'), or as standby (returns 'STANDBY'),9 or is not in such a configuration (returns 'NONE').( The result data type is CHAR (31). o SERVER_IDENTIFICATIONA This option returns a text string containing the Oracle Rdb= release number. This is useful for log file annotation.( The result data type is CHAR (31). o TRANSACTION_TIMESTAMP9 This option returns the date and time that the lastB transaction was started. If a transaction is not active, the< returned date and time may be for a prior transaction.) NOTE9 The database server will start transactions when? performing database operations. So, this timestamp may5 reflect the time of an internal transaction.@ If the default date format is SQL99, this option returns aC value with the data type TIMESTAMP(2), otherwise it returns aB DATE (VMS) data type . The default date format can be changed= using either the SET DIALECT or SET DEFAULT DATE FORMAT= statements, or one of the associated module attributes. o TRANSACTION_SEQUENCE? This is the transaction sequence number (TSN) assigned to@ the most recently started transaction. The TSN is a uniqueA indicator of database transaction activity, however, please< note that the TSN may be reused in some cases. The TSN@ for a READ ONLY transaction reflects the transaction state@ which is visible to the transaction and, therefore, it was@ previously assigned to a READ WRITE transaction. If a READC WRITE transaction does not perform database I/O or was rolled= back, that TSN may be reused by a subsequent READ WRITE transaction.- This option returns a BIGINT data type. 3 variable? Retrieves information about the statement execution recorded; in the diagnostics area and stores it in a simple targe t+ specification (a parameter or variable). 2 Examples? Example 1: Using a GET DIAGNOSTICS statement to retrieve row count< PROCEDURE increate_nh (SQLSTATE, :rows_affected INTEGER); BEGIN ATOMIC UPDATE salary_history6 SET salary_amount = salary_amount * 1.05$ WHERE salary_end IS NULL7 AND employee_id IN (SELECT employee_id5 FROM employees;  WHERE state = 'NH' );6 GET DIAGNOSTICS :rows_affected = ROW_COUNT; END;% Example 2: Using RETURNED_SQLSTATE SQL> DECLARE :Y CHAR(5); SQL> BEGIN cont> SET :Y = 'Hello';< cont> GET DIAGNOSTICS EXCEPTION 1 :Y = RETURNED_SQLSTATE; cont> END; SQL> PRINT :Y; Y 00000 SQL>$ Example 3: Using RETURNED_SQLCODE SQL> DECLARE :X INTEGER; SQL> BEGIN cont> SET :X = 100;; cont> GET DIAGNOSTICS EXCEPTION 1 :X = RETURN ED_SQLCODE; cont> END; SQL> PRINT :X; X 03 Example 4: Returning the current connection nameE SQL> CONNECT TO 'ATTACH FILENAME mf_personnel' AS 'my_connection';' SQL> DECLARE :conn_name VARCHAR(20); SQL> BEGIN9 cont> GET DIAGNOSTICS :conn_name = CONNECTION_NAME; cont> END; SQL> PRINT :conn_name; CONN_NAME my_connection> Example 5: Using the TRANSACTION_TIMESTAMP and TRANSACTION_ SEQUENCE options#  SQL> set transaction read write; SQL> show transaction Transaction information:- Statement constraint evaluation is off On the default alias Transaction characteristics: Read Write3 Transaction information returned by base system:* a read-write transaction is in progress& - updates have not been performed1 - transaction sequence number (TSN) is 0:256? - snapshot space for TSNs less than 0:256 can be reclaimedR - recovery unit journ al filename is USER2:[RDM$RUJ]SCRATCH$00018679B3AD.RUJ;1 - session ID number is 8 SQL> SQL> declare :x date vms; SQL>> SQL> begin get diagnostics :x = transaction_timestamp; end; SQL> print :x; X 27-MAY-1999 22:39:17.02 SQL> SQL> declare :y bigint; SQL>= SQL> begin get diagnostics :y = transaction_sequence; end; SQL> print :y; Y 256 SQL>3 SQL> select current_timestamp from rdb$database ; 27-MAY-1999 22:39:18.20 1 row selected SQL> SQL> commit;B Example 6: Using the HOT_STANDBY_MODE and SERVER_IDENTIFICATION options SQL> set flags 'trace';& SQL> declare :id, :hsmode char(31); SQL> begin5 cont> get diagnostics :id = SERVER_IDENTIFICATION,4 cont> :hsmode = HOT_STANDBY_MODE; cont> trace :id, :hsmode; cont> end;) ~Xt: Oracle Rdb V7.1 NONE? Example 7: Using the LIMIT_CPU_TIME, LIMIT_ROWS_F ETCHED, and LIMIT_ELAPSED_TIME options SQL> set flags 'trace';: SQL> set query execution limit elapsed time 10 minutes; SQL> begin$ cont> declare :row_limit integer;( cont> declare :elapsed_limit integer;$ cont> declare :cpu_limit integer; cont> get diagnostics) cont> :cpu_limit = LIMIT_CPU_TIME,- cont> :row_limit = LIMIT_ROWS_FETCHED,1 cont> :elapsed_limit = LIMIT_ELAPSED_TIME;2 cont> trace 'LIMIT_ROWS_FETCHED: ', :row_limit;2 cont> trace 'LIMIT_CPU_TIME: ', :cpu_limit;6 cont> trace 'LIMIT_ELAPSED_TIME: ', :elapsed_limit; cont> end; ~Xt: LIMIT_ROWS_FETCHED: 0 ~Xt: LIMIT_CPU_TIME: 0 ~Xt: LIMIT_ELAPSED_TIME: 600 SQL>; Example 8: Using the TRACE_ENABLED keyword in a compound statement SQL> declare :x integer; SQL> begin, cont> get diagnostics :x = TRACE_ENABLED; cont> end; SQL> print :x; X 0 SQL> set flags 'trace'; SQL> begin, cont> get diagnostics :x = TRACE_ENABLED; cont> end; SQL> print :x; X 1 ww1 GET_ENVIRONMENTC Loads values defined by OpenVMS DCL symbols or logical names and: SQL session values into locally declared SQL variables. 2 Environment? You can use the GET ENVIRONMENT statement in interactive SQL only. 2 Format7 GET ENVIRONMENT -+--------------------------------+--+7 +-> ( --> gete nv-options --> ) --+ |7 +------------------------ <-------------------------+9 +---+- : = identifier -+------------------->% +------------ , <-------------+ getenv-options =  --+-+--> SESSION -+-+-> | +--> TRACE ---+ | +------ , <------+ 2 Arguments 3 SESSION= Directs GET ENVIRONMENT to return selected interactive SQLA session options. These options can be used to save and restore7 session state during the execution of an  SQL script. 3 TRACE@ Displays the translated string value prior to being convertedB to the data type of the variable. This can assist in diagnosingB data conversion errors. The display will indicate if the resultC was derived from a local symbol, global symbol, logical name, or session value. For example: SQL> GET ENVIRONMENT (TRACE)( cont> :xx indicator :xx_ind = XX; 01: XX = XX "--" (Local)@ %RDB-E-ARITH_EXCEPT, truncation of a numeric value at runti me, -COSI-F-INPCONERR, input conversion errorB The following table shows the associated SET command which willC accept the output from GET ENVIRONMENT (SESSION). These commandsD allow application to re-establish the environment after using SETA commands within an SQL script. Refer to the listed SET commandA for details of the string value that will be returned from GET ENVIRONMENT.- Table 1-3 GET ENVIRONMENT session keywords0 SESSION Keyword Associated SET command% DEFAULT_CATALOG SET CATALOG5 CONSTRAINT_MODE SET DEFAULT CONSTRAINT MODE. CHARACTER_LENGTH SET CHARACTER LENGTH2 COMPOUND_ SET COMPOUND TRANSACTION TRANSACTIONS1 DATE_FORMAT SET DEFAULT DATE FORMAT5 DEFAULT_CONSTRAINT_ SET DEFAULT CONSTRAINT MODE MODE% DIALECT SET DIALECT) HOLD_CURSORS SET HOLD CURSOR1 NULL_STRING SET DISPLAY NULL STRING* QUIET_COMMIT  SET QUIET COMMIT+ QUOTING_RULES SET QUOTING RULES+ KEYWORD_RULES SET KEYWORD RULES$ DEFAULT_SCHEMA SET SCHEMA# DEFAULT_ALIAS SET ALIAS 2 Examples1 Example 1: Using the GET ENVIRONMENT Statement $ emp_id = "00164" $ SQL$' SQL> ATTACH 'FILENAME MF_PERSONNEL'; SQL> DECLARE :e CHAR(5);$ SQL> GET ENVIRONMENT :e = emp_id;K SQL> SELECT last_name, first_name FROM employees WHERE employee_id = :e; LAST_NAME F IRST_NAME Toliver Alvin 1 row selected SQL> ROLLBACK;& Example 2: Using the SESSION option? This example uses the SESSION option to save the DIALECT and0 restore it upon completion of the SQL script.& SQL> declare :Rdb_DIALECT char(10);9 SQL> get environment (session) :Rdb_DIALECT = DIALECT; SQL> set dialect 'SQL92';3 SQL> -- get SQL92 semantics for UNIQUE constrain* SQL> create table T (a integer unique);! SQL> set dialect :Rdb_DIALECT; SQL> undeclare :Rdb_DIALECT; ww1 GRANTB Creates or adds privileges to an entry to the Oracle Rdb access= privilege set, called the access control list (ACL), for a> database, table, view, column, module, or external routine.? Each entry in an ACL consists of an identifier and a list of) privileges assigned to the identifier:9 o Each identifier specifies a user or a set of users.D o The list of privileges specifies which operations that u  ser orB user group can perform on the database, table, view, column," module, or external routine.? When a user tries to perform an operation on a database, SQL= reads the associated ACL from top to bottom, comparing the? identifier of the user with each entry. As soon as SQL findsA the first match, it grants the rights listed in that entry andA stops the search. All identifiers that do not match a previousA entry "fall through" to the entry [*,*] (equivalent to th  e SQLD keyword PUBLIC). If no entry has the identifier [*,*], then usersD with unmatched identifiers are denied all access to the database,4 table, view, column, module, or external routine.D For this reason, both the entries and their order in the list are important.B Under the Oracle Rdb default protection scheme, when you create@ a new database, table, view, module, or external routine, you> get all access rights to that object, including DBCTRL. All? other users o  f that object are given no access rights to it.? For any tables or views created under the Oracle Rdb defaultC protection scheme, the creator of the table or view receives allC the access rights to the object, including DBCTRL, and all other0 users receive no access rights to the object.? The DBCTRL access right enables an object's creator to grantA DBCTRL to other users. See the Oracle Rdb SQL Reference ManualC for information on how you can tailor the default protection  for4 any new tables that you create within a database.? To remove privileges from or entirely delete an entry to theA Oracle Rdb access privilege set for a database, table, column,/ module, or external routine, see the REVOKE. 2 Environment# You can use the GRANT statement: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a nonstored procedure in a nonstored SQL module> o In dynamic SQL as a statement to b  e dynamically executed 2 Format! GRANT -------------------------+! +------------------------------+D ++-> db-privs -> ON DATABASE ALIAS -+-+--> +-+-----------++D | | +----- , <---+ | ||D | +------> * ------+ ||D +-> table-privs -> ON -+----------++++> -+++-------+|D | +-> TABLE -+||+> --+|| ||D | |+- ------- , <------+| ||D | +--------> * --------+ ||D +-> column-privs ----> ON COLUMN ---+-> --+-------+|D | +------- , <--------+ ||D +-> module-privs ----> ON MODULE --++-> --++------+|D | |+------- , <--------+| ||D | +-------> * ----------+ ||D +-> ext-routine-privs +> ON FUNCTION -+++-> ++|D | +> ON PROCEDURE +|+----------- , <-------+||D | +-----------> * ---------+|D +-> sequence-privs --> ON SEQUENCE -++> -++------+D |+------------ , <---+| |D +------------> * -----+ |D +---------------------------<-------------------------------------+E +-> grant-to ------------------------------------------------------> grant-to = B --> TO ++-> identifier --+-+------------------------------+-+--->> |+-> PUBLIC ------+ +-> AFTER -+-> identifier ---+-+ |> | | +-> PUBLIC -------+ | |> | +-> POSITION --------------+ |> +-------------------- , <----------------------------+ db-privs = % ----+---+-+-> SELECT -----+-+----+-># | | +-> INSERT -----+ | |# | | +-> OPERATOR ---+ | |# | | +-> DEL ETE -----+ | |# | | +-> CREATE -----+ | |# | | +-> ALTER ------+ | |# | | +-> DROP -------+ | |# | | +-> DBCTRL -----+ | |# | | +-> DBADM ------+ | |# | | +-> SHOW -------+ | |# | | +-> REFERENCES -+ | |# | | +-> UPDATE -----+ | |# | | +-> SECURITY ---+ | |# | | +-> DISTRIBTRAN + | |# | +------- , <--------+ |# +-------> ALL PRIVILEGES ----+ table-privs= 8 -+-  -+-+-> SELECT -------------------------------+-+-+->6 | | +-> INSERT -------------------------------+ | |6 | | +-> OPERATOR -----------------------------+ | |6 | | +-> DELETE -------------------------------+ | |6 | | +-> CREATE -------------------------------+ | |6 | | +-> ALTER --------------------------------+ | |6 | | +-> DROP ---------------------------------+ | |6 | | +-> DBCTRL -------------------------------+ | |6 | | +-> SHOW ---------------------------------+ | |6 |  | +-> REFERENCES +--------------------------+ | |6 | | | +> ( +> +> ) + | |6 | | | +----- , <-------+ | | |6 | | +-> UPDATE +------------------------------+ | |6 | | +> ( +> -+---> ) + | |6 | | +----- , <--------+ | |6 | +------------------- , <----------------------+ |6 +------> ALL PRIVILEGES ---------------------------+ column-privs= ! ---+-+-+-> UPDATE -----+-+--+--> | | +-> REFERENCES -+ | | | +------- , <--------+ | +-----> ALL PRIVILEGES --+ module-privs = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------- -----+ |5 +------> ALL PRIVILEGES --------------------------+ ext-routine-privs = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> A LL PRIVILEGES --------------------------+ sequence-privs =' -+--> ALL --+-----------------+---+-->$ | +--> PRIVILEGES --+ |$ +++-> ALTER --+-+----------------+ |+-> DROP --+ | |+-> SELECT -+ | +----- , <-----+ identifier = " --+-+-> user-identifier ----+-+-> | +-> general-identifier -+ | | +-> system-identifier -+ | | +-> role-name ----------+ | +------------ + <-----------+ 2 Arguments 3 AFTER Syntax opti ons:" AFTER identifier | AFTER PUBLICD Specifies the position of the entry within the ACL to be modified or created.D With the AFTER or POSITION argument, you can specify the position@ in the list after which SQL searches for an ACL entry with anD identifier that matches the one specified in the TO clause of the GRANT statement.B Following are specifics about the AFTER and POSITION arguments:B o In the AFTER argument, the identifier specifies the entry inC  the ACL after which SQL begins its search for the entry to beC modified or created. If none of the entries in the ACL has anC identifier that matches the identifier specified in the AFTER? argument, SQL generates an error and the statement fails.A Starting after the entry specified by the identifier in the@ AFTER argument, SQL searches the entries in the ACL. If anC entry has an identifier that matches the identifier specified@ by the TO clause of th  e GRANT statement, SQL creates a new@ entry that contains only those privileges specified in theD GRANT statement. SQL retains only the entry appearing first inB the ACL, and deletes any entries with duplicate identifiers.? If none of the entries has an identifier that matches theC identifier specified by the TO clause of the GRANT statement,; SQL creates a new ACL entry immediately following the1 identifier specified in the AFTER argument.D Spec  ifying PUBLIC is equivalent to a wildcard specification of all user identifiers.B o In the POSITION argument, the integer specifies the earliestA relative position in the ACL of the entry to be modified or created.D Starting with the position specified by the POSITION argument,= SQL searches the entries in the ACL. If an entry has an= identifier that matches the identifier specified by the? TO clause of the GRANT statement, SQL creates a new entr y@ that contains only those privileges specified in the GRANTB statement. SQL retains only the entry appearing first in the> ACL, and deletes any entries with duplicate identifiers.? If none of the entries has an identifier that matches theC identifier specified by the TO clause of the GRANT statement,A SQL creates a new entry for that identifier at the relativeC position specified in the POSITION argument (even if an entry> before the position at ! which SQL began its search had an identifier that matched).D If you specify a position higher than the number of entries inB the list, SQL places the entry last in the ACL. For example,A if you specify position 12 and there are only 10 entries in@ the list, the new entry is placed in position 11 and given that position number.> o If you omit the AFTER or POSITION argument, SQL searches@ the entire ACL for an identifier list that matches the oneD" specified in the TO clause of the GRANT statement. If it findsC a match, it modifies the ACL entry by adding those privilegesC specified in the privilege list that are not already present.D If there is no match, SQL creates a new entry at the beginning of the ACL. 3 ALL_PRIVILEGESC Specifies that SQL should grant all privileges in the ACL entry. 3 general-identifier> Identifies groups of users on the system and are defined by@ the OpenV# MS system manager in the system rights database. The. following are possible general identifiers: DATAENTRY SECRETARIES MANAGERS 3 ON_SEQUENCE_sequence-name@ Specifies whether the GRANT statement applies to ACLs for the named sequence or sequences. 3 ON Syntax options: ON DATABASE ALIAS * ON TABLE * ON TABLE * ON MODULE * ON FUNCTION * ON PROCEDURE * ON SEQUENCE *=Specifies whether th$ e GRANT statement applies to ACLs for all?objects of the specified type. If privileges are denied for the5operation on some objects, then the GRANT is aborted. 3 POSITION_nD Specifies the position of the entry within the ACL to be modified or created.D With the AFTER or POSITION argument, you can specify the position@ in the list after which SQL searches for an ACL entry with anD identifier that matches the one specified in the TO clause of the GRANT statement. % B Following are specifics about the AFTER and POSITION arguments:B o In the AFTER argument, the identifier specifies the entry inC the ACL after which SQL begins its search for the entry to beC modified or created. If none of the entries in the ACL has anC identifier that matches the identifier specified in the AFTER? argument, SQL generates an error and the statement fails.A Starting after the entry specified by the identifier in the@ AFTER argument & , SQL searches the entries in the ACL. If anC entry has an identifier that matches the identifier specified@ by the TO clause of the GRANT statement, SQL creates a new@ entry that contains only those privileges specified in theD GRANT statement. SQL retains only the entry appearing first inB the ACL, and deletes any entries with duplicate identifiers.? If none of the entries has an identifier that matches theC identifier specified by the TO clause of the G ' RANT statement,; SQL creates a new ACL entry immediately following the1 identifier specified in the AFTER argument.D Specifying PUBLIC is equivalent to a wildcard specification of all user identifiers.B o In the POSITION argument, the integer specifies the earliestA relative position in the ACL of the entry to be modified or created.D Starting with the position specified by the POSITION argument,= SQL searches the entries in the ACL. If ( an entry has an= identifier that matches the identifier specified by the? TO clause of the GRANT statement, SQL creates a new entry@ that contains only those privileges specified in the GRANTB statement. SQL retains only the entry appearing first in the> ACL, and deletes any entries with duplicate identifiers.? If none of the entries has an identifier that matches theC identifier specified by the TO clause of the GRANT statement,A SQL creates a ne ) w entry for that identifier at the relativeC position specified in the POSITION argument (even if an entry> before the position at which SQL began its search had an identifier that matched).D If you specify a position higher than the number of entries inB the list, SQL places the entry last in the ACL. For example,A if you specify position 12 and there are only 10 entries in@ the list, the new entry is placed in position 11 and given that positio* n number.> o If you omit the AFTER or POSITION argument, SQL searches@ the entire ACL for an identifier list that matches the oneD specified in the TO clause of the GRANT statement. If it findsC a match, it modifies the ACL entry by adding those privilegesC specified in the privilege list that are not already present.D If there is no match, SQL creates a new entry at the beginning of the ACL. 3 privileges Types of privileges: db-p+ rivs table-privs column-privs module-privs ext-routine-privs sequence-privsCSpecifies the list of privileges you want to add to an existing ACLAentry or create in a new one. The operations permitted by a givenCprivilege keyword differ, depending on whether you granted it for a?database, table, column, module, external routine, or sequence.= The following table lists the privilege keywords and their= meanings for databases, tables, columns, module , s, external routines, and sequences.D Table 1-4 SQL Privileges for Databases, Tables, Columns, Modules,, External Routines and Sequences For the Access@ Privilege Set of For the Access Privilege Set of? a Database, a Table, Column, View, Module,> Grants the External Routine or Sequence,9 Privilege Privilege to: Grants the Privilege to:C ALTER Change database Alter the table, inde - x, or storage> parameters or map. Alter a module, external? change a domain. routine, or sequence. Does not< apply to column privileges.? CREATE Create a Create a view, trigger, index,B catalog, schema, sequence, storage map, or outlineB table, domain, that uses a table. Does not apply6 collating to column privileges. sequence, . storage area, external routine, module, or sequence.B DBADM Perform any data Not applicable, but syntactically) manipulation or allowed. data definition operation on any named object. Override many database privileges.D DBCTRL Create, delete, Grant or revoke an access privilegeC or modify an set entry for t / he table, sequence,B access privilege module, or external routine. Does@ set entry for not apply to column privileges. the database.C DELETE Delete data from Delete data from a table. Does not< a table defined apply to column privileges. in the database.0 DISTRIBTRANRun a Not applicable. distributed (two-phase commit protocol) transa 0 ction against the database.C DROP Delete a Delete the table, index or outlineB catalog, that uses a table. Delete a view,= schema, domain, column, constraint, trigger,A collating sequence, or storage map. DeleteB sequence, or a view, module, external routine,- path name. or sequence.C EXECUTE Not applicable. Allow the execution of a 1 module orA external routine. Does not apply> to column, sequence, or table, privileges.> INSERT Store data in a Store data in the table. Does@ table defined in not apply to column or sequence, the database. privileges.> OPERATOR Not applicable. Not applicable. Syntactically> Syntactically allowed, but not implemented.> 2 allowed, but Reserved for future versions. not implemented. Reserved for future versions.A REFERENCES Not applicable, Define constraints that refer toB but data in a table or column. Define> syntactically tables using the LIKE clause.? allowed. Define synonyms that reference/ those objects.0 SECURITY Override Not applicabl 3 e. many database privileges.: SELECT Attach to a Read data from a table orB database and reference the NEXTVAL and CURRVALB read data from a pseudocolumns in a sequence. Does@ table defined in not apply to column privileges. the database.> SHOW Not applicable. Not applicable. Syntactically> Syntactically allowed, but not implemented.> allowed, b4 ut Reserved for future versions. not implemented. Reserved for future versions.B UPDATE Update data in a Update data in a table or column. table defined in the database.B Privileges on a column are determined by the privileges defined? for the table combined with those specified for the specific column ACL.< The SELECT privilege is a prerequisite for all other data@ manipulation privileges, 5 except UPDATE and REFERENCES. If youB do not grant the SELECT privilege, you effectively deny SELECT,C INSERT, and DELETE privileges, even if they are specified in theB privilege list. It is not possible for you to deny yourself the SELECT privilege.? For the SELECT, INSERT, UPDATE, and DELETE data manipulation> privileges, SQL checks the ACL for the database and for theC individual table before allowing access to a specific table. ForA example, if you are granted SELECT 6 privilege for the EMPLOYEESC table, you are not able to select rows from the table unless you@ also have SELECT privilege for the database that contains the EMPLOYEES table.> A user with the UPDATE privilege on the table automatically@ receives the UPDATE privilege on all columns in the table. ToA update a column, you must have the UPDATE privilege either for@ the column or the table. However, you can restrict the UPDATE@ privileges by defining them only on specific colu 7 mns you wantC users to be able to update, and by removing the UPDATE privilege from the table entry.; You can modify the data in a column only with the UPDATED privilege on the column and the SELECT privilege on the database.> The REFERENCES privilege lets you define a constraint for a? database with ANSI/ISO-style privileges. For a database withB ACL-style privileges, you need the CREATE privilege to define a constraint.? You cannot deny yourself the DBCTRL privi 8 lege for a database= or table that you create. This restriction may cause GRANT9 statements to fail when you might expect them to work.< For instance, suppose an ACL has no entry for PUBLIC. TheB following GRANT statement fails because it creates an entry for@ PUBLIC at the top of the ACL that does not include the DBCTRLD privilege, effectively denying DBCTRL to all other entries on the list, including the owner:4 SQL> GRANT SELECT, INSERT ON EMPLOYEES TO PUBLIC;8 %9 RDB-E-NO_PRIV, privilege denied by database facility 3 role-name? The name of a role, such as one created with the CREATE ROLEC statement or one that can be created automatically. (If the roleA name exists as an operating system group or rights identifier,D then Oracle Rdb will create the role automatically when you issueC the GRANT statement. A role that is created automatically always/ has the attribute of IDENTIFIED EXTERNALLY.) 3 TO Syntax options::  TO identifier | TO PUBLIC? Specifies the identifiers for the new or modified ACL entry.A Specifying PUBLIC is equivalent to a wildcard specification of all user identifiers.- You can specify four types of identifiers: o User identifiers o General identifiers o System-defined identifiers o Role names= You can specify more than one identifier by combining them> with plus signs (+). Such identifiers are called multipleD identifiers. They ; identify only those users who are common to allA the groups defined by the individual identifiers. Users who doB not match all the identifiers are not controlled by that entry.B For instance, the multiple identifier SECRETARIES + INTERACTIVE= specifies only members of the group defined by the generalA identifier SECRETARIES that are interactive processes. It does= not identify members of the SECRETARIES group that are not interactive processes.> The following argumen< ts briefly describe the three types of@ identifiers. For more information about identifiers, see your" operating system documentation. 3 system-identifier> System-defined identifiers are automatically defined by theD system when the rights database is created at system installationA time. System-defined identifiers are assigned depending on theA type of login you execute. The following are all valid system- defined identifiers: BATCH NETWORK = INTERACTIVE LOCAL DIALUP REMOTE 3 user-identifier& Identifies each user on the system.< The user identifier consists of the standard OpenVMS userB identification code (UIC), a group name and a member name (user@ name). The group name is optional. The user identifier can beB in either numeric or alphanumeric format. The following are all< valid user identifiers that could identify the same user: K_JONES [SYSTEM3, K_JONES] [341> ,311]@ You can use the asterisk (*) wildcard character as part of aD user identifier. For example, if you want to specify all users in9 a group, you can enter [system3, *] as the identifier.B When Oracle Rdb creates a database, it automatically creates anD ACL entry with the identifier [*,*] (also known as PUBLIC), which= specifies the privileges given to all users on the system.= You cannot use more than one user identifier in a multiple identifier. 2 Examp ? lesD Example 1: Redeclaring a database to make ACL changes take effectC This example illustrates that GRANT and REVOKE statements do not6 take effect until you attach to the database again.3 SQL> -- Display the ACL for the EMPLOYEES table:+ SQL> SHOW PROTECTION ON TABLE EMPLOYEES; Protection on Table EMPLOYEESP (IDENTIFIER=[sql,warring],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+, ALTER+DROP+DBCTRL+DBADM+REFERENCES)G (IDENTIFIER=[*,*],ACCESS=SELECT @ +INSERT+UPDATE+DELETE+ALTER+DROP) SQL>: SQL> -- User warring, the owner of the database, denies8 SQL> -- herself INSERT access to the EMPLOYEES table:6 SQL> REVOKE INSERT ON TABLE EMPLOYEES FROM warring; SQL> COMMIT; SQL>< SQL> -- The SHOW PROTECTION statement displays the change5 SQL> -- (INSERT is no longer part of the ACL entry SQL> -- for warring):+ SQL> SHOW PROTECTION ON TABLE EMPLOYEES; Protection on Table EMPLOYEESO (IDENTIFIER=[sql,warring],AA CCESS=SELECT+UPDATE+DELETE+SHOW+CREATE+ALTER+& DROP+DBCTRL+DBADM+REFERENCES)G (IDENTIFIER=[*,*],ACCESS=SELECT+INSERT+UPDATE+DELETE+ALTER+DROP) SQL>/ SQL> -- But the change is not yet effective.D SQL> -- User warring can still store rows in the EMPLOYEES table:= SQL> INSERT INTO EMPLOYEES (EMPLOYEE_ID) VALUES ('99999'); 1 row inserted SQL> SELECT EMPLOYEE_ID cont> FROM EMPLOYEES' cont> WHERE EMPLOYEE_ID = '99999'; EMPLOYEE_ID 99999 B 1 row selected SQL> ROLLBACK; SQL>M SQL> -- To make the ACL change take effect, issue another ATTACH statement/ SQL> -- to override the current declaration:$ SQL> ATTACH 'FILENAME personnel';3 This database context has already been declared.6 Would you like to override this declaration (No)? Y SQL>G SQL> -- Now warring cannot insert new rows into the EMPLOYEES table:= SQL> INSERT INTO EMPLOYEES (EMPLOYEE_ID) VALUES ("99999");8 %RDB-E-NO_PRIV, privilege denC ied by database facility SQL>B SQL> -- A GRANT statement gives all privileges back to warring:0 SQL> GRANT ALL ON TABLE EMPLOYEES TO warring; SQL> COMMIT;6 Example 2: Creating an ACL with an SQL command file@ The following SQL command file creates an ACL for the defaultA database by specifying the default alias RDB$DBHANDLE. It uses3 two general guidelines for ordering ACL entries:@ o The less restrictive the user identifier, the lower on the list that AC D L should go.B o The more powerful the privilege, the higher on the list that ACL should go.B Because SQL reads the list from top to bottom, you should placeA entries with more specific identifiers earlier, and those withD more general ones later. For example, if you place the entry withB the most general user identifier, [*,*], first in the list, allA users match it, and Oracle Rdb grants or denies all the access' rights specified there to all users.= SimilarlyE , if you place the general entry [admin,*] beforeA the specific entry [admin,ford], SQL matches user [admin,ford]B with [admin,*] and denies the access rights INSERT, UPDATE, and) DELETE, which user [admin,ford] needs.5 -- Database Administrator -- needs all privileges. -- GRANT ALL& ON DATABASE ALIAS RDB$DBHANDLE TO [group2,adams] POSITION 1;F -- Assistant -- needs to be able to use data definition statements. --& GRANT SEF LECT,CREATE,ALTER,DROP& ON DATABASE ALIAS RDB$DBHANDLE TO [group2,clark] POSITION 2;I -- Operator -- needs to be able to perform database maintenance tasks. --" GRANT SELECT, ALTER, DBADM& ON DATABASE ALIAS RDB$DBHANDLE TO [group2,lawrence] POSITION 3;I -- Security Administrator -- needs to specify and show security events8 -- audited for a database and review the audit trail. -- GRANT SECURITY& ONG DATABASE ALIAS RDB$DBHANDLE TO [group2,davis] POSITION 4;J -- Manager -- needs to be able to use all data manipulation statements. --) GRANT SELECT,INSERT,UPDATE,DELETE& ON DATABASE ALIAS RDB$DBHANDLE TO [admin,smith] POSITION 5;D -- Secretary -- needs to be able to read, write, and delete data.2 -- No access to data definition or maintenance. --) GRANT SELECT,INSERT,UPDATE,DELETE& ON DATABASE ALIAS RDB$DBH HANDLE TO [admin,ford] POSITION 6;J -- Programmers -- need to perform data definition and data manipulationB -- on some tables and constraints to test application programs. --F GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,ALTER,DROP,REFERENCES& ON DATABASE ALIAS RDB$DBHANDLE TO PROGRAMMERS POSITION 7;N -- Clerks -- need to be able only to read data. No access to modify, erase,8 -- store, data definition, or maintenance statements.I  -- GRANT SELECT& ON DATABASE ALIAS RDB$DBHANDLE TO [admin,*] POSITION 8;M -- Deny access to all users not explicitly granted access to the database. -- REVOKE ALL& ON DATABASE ALIAS RDB$DBHANDLE FROM PUBLIC POSITION 9;= Example 3: Granting column access and denying table access? You need the REFERENCES privilege to define constraints that? affect a particular column. You need the UPDATE privilege t J o@ update data in a column. A user with the UPDATE privilege for> a table automatically receives the UPDATE privilege for all? columns in that table. To update a column, you must have theD UPDATE privilege either for the column or for the table. However,= a database administrator can restrict UPDATE privileges byA defining them only for columns users should be able to update,? and then removing the UPDATE privilege from the table entry.B Because current salary is sensitiveK information, you might want1 to restrict the ability to update this amount.A The following example prevents user [admin,ford] from updatingA any column in the SALARY_HISTORY table except SALARY_START and@ SALARY_END. For instance, user [admin,ford] cannot update the SALARY_AMOUNT column.: SQL> GRANT UPDATE ON COLUMN SALARY_HISTORY.SALARY_START cont> TO [admin,ford];8 SQL> GRANT UPDATE ON COLUMN SALARY_HISTORY.SALARY_END cont> TO [admin,ford]; SQL> --@ SQL L > REVOKE UPDATE ON TABLE SALARY_HISTORY FROM [admin,ford]; SQL> -- SQL> COMMIT; SQL> --0 SQL> SHOW PROTECTION ON TABLE SALARY_HISTORY;% Protection on Table SALARY_HISTORYO (IDENTIFIER=[grp2,jones],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+@ ALTER+DROP+DBCTRL+DBADM+REFERENCES+SECURITY+DISTRIBTRAN)% (IDENTIFIER=[*,*],ACCESS=NONE) SQL> --> SQL> SHOW PROTECTION ON COLUMN SALARY_HISTORY.SALARY_START;3 Protection on Column SALARY_HISTORY.SALARY_STARM T. (IDENTIFIER=[admin,ford],ACCESS=UPDATE)% (IDENTIFIER=[*,*],ACCESS=NONE)C Example 4: Granting SELECT Privilege to All Users for a Sequence) SQL> SHOW PROTECTION ON SEQUENCE EMPID Protection on Sequence EMPIDF (IDENTIFIER=[RDB,STRAUTS],ACCESS=SELECT+SHOW+ALTER+DROP+DBCTRL)% (IDENTIFIER=[*,*],ACCESS=NONE)1 SQL> GRANT SELECT ON SEQUENCE EMPID TO PUBLIC;* SQL> SHOW PROTECTION ON SEQUENCE EMPID; Protection on Sequence EMPIDF (IDENTIFIER=[ N RDB,STRAUTS],ACCESS=SELECT+SHOW+ALTER+DROP+DBCTRL)' (IDENTIFIER=[*,*],ACCESS=SELECT): Example 5: Granting INSERT ON TABLE Privilege to a Role% SQL> SHOW PROTECTION ON TABLE JOBS Protection on Table JOBSR (IDENTIFIER=[250,254],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+& DROP+DBCTRL+DBADM+REFERENCES)S (IDENTIFIER=PUBLIC,ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+DROP +DBADM+REFERENCES)" SQL> CREATE ROLE ADMINISTRATOR;D O SQL> GRANT INSERT ON TABLE JOBS TO ADMINISTRATOR AFTER [250,254];% SQL> SHOW PROTECTION ON TABLE JOBS Protection on Table JOBSR (IDENTIFIER=[250,254],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+& DROP+DBCTRL+DBADM+REFERENCES)/ (IDENTIFIER=ADMINISTRATOR,ACCESS=INSERT)S (IDENTIFIER=PUBLIC,ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+DROP +DBADM+REFERENCES)+ Example 6: Allowing All Access to a User( SQL> -- Allow all access P to user JAIN3 SQL> GRANT SELECT ON DATABASE ALIAS * to jain;3 SQL> GRANT SELECT ON TABLE * to jain;3 SQL> GRANT EXECUTE ON MODULE * to jain;3 SQL> GRANT EXECUTE ON PROCEDURE * to jain;3 SQL> GRANT EXECUTE ON FUNCTION * to jain; : Example 7: Automatically Creating a User While Granting Privileges+ SQL> ATTACH 'FILENAME MF_PERSONNEL.RDB'; SQL> SHOW USERS3 Users in database with filename mf_personnel.rdb tsmith Q jstuart9 SQL> GRANT ALL ON DATABASE ALIAS RDB$DBHANDLE TO CDAY;L %RDB-W-META_WARN, metadata successfully updated with the reported warning7 -RDMS-W-PRFCREATED, some users or roles were created SQL> SHOW USERS3 Users in database with filename mf_personnel.rdb tsmith jstuart cday wwo 1 GRANT_ANSI? Creates or adds ANSI/ISO-style privileges to an entry of the? Oracle Rdb access privilege set for a database, table, vi R ew,C column, module, sequence, or routine. At database creation time,@ you specify whether the database protection mechanism will beC ANSI/ISO-style or ACL-style. For more information on creating orC changing the style of privileges associated with a database, see! the CREATE DATABASE statement.@ Each entry in an ANSI/ISO-style access privilege set consists< of an identifier and a list of privileges assigned to the identifier.8 o Each identifier specifies a user oS r PUBLIC access.C o The set of privileges specifies what operations that user can% perform on the database object. ANSI/ISO-style privileges:D o Grant access to the creator when an object is created. Because= only the creator is granted access to the newly created; object, additional access must be granted explicitly.7 o Support only the PUBLIC identifier as a wildcard.@ o Support only user identifiers that translate to an OpenVMS: user ident T ification code (UIC), Rdb users, or roles.: For ANSI/ISO-style databases, a user's privileges are aA combination of all privilege sets that apply to that user. TheD access privilege set is not order-dependent. The user matches theB entry in the access privilege set; receives whatever privileges> have been granted for the database object; and receives the@ privileges defined for PUBLIC. A user without an entry in the@ access privilege set receives only the privileges defined forU @ PUBLIC, which always has an entry in the access privilege set? even if PUBLIC has no access to the database, table, column, module, or external routine.? To remove privileges from or entirely delete an entry to theA Oracle Rdb access privilege set for a database object, see the REVOKE_ANSI statement. 2 Environment# You can use the GRANT statement: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a non V stored procedure in a nonstored SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format GRANT -----------> ----------+ +-------------- <-------------+N ++-> db-privs-ansi -------> ON DATABASE ALIAS ++-> -++-------------++N | |+--- , <-----+| ||N | +----> * ------+ ||N +-> table-privs-ansi ----> ON +----->----+---+++-> -+W --------+|N | +-> TABLE -+ ||+-> --+ ||N | |+-------- , <---------------+|N | +--------> * ----------------+|N +-> column-privs-ansi ---> ON COLUMN ---+> --+--------------+|N | +------- , <-------+ ||N +-> module-privs-ansi ---> ON MODULE --++-> --++------------+|N | X |+------- , <--------+| ||N | +-------> * ----------+ ||N +-> ext-routine-privs-ansi -+> ON FUNCTION --+-++-> -++-+|N | +> ON PROCEDURE -+ |+--------- , <---------+| ||N | +---------> * -----------+ ||N +-> sequence-privs-ansi ---> ON SEQUENCE -++> -++---------+|N Y |+------- , <--------+| |N +-------> * ----------+ |N +----------------------------<---------------------------------------------+O +-> grant-ansi-to ----------------------------------------------------------> grant-ansi-to = K ---> TO -+-+-> identifier-ansi-style ---+-+-+-----------------------+---->F | +-> PUBLIC ------------------+ | +-> WITH GRANT OPTION --+, +------------- , <---------------+Z  db-privs-ansi = % ----+---+-+-> SELECT -----+-+----+-># | | +-> INSERT -----+ | |# | | +-> OPERATOR ---+ | |# | | +-> DELETE -----+ | |# | | +-> CREATE -----+ | |# | | +-> ALTER ------+ | |# | | +-> DROP -------+ | |# | | +-> DBCTRL -----+ | |# | | +-> DBADM ------+ | |# | | +-> SHOW -------+ | |# | | +-> REFERENCES -+ | |# | | +-> UPDATE -----+ | |# | | +-> SECUR[ ITY ---+ | |# | | +-> DISTRIBTRAN + | |# | +------- , <--------+ |# +-------> ALL PRIVILEGES ----+ table-privs-ansi = : -+--+-+-> SELECT ---------------------------------+-+-+->8 | | +-> INSERT ---------------------------------+ | |8 | | +-> DELETE ---------------------------------+ | |8 | | +-> CREATE ---------------------------------+ | |8 | | +-> ALTER ----------------------------------+ | |8 | | +-> DROP ---------------------------------- \ -+ | |8 | | +-> DBCTRL ---------------------------------+ | |8 | | +-> SHOW -----------------------------------+ | |8 | | +-> REFERENCES +---------------------------+ | |8 | | | +> ( +> +> ) -+ | |8 | | | +----- , <-------+ | | |8 | | +-> UPDATE -+-------------------------------+ | |8 | | +> ( +> --+--> ) -+ | |8 | | +----- , <---------+ | |8 | +------------------- , <-----] -------------------+ |8 +------> ALL PRIVILEGES -----------------------------+  column-privs-ansi = ! ---+-+-+-> UPDATE -----+-+--+--> | | +-> REFERENCES -+ | | | +------- , <--------+ | +-----> ALL PRIVILEGES --+ module-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |^ 5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ ext-routine-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 | | +-> REFER_ ENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ identifier-ansi-style = " ----+-> uic-identifier ----+----> +-> user-identifier ---+ +-> role-name ---------+ sequence-privs-ansi =  -+-+-+-> ALTER -----+-+-+--> | | +-> DBCTRL ----+ | | | | +-> DROP ------+ | | | | +-> SELECT ----+ | | | +-------` , <-------+ | +--> ALL PRIVILEGES ---+ 2 Arguments 3 ALL_PRIVILEGESB Specifies that SQL should grant all privileges to the specified users. 3 ON_object-type Syntax options: ON DATABASE ALIAS alias ON TABLE table-name ON TABLE view-name ON MODULE module-name ON FUNCTION routine-name ON PROCEDURE routine-name ON SEQUENCE sequence-name@ Specifies whether the GRANT statement applies to ACLs for thea @ named object. You can specify a list of names for any form ofB the ON clause. You must qualify a column name with at least the associated table name.@ Specifies whether the GRANT statement applies to ACLs for allB objects of the specified type. If privileges are denied for the8 operation on some objects, then the GRANT is aborted. 3 privileges Type of privileges: db-privs-ansi table-privs-ansi column-privs-ansi module-privs-ansi b ext-routine-privs-ansi sequence-privs-ansi>Specifies the set of privileges you want to add to an existingAaccess privilege set entry or create in a new one. The operationsCpermitted by a given privilege keyword differ, depending on whetherAyou granted it for a database, table, column, module, or external@routine. The Privileges Table (in the GRANT) lists the privilegeDkeywords and their meanings for databases, tables, columns, modules, external routines and sequences. c 3 role-name? The name of a role, such as one created with the CREATE ROLEB statement. If the role name exists as an operating system group= or rights identifier, then Oracle Rdb will create the role@ automatically when you issue the GRANT statement. A role thatB is created automatically always has the attribute of IDENTIFIED EXTERNALLY. 3 TO_identifier_ansi_style; Specifies the identifiers for the new or modified access< privilege set entry. Specifying PUBLIC d is equivalent to a2 wildcard specification of all user identifiers.? In ANSI/ISO-style databases, you are allowed to specify onlyA single-user user identifiers; no general or system identifiers@ are allowed. Access privilege set entries identify only those? users who are common to all groups defined by the individual> identifiers. Users who do not match all identifiers are notA controlled by that entry. ANSI/ISO-style access privilege sets! support only user identifiers.e  3 user-identifierD Specifies a user identifier that uniquely identifies each user on the system.C On OpenVMS, the user identifier consists of the standard OpenVMSA user identification code (UIC), a group name and a member nameC (user name). The group name is optional. The user identifier canA be in either numeric or alphanumeric format. The following are@ all valid user identifiers that could identify the same user: K_JONES [SYSTEM3, K_JONES] f [341,311]B When Oracle Rdb creates an ANSI/ISO-style database, the creatorD of the database gets all privileges, and the PUBLIC entry gets no privileges.> In an ANSI/ISO-style database, you cannot use multiple user identifiers.C In ANSI/ISO-style user identifiers, the only wildcard allowed is" in the public identifier [*,*].D For more information about identifiers, see the OpenVMS operating system documentation. 3 WITH_GRANT_OPTIONA Allows the g user who has been granted a privilege the option of* granting that privilege to other users.B The WITH GRANT OPTION clause specifies that the grantees in theD TO clause may grant the privileges in the privilege list to otherD users for as long as they have the privileges. When the privilege? is revoked from the grantee who received the privileges with@ the WITH GRANT OPTION clause, the privileges also are revokedC from all the users who received the privileges from that granteh eC (unless these users have received the privilege from yet another% user who still has the privilege). 2 Examples( Example 1: Using PUBLIC as a wildcard@ This example shows that PUBLIC translates to [*,*] and can be6 used to grant access to the database for all users.1 SQL> show protection on database rdb$dbhandle;# Protection on Alias RDB$DBHANDLE [RDB,DOCS]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,I i DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN# Without Grant Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE> SQL> grant select on database alias rdb$dbhandle to public;1 SQL> show protection on database rdb$dbhandle;# Protection on Alias RDB$DBHANDLE [RDB,DOCS]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,I DBCTRL,OPERATOR,DBADM,SECURj ITY,DISTRIBTRAN# Without Grant Option: NONE [*,*]:# With Grant Option: NONE% Without Grant Option: SELECT SQL> commit;= Example 2: Granting a privilege with the WITH GRANT OPTION clause.= This example shows how the WITH GRANT OPTION causes Rdb to@ maintain a separate list of privileges that were granted by a? user with ability to GRANT to others. This extra information? is queries using the SHOW USERS WITH and SHOW USERS GRANTING k commands.+ SQL> show protection on table EMPLOYEES; Protection on Table EMPLOYEES [RDB,DOCS]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,0 DBCTRL,REFERENCES# Without Grant Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE? SQL> grant delete on employees to freeman with grant option; SQL>+ SQL> show protection on table EMPLOYEES; Protectiol n on Table EMPLOYEES [RDB,FREEMAN]:% With Grant Option: DELETE# Without Grant Option: NONE [RDB,DOCS]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,0 DBCTRL,REFERENCES# Without Grant Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE SQL>= SQL> -- Show the list of users who will loose their DELETE= SQL> -- privilege if the privilegm e is taken away from DOCS SQL>6 SQL> show users with delete on employees from DOCS;< Users granted privileges on table EMPLOYEES by [RDB,DOCS] [RDB,FREEMAN] [RDB,DOCS] [RDB,FREEMAN] SQL>F SQL> -- Check if anyone on the list has given DELETE to anyone else SQL>: SQL> show users granting delete on employees to PUBLIC;8 Users granting privileges on table EMPLOYEES to [*,*] No users found SQL>( Example 3: Granting column privilegesA This n example shows the two forms of the GRANT column statement0 and the effects it has on the target columns.1 SQL> -- First show existing column protections SQL>8 SQL> show protection on column CANDIDATES.FIRST_NAME;- Protection on Column CANDIDATES.FIRST_NAME> SQL> show protection on column CANDIDATES.CANDIDATE_STATUS;3 Protection on Column CANDIDATES.CANDIDATE_STATUS SQL>@ SQL> -- Show alternate formats for the GRANT column statement SQL>G SQL> grant update (o CANDIDATE_STATUS) on table CANDIDATES to freeman;@ SQL> grant update on column CANDIDATES.FIRST_NAME to freeman; SQL>3 SQL> -- Show the effects of the GRANT statements SQL>8 SQL> show protection on column candidates.FIRST_NAME;- Protection on Column CANDIDATES.FIRST_NAME [RDB,FREEMAN]:# With Grant Option: NONE% Without Grant Option: UPDATE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE> SQL> show protectiop n on column candidates.CANDIDATE_STATUS;3 Protection on Column CANDIDATES.CANDIDATE_STATUS [RDB,FREEMAN]:# With Grant Option: NONE% Without Grant Option: UPDATE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE SQL>/ Example 4: Granting privileges on a SequenceC This example shows that the set of privileges granted by ALL forC sequences is a small subset of those used for other objects such as tables and vie q ws.( SQL> create sequence EMPLOYEE_ID_GEN;9 SQL> grant all on sequence EMPLOYEE_ID_GEN to freeman;; SQL> grant select on sequence EMPLOYEE_ID_GEN to public;4 SQL> show protection on sequence EMPLOYEE_ID_GEN;) Protection on Sequence EMPLOYEE_ID_GEN [RDB,FREEMAN]:# With Grant Option: NONEG Without Grant Option: SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES [RDB,DOCS]:G With Grant Option: SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES# Without Gr rant Option: NONE [*,*]:# With Grant Option: NONE% Without Grant Option: SELECT SQL> ww-1 GRANT_ROLES= Grants a role to a user, another role, or the PUBLIC user. 2 Environment- You can use the GRANT statement for roles: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a nonstored procedure in a nonstored SQL module> o In dynamic SQL as a statement to be s dynamically executed 2 Format2 GRANT --+----> --------+---> TO ----+2 +-------- , <--------------+ |2 +-------------------<---------------------------+2 +-------+-+--> ------+--+------------>% | +--> -----+ |% | +--> PUBLIC ----------+ |% +--------- , <-------------+ 2 Arguments 3 role-name= The name of a role previously created with the CREATE ROLE< statement. If the role nat me exists as an operating systemA group or rights identifier, then Oracle Rdb will automaticallyB create the role when you issue the GRANT statement. A role that? is created automatically always has the attribute IDENTIFIED EXTERNALLY. 3 TOSyntax options:) TO username | TO role-name | TO PUBLICB Specifies the user name, role name, or the PUBLIC user to which? you want to grant the role. The PUBLIC user is the user name? associated with all anonymous usersu who access the database.C If the user name or role name exists as an operating system userB or rights identifier, then Oracle Rdb will automatically createA the user name or role name when you issue the GRANT statement.= A role or user that is created automatically is IDENTIFIED EXTERNALLY. 2 Example) Example 1: Granting and Revoking RolesE SQL> -- Create three users and two roles. Oracle Rdb automaticallyG SQL> -- generates users and roles if they are ident v ified externally.3 SQL> CREATE USER ABLOWNEY IDENTIFIED EXTERNALLY;2 SQL> CREATE USER BGREMBO IDENTIFIED EXTERNALLY;0 SQL> CREATE USER LWARD IDENTIFIED EXTERNALLY;8 SQL> CREATE ROLE SALES_MANAGER IDENTIFIED EXTERNALLY;; SQL> CREATE ROLE DIVISION_MANAGER IDENTIFIED EXTERNALLY;: SQL> -- Grant the SALES_MANAGER role to users ABLOWNEY,5 SQL> -- BGREMBO, and to the DIVISION MANAGER ROLE.C SQL> GRANT SALES_MANAGER TO ABLOWNEY, BGREMBO, DIVISION_MANAGER;> SQL> -- Grant the DIVw ISION_MANAGER role to LWARD. LWARD nowA SQL> -- has both the SALES_MANAGER and DIVISION_MANAGER roles.( SQL> GRANT DIVISION_MANAGER TO LWARD;> SQL> -- Revoke the DIVISION_MANAGER role from LWARD. He has SQL> -- left the company.+ SQL> REVOKE DIVISION_MANAGER FROM LWARD;; SQL> -- Grant the DIVISION_MANAGER role to BGREMBO. She1 SQL> -- has been promoted to division manager.* SQL> GRANT DIVISION_MANAGER TO BGREMBO; ww-1 HELPD Gives you acces!x s to assistance on all SQL statements, components, and concepts. 2 Environment< You can issue the HELP statement only in interactive SQL. 2 Format" HELP --+--------------------+--> +-> help-topic ----+ 2 Arguments 3 topic7 The SQL statement or concept on which you need help. 2 Example* Example 1: Obtaining online Help in SQL SQL> HELP SELECT ww> 1 IF_Control= Executes one or more SQL staty ements conditionally. It then; continues processing by executing any SQL statement that! immediately follows the block. 2 Environment@ You can use the IF control statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format if-statement = B -----> IF predicate THEN --+-> compound z -use-statement -+--------+B +------------ <-------------+ |B +---------------------------------------------------------------+B ++-+--------------------------------------------------------+-+-+B | +-> ELSEIF predicate THEN -+-> compound-use-statement -+-+ | |B | +------------ <-------------+ | |B +---------------------------- <------------------------------+ |B +---------------------------------------------------------------+C +{ --+----------------------------------------+--> END IF --------->. +-> ELSE --+-> compound-use-statement -+-+, +------------ <-------------+  2 Arguments 3 compound-use-statementA See the Compound_Statement HELP topic for a description of the9 SQL statements that are valid in a compound statement. 3 END_IF@ Marks the end of an IF statement. Every IF statement must end with the END IF clause. 3 ELSE_compound_use_statement?| Executes one or more SQL statements associated with the ELSEA clause but only when the value of the IF and ELSEIF predicates evaluate to FALSE or UNKNOWN. 3 ELSEIF_THENB If the ELSEIF predicate evaluates to TRUE, SQL executes the SQLB statements in the THEN clause. If the ELSEIF predicate does notC evaluate to TRUE, SQL evaluates the predicates in any subsequent ELSEIF or ELSE clauses. 3 IF_THENB Executes one or more SQL statements in an IF . . . END IF } block> only when the value of an IF predicate evaluates to TRUE. A? predicate, also called a conditional expression, specifies a> condition that SQL evaluates to TRUE, FALSE, or UNKNOWN. IfA the predicate evaluates to TRUE, SQL executes the statement in? the THEN clause. If the predicate does not evaluate to TRUE,? SQL evaluates the predicate in any ELSEIF clauses. If the IFD statement contains no ELSEIF clauses, SQL executes any statements in the ELSE clause. 3 p~ redicateD See the Predicates HELP topic for more information on predicates. 2 Examples+ Example 1: Using an IF control statement% IF (SELECT COUNT (*) FROM STUDENTS' WHERE CLASS = :CLASS_NUM) > 30 THEN* SET :MSG = 'Class is too large.'; ELSE) SET :MSG = 'Class size is O.K.'; END IF; ww> 1 IMPORT@ Creates an Oracle Rdb database from an interchange .rbr file.A You use the IMPOR  T statement with the EXPORT statement to make@ changes to Oracle Rdb databases that cannot be made any other@ way. The EXPORT statement unloads a database to an .rbr file.A The IMPORT statement re-creates the database with changes that@ may not be allowed by an ALTER DATABASE statement. The IMPORT statement lets you:B o Convert from a single-file to a multifile database, and vice versa.A o Change database root file parameters that you cannot change( with the ALTER DATABASE statement: - COLLATING SEQUENCE& - SEGMENTED STRING STORAGE AREA - PROTECTION IS ANSI/ACLS - DEFAULT STORAGE AREAD o Change storage area parameters that you cannot change with the ALTER DATABASE statement: - PAGE SIZE - PAGE FORMAT - THRESHOLDS - INTERVAL$ - FILENAME, SNAPSHOT FILENAMEA o Reload tables with existing rows to take advantage of newly created hashed index es.? o Reload tables to take advantage of new or changed storage maps.= o Move a database to another directory or disk structure.? However, if moving a database is the only change you needA to make, it is more efficient to use the RMU Backup and RMU Restore commands.= o Create an empty target database that uses the same data? definitions as a source database by copying the metadata,& but not the data, to the target.D If you use t he NO DATA option, the IMPORT statement creates anC Oracle Rdb database whose metadata is identical to that foundB in the source database used by the EXPORT statement, but theD duplicate database contains no data. The NO DATA option is notC compatible with the repository databases. See the description8 in the Arguments section under the NO DATA option. 2 Environment< You can use the IMPORT statement in interactive SQL only. 2 Format) IMPORT DATABA SE --> FROM -+) +--------------------------------------+8 +-+-> FILENAME --+----------------------+-+8 | +-> literal-user-auth -+ |8 +-> WITH ALIAS -----------------------------+8 +----------------------------<------------------------+: ++-+--------------------------------------+-+----------->. | +-> import-options --------------------+ |. | +-> character-sets --------------------+ |. | +-> import-root-file-params-1 ---------+ |. | +-> import-root-file-params-2 ---------+ |. | +-> import-root-file-params-3 ---------+ |. | +-> import-root-file-params-4 ---------+ |. | +-> storage-area-params-1 -------------+ |. | +-> storage-area-params-2 -------------+ |. | +-> create-clause/statement -----------+ |. | +-> drop-statement --------------------+ |. +-----------------<------------------------+  literal-user-auth = 6 ---> USER '' -+------------------------+-->3 + -> USING '' -+  import-options=- -+-+-------+-+-> ACL ----------------+-+--->) | +-> NO -+ +-> BANNER -------------+ |) | +-> BATCH UPDATE -------+ |) | +-> CDD LINKS ----------+ |) | +-> DATA ---------------+ |) | +-> FORWARD_REFERENCES -+ |) | +-> TRACE --------------+ |) +-> COMMIT EVERY TABLE --------------+) +-> COMMIT EVERY n ROWS --------------+ character-sets = 9 -+-+--> DEFAULT CHA RACTER SET --+-+->7 | +--> NATIONAL CHARACTER SET -+ |7 | +--> IDENTIFIER CHARACTER SET -+ |7 | +--> DISPLAY CHARACTER SET ----+7 +---------------------- <---------------------------+ import-root-file-params-1 = ; -+-> PATHNAME -----------------------------+->9 +-> attach-options -----------------------------------+9 +-> COLLATING SEQUENCE ------+ |9 | +------ -----------------------------------+ |9 | ++---------------+----+----------------+--+ |9 | +-> COMMENT IS -+ +-> ' ' -+ | |9 | +-----------------------------------------+ |9 | +--> -+-----------------------+---------+9 | +-> FROM + |9 +-> NUMBER OF USERS --> ---------------+9 +-> NUMBER OF BUFFERS -----> --------+9 +-> NUMBER OF CLUSTER NODES ----> --+ |9 | +---------------------------------------------+ |9 | +-+-----------------------------------------+----+9 | +-> ( -+-> SINGLE ---+-> INSTANCE --> ) --+ |9 | +-> MULTIPLE -+ |9 +-> NUMBER OF RECOVERY BUFFERS -> |9 +-> BUFFER SIZE IS -> -> BLOCKS ------+9 +-> global-buffer-params -----------------------------+ attach-options = H -+-> DBKEY -+-> SCOPE IS -+-> ATT ACH -------+-----------------------+->F +-> ROWID -+ +-> TRANSACTION --+ |F +-> MULTISCHEMA IS -+-> ON --+-------------------------------------+F | +-> OFF -+ |F +-> PRESTARTED TRANSACTIONS ARE -+-> ON --+------------------------+F | +-> OFF -+ |F +-+-------+-> RESTRICTED ACCESS -----------------------------------+ +-> NO -+ global-buff er-params= 7 --> GLOBAL BUFFERS ARE -+-> ENABLED --+--------------+7 +-> DISABLED -+ |7 +----------------------------------------------------+: +---------------------------------------------------+--->6 +> ( -++-> NUMBER IS ----++> ) +1 |+-> USER LIMIT IS ---+|1 |+-> PAGE TRANSFER VIA --+-> DISK ---+--+|1 || +-> MEMORY -+ |1 |+-> LARGE MEMORY IS --+--> ENABLED - -+--+1 | +--> DISABLED -+ |1 +------------------- , <----------------+  import-root-file-params-2 = G -+-> SNAPSHOT IS -+> ENABLED -+-> IMMEDIATE --+-+------------------+->E | | +-> DEFERRED ---+ | |E | +> DISABLED ------------------+ |E +-> DICTIONARY IS ---+---> REQUIRED -------+----------------------+E | +---> NOT REQUIRED ---+  |E +-> ADJUSTABLE LOCK GRANULARITY IS -+-> ENABLED -> alg-options -+-+E | +-> DISABLED ---------------+ |E +-> LOCK TIMEOUT INTERVAL IS SECONDS ------------+E +-> SEGMENTED STRING -+-> STORAGE AREA IS ------------+E +-> LIST -------------+ |E +-> DEFAULT ----------+ |E +-> PROTECTION IS ---+---> ANSI --+------------------------- ------+E | +---> ACLS --+ |E +-> RESERVE --+-> CACHE SLOTS -----+--------------------------+* +-> JOURNALS --------+* +-> STORAGE AREAS ---+* +-> SEQUENCES -------+ alg-options = & --+------------------------------+--># +-> ( --> COUNT IS --> ) --+  import-root-file-params-3 = I -+> CARDINALITY COLLECTION IS --------------+--+-> ENABLED --+--------+ >H +> CARRY OVER LOCKS ARE -------------------+ +-> DISABLED -+ |H +> GALAXY SUPPORT IS ----------------------+ |H +> LOCK PARTITIONING IS -------------------+ |H +> LOGMINER SUPPORT IS --------------------+ |H +> METADATA CHANGES ARE -------------------+ |H +> STATISTICS COLLECTION IS ---------------+ |H +> WORKLOAD COLLECTION IS -----------------+  |H +> SYSTEM INDEX -+-> COMPRESSION IS -+-> ENABLED ---+-----+----------+H | | +-> DISABLED --+ | |H | +-> ( -+-> system-index-options -+-> ) --+ |H | +---------- , <-----------+ |H +> PRESTARTED TRANSACTIONS ARE +> ENABLED -> prestart-trans-options ++H | +> DISABLED -------------------------+|H +> SECURITY CHECKING IS ---> security-checki ng-options --------------+H +> SYNONYMS ARE ENABLED ---------------------------------------------+ system-index-options = F -+-> COMPRESSION IS --------------------------------++- ENABLED -++->D +-> PREFIX CARDINALITY COLLECTION IS --------------++> DISABLED +|D +-> PREFIX CARDINALITY COLLECTION IS ENABLED FULL ---------------+D +-> TYPE IS SORTED --+-----------+-------------------------------+$ +-> RANKED -+ prestart-trans-options = ' -+------- --------------------------+->% +-> WAIT SECONDS FOR TIMEOUT -+% +-> WAIT MINUTES FOR TIMEOUT -+% +-> NO TIMEOUT -------------------+ security-checking-options = E -+-> EXTERNAL -+------------------------------------------------++->C | +-> ( -> PERSONA SUPPORT IS -+-> ENABLED --+> ) -+|C | +-> DISABLED -+ |C +-> INTERNAL -+-----------------------------------------------+-+A +-> ( -> ACCOUNT CHECK IS -+---> ENABLED --+> ) +< +---> DISABLED -+ import-root-file-params-4 = I -+-> ASYNC BATCH WRITES ARE --+-> ENABLED --> async-bat-wr-options -+-+>H | +-> DISABLED -------------------------+ |H ++------------+-> ASYNC PREFETCH IS --+ |H |+> DETECTED -+ +-------------------+ |H | +-+-> ENABLED ---> async-prefetch-options +------- -+H | +-> DISABLED ---------------------------+ |H +-> ROW CACHE IS -+-> ENABLED --+-+----------------------+-----------+H | +-> DISABLED -+ +-> row-cache-options -+ |H ++------+-> INCREMENTAL BACKUP SCAN OPTIMIZATION --------------------+H |+> NO -+ |H +-> MULTITHREAD AREA ADDITIONS ----> multithread-options ------------+H +-> RECOVERY JOURNAL -> ( -> ruj-options -> ) ---------- -------------+H +-> SHARED MEMORY IS --+-> SYSTEM ---------------------+-------------+: +-> PROCESS --+-------------+---+6 +-> RESIDENT -+ asynch-bat-wr-options = C -+----------------------------->-------------------------------+->A + ( ++-> CLEAN BUFFER COUNT IS BUFFERS --++> ) +< |+-> MAXIMUM BUFFER COUNT IS BUFFERS +|< +------------------- , <-----------------------------+   async-prefetch-options = A --+-----------------------------------------------------------+>@ +-> ( -+-+-> DEPTH IS BUFFERS -----+--+> )-+; | +-> THRESHOLD IS BUFFERS -+ |; +----------------- , <--------------------------+  row-cache-options = L -> ( -++-> CHECKPOINT -+-> ALL ROWS TO BACKING FILE -----------+-++-> ) -->D || +-> TIMED EVERY SECONDS ------------+ ||D ||  +-> UPDATED ROWS TO -+-> BACKING FILE -++ ||D || +-> DATABASE -----+ ||D |+-> LOCATION IS --> ---------------------+|D |+-> NO --+--> LOCATION --------+--------------------------+|D || +--> SWEEP INTERVAL --+ ||D |+-> NUMBER OF SWEEP ROWS IS --------------------------+|D |+-> SWEEP INTERVAL IS SECONDS ------------------------+|D +-------------------------- , <-- ---------------------------+ multithread-options = 2 ---+-----------------------------------------+-->/ +-> ( --+-> ALL AREAS -----------+--> ) --+& +-> LIMIT TO AREAS --+  ruj-options = , -+-> LOCATION IS --> -+-->) +-> NO LOCATION ----------------------+) +-> BUFFER MEMORY IS -+-> LOCAL ------+) +-> GLOBAL -----+ storage-area-params-1 = ; --+-> ALLOCATION IS ---> --> PAGES ----- +->9 +-> CACHE USING --------------------+9 +-> NO ROW CACHE ------------------------------------+9 +-> extent-params -----------------------------------+9 +-> INTERVAL IS --> -------------+9 +-> LOCKING IS --+-> ROW --+--> LEVEL ---------------+9 | +-> PAGE -+ |9 +-> PAGE FORMAT IS +-> UNIFORM -+--------------------+9 | +-> MIXED ---+ |9 +-> PAGE SIZE IS  ----> --> BLOCKS -----+  extent-params = 6 --+-> EXTENT IS -+-> ENABLED -------------------++-->3 | +-> DISABLED ------------------+|3 | +-> --> PAGES --+|3 | +-> (extension-options) -------+|3 +---------------------<------------------------+  extension-options = ' ---> MINIMUM OF PAGES, --+' +------------------------------------+' +--> MAXIMUM OF PAGES, --+' +------------------------------------+) +--> PERCENT GROWTH IS ------->  storage-area-params-2 = @ --+-> CHECKSUM CALCULATION IS -----------+--+-> ENABLED --+-+->> +-> SNAPSHOT CHECKSUM CALCULATION IS --+ +-> DISABLED -+ |> +-> SNAPSHOT ALLOCATION IS --> ----> PAGES ---+> +-> SNAPSHOT EXTENT IS -+-> ----> PAGES --++> | +-> (extension-options) ---------+|> +-> SNAPSHOT FILENAME --> ----------------- ---+> +-> THRESHOLDS ARE ( +-----------------------+> ) -+> | +> , -+----------++ |> | +> , + |> +------------------------------<--------------------------+  create-clause/statement = ( -+-> create-cache-clause -----------+->& +-> create-index-statement --------+& +-> create-storage-area-clause ----+& +-> create-storage-map-statement --+  drop-statement = , ---+- > DROP CACHE -----+->* +-> DROP INDEX ---------+* +-> DROP STORAGE AREA ---+* +-> DROP STORAGE MAP -----+    2 Arguments 3 ACL Syntax options: ACL | NO ACLD Specifies that the IMPORT statement uses the access control listsC from the original database when it creates the new database. TheC ACL option is the default. If you are using the IMPORT statement? to restructure a database, yo u typically want to use the ACL0 option and preserve the access control lists.B The NO ACL option overrides the ACLs from the original database? and uses the database system default ACLs. Specify NO ACL if@ you are using the IMPORT statement to rebuild a database on aA different system. The NO ACL option makes you the owner of the9 new database and creates default access control lists. 3 BANNERSyntax options: BANNER | NO BANNERB This clause requests th at IMPORT display informational messages< during the import of the database header, such as product? identification, and values for some database parameters. The> default is NO BANNER which will mean most IMPORT statements generate no output. 3 BATCH_UPDATE Syntax options:! BATCH UPDATE | NO BATCH UPDATE> Specifies whether the IMPORT statement stores user data and< indexes using batch-update transactions (BATCH UPDATE) or@ read/write transactions for each  table (NO BATCH UPDATE). The) NO BATCH UPDATE option is the default.< A batch-update transaction is faster but does not perform? recovery-unit journaling, which means you cannot recover theB database in the event of a failure during the IMPORT operation.A With the NO BATCH UPDATE option, you can recover the database.@ For more information about batch-update transactions, see the SET_TRANSACTION statement. 3 CDD_LINKS Syntax options: CDD LINKS | NO CDD LINKS? Determines whether the IMPORT statement tries to reestablishD links between database definitions originally based on repositoryB definitions (domains and tables created with the FROM path name/ clause) and their sources in the repository.= The default depends on whether or not the IMPORT statement> specifies the PATHNAME option. If the IMPORT statement does= specify PATHNAME, the default is CDD LINKS; if it does not1 specify PATHNAME, the default is NO CDD LINKS .A The CDD LINKS option specifies that the IMPORT statement tries= to reestablish repository links even if you do not specifyA the PATHNAME option. If you specify CDD LINKS and the databaseA repository definition on which a database definition was basedD does not exist, the IMPORT statement generates a warning message.> The NO CDD LINKS option specifies that the IMPORT statement? does not establish data repository links even if you specifyA the PATHNAME option. Specif y NO CDD LINKS if you are using the@ IMPORT statement to rebuild a database on a different system. 3 COMMIT_EVERY Syntax options:+ COMMIT EVERY TABLE | COMMIT EVERY n ROWSC Specifies whether the IMPORT statement commits entire tables, orD commits a certain number of rows at regular intervals. If you useC the COMMIT EVERY n ROWS clause, you can supply a value from 1 to 2147483647 for n.C The default is COMMIT EVERY TABLE. If you use the COMMIT EVERY nD  ROWS clause, the table will be left with a partial set of rows if the IMPORT process fails.& NOTEA If the table being imported includes a storage map with the> PLACEMENT VIA INDEX clause, then the COMMIT EVERY clauseA is ignored for that table. A message is displayed to inform@ the database administrator of the tables that did not haveA COMMIT EVERY applied. This condition is shown in Example 6. 3 create-cache-clause : See the CREATE CACHE clause for a complete description. 3 create-index-statement= See the CREATE INDEX statement for a complete description. 3 create-storage-area-clauseD See the CREATE STORAGE_AREA statement for a complete description. 3 create-storage-map-statementC See the CREATE STORAGE_MAP statement for a complete description. 3 DATA Syntax options: DATA | NO DATAA Specifies whether the database created by the IMPORT stat ementC includes the data and metadata contained in the source database,- or the metadata only. DATA is the default.? When you specify the NO DATA option, you import the metadataB that defines a database from an .rbr file and exclude the data.B Duplicating the metadata of a database while excluding the data! offers the following benefits:C o You can use established, tested metadata to create a databaseB to store new data. Standardized metadata can be created once% but used in multiple databases.> o You can use the duplicated metadata to test the databaseB structure. You can experiment with storage areas and storageC maps, and by entering sample data, you can test other aspects of database structure.C o If a database needs testing by someone outside of your group,? you can submit the database metadata without exposing anyC sensitive data. Also, if the database is very large, you need6 not submit multipl e reels of tape to the tester.& NOTE: The NO DATA option is not compatible with repository? databases (CDD$DATABASE.RDB). An .rbr file, created by an= EXPORT statement with the DATA option (the default) andA generated from a CDD$DATABASE.RDB file, cannot be used with@ the NO DATA option for the IMPORT statement. SQL issues an@ error message stating that the NO DATA option is not valid for repository databases.  3 DROP_CACHE Syntax options: DROP CACHE row-cache-name7 Prevents the specified row area from being imported. 3 DROP_INDEX_index-name4 Prevents the specified index from being imported. 3 DROP_STORAGE_AREA; Prevents the specified storage area from being imported. 3 DROP_STORAGE_MAP_map-name: Prevents the specified storage map from being imported. 3 FILENAME_file_spec3 Specifies the file associated with the database.B If you  omit the FILENAME argument, the file specification takes the following defaults:0 o Device: the current device for the process6 o Directory: the current directory for the processB o File name: the alias (if you omit the FILENAME argument, you) must specify the WITH ALIAS clause)9 Use either a full file specification or a partial fileA specification. You can use a logical name for all or part of a file specification.A If you use a simple file name, SQL cr eates the database in the> current default directory. Because the IMPORT statement may? create more than one file with different file extensions, do< not specify a file extension with the file specification. 3 FORWARD_REFERENCESSyntax options:, FORWARD_REFERENCES | NOFORWARD_REFERENCESD The EXPORT interchange file contains declarations of all routines? that will be referenced by other definitions. The default is@ to declare the interfaces to those routines pri or to creating> domains, tables, views, triggers, functions, procedures andA modules that may need them. The default is FORWARD_REFERENCES.D Use NO FORWARD_REFERENCES to disable these declarations. However,< this may result in definition failures during the IMPORT.= If you include the FORWARD_REFERENCES option on the IMPORTA command line then informational messages will be generated for each declared routine. 3 FROM_file_specD Names the interchange .rbr file that the IMPORT statement uses as% a source to create a new database. 3 import-root-file-paramsC Parameters that control the characteristics of the database rootB file associated with the database, or characteristics stored in< the database root file that apply to the entire database.= For more information on other "import-root-file-params-1",@ "import-root-file-params-2", "import-root-file-params-3", and> "import-root-file-params-4", see the descriptions of "root- B file-params-1", "root-file-params-2", "root-file-params-3", and/ "root-file-params-4" in the CREATE DATABASE. 3 limit-to-clauseD See Select_Expressions in the Oracle Rdb SQL Reference Manual for) information about the LIMIT TO clause. 3 literal-user-auth@ Specifies the user name and password for access to databases,! particularly remote databases.B This literal lets you explicitly provide user name and password' information in the IMPORT statement. 3 order-by-clauseD See Select_Expressions in the Oracle Rdb SQL Reference Manual for) information about the ORDER BY clause. 3 PROTECTION_IS Syntax options:* PROTECTION IS ANSI | PROTECTION IS ACLS@ By default, the IMPORT statement retains the protection style= of the database that was exported. However, if you specify< PROTECTION IS ANSI or PROTECTION IS ACLS, then the IMPORT= statement creates a database with that protection type. If? the protect ion of the database created is different from theC protection of the database that was exported, then no protectionA records are imported and you will receive default protections. 3 select-clauseD See Select_Expressions in the Oracle Rdb SQL Reference Manual for' information about the SELECT clause. 3 storage-area-paramsD Specifies parameters that control the characteristics of databaseC storage area files. You can specify most storage area parametersC for either single-file or multifile databases, but the effect of the clauses differs.< o For single-file databases, the storage area parameters@ specify the characteristics for the single storage area in the database.B o For multifile databases, the storage area parameters specifyB a set of default values for any storage areas created by the? IMPORT statement that do not specify their own values for? the same parameters. The attributes of a storage area are> supplied by the interchange file unless redefined by the? IMPORT statement. The default values apply to the storage: area named in CREATE STORAGE AREA database elements.? For details about storage area parameters, see the CREATE STORAGE_AREA clause.) NOTE; The CREATE STORAGE AREA clauses can override these? default values. The default values do not apply to any< storage areas created later w ith the ALTER DATABASE statement. 3 TRACE Syntax options: TRACE | NO TRACE> Specifies whether usage statistics are logged by the IMPORT1 statement. The NO TRACE option is the default.9 Some actions taken by the IMPORT statement can consumeC significant amounts of I/O resources and CPU time. These actions$ include the following operations: o Loading data o Defining indexes o Defining constraints? When you specify the TRACE  option with the IMPORT statement,@ SQL writes a message when each operation begins, and writes aA summary of DIO (direct input/output operations), CPU, and PAGEA FAULT statistics when the operation completes. When the IMPORT? statement finishes execution, a summary of all DIO, CPU, and@ PAGE FAULT statistics is displayed. The display also includesA information on access to the .rbr file, database creation, andD loading of data. For more information about these statistics, see < the Oracle Rdb7 Guide to Database Performance and Tuning. 3 USER_username Syntax option: USER 'username'B Defines a character string literal that specifies the operating? system user name that the database system uses for privilege checking. 3 USING_password Syntax option: USING 'password'? Defines a character string literal that specifies the user's; password for the user name specified in the USER clause. 3 WITH_ALIAS_al ias@ Specifies the alias for the implicit database attach executed? by the IMPORT statement. An alias is a name for a particular attachment to a database.A You must specify an alias or a file name. If you omit the WITH> ALIAS clause, the default alias for the database created byA the IMPORT statement is RDB$DBHANDLE. If you omit the FILENAMEA argument, the IMPORT statement also uses the alias as the file? name for the database root file and creates the root file inB the current default directory. If you omit WITH ALIAS, you must! specify the FILENAME argument. 2 Examples0 Example 1: Converting to a multifile databaseD This example uses the EXPORT and IMPORT statements to convert the> online sample database, personnel, to a multifile database. SQL> export database cont> filename PERSONNEL cont> into PERS; SQL> SQL> import database cont> from PERS" cont> filename MF_PERSONNEL& cont>  default storage area MFP0% cont> create storage area MFP0& cont> filename MFP0_DEFAULT' cont> page format is UNIFORM% cont> create storage area MFP1 cont> filename MFP1% cont> create storage area MFP2 cont> filename MFP2- cont> create storage map EMPLOYEES_MAP cont> for EMPLOYEES4 cont> store randomly across (MFP1, MFP2); SQL> SQL> show storage area;7 Storage Areas in database with filena me MF_PERSONNEL< MFP0 Default storage area MFP1 MFP2: RDB$SYSTEM List storage area.? Note that the storage area RDB$SYSTEM was created implicitlyA in this example. The database administrator could add a CREATED STORAGE AREA RDB$SYSTEM clause to this IMPORT example so that theB name, location and space allocation for the RDB$SYSTEM area can be controlled.> Example 2: Importing a database created with ANSI/ISO-style privileges@ This example imports a database originally created using ACLS< style protection to create a new database with ANSI style protections. SQL> import database cont> from PERS cont> alias NEW_PERS" cont> filename MF_PERSONNEL cont> protection is ANSI cont> ;- SQL> show protection on database NEW_PERS; Protection on Alias NEW_PERS [DEV,SMITH]:R With Grant Option: SELECT,INSERT,UPDATE,DELE TE,SHOW,CREATE,ALTER,DROP,I DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN# Without Grant Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE SQL>4 SQL> show protection on table NEW_PERS.EMPLOYEES;) Protection on Table NEW_PERS.EMPLOYEES [DEV,SMITH]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,0 DBCTRL,REFERENCES# Without Gra nt Option: NONE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE< Example 3: Importing a database and displaying statistics? This example imports a database and uses the TRACE option to/ display DIO, CPU, and PAGE FAULT statistics.* SQL> IMPORT DATABASE FROM personnel.rbr$ cont> FILENAME personnel_new.rdb cont> TRACE6 cont> CREATE INDEX LOCAL_INDEX ON jobs (job_code);% IMPORTing STORAGE AREA: RDB$SYSTEM IMPORTing tab le COLLEGES@ Completed COLLEGES. DIO = 103, CPU = 0:00:00.89, FAULTS = 169. Starting INDEX definition COLL_COLLEGE_CODEG Completed COLL_COLLEGE_CODE. DIO = 25, CPU = 0:00:00.24, FAULTS = 26 IMPORTing table DEGREES< Completed DEGREES. DIO = 96, CPU = 0:00:01.15, FAULTS = 9- Starting INDEX definition DEG_COLLEGE_CODEE Completed DEG_COLLEGE_CODE. DIO = 27, CPU = 0:00:00.36, FAULTS = 1' Starting INDEX definition DEG_EMP_ID? Completed DEG_EMP_ID. DIO = 39, CPU = 0:00:00.49, FAULTS = 2 IMPORTing table DEPARTMENTS@ Completed DEPARTMENTS. DIO = 99, CPU = 0:00:00.70, FAULTS = 3 IMPORTing table EMPLOYEES@ Completed EMPLOYEES. DIO = 182, CPU = 0:00:01.60, FAULTS = 21 . . .7 Starting CONSTRAINT definition SH_EMPLOYEE_ID_IN_EMPJ Completed SH_EMPLOYEE_ID_IN_EMP. DIO = 48, CPU = 0:00:00.56, FAULTS = 2= Starting CONSTRAINT definition WS_STATUS_CODE_DOM_NOT_NULLP Completed WS_STATUS_CODE_DOM_NOT_NULL. DIO = 36, CPU = 0:00:00.23,  FAULTS = 0@ Completed import. DIO = 3530, CPU = 0:00:32.97, FAULTS = 2031 SQL>A Example 4: Reserving Sequence Slots During an Import Operation- SQL> IMPORT DATABASE FROM MF_PERSONNEL.RBR+ cont> FILENAME 'mf_personnel.rdb' BANNER cont> RESERVE 64 SEQUENCES; . . .& Unused Sequences were 32 now are 64% IMPORTing STORAGE AREA: RDB$SYSTEM& IMPORTing STORAGE AREA: DEPARTMENTS% IMPORTing STORAGE AREA: EMPIDS_LOW* Example 5: Specifying the BANNER option4 SQL> import data from x file mf_personnel BANNER;8 Exported by Oracle Rdb X7.1-201 Import/Export utility) A component of Oracle Rdb SQL X7.1-201! Previous name was mf_personnel1 It was logically exported on 29-MAY-2003 12:32 Multischema mode is DISABLED! Database NUMBER OF USERS is 50) Database NUMBER OF CLUSTER NODES is 16' Database NUMBER OF DBR BUFFERS is 20 Database SNAPSHOT is ENABLED! Database SNAPSHOT is IMMEDIATE% Database JOURNA L ALLOCATION is 512$ Database JOURNAL EXTENSION is 512# Database BUFFER SIZE is 6 blocks# Database NUMBER OF BUFFERS is 204 Adjustable Lock Granularity is Enabled Count is 3( Database global buffering is DISABLED+ Database number of global buffers is 250) Number of global buffers per user is 53 Database global buffer page transfer is via DISK" Journal fast commit is DISABLED6 Journal fast commit checkpoint interval is 0 blocks3 Journal fast commit checkpoint time is 0 seconds- Commit to journal optimization is Disabled2 Journal fast commit TRANSACTION INTERVAL is 256 LOCK TIMEOUT is 0 seconds# Statistics Collection is ENABLED Unused Storage Areas are: 0' System Index Compression is DISABLED Journal was Disabled Unused Journals are: 1& Journal Backup Server was: Manual& Journal Log Server was: Manual( Journal Overwrite was: Disabled" Journal shutdown minutes was 60# Asynchronous Prefetch is ENABLED $ Async prefetch depth buffers is 5& Asynchronous Batch Write is ENABLED' Async batch write clean buffers is 5% Async batch write max buffers is 4 Lock Partitioning is DISABLED0 Incremental Backup Scan Optim uses SPAM pages Unused Cache Slots are: 1" Workload Collection is DISABLED$ Cardinality Collection is ENABLED Metadata Changes are ENABLED Row Cache is DISABLED, Detected Asynchronous Prefetch is ENABLED4 Detected Asynchronous Prefetch Depth Buffers is 48 Detected Asynchronous Prefetch Threshold Buffers is 4. Open is Automatic, Wait period is 0 minutes Shared Memory is PROCESS Unused Sequences are: 32' The Transaction Mode(s) Enabled are: ALL% IMPORTing STORAGE AREA: RDB$SYSTEM& IMPORTing STORAGE AREA: DEPARTMENTS% IMPORTing STORAGE AREA: EMPIDS_LOW% IMPORTing STORAGE AREA: EMPIDS_MID& IMPORTing STORAGE AREA: EMPIDS_OVER# IMPORTing STORAGE AREA: EMP_INFO IMPORTing STORAGE AREA: JOBS) IMPOR Ting STORAGE AREA: MF_PERS_SEGSTR) IMPORTing STORAGE AREA: SALARY_HISTORY IMPORTing table CANDIDATES IMPORTing table COLLEGES IMPORTing table DEGREES IMPORTing table DEPARTMENTS IMPORTing table EMPLOYEES IMPORTing table JOBS IMPORTing table JOB_HISTORY IMPORTing table RESUMES! IMPORTing table SALARY_HISTORY IMPORTing table WORK_STATUS IMPORTing view CURRENT_SALARY IMPORTing view CURRENT_JOB IMPORTing view CURRENT_INFO+ Example 6: Using  the COMMIT EVERY option SQL> import database/ cont> from 'TEST$DB_SOURCE:MF_PERSONNEL'$ cont> filename 'MF_PERSONNEL' cont>! cont> commit every 10 rows cont>, cont> create storage area DEPARTMENTS' cont> filename 'DEPARTMENTS'% cont> page format is mixed0 cont> snapshot filename 'DEPARTMENTS'+ cont> create storage area EMPIDS_LOW& cont> filename 'EMPIDS_LOW'% cont> page format is mixed/ c ont> snapshot filename 'EMPIDS_LOW'+ cont> create storage area EMPIDS_MID& cont> filename 'EMPIDS_MID'% cont> page format is mixed/ cont> snapshot filename 'EMPIDS_MID', cont> create storage area EMPIDS_OVER' cont> filename 'EMPIDS_OVER'% cont> page format is mixed0 cont> snapshot filename 'EMPIDS_OVER' . . . cont> ; ! end of import3 Definition of STORAGE AREA RDB$SYSTEM overrid den7 Definition of STORAGE AREA MF_PERS_SEGSTR overridden3 Definition of STORAGE AREA EMPIDS_LOW overridden3 Definition of STORAGE AREA EMPIDS_MID overridden4 Definition of STORAGE AREA EMPIDS_OVER overridden4 Definition of STORAGE AREA DEPARTMENTS overridden7 Definition of STORAGE AREA SALARY_HISTORY overridden- Definition of STORAGE AREA JOBS overridden1 Definition of STORAGE AREA EMP_INFO overriddenQ COMMIT EVERY ignored for table EMPLOYEES due to PLACEMENT VIA IND EX processingS COMMIT EVERY ignored for table JOB_HISTORY due to PLACEMENT VIA INDEX processing SQL> ww` 1 INCLUDE@ Inserts declarations or code into a precompiled host language8 program. You can use the INCLUDE statement to insert:@ o Host language declarations for the SQL Communications Area" (SQLCA) and a message vectorD o Host language declarations for the SQL Descriptor Areas (SQLDA and SQLDA2) o Host language source cod eB o Host language declarations for repository record definitions 2 EnvironmentA You can use the INCLUDE statement in precompiled host language; programs only. Programs must either use an INCLUDE SQLCAA statement or explicitly declare an SQLCODE variable. The other/ forms of the INCLUDE statement are optional. 2 Format7 INCLUDE --+--> SQLCA --+-------------+-------------+->5 | +-> EXTERNAL -+ |5 +--> SQLDA ------ ------------------------+5 +--> SQLDA2 -----------------------------+5 +--> ------------------------+5 +--> FROM DICTIONARY -----+ |5 +--------------------------------+ |5 +-+----------------------------+-+ |5 +-> FIXED -----------------+-+ | |5 +-> NULL TERMINATED BYTES -+ | |5 +--------------------------------+ |5 +-+----------- ----+-----------------+# +-> AS --+  2 Arguments 3 AS_name@ Specifies a name to override the structure name of the recordA from the repository. By default, the SQL precompiler takes the2 structure name from the repository record name. 3 EXTERNAL@ Declares an external reference to the SQLCA structure for SQLD precompiled C programs. If you have multiple modules that use theC INCLUDE SQLCA statement, you can add the EXTERNAL keyword to all but one of them.B If your application shares the SQLCA among multiple images, oneD image must define the SQLCA while all other images must reference> the SQLCA. Use the EXTERNAL keyword to reference the SQLCA. 3 file-specB The file specification for source code to be inserted into yourC program. The file specification must refer to a standard OpenVMSB text file. SQL does not support the INCLUDE statement from textD libraries (file extension .tlb) . Use the SQL INCLUDE statement in either of these cases:: o The source code to be included contains embedded SQL statements.D o The source code to be included contains host language variableB declarations to which embedded SQL statements in other parts of the program refer.C If the source code contains neither SQL statements nor variablesA to which SQL statements refer, using the SQL INCLUDE statementA is no different from using host language statem ents to include files. 3 FIXEDC The FIXED and NULL TERMINATED BYTES clauses tell the precompilerA how to interpret C language CHAR fields. If you specify FIXED,@ the precompiler interprets CHAR fields from the repository as fixed character strings. 3 FROM_DICTIONARY> Specifies the path name for a repository record definition.< Because SQL treats the path name as a string literal, youC should enclose it in single quotation marks. SQL declares a hostB structure corresponding to the repository record definition andA gives it the same name. SQL statements embedded in the program( can then refer to the host structure.< Typically, programs use the FROM DICTIONARY argument as a? convenient way to declare host structures that correspond to. table definitions stored in the repository.B SQL stores table definitions in the repository in the following cases only:9 o Both the CREATE DATABASE statement and the database? declaration for the attach in which the table was defined& specified the PATHNAME argument.D o The database definitions were copied to the repository with an INTEGRATE statement.< However, programs can use the FROM DICTIONARY argument to? declare host structures for any CDD$RECORD repository objectB type, including those repository objects defined as part of the database.@ Using the INCLUDE statement does more than using a comparable@ host language state ment that inserts a CDD$RECORD object intoD the program. The INCLUDE FROM DICTIONARY statement lets you referC to the repository record in an embedded SQL statement, while the$ host language statement does not. 3 NULL_TERMINATED_BYTES; Specifies that CHAR fields from the repository are null-? terminated. The module processor interprets the length fieldB in the repository as the number of bytes in the string. If n isA the length in the repository, then the number of da ta bytes is0 n-1, and the length of the string is n bytes.B In other words, the precompiler assumes that the last characterC of the string is for the null terminator. Thus, a field that theD repository lists as 10 characters can only hold a 9-character SQL field from the C precompiler.@ If you do not specify a character interpretation option, NULL# TERMINATED BYTES is the default.; For more information, see the NULL TERMINATED CHARACTERS@ argument in the SQL Modul e Language chapter of the Oracle Rdb SQL Reference Manual. 3 SQLCA> Specifies that SQL inserts into the program the SQLCA and a< message vector (RDB$MESSAGE_VECTOR) structure specific toD supported database systems. Both the SQLCA and the message vector- provide ways of handling error conditions:= o The SQLCA is a collection of variables that SQL uses to? provide information about the execution of SQL statementsA to application programs. The SQLCA shows i f a statement wasD successful and, for some conditions, the particular error when% a statement was not successful.C o The message vector is also a collection of variables that SQL@ updates after SQL executes a statement. The message vectorA also lets programs check if a statement was successful, butA provides more detail than the SQLCA about the type of error2 condition if a statement was not successful.D For more information on the SQLCA and the mes sage vector, see the# Oracle Rdb SQL Reference Manual. 3 SQLDAC Specifies that SQL inserts the SQLDA into the program. The SQLDAC is a collection of variables used only in dynamic SQL. The SQLDAD provides information about dynamic SQL statements to the program,B and information about host language variables in the program to SQL. 3 SQLDA2> Specifies that SQL inserts the SQLDA2 into the program. The< SQLDA2, like the SQLDA, is a collection of variables  thatC provides information about dynamic SQL statements to the programB and information about host language variables in the program toD SQL. You should use the SQLDA2 in any dynamic statement where theD column name used in a parameter marker or select list item is one+ of the date-time or interval data types.C For more information on the SQLDA and SQLDA2, see the Oracle Rdb SQL Reference Manual. 2 Examples4 Example 1: Including a host structure declaration= This simple COBOL program uses the INCLUDE FROM DICTIONARY@ statement to declare a host structure that corresponds to theC EMPLOYEES table in the sample personnel database. The repository= path name specifies the RDB$RELATIONS repository directory5 between the database directory and the table name. IDENTIFICATION DIVISION. PROGRAM-ID. INCLUDE_FROM_CDD. *6 * Illustrate how to use the INCLUDE FROM DICTIONARY; * statement to declare a host structure corresponding to  * the EMPLOYEES table: * DATA DIVISION. WORKING-STORAGE SECTION.0 EXEC SQL WHENEVER SQLERROR GOTO ERR END-EXEC. * * Include the SQLCA:# EXEC SQL INCLUDE SQLCA END-EXEC. * * Declare the schema:. * (Notice that declaring the alias with the0 * FILENAME qualifier would not have precluded8 * using the INCLUDE FROM DICTIONARY statement later.)" EXEC SQL DECLARE PERS ALIAS FOR5 PATHNAME 'CDD$DEFAULT.PERSONNEL' END-EXEC. *4 * Create a host structure that corresponds to the5 * EMPLOYEES table with the INCLUDE FROM DICTIONARY7 * statement. The path name in the INCLUDE statement4 * must specify the RDB$RELATIONS directory before * the table name:# EXEC SQL INCLUDE FROM DICTIONARY: 'CDD$DEFAULT.PERSONNEL.RDB$RELATIONS.EMPLOYEES' END-EXEC. *0 * Declare an indicator structure for the host@ * structure created by the INCLUDE FROM DICTIONARY statement: 01 EMPLOYEES-IND.5 0 2 EMP-IND OCCURS 12 TIMES PIC S9(4) COMP.# EXEC SQL DECLARE E_CURSOR CURSOR1 FOR SELECT * FROM EMPLOYEES END-EXEC. PROCEDURE DIVISION. 0.. DISPLAY "Display rows from EMPLOYEES:".' EXEC SQL OPEN E_CURSOR END-EXEC.A EXEC SQL FETCH E_CURSOR INTO :EMPLOYEES:EMP-IND END-EXEC.$ PERFORM UNTIL SQLCODE NOT = 05 DISPLAY EMPLOYEE_ID, FIRST_NAME, LAST_NAMEC EXEC SQL FETCH E_CURSOR INTO :EMPLOYEES:EMP-IND END-EXEC END-PERFO RM.( EXEC SQL CLOSE E_CURSOR END-EXEC." EXEC SQL ROLLBACK END-EXEC. EXIT PROGRAM. ERR.< DISPLAY "unexpected error ", sqlcode with conversion. CALL "SQL$SIGNAL".! Example 2: Including the SQLCA< This fragment from a PL/I program shows the INCLUDE SQLCAA statement and illustrates how an error-handling routine refers to the SQLCA.D The program creates an intermediate result table, TMP, and copiesC the EMPLOYEES table from the pers onnel database into it. It thenC declares a cursor for TMP and displays the rows of the cursor on the terminal screen. /* Include the SQLCA: */ EXEC SQL INCLUDE SQLCA;5 EXEC SQL WHENEVER SQLERROR GOTO ERROR_HANDLER;5 EXEC SQL DECLARE ALIAS FOR FILENAME personnel; DCL MANAGER_ID CHAR(5), LAST_NAME CHAR(20), DEPT_NAME CHAR(20);$ DCL COMMAND_STRING CHAR(256); EXEC SQL CREATE TABLE TMP# (MANAGER_ID CHAR(5),# LAST_NAME CHAR(20),$ DEPT_NAME CHAR(20)); COMMAND_STRING = 'INSERT INTO TMP' SELECT E.LAST_NAME,( E.FIRST_NAME,, D.DEPARTMENT_NAME2 FROM EMPLOYEES E, DEPARTMENTS D7 WHERE E.EMPLOYEE_ID = D.MANAGER_ID';2 EXEC SQL EXECUTE IMMEDIATE :COMMAND_STRING;7 EXEC SQL DECLARE X CURSOR FOR SELECT * FROM TMP; E XEC SQL OPEN X;> EXEC SQL FETCH X INTO MANAGER_ID, LAST_NAME, DEPT_NAME; DO WHILE (SQLCODE = 0); PUT SKIP EDIT? (MANAGER_ID, ' ', LAST_NAME, ' ', DEPT_NAME) (A,A,A,A,A);B EXEC SQL FETCH X INTO MANAGER_ID, LAST_NAME, DEPT_NAME; END; EXEC SQL ROLLBACK;& PUT SKIP EDIT (' ALL OK') (A); RETURN; ERROR_HANDLER:A /* Display the value of the SQLCODE field in the SQLCA: */F P UT SKIP EDIT ('UNEXPECTED SQLCODE VALUE ', SQLCODE) (A, F(9));+ EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK; wwq7 1 INSERTB Adds a new row, or a number of rows, to a table or view.You canB also use the INSERT statement with a cursor to assign values toB the segments in a column of the LIST OF BYTE VARYING data type.> Before you assign values to the segments in a column of the@ LIST OF BYTE VARYING data type, you must first assign a value@ to one or more other columns in the same row. To do this, useB a positioned insert. A positioned insert is an INSERT statementB that specifies an insert-only table cursor. This type of INSERT? statement sets up the proper row context for subsequent list- cursors to assign values to list segments.B You can specify the name of a static, a dynamic, or an extendedA dynamic cursor in a positioned insert. If you specify a staticD cursor name, that cursor name must also be specified in a DECLAREB CURSOR statement within the same module. See the DECLARE CURSORB statement for more information on static, dynamic, and extended dynamic cursors.< When you use an INSERT statement to assign values to list segments:4 o The current transaction must not be read-only.? o You cannot specify a cursor name that refers to an update table cursor.5 o Your cursor must specify an intermediate table.C o The value that you assign is a ppended to the end of the list. 2 Environment$ You can use the INSERT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 FormatF INSERT INTO -+-> ----+-+---------------------------+-+-+F +-> -----+ +-> AS --+ | |F +-> CURSOR -- -------------------------+ |F +-------------------------------------------------------------------+G +---> DEFAULT VALUES ------------------+->-+---------------------+-+->E +--------------------------------+---+ | +-> returning-clause -+ |E +---> ( -+> +-> ) -+ | | |E +-------- , <----+ | | |E +---------------<--------------------+ | |E +-> value-clause ----------------------+  |E +-> select-expr -+--------------------+--->------------------------+( +-> optimize-clause -+ value-clause = : ----> VALUES -> ( -++> ----------++-> ) --->1 |+> +|1 |+> value-expr -----------+|1 |+> DEFAULT --------------+|1 +------- , <---------------+ returning-clause = C -+------------------------------- ---------++-------------------+->A +-> RETURNING value-expr ----------------++> INTO +, +-> PLACEMENT ONLY RETURNING -+-> DBKEY -+, +-> ROWID -+ value-expr = ( ---+--> numeric-value-expr -----+----->" +--> char-value-expr --------+" +--> date-time-value-expr ---+" +--> interval-value-expr ----+" +--> date-vms-value-expr ----+" +--> DBKEY ------------------+" +--> NULL -------------------+" +--> ROWID ------- -----------+ select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+--------------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ optimize-clause = H --+-------------------------------------- -------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  select-merge-clause = > -+-> EXCEPT -+--------------+---+----+-------------------+-->; | +-> DISTINCT --+ | +-> CORRESPONDING --+; +-> INTERSECT -+-------------+-+ +-> NATURAL --------+" | +-> DISTINCT -+ |" +-> MINUS ---------------------+" +-> UNION --+-------------+----+ +-> ALL ------+ +-> DISTINCT -+ 2 Arguments 3 column-nameA Specifies a list of names of columns in the table or view. YouC can list the columns in any order, but the names must correspond! to those of the table or view.> If you do not include all the column names in the list, SQLD assigns a null value to those not specified, unless columns were: o Defined with a default* o Based on a domain that has a defaultD o Defined with the NOT NULL clause in the CREATE TABLE statement@ You cannot omit from an INSERT statement the names of columnsD defined with the NOT NULL clause. If you do, the statement fails.> Omitting the list of column names altogether is the same asA listing all the columns of the table or view in the same order as they were defined.? You must omit the list of column names when using the INSERTA statement to assign values to the segments in a column of data@ type LIST OF BYTE VARYING. Column nam es are not valid in this context. 3 CURSOR_cursor_name@ Keyword required when using cursors. You must use a cursor toC insert values into any row that contains a column of the LIST OF BYTE VARYING data type. 3 DEFAULTB Forces the named column to assume the default value defined for, that column (or NULL if none is defined).C If the DEFAULT clause is used in an INSERT statement then one of! the following will be applied:@ o If a DEFAULT attribu te is present for the column then that* value will be applied during INSERT.C o Else if an AUTOMATIC attribute is present for the column thenD that value will be applied during INSERT. This can only happenB if the SET FLAGS 'AUTO_OVERRIDE' is used since during normal- processing these columns are read-only.5 o Otherwise a NULL will be applied during INSERT. 3 DEFAULT_VALUESC Specifies that every column in the table is assigned the default7 value (or NULL, if the column has no default value). 3 INTO_parameterA Inserts the value specified to a specified parameter. The INTO4 parameter clause is not valid in interactive SQL. 3 INTO Syntax options:# INTO table-name | INTO view-nameB The name of the target table or view to which you want to add aA row. Inserts the value specified to a specified parameter. The9 INTO parameter clause is not valid in interactive SQL. 3 limit-to-clauseD  See Select_Expressions in the Oracle Rdb SQL Reference Manual for, a description of the LIMIT TO expression. 3 OPTIMIZE_AS_query_nameB The OPTIMIZE AS clause assigns a name to the query. Use the SET/ FLAGS 'STRATEGY' to see this name displayed. 3 OPTIMIZE_FOR< The OPTIMIZE FOR clause specifies the preferred optimizer@ strategy for statements that specify a select expression. The# following options are available: o FAST FIRSTB A query optimized for FAST FIRST returns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optimization. A good candidate for FAST FIRST> optimization is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST  optimization.C If optimization strategy is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records inD the query, and performs updates or writes a report, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization. o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly: valuable for tables that use the strict partitioning functionality. 3 OPTIMIZE_USING_outline_nameB The OPTIMIZE USING clause explicitly names the query outline toD be used with the select expression even if the outline ID for the7 select expression and for the outline are different.D See the CREATE OUTLINE statement for more information on creating an outline. 3 OPTIMIZE_WITHA Selects one of three optimzation controls: DEFAULT (as used byD previous versions of Rdb), AGGRESSIVE (assumes smaller numbers ofB rows will be selected), and SAMPLED (which uses literals in the7 query to perform preliminary estimation on indices).6 The following example shows how to use this clause.< SQL> select * from employees where employee_id > '00200'- cont> optimize with sampled selectivity; 3 order-by-clauseD See Select_Expressions in the Oracle Rdb SQL Reference Manual for, a description of the ORDER BY expression. 3 PLACEMENT_ONLY_RETURNING  Syntax options:B PLACEMENT ONLY RETURNING DBKEY | PLACEMENT ONLY RETURNING ROWID? Returns the dbkey of a specified record, but does not insertB any actual data. The PLACEMENT ONLY RETURNING DBKEY clause lets? you determine the target page number for records that are toB be loaded into the database. When you use this clause, only theB area and page numbers from the dbkeys are returned. Use of thisD clause can improve bulk data loads. If you use the PLACEMENT ONLYB cla use, you can return only the dbkey values. Use the PLACEMENTC ONLY RETURNING DBKEY clause only in programs that load data intoD an existing database and only with rows placed via a hashed index? in the storage map. For more information, see the Oracle Rdb+ Guide to Database Design and Definition.7 The keyword ROWID is a synonym to the DBKEY keyword. 3 RETURNING_value_exprC Returns the value of the column specified in the values list. IfB DBKEY or ROWID is specifi ed, this argument returns the database> key (dbkey) of the row being added. (The ROWID keyword is a@ synonym to the DBKEY keyword.) When the DBKEY value is valid,? subsequent queries can use the DBKEY value to access the row directly.A The RETURNING DBKEY clause is not valid in an INSERT statementC used to assign values to the segments in a column of the LIST OF BYTE VARYING data type. 3 select-clauseD See Select_Expressions in the Oracle Rdb SQL Reference Manu al for* a description of the SELECT expression. 3 select-expr? Specifies a select expression that specifies a result table.B The result table can contain zero or more rows. All the rows ofC the result table are added to the target table named in the INTO clause.A This is the only situation supported in SQL that allows you to7 specify a second database in a single SQL statement.C The number of columns in the result table must correspond to theB number of c olumns specified in the list of column names. If youC did not specify a list of column names, the number of columns inD the result table must be the same as the number of columns in theC target table. For each row of the result table, the value of theD first column is assigned to the first column of the target table,4 the second value to the second column, and so on.@ You cannot specify a select expression in an INSERT statementC used to assign values to the segments in a colu mn of the LIST OF BYTE VARYING data type.B For detailed information on select expressions, see the Select_ Expressions HELP topic. 3 VALUES_value_exprB Specifies a list of values to be added to the table as a singleA row. The values can be specified through parameters, qualifiedC parameters, column select expressions, value expressions, or the default values.@ The values listed in the VALUES argument can be selected fromC another table, but both tables mu st reside in the same database.A The number of values in the list must correspond to the numberC of columns specified in the list of column names. If you did notB specify a column list, the number of values in the list must beB the same as the number of columns in the table. The first valueD specified in the list is assigned to the first column, the second) value to the second column, and so on.B Values for IDENTITY, COMPUTED BY, and AUTOMATIC COLUMNS are notC able to b e inserted so these column types are not considered for the default column list.D See the SQL Online Help topic INSERT EXAMPLES for an example that= shows an INSERT statement with a column select expression. 2 Examples. Example 1: Adding a row with literal values@ The following interactive SQL example stores a new row in theD DEPARTMENTS table of the sample personnel database. It explicitlyA assigns a literal value to each column in the row. Because theA state ment includes the RETURNING DBKEY clause, SQL returns the dbkey value 29:435:9. SQL> INSERT INTO DEPARTMENTS cont> -- List of columns: cont> (DEPARTMENT_CODE, cont> DEPARTMENT_NAME, cont> MANAGER_ID, cont> BUDGET_PROJECTED, cont> BUDGET_ACTUAL) cont> VALUES cont> -- List of values: cont> ('RECR', cont> 'Recreation', cont> '00175', cont> 240000, cont> 128776) cont> RETURNING DBKEY;  DBKEY 29:435:9 1 row inserted+ Example 2: Adding a row using parametersB This example is a COBOL program fragment that adds a row to theC JOB_HISTORY table by explicitly assigning values from parameters) to columns in the table. This example:$ o Prompts for the column values.A o Declares a read/write transaction. Because you are updatingC the JOB_HISTORY table, you do not want to conflict with otherC users who may be reading data from this table. Therefore, you; use the protected share mode and the write lock type.B o Stores the row by assigning the parameters to the columns of the table.> o Checks the value of the SQLCODE variable and repeats the6 INSERT operation if the value is less than zero.= o Uses the COMMIT statement to make the update permanent. STORE-JOB-HISTORY.< DISPLAY "Enter employee ID: " WITH NO ADVANCING. ACCEPT EMPL-ID.<  DISPLAY "Enter job code: " WITH NO ADVANCING. ACCEPT JOB-CODE.< DISPLAY "Enter starting date: " WITH NO ADVANCING. ACCEPT START-DATE.< DISPLAY "Enter ending date: " WITH NO ADVANCING. ACCEPT END-DATE.< DISPLAY "Enter department code: " WITH NO ADVANCING. ACCEPT DEPT-CODE.< DISPLAY "Enter supervisor's ID: " WITH NO ADVANCING. ACCEPT SUPER. EXEC SQL% SET TRANSACTION READ WRITE< RESER VING JOB_HISTORY FOR PROTECTED WRITE END-EXEC EXEC SQL" INSERT INTO JOB_HISTORY (EMPLOYEE_ID, JOB_CODE, JOB_START, JOB_END,$ DEPARTMENT_CODE," SUPERVISOR_ID) VALUES (:EMPL-ID, :JOB-CODE, :START-DATE, :END-DATE, :DEPT-CODE, :SUPER) END -EXEC IF SQLCODE < 0 THEN3 EXEC SQL ROLLBACK END-EXEC6 DISPLAY "An error has occurred. Try again."" GO TO STORE-JOB-HISTORY END-IF# EXEC SQL COMMIT END-EXEC / Example 3: Copying from one table to another@ This interactive SQL example copies a subset of data from theC EMPLOYEES table to an identical intermediate result table. To doC this, it uses a select expression that limits rows of the select@ express ion's result table to those with data on employees who live in New Hampshire. SQL> INSERT INTO TEMP cont> (EMPLOYEE_ID, cont> LAST_NAME, cont> FIRST_NAME, cont> MIDDLE_INITIAL, cont> ADDRESS_DATA_1, cont> ADDRESS_DATA_2, cont> CITY, cont> STATE, cont> POSTAL_CODE, cont> SEX, cont> BIRTHDAY, Cont> STATUS_CODE) cont> SELECT * FROM EMPLOYEES cont> WHERE STATE = 'NH'; 9 0 rows inserted SQL>< Example 4: Copying rows between databases with the INSERT statementC This example copies the contents of the EMPLOYEES table from the5 personnel database to another database, LOCALDATA./ SQL> ATTACH 'ALIAS PERS FILENAME personnel';2 SQL> ATTACH 'ALIAS LOCALDB FILENAME localdata'; SQL> SQL> DECLARE TRANSACTION# cont> ON PERS USING (READ ONLY4 cont> RESERVING PERS.EMPLOYEES FOR SHARED READ) cont> AND' cont> ON LOCALDB  USING (READ WRITE9 cont> RESERVING LOCALDB.EMPLOYEES FOR SHARED WRITE); SQL>% SQL> INSERT INTO LOCALDB.EMPLOYEES( cont> SELECT * FROM PERS.EMPLOYEES; 100 rows inserted SQL> > Example 5: Adding data to columns of data type LIST OF BYTE VARYING> The following interactive SQL example adds a new row to theC RESUMES table of the sample personnel database. It first assigns> a value to the EMPLOYEE_ID column, then adds three lines of? information to th  e RESUME column of the same row. The RESUMEB column has the LIST OF BYTE VARYING data type. You must specify@ the name of the list column (RESUME) in addition to the tableB column when declaring the table cursor for a positioned insert.Q SQL> DECLARE TBLCURSOR INSERT ONLY TABLE CURSOR FOR SELECT EMPLOYEE_ID, RESUME cont> FROM RESUMES;C SQL> DECLARE LSTCURSOR INSERT ONLY LIST CURSOR FOR SELECT RESUME$ cont> WHERE CURRENT OF TBLCURSOR; SQL> OPEN TBLCURSOR;D SQL> INSERT INTO CURSOR TBLCURSOR (EMPLOYEE_ID) VALUES ('00167'); 1 row inserted SQL> OPEN LSTCURSOR;M SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('This is the resume for 00167');; SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('Boston, MA');C SQL> INSERT INTO CURSOR LSTCURSOR VALUES ('Oracle Corporation'); SQL> CLOSE LSTCURSOR; SQL> CLOSE TBLCURSOR; SQL> COMMIT;D Example 6: Using the PLACEMENT ONLY RETURNING DBKEY clause of the INSERT statement SQL> INSERT INTO EMPLOY EES- cont> (EMPLOYEE_ID, LAST_NAME, FIRST_NAME) cont> VALUES% cont> ('5000', 'Parsons', 'Diane')( cont> PLACEMENT ONLY RETURNING DBKEY; DBKEY 56:34:-1 1 row allocated SQL>> Example 7: Inserting the user name and an amount into table columns: SQL> CREATE TABLE TABLE1 cont> (ID CHAR(15), cont> AMOUNT INT(4));' SQL> INSERT INTO TABLE1 (ID, AMOUNT)( cont> VALUES (USER, 1000); SQL> SELECT * F ROM TABLE1;& ID AMOUNT& ELLINGSWORTH 1000.0000 1 row selectedB Example 8: Inserting a name and a column select expression into7 the same table columns used in the previous example:' SQL> INSERT INTO TABLE1 (ID, AMOUNT)$ cont> VALUES ('BROWN',; cont> (SELECT COUNT (*) FROM TABLE1)); SQL> SELECT * FROM TABLE1;& ID AMOUNT& HALVORSON 1000.0000& BROW N 1.0000 2 rows selected; Example 9: Inserting Default Values for Selected Columns SQL> INSERT INTO DEPARTMENTS: cont> (DEPARTMENT_CODE, DEPARTMENT_NAME, BUDGET_ACTUAL) cont> VALUES( cont> ('RECR','Recreation', DEFAULT); 1 row inserted? SQL> SELECT * FROM DEPARTMENTS WHERE DEPARTMENT_CODE='RECR';A DEPARTMENT_CODE DEPARTMENT_NAME MANAGER_ID& BUDGET_PROJECTED BUDGET_ACTUAL; RECR Recreation  NULL& NULL NULL 1 row selectedA Example 10: Inserting a Row of All Default Values into a Table SQL> INSERT INTO CANDIDATES cont> DEFAULT VALUES; 1 row inserted SQL> SELECT * FROM CANDIDATES! cont> WHERE LAST_NAME IS NULL;0 LAST_NAME FIRST_NAME MIDDLE_INITIAL CANDIDATE_STATUS RESUME& NULL NULL NULL NULL >> >> >> NULL 1 row selec ted ww_1 INSERT_FROM_FILENAMEC Loads a column of the LIST OF BYTE VARYING data type from a textB or binary file without needing to use special application code.B The specified file is opened and each row is read and stored in@ the LIST OF BYTE VARYING column specified by the list cursor. 2 Environment< You can use the INSERT statement in interactive SQL only. 2 Format/ INSERT INTO CURSOR ------> ----+/ +--------------- -----<----------------------+E +--> FILENAME --> -+--------------------------------+->C +-> AS -+-> BINARY -------------++B +-> TEXT ---------------+B +-> CHARACTER VARYING --+ 2 Arguments 3 AS Syntax options:- AS BINARY | AS CHARACTER VARYING | AS TEXT@ Specifies whether the file specified with the FILENAME clause contains thes e types of data: o BINARYC Used to load unformatted data such as images and audio files.D The contents are broken into 512 octet segments during INSERT. o CHARACTER VARYING@ Used to load text but with no terminator. The contents are$ written one line to a segment. o TEXT> Used to load text, a terminator is added to each segmentA loaded. The contents are written one line to a segment withC trailing terminators carriage return (CR)  and line feed (LF). 3 FILENAME_filespec@ The specification for the file that you want to load into the LIST OF BYTE VARYING column. !3 INSERT_INTO_CURSOR_cursor-name@ The name of the target list cursor to which you want to add a list segment. 2 Example: Example 1: Adding a New Row Using Data from a Text File" SQL> -- Declare a table cursor. SQL> DECLARE TABLE_CURSOR! cont> INSERT ONLY TABLE CURSOR# cont> FOR SELECT * FROM RESUMES;/ SQL > -- Open table cursor and insert values. SQL> OPEN TABLE_CURSOR;( cont> INSERT INTO CURSOR TABLE_CURSOR cont> VALUES ('10065', NULL); 1 row inserted! SQL> -- Declare a list cursor. SQL> DECLARE LIST_CURSOR cont> INSERT ONLY LIST CURSOR9 cont> FOR SELECT RESUME WHERE CURRENT OF TABLE_CURSOR; SQL --Open list cursor. SQL> OPEN LIST_CURSOR;? SQL> --Load text from file into LIST OF BYTE VARYING column.& SQL> INSERT INTO CURSOR LIST_CURSOR- cont> FILENAM E 'resume_10065.sql' AS TEXT; SQL> CLOSE LIST_CURSOR; SQL> CLOSE TABLE_CURSOR; SQL> COMMIT; ww_ 1 INTEGRATED Makes definitions in a database and in a repository correspond byA changing definitions in either the database or the repository.B The INTEGRATE statement can also create database definitions in@ the repository by copying from a database file to a specified repository. 2 EnvironmentA You can issue the INTEGRATE statement o nly in interactive SQL. 2 Format INTEGRATE ---+ +------------+ ++-> DATABASE --+ | +------------+I | ++--> FILENAME -> -> CREATE PATHNAME -> +->G | +--> PATHNAME -> +-+-> ALTER FILES ------+---------+= | | +-> ALTER DICTIONARY -+% +-> DOMAIN --> -----+% +-> TABLE ---> ------+  domain-name = 7 -+---------------------------+-> --->  +-+-> -+-> . -+ +-> -------+ table-name = 3 -+-------------------------+-> +->1 +-+-> +> . -+ |1 | +-> ------+ |1 +---> " " --------------+  2 Arguments $3 DATABASE_FILENAME_CREATE_PATHNAME: Stores existing database system file definitions in the< repository for the first time. Use the INTEGRATE DATABASED FILENAME cl  ause if you did not specify PATHNAME or the repository3 was not installed when you created the database.D If you use the INTEGRATE DATABASE FILENAME clause, the repository> database node specified in the path name must not exist. If? older repository definitions do exist with the path name youD are specifying, specify a different repository path name, placing* the new database definitions elsewhere.A The file-name clause is the full or partial file specification@ that sp  ecifies the source of the database definitions. You do> not need to specify the file extension. The database systemA automatically uses the database root file ending with the .rdb file extension.C Path-name-2 is the repository path name for the repository whereB the INTEGRATE statement creates the database definitions (usingC the database system files as the source). You can specify eitherB a full repository path name or a relative repository path name.C This must be the  path name, not the name of the database itself. 3 DATABASE_PATHNAME_ALTER_FILESB Alters any table and domain definitions created with the CREATEC TABLE FROM statement or the CREATE DOMAIN FROM statement so theyC match their sources in the repository. The INTEGRATE . . . ALTERD FILES statement has no effect on definitions not created with theB FROM clause. This is useful if the database file definitions no2 longer match the definitions in the repository.= Path-name-1  is the repository path name for the repositoryB database that is the source for altering the definitions in theD database. You can specify either a full repository path name or a! relative repository path name.' CAUTION> Using the ALTER FILES clause may destroy data associatedA with definitions in your database file if those definitions@ are not defined in your repository. In this situation, you? will lose real data. For this re ason, use the ALTER FILES clause with caution. %3 DATABASE_PATHNAME_ALTER_DICTIONARY@ Alters the database definitions in the dictionary so they areB the same as those in the database. This is useful if repository> definitions no longer match the definitions in the database@ file. Note, though, that altering database definitions in the? repository may affect other applications that refer to these definitions.A The repository must already exist and may contain definitions.= Path-name-1 is the repository path name for the repositoryA database that SQL alters using the definitions in the databaseB file as a source. You can specify either a full repository path name or a relative path name. 3 DOMAIN_ALTER_FILESC Alters the domain definitions in the database to match the field@ definitions in the repository. Collating sequences referencedA by the domain and columns that are based on the domain and theD tables that con tain them may also be altered if they have changed in the repository. 3 DOMAIN_ALTER_DICTIONARY> Alters the field definitions in the repository to match the: domain definitions in the database. Collating sequencesD referenced by the domain and columns that are based on the domainD and the tables that contain them may also be altered if they have changed in the database. 3 TABLE_ALTER_FILESC Alters the table definitions in the database to match the record? definitions in the repository. Other objects referencing theD table or that are referenced by it and have changed definition in: the repository may be altered. These other objects are: o Domains o Collating sequences) o Other referenced tables and columns3 o Foreign key constraints and check constraints o Indexes$ o Views that reference the table; o Storage maps and storage areas referenced by an index 3 TABLE_ALTER_DICTIONARY?  Alters the record definitions in the repository to match theC table definitions in the database. Other objects referencing theB table or that are referenced by it and have changed definitions; in the database may be altered. These other objects are: o Fields o Collating sequences) o Other referenced records and fields3 o Foreign key constraints and check constraints o Indexes 2 ExamplesA The following example shows how to use the INTEGRAT  E statementA with the ALTER FILES clause. In this example, fields (domains)= are defined in the repository. Then, using SQL, a table isA created based on the repository definitions. Subsequently, the? repository definitions are changed so the definitions in theB database file and the repository no longer match. The INTEGRATE= statement resolves this situation by altering the database> definitions using the repository definitions as the source. $ ! $ ! Define CDD$DE FAULT $ !6 $ DEFINE CDD$DEFAULT SYS$COMMON:[REPOSITORY]CATALOG $ !@ $ ! Enter the CDO to create new field and record definitions: $ ! $ REPOSITORY CDO> !B CDO> ! Create two field (domain) definitions in the repository: CDO> !2 CDO> DEFINE FIELD PART_NUMBER DATATYPE IS WORD., CDO> DEFINE FIELD PRICE DATATYPE IS WORD. CDO> !8 CDO> ! Define a record called INVENTORY using the two$ CDO> ! fields previously defined: CDO> ! CDO> DEFINE RECORD IN VENTORY. CDO> PART_NUMBER. CDO> PRICE. CDO> END RECORD INVENTORY. CDO> ! CDO> EXIT $ ! $ ! Enter SQL: $ ! $ SQL SQL> !- SQL> ! In SQL, create the database ORDERS: SQL> !5 SQL> CREATE DATABASE ALIAS ORDERS PATHNAME ORDERS; SQL> !9 SQL> ! Create a table in the database ORDERS using theB SQL> ! INVENTORY record (table) just created in the repository: SQL> !B SQL> CREATE TABLE FROM SYS$COMMON:[REPOSITORY]CATALOG.INVENTORY con t> ALIAS ORDERS; SQL> !? SQL> ! Use the SHOW TABLE statement to see information about SQL> ! INVENTORY the table: SQL> !# SQL> SHOW TABLE ORDERS.INVENTORY) Information for table ORDERS.INVENTORY= CDD Pathname: SYS$COMMON:[REPOSITORY]CATALOG.INVENTORY;1& Columns for table ORDERS.INVENTORY:: Column Name Data Type Domain: ----------- --------- ------F PART_NUMBER SMALLINT ORDE RS.PART_NUMBER@ PRICE SMALLINT ORDERS.PRICE . . . SQL> COMMIT; SQL> EXIT $ ! $ ! Enter CDO again: $ ! $ REPOSITORY CDO> !: CDO> ! Verify that the fields PART_NUMBER and PRICE are" cdo> ! in the record INVENTORY: CDO> ! CDO> SHOW RECORD INVENTORY! Definition of record INVENTORY+ | Contains field PART_NUMBER% | Contains field PRICE CDO> !A CDO> ! Define the fields VENDOR_NAME and QUANTITY. Add them toL CDO> ! the record INVENTORY using the CDO CHANGE RECORD command. Now, theJ CDO> ! definitions used by the database no longer match the definitions; CDO> ! in the respository, as the CDO message indicates: CDO> !5 CDO> DEFINE FIELD VENDOR_NAME DATATYPE IS TEXT 20./ CDO> DEFINE FIELD QUANTITY DATATYPE IS WORD. CDO> ! CDO> CHANGE RECORD INVENTORY. CDO> DEFINE VENDOR_NAME. CDO> END. CDO> DEFINE QUANTITY. C! DO> END. CDO> END INVENTORY RECORD.I %CDO-I-DBMBR, database SQL_USER:[PRODUCTION]CATALOG.ORDERS(1) may need to be INTEGRATED CDO> !F CDO> ! Use the SHOW RECORD command to see if the fields VENDOR_NAME8 CDO> ! and QUANTITY are part of the INVENTORY record: CDO> ! CDO> SHOW RECORD INVENTORY! Definition of record INVENTORY+ | Contains field PART_NUMBER% | Contains field PRICE+ | Contains field VENDOR_NAME( | Conta" ins field QUANTITY CDO> ! CDO> EXIT $ ! $ ! Enter SQL again: $ ! $ SQL SQL> !C SQL> ! Use the INTEGRATE . . . ALTER FILES statement to updateP SQL> ! the definitions in the database file, using the repository definitionsL SQL> ! as the source. Note the INTEGRATE statement implicitly attaches to SQL> ! the database. SQL> !I SQL> INTEGRATE DATABASE PATHNAME SYS$COMMON:[REPOSITORY]CATALOG.ORDERS cont> ALTER FILES; SQL> !H SQL # > ! Use the SHOW TABLE statement to see if the table INVENTORY hasF SQL> ! changed. SQL has added the VENDOR_NAME and QUANTITY domains SQL> ! to the database file: SQL> ! SQL> SHOW TABLE INVENTORY" Information for table INVENTORY= CDD Pathname: SYS$COMMON:[REPOSITORY]CATALOG.INVENTORY;1 Columns for table INVENTORY:: Column Name Data Type Domain: ----------- --------- ------? PART_NUMBER $ SMALLINT PART_NUMBER9 PRICE SMALLINT PRICE? VENDOR_NAME CHAR(20) VENDOR_NAME< QUANTITY SMALLINT QUANTITY . . . SQL> COMMIT; SQL> EXITA The following example shows how to update the repository using< the database files as the source by issuing the INTEGRATEA statement with the ALTER DICTIONARY clause. The example startsB with the definition % s in the repository matching the definitions? in the database file. There is a table in the database and a= record in the repository, both called CUSTOMER_ORDERS. The? CUSTOMER_ORDERS table has four columns based on four domains@ of the same name: FIRST_ORDER, SECOND_ORDER, THIRD_ORDER, and FOURTH_ORDER.D This example adds to the database file a domain called FIFTH_DOM,A on which the local column called FIFTH_ORDER is based. At thisD point, the database file and the repo& sitory definitions no longerA match. The INTEGRATE . . . ALTER DICTIONARY statement resolvesD this situation by altering the repository using the database file definitions as the source. 8 SQL> ! Create the database using the PATHNAME clause: SQL> !& SQL> CREATE DATABASE FILENAME TEST1< cont> PATHNAME SYS$COMMON:[REPOSITORY]TEST1; SQL> !0 SQL> ! Create domains for the TEST1 database: SQL> !* SQL> CREATE DOMAIN FIRST_ORDER CHAR(4);+ SQL> CR' EATE DOMAIN SECOND_ORDER CHAR(4);* SQL> CREATE DOMAIN THIRD_ORDER CHAR(4);+ SQL> CREATE DOMAIN FOURTH_ORDER CHAR(4);$ SQL> CREATE TABLE CUSTOMER_ORDERS& cont> (FIRST_ORDER FIRST_ORDER,( cont> SECOND_ORDER SECOND_ORDER,& cont> THIRD_ORDER THIRD_ORDER,) cont> FOURTH_ORDER FOURTH_ORDER); SQL> COMMIT; SQL> DISCONNECT DEFAULT; SQL> !@ SQL> ! Attach to the database with the FILENAME clause so the$ SQL> ! repository is not updated: SQL> !- ( SQL> ATTACH 'ALIAS TEST1 FILENAME TEST1'; SQL> !F SQL> ! Use the SHOW TABLE statement to see what columns and domains0 SQL> ! are part of the table CUSTOMER_ORDERS: SQL> !3 SQL> SHOW TABLE (COLUMNS) TEST1.CUSTOMER_ORDERS;- Information on table TEST1.CUSTOMER_ORDERS+ Columns for table TEST1.CUSTOMER_ORDERS:: Column Name Data Type Domain: ----------- --------- ------? FIRST_ORDER CHAR( ) 4) FIRST_ORDER@ SECOND_ORDER CHAR(4) SECOND_ORDER? THIRD_ORDER CHAR(4) THIRD_ORDER@ FOURTH_ORDER CHAR(4) FOURTH_ORDER SQL> !: SQL> ! Create a new domain called FIFTH_DOM. Add a new@ SQL> ! column to the CUSTOMER_ORDERS table called FIFTH_ORDER. SQL> ! and base it on the domain FIFTH_DOM: SQL> !. SQL> CREATE DOMAIN TEST1.FIFTH_DOM CHAR(4);J SQL> ALTER TABLE TEST1.CUSTOMER * _ORDERS ADD FIFTH_ORDER TEST1.FIFTH_DOM; SQL> !O SQL> ! Check the CUSTOMER_ORDERS table to verify that the column FIFTH_ORDER SQL> ! was created: SQL> !3 SQL> SHOW TABLE (COLUMNS) TEST1.CUSTOMER_ORDERS;- Information on table TEST1.CUSTOMER_ORDERS: Column Name Data Type Domain: ----------- --------- ------E FIRST_ORDER CHAR(4) TEST1.FIRST_ORDERF SECOND_ORDER C+ HAR(4) TEST1.SECOND_ORDERE THIRD_ORDER CHAR(4) TEST1.THIRD_ORDERF FOURTH_ORDER CHAR(4) TEST1.FOURTH_ORDERC FIFTH_ORDER CHAR(4) TEST1.FIFTH_DOM SQL> COMMIT; SQL> EXIT $ ! $ ! Invoke CDO: $ ! $ REPOSITORY CDO> !I CDO> ! Note that only the database definition for TEST1 appears in the CDO> ! repository directory: CDO> ! DIRECTORY$ Directory SYS$COM , MON:[REPOSITORY]: TEST1(1) CDD$DATABASE CDO> !Q CDO> ! Check the record CUSTOMER_ORDERS. The field FIFTH_ORDER is not part ofM CDO> ! the record CUSTOMER_ORDERS. This means that the definitions in theG CDO> ! database file do not match the definitions in the repository. CDO> ! CDO> !7 CDO> SHOW RECORD CUSTOMER_ORDERS FROM DATABASE TEST1+ Definition of the record CUSTOMER_ORDERS. | Contains field FIRST_ORDER/ - | Contains field SECOND_ORDER. | Contains field THIRD_ORDER/ | Contains field FOURTH_ORDER CDO> EXIT $ ! $ ! Enter SQL again: $ ! $ SQL SQL> !O SQL> ! To make the definitions in the repository match those in the databaseM SQL> ! file, use the INTEGRATE statement with the ALTER DICTIONARY clause.F SQL> ! Note that the INTEGRATE statement implicitly attaches to the SQL> ! database. SQL> !; SQL> INTEGR. ATE DATABASE PATHNAME TEST1 ALTER DICTIONARY; SQL> COMMIT; SQL> EXIT $ ! $ ! Enter CDO again: $ ! $ REPOSITORY CDO> !Q CDO> ! Use the SHOW RECORD command to verify that the field FIFTH_ORDER is nowO CDO> ! part of the record CUSTOMER_ORDERS. Now, the definitions in both the8 CDO> ! repository and the database file are the same. CDO> !7 CDO> SHOW RECORD CUSTOMER_ORDERS FROM DATABASE TEST1' Definition of record CUSTOMER_ORDERS+ | Contains fi / eld FIRST_ORDER, | Contains field SECOND_ORDER+ | Contains field THIRD_ORDER, | Contains field FOURTH_ORDER+ | Contains field FIFTH_ORDER CDO> !N CDO> ! Use the ENTER command to make the record (table) CUSTOMER_ORDERS andK CDO> ! its fields (domains) appear in the repository. The ENTER command< CDO> ! assigns a repository directory name to an element. CDO> !3 CDO> ENTER FIELD FIRST_ORDER FROM DATABASE TEST0 1 CDO> !F CDO> ! Verify that a repository path name was assigned to the field CDO> ! FIRST_ORDER: CDO> ! CDO> DIRECTORY% Directory SYS$COMMON:[REPOSITORY]3 FIRST_ORDER(1) FIELD: TEST1(1) CDD$DATABASE4 CDO> ENTER FIELD SECOND_ORDER FROM DATABASE TEST1 . . .1 CDO> ENTER FIELD FIFTH_DOM FROM DATABASE TEST1 CDO> !F CDO> ! Now all the domains and tables in TEST1 have been 1 assigned a$ CDO> ! repository directory name: CDO> DIRECTORY$ Directory SYS$COMMON:[REPOSITORY]4 CUSTOMER_ORDERS(1) RECORD3 FIFTH_DOM(1) FIELD3 FIRST_ORDER(1) FIELD3 FOURTH_ORDER(1) FIELD3 SECOND_ORDER(1) FIELD: TEST1(1) CDD$DATABASE3 THIRD_ORDER(1) FIELD@ To store 2 existing database file definitions in the repositoryB for the first time, use the INTEGRATE statement with the CREATE@ PATHNAME clause. This statement builds repository definitions) using the database file as the source.D The following example shows how to store existing database system> file definitions in the repository for the first time. This@ example first creates a database only in a database file, notC in the repository. Next, the INTEGRATE statement with the CREATEC 3 PATHNAME clause updates the repository with the data definitions! from the database system file. SQL> !J SQL> ! Create a database without requiring the repository (the default)$ SQL> ! or specifying a path name: SQL> !# SQL> CREATE DATABASE ALIAS DOGS; SQL> !@ SQL> ! Now create a table for the breed of dog, poodles. The4 SQL> ! columns in the table are types of poodles: SQL> !! SQL> CREATE TABLE DOGS.POODLES cont> ( STANDARD CHAR(10), cont> M4 INIATURE CHAR(10), cont> TOY CHAR(10) ); SQL> !@ SQL> ! Use the SHOW TABLE statement to see the table POODLES: SQL> !) SQL> SHOW TABLE (COLUMNS) DOGS.POODLES$ Information on table DOGS.POODLES" Columns for table DOGS.POODLES:: Column Name Data Type Domain: ----------- --------- ------+ STANDARD CHAR(10)+ MINIATURE CHAR(10)+ TOY 5 CHAR(10) SQL> COMMIT; SQL> EXIT $ ! $ ! Enter CDO: $ ! $ REPOSITORY CDO> !O CDO> ! Use the DIRECTORY command to check if the database definition DOGS is CDO> ! in the repository: CDO> ! CDO> DIRECTORY$ Directory SYS$COMMON:[REPOSITORY]3 %CDO-E-NOTFOUND, entity not found in dictionary CDO> !( CDO> ! DOGS is not in the repository. CDO> ! CDO> EXIT $ ! $ ! Enter SQL again: $ ! $ SQL SQL> !I SQL> ! 6 Use the INTEGRATE statement using the CREATE PATHNAME clause to= SQL> ! update the repository using the DOGS database file: SQL> !E SQL> INTEGRATE DATABASE FILENAME SQL_USER:[PRODUCTION.ANIMALS]DOGS5 cont> CREATE PATHNAME SYS$COMMON:[REPOSITORY]DOGS; SQL> COMMIT; SQL> EXIT $ ! $ ! Enter CDO again: $ ! $ REPOSITORY CDO> !L CDO> ! Use the DIRECTORY command to check if the database definition DOGS2 CDO> ! has been integrated into the repository: 7 CDO> ! CDO> DIRECTORY% Directory SYS$COMMON:[REPOSITORY]: DOGS(1) CDD$DATABASE CDO> !: CDO> ! You can also use the SHOW USED_BY command to see@ CDO> ! if the record (table) POODLES and the fields (columns)? CDO> ! STANDARD, MINIATURE, and TOY are part of the database CDO> ! definition DOGS. CDO> ! CDO> SHOW USED_BY/FULL DOGS, Members of SYS$COMMON:[REPOSITORY]DOGS(1)@ | DOGS (Type : CDD$RDB 8 _DATABASE)" | | via CDD$DATABASE_SCHEMA . . .R | SYS$COMMON:[REPOSITORY]CDD$RDB_SYSTEM_METADATA.RDB$CDD_NAME;1(Type : FIELD)2 | | | | via CDD$DATA_AGGREGATE_CONTAINS: | | POODLES (Type : RECORD)) | | | via CDD$RDB_DATA_AGGREGATE= | | | STANDARD (Type : FIELD)2 | | | | via CDD$DATA_AGGREGATE_CONTAINSA | | | | SQL$10CHR (Type : FIELD)4 | 9 | | | | via CDD$DATA_ELEMENT_BASED_ON= | | | MINIATURE (Type : FIELD)2 | | | | via CDD$DATA_AGGREGATE_CONTAINSA | | | | SQL$10CHR (Type : FIELD)4 | | | | | via CDD$DATA_ELEMENT_BASED_ON= | | | TOY (Type : FIELD)2 | | | | via CDD$DATA_AGGREGATE_CONTAINSA | | | | SQL$10CHR (Type : FIELD)4 | | | | | via CDD$DAT: A_ELEMENT_BASED_ON . . . CDO> EXIT? The following example shows how to update a repository fieldB using the database files as the source by issuing the INTEGRATEA DOMAIN statement with the ALTER DICTIONARY clause. The example= starts with the definitions in the repository matching the= definitions in the database file. There is a domain in the? database and a field in the repository, both called DOMTEST.C This example alters the domain in the d ; atabase file name TESTDB.B At this point, the database file and the repository definitions? no longer match. The INTEGRATE DOMAIN . . . ALTER DICTIONARY? statement resolves this situation by altering the repository5 using the database file definitions as the source.0 SQL> -- Create a database, domain, and table. SQL> --8 SQL> CREATE DATABASE FILENAME TESTDB PATHNAME TESTDB;0 SQL> CREATE COLLATING SEQUENCE FRENCH FRENCH; SQL> CREATE DOMAIN DOMTEST cont> CHAR(5< )) cont> COLLATING SEQUENCE IS FRENCH; SQL> CREATE DOMAIN TEST_DOM_1 cont> CHAR(1); SQL> CREATE TABLE TEMP_TAB cont> (ROW1 CHAR(5), cont> ROW2 DOMTEST, cont> ROW3 TEST_DOM_1, cont> ROW4 INT); SQL> COMMIT; SQL> SHOW DOMAIN DOMTEST* DOMTEST CHAR(5) Collating sequence: FRENCH SQL> --H SQL> -- Disconnect from the database and invoke Oracle CDD/RepositoryD SQL> -- user interface and show the field D= OMTEST from the TESTDB SQL> -- database. SQL> -- SQL> DISCONNECT ALL; SQL> EXIT $ CDO/ CDO> SHOW FIELD DOMTEST FROM DATABASE TESTDB Definition of field DOMTEST9 | Datatype text size is 5 characters( | Collating sequence 'FRENCH' CDO> !Q CDO> ! Exit from Oracle CDD/Repository and attach to the database by file name CDO> ! only. CDO> ! CDO> EXIT! SQL> ATTACH 'FILENAME TESTDB'; SQL> --$ SQL> -- Alter the dom> ain DOMTEST. SQL> -- SQL> ALTER DOMAIN DOMTEST cont> CHAR(10)) cont> COLLATING SEQUENCE IS FRENCH; SQL> COMMIT; SQL> SHOW DOMAIN DOMTEST+ DOMTEST CHAR(10) Collating sequence: FRENCH SQL> --M SQL> -- Disconnect from the database and attach by path name only to issue* SQL> -- the INTEGRATE DOMAIN statement. SQL> -- SQL> DISCONNECT ALL;! SQL> ATTACH 'PATHNAME TESTDB';2 SQL> INTEGRATE DOMAIN DOMTEST ALTER DICTIONAR? Y; SQL> COMMIT; SQL> --M SQL> -- Disconnect from the database and invoke Oracle CDD/Repository V6.1L SQL> -- user interface and show the altered field DOMTEST from the TESTDB SQL> -- database. SQL> -- SQL> DISCONNECT ALL; SQL> EXIT $ CDO/ CDO> SHOW FIELD DOMTEST FROM DATABASE TESTDB Definition of field DOMTEST: | Datatype text size is 10 characters( | Collating sequence 'FRENCH'6 | Generic CDD$DATA_ELEMENT_CHARSET is @ '0' ww1 ITERATE_ControlC Causes the current iteration of the loop to abort and either theA next iteration to start or the loop to terminate; depending on the termination conditions. 2 EnvironmentD You can use the ITERATE control statement in a compound statement! of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o A In dynamic SQL as a statement to be dynamically executed 2 Format' ITERATE --+-----------------------+-->$ +-> --+ 2 Arguments 3 statement-label= Names the label assinged to a compound statement or a loop statement. 2 Example1 Example 1: Using the ITERATE Control StatementB The following example shows the ITERATE control statement beingD used to prematurely complete the processing of the current row in a F B OR cursor loop: SQL> BEGIN. cont> FOR :ord AS TABLE CURSOR ord_cursor; cont> AS SELECT * FROM orders WHERE customer_id = :cid cont> DOJ cont> IF stock_count (:ord.product_id, :ord.quantity) IS NULL THEN cont> ITERATE; cont> END IF;- cont> -- transfer stock to this order@ cont> UPDATE stock SET on_hand = on_hand - :ord.quantity2 cont> WHERE product_id = :ord.product_id;> cont> UPDATE orders SET :ord.available =C :ord.quantity+ cont> WHERE CURRENT OF ord_cursor; cont> END FOR; cont> END; ww1 LEAVE_ControlC Unconditionally ends execution within a compound statement blockD or a looping statement but resumes execution on any SQL statement1 that immediately follows the exited statement. 2 EnvironmentC You can use the LEAVE control statement in a compound statement: o In interactive SQL: o Embedded in host language programs to D be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format leave-statement = ( ---> LEAVE -+----------------------+-->% +-> -+ 2 Arguments 3 statement-labelD Names the label assinged to a compound statement, loop statement, or multistatement procedure. 2 Examples= Example 1: Using the LEAVE control statement within a loop SQL> E set flags 'trace'; SQL> SQL> create module REPORTS cont> /*< ***> This procedure counts the employees of a given state< ***> who have had a decrease in their salary during their ***> employment ***> */" cont> procedure COUNT_DECREASED cont> (in :state CHAR(2)* cont> ,inout :n_decreased INTEGER); cont> begin cont> set :n_decreased = 0; cont> cont> EMP_LOOP: cont> for :empfor cont> as each row of# cont> select employF ee_id5 cont> from EMPLOYEES where state = :state cont> do cont> begin8 cont> declare :last_salary INTEGER (2) default 0; cont> cont> HISTORY_LOOP: cont> for :salfor cont> as each row of) cont> select salary_amount) cont> from SALARY_HISTORY= cont> where employee_id = :empfor.employee_id+ cont> order by salary_start cont> do8 cont> if :salfor.salary_aG mount < :last_salary cont> then9 cont> set :n_decreased = :n_decreased + 1;L cont> trace :empfor.employee_id, ': ', :salfor.salary_amount;( cont> leave HISTORY_LOOP; cont> end if; cont>: cont> set :last_salary = :salfor.salary_amount; cont> end for; cont> end; cont> end for; cont> end; cont> cont> end module; SQL> SQL> declare :n integer;( SQL> call COUNT_DECREASED ('NH H', :n); ~Xt: 00200: 40789.00 ~Xt: 00248: 46000.00 ~Xt: 00471: 52000.00 N 3 SQL> SQL> rollback;6 Example 2: Ending Execution of a Compound Statement# PROCEDURE SAMPLE (IN :ID MONEY); BEGIN DECLARE: AMOUNT MONEY/ (SELECT TOTAL_AMOUNT FROM M_TABLE); LOOP IF :AMOUNT IS NULL THEN LEAVE; END IF; . . ." SET :AMOUNT =:AMOUNT-100.00; IF :AMOUNT < 0.00 THI EN LEAVE; END IF; END LOOP; END; ww 1 LOCK_TABLED Specifies a list of tables to be readied in a given lock mode andD added to the list of reserved tables for the current transaction.A If a view is specified, then the base tables referenced by the. view are locked in the specified lock mode. 2 EnvironmentD You can use the LOCK TABLE statement in a compound statement of a multistatement procedure: o In interactiJ ve SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 2 FormatG LOCK TABLE --+-+--> --+-+--> FOR -+-->lock-mode MODE --++G | +-------- , <-------+ +--> IN --+ ||G +--------------------- , <-----------------------------+|G +------------------------------------ <--------------------K ----------+G +------------+----------------------------+-------------------------->, +-----> NOWAIT --------------+, +--+-------------+--> WAIT --+ +--> DEFAULT -+ lock-mode = 6 ---+---> SHARED -----+---+---> DATA DEFINITION -+-->3 +---> PROTECTED ---+ +---> READ ------------+3 +---> EXCLUSIVE ---+ +---> WRITE -----------+ 2 Arguments 3 DATA_DEFINITION Syntax options:! DATA DEFINITION | READ | L WRITE= See the SET TRANSACTION statement for a description of the arguments. 3 lock_mode Syntax options:) IN lock-mode MODE | FOR lock-mode MODEB Specifies the lock mode to be used for the specified tables andC views. The IN and FOR keywords are synonymous. A table lock mode? can be promoted, but cannot be demoted. For example, you canD promote a SHARED READ lock to SHARED WRITE, but you cannot demote- a SHARED WRITE mode to a SHARED READ mode.? M See the SET TRANSACTION statement for a description of these arguments. 3 table-nameA The names of one or more tables or views currently existing inB the database that you want to lock and reserve. You can specify? tables created as GLOBAL or LOCAL TEMPORARY TABLES, but they? will be ignored because these types of tables do not containC shared data and so are never locked. You can specify tables from@ multiple databases by using the alias name as a prefix to theN ? table name. If you do not specify an alias, then the default alias is used. 3 wait-mode Syntax options: WAIT | NOWAIT | DEFAULT WAITB Specifies what the LOCK TABLE statement does when it encounters? a locked table. If you specify WAIT, the statement waits forC other transactions to complete and then proceeds. If you specify< NOWAIT, your transaction returns an error message when it? encounters a locked table. If you specify DEFAULT WAIT, then? theO lock mode specified for the current transaction is used.B If you specify a different lock mode than was specified for theB transaction, the mode you specify with the LOCK TABLE statement: takes precedence, unless the table is already reserved." The WAIT clause is the default. 2 Examples* Example 1: Locking a Table in READ MODE; SQL> LOCK TABLE EMPLOYEES IN PROTECTED READ MODE NOWAIT;3 Example 2: Locking Two Tables in Different Modes8 SQL> LOCK TABLE DB1.JP OB_HISTORY IN SHARED WRITE MODE,9 cont> DB2.SALARY_HISTORY IN EXCLUSIVE WRITE MODE; ww1 LOOP_ControlC Allows the repetitive execution of one or more SQL statements in a compound statement.1 See also the FOR, REPEAT and WHILE statements. 2 Environment@ You can use the LOOP control statement only within a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of aQ procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format loop-statement = 1 ---+-----------------------+-------------------+1 +-> : + |1 +-------------------------------------------+0 +-> LOOP --+-> compound-use-statement -+---+0 +-------------<-------------+ |0 +------------------------------------------+) +-> END LOOP --+------------------+->' R +-> +  compound-use-statement = , ----+-> call-statement --------------+--> ;' +-> commit-statement ------------+' +-> control-statement -----------+' +-> delete-statement ------------+' +-> get-diagnostics-statement ---+' +-> insert-statement ------------+' +-> lock-table-statement --------+' +-> rollback-statement ----------+' +-> set-transaction-statement ---+' +-> singleton-select-statement --+' +-> startS -transaction-statement -+' +-> trace-statement -------------+' +-> update-statement ------------+ 2 Arguments 3 beginning-labelD Assigns a name to a control loop. A beginning label used with theD LEAVE statement lets you perform a controlled exit from a loop. AC named loop is called a labeled loop statement. If you include anD ending label, it must be identical to its corresponding beginningB label. A beginning label must be unique within the procedure T in which the label is contained. 3 compound-use-statement@ Identifies the SQL statements allowed in a compound statement? block. See the Compound_Statement HELP topic for the list of valid statements. 3 END_LOOP@ Marks the end of a control loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique within the- procedure in which the label is contained.B The o U ptional end-label argument makes multistatement procedures< easier to read, especially in very complex multistatement procedure blocks. 3 LOOPB Marks the start of a control loop. A LOOP statement enables you@ to execute the associated sequence of SQL statements called aC compound statement. After SQL executes the statements within the@ loop, control returns to the LOOP statement at the top of the@ loop for subsequent statement execution. Looping occurs untilC SQL eV ncounters an error exception or executes a LEAVE statement.B In either case, SQL passes control out of the LOOP block to the2 statement immediately after the LOOP statement. 2 Examples( Example 1: Executing a loop statement SQL> create table ENROLLMENTS* cont> (last_name char(20),* cont> first_name char(10),& cont> middle_initial char,+ cont> class_name char(10)); SQL> SQL> begin& cont> declare :n integeW r default 5; cont> loop$ cont> insert into ENROLLMENTS. cont> values ('Jones', 'Robert', 'A',8 cont> 'Class ' || CAST(:n as char(1))); cont> set :n = :n - 1; cont> if :n <= 0 then cont> leave; cont> end if; cont> end loop; cont> end; SQL>" SQL> select * from ENROLLMENTS;C LAST_NAME FIRST_NAME MIDDLE_INITIAL CLASS_NAME@ Jones Robert A Class 5@ X Jones Robert A Class 4@ Jones Robert A Class 3@ Jones Robert A Class 2@ Jones Robert A Class 1 5 rows selected SQL> wwד1 OPENC Opens a cursor so that rows of its result table can be retrievedA through FETCH statements. The OPEN statement places the cursor, before the first row of its result Y table. 2 Environment" You can use the OPEN statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 FormatE OPEN -+-> ++---------------->----------------------+->C +-> --++-> USING --+-> -----------++C | +-> -+|C | +------ , <----------------+|Z C +-> USING DESCRIPTOR -+  2 Arguments 3 cursor-name; Specifies the name of the cursor you want to open. Use a= parameter if the cursor referred to by the cursor name was@ declared at run time with a dynamic DECLARE CURSOR statement.A Specify the parameter used for the cursor name in the extended$ dynamic DECLARE CURSOR statement.D You can use a parameter to refer to the cursor name only when the7 OPEN statem[ ent refers to an extended dynamic cursor. 3 parameter; Specifies the name of the cursor you want to open. Use a= parameter if the cursor referred to by the cursor name was@ declared at run time with a dynamic DECLARE CURSOR statement.A Specify the parameter used for the cursor name in the extended$ dynamic DECLARE CURSOR statement.D You can use a parameter to refer to the cursor name only when the7 OPEN statement refers to an extended dynamic cursor. 3 USI\ NG Syntax options: USING parameter USING qualified-parameter& USING DESCRIPTOR descriptor-nameB Specifies in dynamic SQL parameters (host language variables in? a precompiled OPEN statement or formal parameters in an OPEN> statement that is part of an SQL module language procedure)@ or qualified parameters (structures) whose values SQL uses toA replace parameter markers in a prepared SELECT statement namedA in the cursor declaration. These parameters ] are not for use in? interactive SQL. SQL replaces the parameter markers with the> values of the host language variables when it evaluates theC SELECT statement of the cursor. See the Oracle Rdb SQL ReferenceA Manual for more information on the SQL module language and the! SQL precompiler, respectively.? You must specify the USING clause when both of the following conditions exist:? o The declaration of the cursor you are opening specifies a% prepared SELECT ^ statement name.< o The statement string for the prepared SELECT statement! includes parameter markers.A SQL does not allow the USING clause in an OPEN statement for a? cursor that is not based on a prepared SELECT statement. ForD more information on parameter markers, see the PREPARE statement,@ and the chapter on dynamic SQL in the Oracle Rdb Guide to SQL Programming.> There are two ways to specify parameters in a USING clause:@ o With a list of parameter _ s. The number of parameters in theA list must be the same as the number of parameter markers inA the prepared SELECT statement. (If any of the parameters inB an OPEN statement is a host structure, SQL counts the numberC of variables in that structure when it compares the number ofA parameters in the USING clause with the number of parameter0 markers in the prepared SELECT statement.)A o With the name of a descriptor that corresponds to an SQLDA.@ Sp ` ecify the name of the descriptor in the USING DESCRIPTORB clause. If you use the INCLUDE statement to insert the SQLDA= into your program, the descriptor name is simply SQLDA.A The SQLDA is a collection of variables used only in dynamic= SQL. In an OPEN statement, the SQLDA points to a number< of host language variables with which SQL replaces theB parameter markers in a prepared SELECT statement. The number> of variables must match the number of parametea r markers.D The data types of host language variables must be compatible with< the values of the corresponding column of the cursor row. 2 Examples9 Example 1: Opening a cursor declared in a PL/I program@ This program fragment uses embedded DECLARE CURSOR, OPEN, andD FETCH statements to retrieve and print the name and department ofB managers. The OPEN statement places the cursor at the beginning of rows to be fetched. /* Declare the cursor: */& EXEC SQL b DECLARE MANAGER CURSOR FOR> SELECT E.FIRST_NAME, E.LAST_NAME, D.DEPARTMENT_NAME2 FROM EMPLOYEES E, DEPARTMENTS D7 WHERE E.EMPLOYEE_ID = D.MANAGER_ID ; /* Open the cursor: */ EXEC SQL OPEN MANAGER;8 /* Start a loop to process the rows of the cursor: */ DO WHILE (SQLCODE = 0);- /* Retrieve the rows of the cursor; and put the value in host language variables: */> EXEC SQL FETCH MANAGER INTO :FNAME, :c LNAME, :DNAME;3 /* Print the values in the variables: */ . . . END; /* Close the cursor: */ EXEC SQL CLOSE MANAGER;2 Example 2: Opening a cursor to insert list dataB The following interactive SQL example uses cursors to add a new= row to the RESUMES table of the sample personnel database:6 SQL> DECLARE TBLCURSOR INSERT ONLY TABLE CURSOR FOR1 cont> SELECT EMPLOYEE_ID, RESd UME FROM RESUMES;5 SQL> DECLARE LSTCURSOR INSERT ONLY LIST CURSOR FOR2 cont> SELECT RESUME WHERE CURRENT OF TBLCURSOR; SQL> OPEN TBLCURSOR;2 SQL> INSERT INTO CURSOR TBLCURSOR (EMPLOYEE_ID) cont> VALUES ("00167"); 1 row inserted SQL> OPEN LSTCURSOR;$ SQL> INSERT INTO CURSOR LSTCURSOR1 cont> VALUES ("This is the resume for 00167");$ SQL> INSERT INTO CURSOR LSTCURSOR cont> VALUES ("Boston, MA");$ SQL> INSERT INTO CURSOR LSTCURSOR' cont> VALUES ("Oracle Ce orporation"); SQL> CLOSE LSTCURSOR; SQL> CLOSE TBLCURSOR; SQL> COMMIT; wwד1 Operating_System_Invocation@ Gives access to the operating system command line environment from within SQL.D The dollar sign ($) tells SQL to spawn a subprocess and pass theD rest of the line to the operating system for processing. You mustA follow the dollar sign with an operating system command. AfterA the operating system processes the command, it logs out o f f the1 subprocess process and returns control to SQL. 2 EnvironmentD You can invoke operating system commands only in interactive SQL. 2 Format $ operating-system-command  2 Arguments 3 operating-system-command. Specifies a valid operating system command. 2 Examples= Example 1: Using the DCL DIRECTORY command from within SQL SQL> $ DIRECTORY *.SQL Directory DISK2:[DEPT3.ACCT]A DEFPRO.SQL;6 NOTEQUAL.SQL;1 QUg ERY.SQL;1 REFEXAM.SQL;12 STORE.SQL;1 UPDATE.SQL;2 Total of 6 files. SQL> wwד 1 PREPAREC Prepares an SQL statement dynamically generated by a program for3 execution, and assigns a name to that statement.> Dynamic SQL lets programs accept or generate SQL statements> at run time, in contrast to SQL module language procedures.A Unlike precompiled SQL or SQL module language statements, suchD dynamically executed SQL statements are n h ot necessarily part of aC program's source code, but can be generated while the program isB running. Dynamic SQL is useful when you cannot predict the type6 of SQL statement your program will need to process.B The PREPARE . . . INTO statement stores in the SQLDA the numberC and data types of any select list items of a prepared statement.A The SQLDA provides information about dynamic SQL statements toD the program and information about memory allocated by the program to SQi L.? The Oracle Rdb SQL Reference Manual describes in more detail? the specific fields of the SQLDA, and how programs use it to> communicate about select list items in prepared statements. 2 Environment% You can use the PREPARE statement:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 Format7 PREPARE -+-> --------+--------------+7 +-> + j |7 +-------------------------------------------+7 ++----------------------------------------+-+7 +-> SELECT LIST INTO + |7 +-------------------------------------------+: +-> FROM --+-> ' -> -> ' -+->8 +-> ------------------+  2 Arguments 3 descriptor-nameA Specifies the name of a structure declared in the host program@ as an SQLDA to which SQL k writes information about select listA items. Precompiled programs can use the embedded SQL statementB INCLUDE SQLDA to automatically insert a declaration of an SQLDA> structure, called SQLDA, in the program when it precompiles> the program. Programs that use the SQL module language must@ explicitly declare an SQLDA. Either precompiled or SQL moduleB language programs can explicitly declare additional SQLDAs, but' must declare them with unique names. 3 FROM Syntax l options: FROM statement-string FROM parameterD Specifies the SQL statement to be prepared for dynamic execution.? You either specify the statement string directly enclosed in= single quotation marks, or in a parameter (a host languageD variable in a precompiled PREPARE statement or a formal parameter@ in a PREPARE statement that is part of an SQL module language1 procedure) that contains the statement string.> Whether specified directly or by a parameter, t m he statement: string must be a character string that is a dynamically@ executable SQL statement. If you specify the statement stringC directly, the maximum length is 1,024 characters. If you specifyA the statement string as a parameter, the maximum length of the) statement string is 65,535 characters.= The form for the statement is the same as for embedded SQL statements, except that:2 o You must not begin the string with EXEC SQL.> o In places where SQL allows n host language variables in an< embedded statement, you must specify parameter markers instead.D If you try to prepare an invalid statement, you will find a valueB in the SQLCODE, the SQLCODE field of the SQLCA, or the SQLSTATE( status parameter indicating an error.@ The values returned to the SQLCODE field are described in the? Oracle Rdb SQL Reference Manual. Check the message vector toC see which error message was returned. If necessary, refer to theD error m o essage explanations and user actions located by default in the SQL HELP ERRORS.C Parameter markers are question marks (?) that denote parametersD in the statement string of a PREPARE statement. Parameter markersB are replaced by values in parameters or dynamic memory when theB prepared statement is executed by an EXECUTE or OPEN statement. 3 SELECT_LIST_INTOB Specifies that SQL writes information about the number and dataB type of select list items in the statemen p t string to the SQLDA.A The SELECT LIST keywords clarify the effect of the INTO clause and are optional.< Using the SELECT LIST clause in a PREPARE statement is anD alternative to issuing a separate DESCRIBE . . . INPUT statement.3 See the DESCRIBE statement for more information.> The SELECT LIST clause in a PREPARE statement is deprecated@ syntax. For more information about deprecated syntax, see the# Oracle Rdb SQL Reference Manual.& q NOTE> The PREPARE statement LIST keyword is not related to the% LIST data type or list cursors. 3 statement-nameD Identifies the prepared version of the SQL statement specified inD the FROM clause. Depending on the type of SQL statement prepared,? DESCRIBE, EXECUTE, and dynamic DECLARE CURSOR statements can? refer to the statement name assigned in a PREPARE statement.@ You can supply either a parameter or a compile-time statement> name. Specifying a pa r rameter lets SQL supply identifiers to@ programs at run time. Use an integer parameter to contain the> statement identifier returned by SQL, or a character string? parameter to contain the name of the statement that you pass to SQL.= A single set of dynamic SQL statements (PREPARE, DESCRIBE,; EXECUTE, Extended Dynamic DECLARE CURSOR) can handle any> number of dynamically executed statements. If you decide toB use parameters, statements that refer to the prepared statement s A (DESCRIBE, EXECUTE, extended dynamic DECLARE CURSOR) must also: use a parameter instead of the explicit statement name.? Refer to the DECLARE Dynamic_CURSOR statement for an exampleB demonstrating the PREPARE statement used with a dynamic DECLARE CURSOR statement. 3 statement-id-parameterD Identifies the prepared version of the SQL statement specified inD the FROM clause. Depending on the type of SQL statement prepared,? DESCRIBE, EXECUTE, and dynamic DECLARE t CURSOR statements can? refer to the statement name assigned in a PREPARE statement.@ You can supply either a parameter or a compile-time statement> name. Specifying a parameter lets SQL supply identifiers to@ programs at run time. Use an integer parameter to contain the> statement identifier returned by SQL, or a character string? parameter to contain the name of the statement that you pass to SQL.= A single set of dynamic SQL statements (PREPARE, DESCRIBE,; EXECUTEu , Extended Dynamic DECLARE CURSOR) can handle any> number of dynamically executed statements. If you decide toB use parameters, statements that refer to the prepared statementA (DESCRIBE, EXECUTE, extended dynamic DECLARE CURSOR) must also: use a parameter instead of the explicit statement name.: See the DECLARE Dynamic_CURSOR statement for an exampleB demonstrating the PREPARE statement used with a dynamic DECLARE CURSOR statement. 2 ExamplesB Example 1: Prepar v ing an INSERT statement with parameter markers= This PL/I program illustrates using a PREPARE statement toA prepare an INSERT statement for dynamic execution. Because theC statement string stored in COMMAND_STRING has parameter markers,@ the program needs to assign values to host language variablesD that will be substituted for the parameter markers during dynamic execution.> In this case, a DESCRIBE statement writes information about@ the parameter markers to the SQLD w A and the program writes the> addresses of the variables to the SQLDA. The program storesC values in the variables and an EXECUTE statement substitutes theA values for the parameter markers in the INSERT statement using the addresses in the SQLDA.6 To shorten the example, this program is simplified:> o The program includes the INSERT statement as part of theC program source code. A program with such coded SQL statementsC does not need to use dynamic SQL at all, b x ut can simply embedB the INSERT statement directly in the program. A program thatA must process SQL statements generated as it executes is the5 only type of program that requires dynamic SQL.: o The program declares host language variables for theB parameter markers without first checking the SQLDA for theirA description. Typically, an application needs to look in the> SQLDA to determine the number and data type of parameterB markers in the statementy string before allocating memory for them.& PREP_INTO: procedure options(main); /*0 * Illustrate a dynamic INSERT statement" * with parameter markers: */ declare FILESPEC char(20), EMP_ID CHAR(5), FNAME CHAR(10), LNAME CHAR(14), CITY CHAR(20),$ COMMAND_STRING char(256);( /* Declare communication area (SQLCA)% * and descriptor area (SQLDA): */! EXEC SQL INCLUDE SQLDA;! EXEC z SQL INCLUDE SQLCA; /* Declare the database: */6 EXEC SQL DECLARE SCHEMA RUNTIME FILENAME :FILESPEC; /* * * procedure division * */ /*3 * Assign values to FILESPEC and COMMAND_STRING,( * and allocate memory for the SQLDA: */ FILESPEC = 'SQL$DATABASE'; COMMAND_STRING =! 'INSERT INTO EMPLOYEES5 (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, CITY) VALUES (?,?,?,?)'; SQLSIZE = 10;! ALLOCATE SQLDA { SET (SQLDAPTR); SQLN = 10; /*7 * Prepare the statement assigned to COMMAND_STRING: */ EXEC SQL PREPARE STMT3 FROM COMMAND_STRING;3 /* Use a DESCRIBE statement to write information9 * about the parameter markers in the statement string * to the SQLDA: */. EXEC SQL DESCRIBE STMT3 MARKERS INTO SQLDA;( /* Assign values to the variables: */ EMP_ID = '99999'; FNAME = 'Bob'; LNAME = 'Addams'; | CITY = 'Francestown'; /*@ * Assign the addresses of the variables to the SQLDATA field * of the SQLDA: */% SQLDATA(1) = ADDR(EMP_ID);$ SQLDATA(2) = ADDR(FNAME);$ SQLDATA(3) = ADDR(LNAME);# SQLDATA(4) = ADDR(CITY); /* Execute STMT3:*/1 EXEC SQL EXECUTE STMT3 USING DESCRIPTOR SQLDA; /*1 * Display the contents of table S to make sure0 * it has the proper contents and clean it up: */ CALL DUMP_S;> E} XEC SQL DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID = "99999"; EXEC SQL COMMIT WORK; RETURN; DUMP_S: PROC;' EXEC SQL DECLARE X CURSOR FOR SELECT3 EMPLOYEE_ID, FIRST_NAME, LAST_NAME, CITY6 FROM EMPLOYEES WHERE EMPLOYEE_ID = "99999"; /*@ * Declare a structure to hold values of rows from the table: */ DCL 1 S, 2 EMP_ID CHAR(5), 2 FNAME CHAR(10), 2 LNAME CHAR(14), 2 CITY CHAR(20);> /* Declare in ~ dicator vector for the preceding structure: */ DCL S_IND (4) FIXED(15) BIN;7 PUT EDIT ('Dump the contents of S') (SKIP, SKIP, A); EXEC SQL OPEN X;" EXEC SQL FETCH X INTO :S:S_IND; DO WHILE (SQLCODE = 0);F PUT EDIT (S_IND(1), ' ', S.EMP_ID, ' ') (SKIP, F(6), A, A, A);> PUT EDIT (S_IND(2), ' ', S.FNAME, ' ') (F(6), A, A, A);= PUT EDIT (S_IND(3), ' ', S.LNAME, ' ') (F(6), A, A, A);6 PUT EDIT (S_IND(4), ' ', S.CITY) (F(6), A, A);% EXEC SQL FETCH X INTO :S:S_IND; END; EXEC SQL CLOSE X; RETURN; END DUMP_S; END PREP_INTO;6 Example 2: Showing the effect of the SQLCA support. #include  #include exec sql1 declare alias filename 'db$:mf_personnel'; exec sql include SQLCA;@ char * s1 = "begin insert into work_status values (?, ?, ?);\> select count(*) into ? from work_status; end"; void main () { int i;+ SQLCA.S QLERRD[2] = SQLCA.SQLERRD[3] = 1; exec sql prepare stmt from :s1;) if (SQLCA.SQLCODE != 0) sql_signal ();9 printf( "SQLCA:\n SQLCODE: %9d\n", SQLCA.SQLCODE); for (i = 0; i < 6; i++)< printf( " SQLERRD[%d]: %9d\n", i, SQLCA.SQLERRD[i]); }B The results below show that there are three input arguments and one output argument. SQLCA: SQLCODE: 0 SQLERRD[0]: 0 SQLERRD[1]: 0 SQLERRD[2]: 1  SQLERRD[3]: 3 SQLERRD[4]: 0 SQLERRD[5]: 0 ww1 PRINT) Displays a message in interactive SQL. 2 Environment6 You can use the PRINT statement in interactive SQL. 2 FormatJ PRINT -+-+-> --+--+--------------------------------------+-+-->G | +-> -+ +-> AS -+----------------------++ |G | +-> edit-using-clause -+ |G +--------- --------------- , <---------------------------------+  edit-using-clause = ' --> EDIT USING -+-> edit-string ---+->% +-> -+ 2 Arguments 3 AS_name? Changes the name displayed in the print statement header. By@ default literal values have a blank header name and variablesC use their name as a header. If the header must include spaces orD lowercase characters then use SET QUOTING RULES or SET DIALECT to enable delimite d identifiers 3 EDIT_USING Syntax options:0 EDIT USING edit-string|EDIT USING domain-nameA Assigns an edit string for use when formatting the variable orD literal value. If a domain name is specified then the EDIT STRING from the domain is used.5 This clause is only permitted for interactive SQL. 3 literal= Specifies the values you want displayed to the user during< execution of the command procedure. Enclose the character& literals in singl e quotation marks. 3 variable1 Prints the contents of the specified variable. 2 Examples; Example 1: Displaying a literal from a command procedure@ The following PRINT statement in a command procedure displays= 'Creating trigger definitions for the database' during the& execution of the command procedure:2 SQL> -- Trigger definition statements are next.> SQL> PRINT 'Creating trigger definitions for the database';1 SQL> CREATE TRIGGER EMPLOYEE_ID_CASCA DE_DELETE . . .# Example 2: Displaying a variable= The following PRINT statement displays the definition of a variable: SQL> DECLARE :X CHAR(10); SQL> BEGIN cont> SET :X = 'Active'; cont> END; SQL> PRINT :X; X Active ww1 QUIT? Stops an interactive SQL session, rolls back any changes you+ made, and returns you to the DCL prompt. 2 Environment< You can issue the QUIT statemen t in interactive SQL only. 2 Format QUIT ww 1 RELEASEB Releases all resources used by a prepared dynamic SQL statement< and prevents the prepared statement from executing again.@ The RELEASE statement is a dynamic SQL statement. Dynamic SQL? lets programs accept or generate SQL statements at run time,A in contrast to SQL statements that are part of the source code> for precompiled programs or SQL module language procedures.A Unlike  precompiled SQL or SQL module language statements, suchD dynamically executed SQL statements are not necessarily part of aC program's source code, but can be generated while the program isB running. Dynamic SQL is useful when you cannot predict the type6 of SQL statement your program will need to process. 2 Environment% You can use the RELEASE statement:: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module 2 F ormat) RELEASE -+> --------+->' +> + 2 Arguments 3 statement-nameA Specifies the name of a prepared statement or a statement name# assigned in a PREPARE statement.= A single set of dynamic SQL statements (PREPARE, DESCRIBE,< EXECUTE, dynamic DECLARE CURSOR) can handle any number of# dynamically executed statements.@ You can supply either a parameter or a compile-time statement> name to identify the statement to be executed. Specifying aA parameter lets SQL supply identifiers to programs at run time.? Use an integer parameter to contain the statement identifier= returned by SQL or a character string parameter to contain= the name of the statement that you pass to SQL. If you use> parameters, statements that refer to the prepared statement: (DESCRIBE, EXECUTE, DECLARE CURSOR) must also use those5 parameters instead of the explicit statement name. 3 statement-i d-parameterA Specifies the name of a prepared statement or a statement name# assigned in a PREPARE statement.= A single set of dynamic SQL statements (PREPARE, DESCRIBE,< EXECUTE, dynamic DECLARE CURSOR) can handle any number of# dynamically executed statements.@ You can supply either a parameter or a compile-time statement> name to identify the statement to be executed. Specifying aA parameter lets SQL supply identifiers to programs at run time.? Use an integer parameter to contain the statement identifier= returned by SQL or a character string parameter to contain= the name of the statement that you pass to SQL. If you use> parameters, statements that refer to the prepared statement: (DESCRIBE, EXECUTE, DECLARE CURSOR) must also use those5 parameters instead of the explicit statement name. 2 Example) Example 1: Using the RELEASE statementD The following fragment from a COBOL program shows using a RELEASEC statement to  release resources from a prepared SELECT statement: . . . FETCHES.. DISPLAY "Here's the row we stored:"% EXEC SQL PREPARE STMT FROM@ 'SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = "99999"' END-EXEC6 EXEC SQL DECLARE C CURSOR FOR STMT END-EXEC# EXEC SQL OPEN C END-EXEC . . . EXEC SQL FETCH C INTO& :EMP_ID:EMP_ID_IND,$ :LNAME:LNAME_IND,$ :FNAME:FNAME_IND,* :MID_INIT:MID_INIT_IND,& :ADDR_1:ADDR_1_IND,& :ADDR_2:ADDR_2_IND," :CITY:CITY_IND,$ :STATE:STATE_IND,& :P_CODE:P_CODE_IND, :SEX:SEX_IND,$ :BDATE:BDATE_IND,% :S_CODE:S_CODE_IND END-EXEC DISPLAY EMP_ID," ", FNAME ," ", MID_INIT," ", LNAME," ", ADDR_1," ", ADDR_2," ", CITY," ", STATE," ", P_CODE," ", SEX," ", BDATE," ", S_CODE. PERFORM CHECK% EXEC SQL CLOSE C END-EXEC. PERFORM CHECK.* EXEC SQL RELEASE STMT END-EXEC. PERFORM CHECK. .  . . ww 1 RENAME< Allows the database administrator to change the name of aA database object. This new name is then available for referenceC in other data definition statements, as well as from queries and routines.& NOTE@ The RENAME statement may require that synonyms are enabledA for the database. Reference the SYNONYMS ARE ENABLED clause: of the ALTER, CREATE and IMPORT DATABASE statements. 2 Environment$ You can use the RENAME statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 2 Format< RENAME --+-----------------+--> oldname --> TO --> newname +--> CONSTRAINT -+ +--> DOMAIN -----+ +--> FUNCTION ---+ +--> MODULE -----+  +--> OUTLINE -----+ +--> PROCEDURE --+ +--> PROFILE ----+ +--> ROLE -------+ +--> SEQUENCE ----+ +--> TABLE -------+ +--> TRIGGER ----+ +--> USER --------+ +--> VIEW --------+ 2 Arguments 3 newnameD The new name for this object. This name must not already exist inC the database for this object type, nor be the name of a synonym.? The one exception is when the s ynonym references the oldname object.A If this is a RENAME TABLE, RENAME VIEW or RENAME SEQUENCE thenC the newname cannot be the name of an existing table, sequence or view. 3 oldname@ The name of an existing object in the database. If the objectD type keyword is specified then an object must exist of that type.@ The name may also be a synonym for an object of the specified type. 2 Examples7 Example 1: Preparing a database for RENAME statement B The RENAME statement for most objects requires that synonyms be@ enabled. This example shows the reported error if a RENAME is2 attempted for an object that requires synonyms.( SQL> attach 'filename personnel_sql'; SQL> show table6 User tables in database with filename personnel_sql CANDIDATES COLLEGES/ CURRENT_INFO A view./ CURRENT_JOB A view./ CURRENT_SALARY A view. DE GREES DEPARTMENTS EMPLOYEES JOBS JOB_HISTORY RESUMES SALARY_HISTORY WORK_STATUS0 SQL> rename table EMPLOYEES to COMPANY_STAFF;0 %RDB-E-NO_META_UPDATE, metadata update failedC -RDMS-E-UNSSYNONYM, this database does not have synonyms enabled SQL> disconnect all;C SQL> alter database filename personnel_sql synonyms are enabled;8 Example 2: Renaming a table in the PERSONNEL database; This example renames the  EMPLOYEES table. The SHOW TABLE? statement lists the new name as well as synonym with the old name of the table.( SQL> attach 'filename personnel_sql';0 SQL> rename table EMPLOYEES to COMPANY_STAFF; SQL> show table6 User tables in database with filename personnel_sql CANDIDATES COLLEGES COMPANY_STAFF/ CURRENT_INFO A view./ CURRENT_JOB A view./ CURRENT_SALARY A view. DEGREES DEPARTMENTS JOBS JOB_HISTORY RESUMES SALARY_HISTORY WORK_STATUSI EMPLOYEES A synonym for table COMPANY_STAFFH SQL> select last_name from COMPANY_STAFF where employee_id = '00164'; LAST_NAME Toliver 1 row selected SQL>0 Example 3: Renaming back to the original nameD This example shows that the rename back to the original name will@ create a new synonym and remo ve the old synonym which had the$ same name as the tables new name.0 SQL> rename table COMPANY_STAFF to EMPLOYEES; SQL> show table6 User tables in database with filename personnel_sql CANDIDATES COLLEGES/ CURRENT_INFO A view./ CURRENT_JOB A view./ CURRENT_SALARY A view. DEGREES DEPARTMENTS EMPLOYEES JOBS JOB_HISTORY RESUMES  SALARY_HISTORY WORK_STATUSE COMPANY_STAFF A synonym for table EMPLOYEES SQL> D Example 4: Can not rename to a name used by the same object class or a synonymA The RENAME command does not allow the new name to be in use byD the same class of objects, or by a synonym. In particular tables,1 views and sequences share the same name space.3 SQL> rename view CURRENT_INFO to CURRENT_SALARY;M %SQL-F-REL_EXISTS, Table CURRENT_SALA RY already exists in this database or schema, SQL> create sequence CURRENT_INFORMATION;8 SQL> rename view CURRENT_INFO to CURRENT_INFORMATION;0 %RDB-E-NO_META_UPDATE, metadata update failedL -RDMS-E-SEQEXTS, there is another sequence named "CURRENT_INFORMATION" in this database@ -RDMS-F-RELNOTCHG, relation CURRENT_INFO has not been changed ww'1 REPEAT_ControlA Repetitively executes one or more SQL statements in a compound& loop until an end condition is met. 2 EnvironmentC You can use the REPEAT control statement in a compound statement! of a multistatement procedure: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format repeat-statement= < --+-----------------------+--> REPEAT --------------------+< +-> : -+  |< +----------------------------<----------------------------+< +-+-> compound-use-statement --+--> UNTIL --> predicate --+< +-------------<--------------+ |< +----------------------------<----------------------------+< +---> END REPEAT --+--------------------+----------------->* +-> --+ 2 Arguments 3 beginning-label:A Assigns a name to the REPEAT statement. A beginning label usedC with the LEAV E statement lets you perform a controlled exit from@ a repeat loop. A named repeat loop is called a labeled repeat> loop statement. A beginning label must be unique within the- procedure in which the label is contained. 3 END_REPEAT_ending-label@ Marks the end of a control loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique within the- procedure in which the label is conta ined.: The optional ending-label argument makes multistatementB procedures easier to read, especially in complex multistatement procedure blocks. 3 REPEAT_compound-use-statement= Repeatedly executes a block of SQL statements until an end@ condition is met, as specified by the UNTIL predicate clause. 3 UNTIL_predicate= Specifies a condition that controls how many times SQL can@ execute the statements embedded within its REPEAT . . . UNTILB block (collec tively referred to as its compound statement). SQLD executes the compound statement once and then evaluates the UNTILA condition. If it evaluates to false or NULL (unknown) and does> not encounter an error exception, SQL executes the compound< statement again. Each time the search condition evaluates? to false or NULL, the REPEAT statement executes the compoundD statement. If the UNTIL condition evaluates to true, SQL bypassesC the compound statement and passes control to the st atement after the END REPEAT statement. 2 ExampleC Example 1: Using a REPEAT Statement to List Files in the Current Directory SQL> SET VERIFY; SQL> ATTACH 'FILE SCRATCH';. SQL> CREATE DOMAIN file_name VARCHAR(255);# SQL> CREATE PROCEDURE find_file2 cont> (IN :FILESPEC file_name BY DESCRIPTOR,? cont> INOUT :RESULTANT_FILESPEC file_name BY DESCRIPTOR,2 cont> INOUT :CONTEXT INTEGER BY REFERENCE);$ cont> EXTERNAL NAME LIB$FIND_FILE* con t> LOCATION 'SYS$LIBRARY:LIBRTL.EXE' cont> LANGUAGE GENERAL cont> PARAMETER STYLE GENERAL cont> COMMENT IS& cont> 'DCL HELP: LIB$FIND_FILE 'F cont> / 'The Find File routine is called with a wildcard file'M cont> / 'specification for which it searches. LIB$FIND_FILE '& SQL> CREATE PROCEDURE Find_file_end/ cont> (IN :CONTEXT INTEGER BY REFERENCE); cont> EXTERNAL" cont> NAME LIB$FIND_FILE_END. cont> LOCATION 'SYS$LIBRARY:LIBRTL.EXE'  cont> LANGUAGE GENERAL# cont> PARAMETER STYLE GENERAL cont> COMMENT IS) cont> 'DCL HELP: LIB$FIND_FILE_END '; cont> / 'The End of Find File routine is called once') cont> / 'after each sequence of 'E cont> / 'calls to LIB$FIND_FILE. LIB$FIND_FILE_END deallocates'E cont> / 'any saved Record Management Service (RMS) context and'? cont> / 'deallocates the virtual memory used to hold the') cont> / 'allocated context block.'; SQL> SET FLAGS 'TRACE'; SQL> BEGIN9 cont> -- This procedure performs a call to an external8 cont> -- routine to list files located in the current cont> -- default directory- cont> DECLARE :done, :context integer = 0;4 cont> DECLARE :search_string FILE_NAME = '*.SQL';& cont> DECLARE :file_spec FILE_NAME; cont> REPEAT9 cont> -- Ask the OpenVMS routine for the next nameC cont> CALL find_file (:search_string, :file_spec, :context);0 cont> IF POSITION ('*'  in :file_spec) = 04 cont> AND POSITION ('%' in :file_spec) = 06 cont> AND POSITION ('...' in :file_spec) = 0 cont> THEN= cont> -- Display the name (there are no wildcards)" cont> TRACE :file_spec; cont> ELSE cont> SET :done = 1; cont> END IF;2 cont> -- Exit when we have no more file names cont> UNTIL :done = 1 cont> END REPEAT;# cont> -- Clean up search context' cont> CALL find_file_end (:context);  cont> END;+ ~Xt: RDBVMS:[USER.V71]CREATE_ROLES.SQL;1# ~Xt: RDBVMS:[USER.V71]TEST.SQL;1 SQL> ww'1 RETURN_Control, Returns the value of the stored function. 2 Environment< You can use the RETURN statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 F ormat RETURN ---> value-expr ---->  2 Arguments 3 value_expr< The value expression to be returned as the result of thisC function call. The value-expr must be assignment-compatible with? the data type defined by the stored function RETURNS clause.C See Value Expressions for more information on value expressions. 2 ExamplesB Example 1: Specifying the RETURN statement in a stored function' SQL> CREATE MODULE utility_functions cont> L ANGUAGE SQL9 cont> FUNCTION abs (IN :arg INTEGER) RETURNS INTEGERA cont> COMMENT 'Returns the absolute value of an integer'; cont> BEGIN cont> RETURN CASE. cont> WHEN :arg < 0 THEN - :arg cont> ELSE :arg cont> END; cont> END; . . . cont> END MODULE; ww' 1 REVOKE> Removes privileges from or entirely deletes an entry in theC Oracle Rdb access control list (ACL) for a database object. Each@ entry in an access control list consists of an identifier (or= role) and a list of privileges assigned to the identifier.9 o Each identifier specifies a user or a set of users.D o The list of privileges specifies which operations that user orD user group can perform on the database, table, column, module,& procedure, function or sequence.? When a user tries to perform an operation on a database, SQL= reads the associated ACL  from top to bottom, comparing theC identifier of the user with each entry. As soon as SQL finds theC first match, it grants the rights listed in that entry and stopsA the search. All identifiers that do not match a previous entryB are compared with the subsequent entry, and if no match occurs,B they receive the rights of ("fall through" to) the entry [*,*],@ if it exists. If no entry has the user identifier [*,*], thenD unmatched user identifiers are denied all access to the d atabase,@ table, or column. For this reason, both the entries and their# order in the list are important.A To create an entry or add privileges to an entry in the Oracle? Rdb access control list for a database object, see the GRANT statement. 2 Environment$ You can use the REVOKE statement: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a nonstored procedure in a nonstored SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format REVOKE -----------------------+ +-----------------------------+H ++-> db-privs --------> ON DATABASE ALIAS -++-> ++----------+-+H | |+----- , <--+| | |H | +-----> * ----+ | |H +-> table-privs -----> ON -+-----------+--++-+-> +-++-+ |H | +-> TABLE --+ || +-> -+ || | |H |  |+------- , <---------+| | |H | +-------> * -----------+ | |H +-> column-privs ----> ON COLUMN ---+-> -+-----------+ |H | +-------- , <------+ | |H +-> module-privs ----> ON MODULE --++-> -++----------+ |H | |+-------- , <------+| | |H | +--------> * --------+  | |H +-> ext-routine-privs -+-> ON FUNCTION --+++-> -++-+ |H | +-> ON PROCEDURE -+|+----------- , <-----+| | |H | +-----------> * -------+ | |H +-> sequence-privs --> ON SEQUENCE -++-> -++--------+ |H |+------- , <--------+| |H +-------> * ----------+ |H +---------------------------------------------------- -----------------+I +-> revoke-from -------------------------------------------------------> db-privs= % ----+---+-+-> SELECT -----+-+----+-># | | +-> INSERT -----+ | |# | | +-> OPERATOR ---+ | |# | | +-> DELETE -----+ | |# | | +-> CREATE -----+ | |# | | +-> ALTER ------+ | |# | | +-> DROP -------+ | |# | | +-> DBCTRL -----+ | |# | | +-> DBADM ------+ | |# | | +-> SHOW -------+ | |# | | +-> REFERENCES -+ | |# | | +-> UPDATE -----+ | |# | | +-> SECURITY ---+ | |# | | +-> DISTRIBTRAN + | |# | +------- , <--------+ |# +---+---> ALL PRIVILEGES -+--+ +---> ENTRY ----------+ table-privs= 9 -+--+-+-> SELECT -------------------------------+-+-+-->6 | | +-> INSERT -------------------------------+ | |6 | | +-> DELETE -------------------------------+ | |6 | | +-> CREATE -------------------------------+ | |6 | | +-> ALTER --------------------------------+ | |6 | | +-> DROP ---------------------------------+ | |6 | | +-> DBCTRL -------------------------------+ | |6 | | +-> SHOW ---------------------------------+ | |6 | | +-> REFERENCES +--------------------------+ | |6 | | | +> ( +> +> ) + | |6 | | | +----- , <-------+ | | |6 | | +-> UPDATE +------------------------------+ | |6 | | +> ( +> --+--> ) + | | 6 | | +----- , <---------+ | |6 | +------------------- , <----------------------+ |6 +---+--> ALL PRIVILEGES --+------------------------+ +--> ENTRY -----------+  column-privs = " ---+-+-+-> UPDATE -----+-+--+--> | | +-> REFERENCES -+ | | | +------- , <--------+ | +---+-> ALL PRIVILEGES -++ +-> ENTRY ----------+ module-privs = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTR L -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +--+---> ALL PRIVILEGES -----+--------------------+ +---> ENTRY --------------+ ext-routine-privs = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +--+---> ALL PRIVILEGES ---+----------------------+ +---> ENTRY ------------+ sequence-privs = 8 -+-+-+-> ALTER -------------------------------+-+--+-->5 | | +-> DBCTRL ------------------------------+ | |5 | | +-> DROP --------------------------------+ | |5 | | +-> REFERENCES --------------------------+ | |5 | | +-> SELECT ------------------------------+ | |5 | | +-> SHOW --------------------------------+ | |5 | +------- , <---------------------------------+ |5 +--> ALL PRIVILEGES ------------------------------+ revoke-from = H --> FROM --+--+-> identifier ---+-+---------------------------++------>A |  +-> PUBLIC -------+ +-> AFTER +-> identifier ---+|A | | +-> PUBLIC -------+|A | +-> POSITION -----------+|A +---------------------- , <-------------------------+ identifier = " --+-+-> user-identifier ----+-+-> | +-> general-identifier -+ | | +-> system-identifier -+ | | +-> role-name ----------+ | +------------ + <-----------+ 2 Arguments 3 AFTER Syntax options: AFTER identifier AFTER PUBLICB Specifies the position of the entry within the ACL. If you omit> the AFTER or POSITION argument, SQL searches the entire ACL? for an identifier list that matches the one specified in the? FROM clause of the REVOKE statement. If it finds a match, itA modifies the ACL entry by deleting the privileges specified inC the privilege list. If there is no match, SQL generates an error5 and the REVOKE statement has no effect on t he ACL.D With the AFTER or POSITION argument, you can specify the position? in the list from which SQL searches for an ACL entry with anB identifier that matches the one specified in the FROM clause of the REVOKE statement.B o In the AFTER argument, the identifier specifies the entry inC the ACL after which SQL begins its search for the entry to beC modified or deleted. If none of the entries in the ACL has anC identifier that matches the identifier specified in the AFTER? argument, SQL generates an error and the statement fails.A Starting after the entry specified by the identifier in theB AFTER argument, SQL searches entries in the ACL. If an entryD has an identifier that matches the identifier specified by theB FROM clause of the REVOKE statement, SQL modifies or deletes that ACL entry.? If none of the entries has an identifier that matches the; identifier specified by the FROM clause of the REV OKE? statement, SQL generates an error and the statement failsB (even if an entry before the position at which SQL began its- search had an identifier that matched).D Specifying PUBLIC is equivalent to a wildcard specification of all user identifiers.B o In the POSITION argument, the integer specifies the earliestA relative position in the ACL of the entry to be modified orB deleted. If the integer is larger than the number of entriesA in t he ACL, SQL generates an error and the statement fails.D Starting with the position specified by the POSITION argument,D SQL searches entries in the ACL. If an entry has an identifierA that matches the identifier specified by the FROM clause ofC the REVOKE statement, SQL modifies or deletes that ACL entry.? If none of the entries has an identifier that matches the; identifier specified by the FROM clause of the REVOKE? statement, SQL generates an erro r and the statement failsB (even if an entry before the position at which SQL began its- search had an identifier that matched). 3 ALL_PRIVILEGESD Specifies that SQL should revoke all privileges in the ACL entry.D The REVOKE ALL PRIVILEGES statement differs from the REVOKE ENTRYA statement in that it does not delete the entire entry from theD ACL. The identifier remains, but without any privileges. An empty@ ACL entry denies all access to users matching the ide ntifier,: even if an entry later in the ACL grants PUBLIC access. 3 ENTRYA Deletes the entire entry in the ACL, including the identifier. 3 FROM Syntax options: FROM identifier FROM PUBLIC= Specifies the identifiers for the ACL entry to be modified< or deleted. Specifying PUBLIC is equivalent to a wildcard) specification of all user identifiers.- You can specify foyr types of identifiers: o User identifiers o General id entifiers o System-defined identifiers o Role names= You can specify more than one identifier by combining them> with plus signs (+). Such identifiers are called multipleD identifiers. They identify only those users who are common to allA the groups defined by the individual identifiers. Users who doB not match all the identifiers are not controlled by that entry.B For instance, the multiple identifier SECRETARIES + INTERACTIVE= specifies only members of the group defined by the generalA identifier SECRETARIES that are interactive processes. It does= not identify members of the SECRETARIES group that are not interactive processes.D For more information about identifiers, see your operating system documentation. 3 general-identifierB Identifies groups of users on the system and are defined by the@ OpenVMS system manager in the system privileges database. The. following are possible general identifiers: o  DATAENTRY o SECRETARIES o MANAGERS 3 ON_object-type Syntax options: ON DATABASE alias ON TABLE table-name ON COLUMN column-name ON MODULE module-name" ON FUNCTION ext-routine-name# ON PROCEDURE ext-routine-name ON SEQUENCE sequence-nameCSpecifies whether the REVOKE statement applies to ACLs for database?objects. You can specify a list of names for any form of the ONCclause. You must qualify a column name with at least the associated table name. 3 POSITION_nB Specifies the position of the entry within the ACL. If you omit> the AFTER or POSITION argument, SQL searches the entire ACL? for an identifier list that matches the one specified in the? FROM clause of the REVOKE statement. If it finds a match, itA modifies the ACL entry by deleting the privileges specified inC the privilege list. If there is no match, SQL generates an error5 and the REVOKE statement has no effec t on the ACL.D With the AFTER or POSITION argument, you can specify the position? in the list from which SQL searches for an ACL entry with anB identifier that matches the one specified in the FROM clause of the REVOKE statement.B o In the AFTER argument, the identifier specifies the entry inC the ACL after which SQL begins its search for the entry to beC modified or deleted. If none of the entries in the ACL has anC identifier that matches the identifier spe cified in the AFTER? argument, SQL generates an error and the statement fails.A Starting after the entry specified by the identifier in theB AFTER argument, SQL searches entries in the ACL. If an entryD has an identifier that matches the identifier specified by theB FROM clause of the REVOKE statement, SQL modifies or deletes that ACL entry.? If none of the entries has an identifier that matches the; identifier specified by the FROM clause of t he REVOKE? statement, SQL generates an error and the statement failsB (even if an entry before the position at which SQL began its- search had an identifier that matched).D Specifying PUBLIC is equivalent to a wildcard specification of all user identifiers.B o In the POSITION argument, the integer specifies the earliestA relative position in the ACL of the entry to be modified orB deleted. If the integer is larger than the number of entriesA in the ACL, SQL generates an error and the statement fails.D Starting with the position specified by the POSITION argument,D SQL searches entries in the ACL. If an entry has an identifierA that matches the identifier specified by the FROM clause ofC the REVOKE statement, SQL modifies or deletes that ACL entry.? If none of the entries has an identifier that matches the; identifier specified by the FROM clause of the REVOKE? statement, SQL generates a n error and the statement failsB (even if an entry before the position at which SQL began its- search had an identifier that matched). 3 privileges Types of privileges: db-privs table-privs column-privs module-privs ext-routine-privs sequence-privs> Specifies the list of privileges you want to remove from anD existing ACL entry. The operations permitted by a given privilege< keyword differ, depending on whether it w as granted for aB database, table, column, module, external routine, or sequence.? The Privileges table in the GRANT statement help topic listsC the privilege keywords and their meanings for databases, tables,6 modules, columns, external routines, and sequences. 3 role-name? The name of a role, such as one created with the CREATE ROLEB statement. If the role name exists as an operating system group= or rights identifier, then Oracle Rdb will create the role@ autom atically when you issue the GRANT statement. A role thatB is created automatically always has the attribute of IDENTIFIED EXTERNALLY. 3 system-identifier> Automatically defined by the OpenVMS system when the rightsB database is created at system installation time. System-defined> identifiers are assigned depending on the type of login youC execute. The following are all valid system-defined identifiers: o BATCH o NETWORK o INTERACTIVE o LOCA L o DIALUP o REMOTE 3 user-identifier/ Uniquely identifies each user on the system.< The user identifier consists of the standard OpenVMS userC identification code (UIC), a group name, and a member name (user@ name). The group name is optional. The user identifier can beB in either numeric or alphanumeric format. The following are all< valid user identifiers that could identify the same user: K_JONES [SYSTEM3, K_JONES] [341,311] @ You can use the asterisk (*) wildcard character as part of aA user identifier. For example, if you want to specify all users@ in a group on an OpenVMS system, you can enter [341,*] as the identifier.B When Oracle Rdb creates a database, it automatically creates anC ACL entry with the identifier [*,*], which grants all privileges except DBCTRL to any user.= You cannot use more than one user identifier in a multiple identifier. 2 ExampleD Example 1: Using REVOKE to manage user access to the database and tables+ SQL> attach 'filename DB$:MF_PERSONNEL'; SQL>% SQL> -- examine current privileges1 SQL> show protection on database RDB$DBHANDLE;# Protection on Alias RDB$DBHANDLES (IDENTIFIER=SQLNET4RDB,ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+9 DROP+DBCTRL+OPERATOR+DBADM+SECURITY+DISTRIBTRAN)9 (IDENTIFIER=[DOC,DOC_READER],ACCESS=SELECT+CREATE)S (IDENTIFIER=[DOC,DOC_WRITER],ACCESS=S ELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+5 ALTER+DROP+DBCTRL+OPERATOR+DBADM+REFERENCES)S (IDENTIFIER=[*,*],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+DROP+# OPERATOR+DBADM+REFERENCES) SQL>% SQL> -- revoke selected privilegesE SQL> revoke CREATE on database alias RDB$DBHANDLE from DOC_WRITER;L SQL> revoke DISTRIBTRAN on database alias RDB$DBHANDLE from DOC_REVIEWER;1 SQL> show protection on database RDB$DBHANDLE;# Protection on Alias RDB$DBHAN DLES (IDENTIFIER=SQLNET4RDB,ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+9 DROP+DBCTRL+OPERATOR+DBADM+SECURITY+DISTRIBTRAN)2 (IDENTIFIER=[DOC,DOC_READER],ACCESS=SELECT)R (IDENTIFIER=[DOC,DOC_WRITER],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+ALTER+/ DROP+DBCTRL+OPERATOR+DBADM+REFERENCES)S (IDENTIFIER=[*,*],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+ALTER+DROP+# OPERATOR+DBADM+REFERENCES) SQL>L SQL> -- No longer all access to DOC_REVIEWER, use wildcard for all tables; SQL> revoke ALL PRIVILEGES on table * from DOC_REVIEWER; SQL> commit;; Example 2: Revoking DROP Sequence Privileges from a User SQL> CREATE SEQUENCE EMPID;) SQL> SHOW PROTECTION ON SEQUENCE EMPID Protection on Sequence EMPIDE (IDENTIFIER=[RDB,STUART],ACCESS=SELECT+SHOW+ALTER+DROP+DBCTRL)% (IDENTIFIER=[*,*],ACCESS=NONE)1 SQL> GRANT SELECT ON SEQUENCE EMPID TO PUBLIC;* SQL> SHOW PROTECTION ON SEQUENCE EMPID;  Protection on Sequence EMPIDE (IDENTIFIER=[RDB,STUART],ACCESS=SELECT+SHOW+ALTER+DROP+DBCTRL)' (IDENTIFIER=[*,*],ACCESS=SELECT)2 SQL> REVOKE DROP ON SEQUENCE EMPID FROM STUART;* SQL> SHOW PROTECTION ON SEQUENCE EMPID; Protection on Sequence EMPID@ (IDENTIFIER=[RDB,STUART],ACCESS=SELECT+SHOW+ALTER+DBCTRL)' (IDENTIFIER=[*,*],ACCESS=SELECT) wwO1 REVOKE_ANSI= Removes privileges from the Oracle Rdb access control listB grant ed by a specific user for a database object. Each entry inC an ANSI/ISO-style access privilege set consists of an identifier7 and a list of privileges assigned to the identifier.= o Each identifier specifies a user or the PUBLIC keyword.B o The set of privileges specifies what operations that user orD user group can perform on the database, table, column, module,& procedure, function or sequence.@ For ANSI/ISO-style databases, the access privilege set is not< o rder-dependent. The user matches the entry in the access@ privilege set, receives whatever privileges have been grantedA on the database object and receives the privileges defined for> PUBLIC. A user without an entry in the access privilege set> receives only the privileges defined for PUBLIC. The PUBLICB identifier always has an entry in the access control list, even2 if PUBLIC has no access to the database object.A To create an entry or add privileges to an entry in the Oracl eB Rdb access control list for a a database object, see the GRANT_ ANSI statement. 2 Environment$ You can use the REVOKE statement: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a nonstored procedure in a nonstored SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format REVOKE -----------------------+ +---------------<-------------+M ++-> db-privs-ansi -------> ON DATABASE A LIAS -++-> -++-----------++M | |+--- , <-----+| ||M | +---> * -------+ ||M +-> table-privs-ansi ----> ON +----->----+--++-+-> +++------+|M | +-> TABLE -+ || +-> -+|| ||M | |+--------- , <------+| ||M | +---------> * -------- + ||M +-> column-privs-ansi ---> ON COLUMN ---+-> +-------------+|M | +-------- , <------+ ||M +-> module-privs-ansi ---> ON MODULE --++-> ++------------+|M | |+-------- , <------+| ||M | +--------> * --------+ ||M +-> ext-routine-privs-ansi -+> ON FUNCTION --+++-> -+++|M |  +> ON PROCEDURE -+|+---------- , <---------+|||M | +----------> * -----------+||M +-> sequence-privs-ansi -> ON SEQUENCE --++- > -++-------+|M |+-------- , <---------+| |M +--------> * -----------+ |M +----------------------------<--------------------------------------------+N +-> revoke-ansi-from ----------------- -------------------------------------> db-privs-ansi = % ----+---+-+-> SELECT -----+-+----+-># | | +-> INSERT -----+ | |# | | +-> OPERATOR ---+ | |# | | +-> DELETE -----+ | |# | | +-> CREATE -----+ | |# | | +-> ALTER ------+ | |# | | +-> DROP -------+ | |# | | +-> DBCTRL -----+ | |# | | +-> DBADM ------+ | |# | | +-> SHOW -------+ | |# | | +-> REFERENCES -+ | |# | | +-> UPD ATE -----+ | |# | | +-> SECURITY ---+ | |# | | +-> DISTRIBTRAN + | |# | +------- , <--------+ |# +-------> ALL PRIVILEGES ----+ table-privs-ansi = ; -+--+-+-> SELECT ---------------------------------+-+-+-->8 | | +-> INSERT ---------------------------------+ | |8 | | +-> DELETE ---------------------------------+ | |8 | | +-> CREATE ---------------------------------+ | |8 | | +-> ALTER ----------------------------------+ | |8 | | + -> DROP -----------------------------------+ | |8 | | +-> DBCTRL ---------------------------------+ | |8 | | +-> SHOW -----------------------------------+ | |8 | | +-> REFERENCES +---------------------------+ | |8 | | | +> ( +> +> ) -+ | |8 | | | +----- , <-------+ | | |8 | | +-> UPDATE -+---------------------- -------+ | |8 | | +> ( +> --+--> ) -+ | |8 | | +----- , <---------+  | |8 | +------------------- , <------------------------+ |8 +------> ALL PRIVILEGES -----------------------------+  column-privs-ansi = ! ---+-+-+-> UPDATE -----+-+--+--> | | +-> REFERENCES -+ | | | +------- , <--------+ | +-----> ALL PRIVILEGES --+ module-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> E XECUTE ----------------------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ ext-routine-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------- -----------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ sequence-privs-ansi = : -+-+-+-> ALTER -------------------------------+-+--+--->6 | | +-> DBCTRL ------------------------------+ | |6 | | +-> DROP --------------------------------+ | |6 | | +-> REFERENCES -------------------------- + | |6 | | +-> SELECT ------------------------------+ | |6 | | +-> SHOW --------------------------------+ | |6 | +------- , <---------------------------------+ |6 +--> ALL PRIVILEGES ------------------------------+ revoke-ansi-from = / --> FROM -+-+-> identifier-ansi-style ---++-->, | +-> PUBLIC ------------------+|, +------------- , <--------------+ identifier-ansi-style = " ------> user-identifier -------->  2 Arguments  3 ALL_PRIVILEGES@ Specifies that SQL should revoke all privileges in the access privilege set entry. 3 FROM Syntax options: FROM identifier-ansi-style FROM PUBLIC? Specifies the identifiers for the access privilege set entryB to be modified or deleted. Specifying PUBLIC is equivalent to a2 wildcard specification of all user identifiers.B The only identifiers are ones that translate to an OpenVMS user identification code (UIC).A  For more information about user identifiers, see the operating system documentation. Syntax options: ON DATABASE alias ON TABLE table-name ON COLUMN column-name ON MODULE module-name" ON FUNCTION ext-routine-name# ON PROCEDURE ext-routine-name ON SEQUENCE sequence-nameCSpecifies whether the REVOKE statement applies to ACLs for database?objects. You can specify a list of names for any form of the ONCclause. You must qualify a col umn name with at least the associated table name. 3 ON Syntax options: ON DATABASE * ON MODULE * ON FUNCTION * ON PROCEDURE * ON SEQUENCE *>Specifies whether the REVOKE statement applies to ACLs for all@objects of the specified types. If privileges are denied for the6operation on some objects, then the REVOKE is aborted. 3 privileges Types of privileges: db-privs-ansi table-privs-ansi column-privs-a nsi module-privs-ansi ext-routine-privs-ansi sequence-privs-ansi> Specifies the list of privileges you want to remove from an@ existing access privilege set entry. The operations permitted? by a given privilege keyword differ, depending on whether itA was granted for a database, table, column, module, routine, orB sequence. The Privileges Table in the GRANT lists the privilege> keywords and their meanings for databases, tables, modules,# external routin es and sequences. 3 user-identifier/ Uniquely identifies each user on the system.< The user identifier consists of the standard OpenVMS userC identification code (UIC), a group name, and a member name (user@ name). The group name is optional. The user identifier can beB in either numeric or alphanumeric format. The following are all< valid user identifiers that could identify the same user: K_JONES [SYSTEM3, K_JONES] [341,311]B When Oracle Rdb creates a database, it automatically creates an? access privilege set entry with the PUBLIC identifier, which= grants all privileges except DBCTRL to any user. In accessC privilege set databases, the only wildcard allowed is the PUBLIC identifier.= You cannot use more than one user identifier in a multiple identifier. 2 Examples< Example 1: Managing User Access with the REVOKE statement- SQL> attach 'filename DB$:ANSI_PERSONNEL'; SQL>% SQL> -- e xamine current privileges1 SQL> show protection on database RDB$DBHANDLE;# Protection on Alias RDB$DBHANDLE [DOC,DOC_WRITER]:R With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,I DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRANR Without Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,I DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN [DOC,DOC_READER]:# With Grant Option: NONE, Without Grant Option: SELECT,CREATE [*,*]:# With Grant Option: NONE# Without Grant Option: NONE SQL>% SQL> -- revoke selected privilegesE SQL> revoke CREATE on database alias RDB$DBHANDLE from DOC_READER;J SQL> revoke DISTRIBTRAN on database alias RDB$DBHANDLE from DOC_WRITER;1 SQL> show protection on database RDB$DBHANDLE;# Protection on Alias RDB$DBHANDLE [DOC,DOC_WRITER]:R With Grant Option: SELECT,INSERT,UPD ATE,DELETE,SHOW,CREATE,ALTER,DROP,= DBCTRL,OPERATOR,DBADM,SECURITYR Without Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,= DBCTRL,OPERATOR,DBADM,SECURITY [DOC,DOC_READER]:# With Grant Option: NONE% Without Grant Option: SELECT [*,*]:# With Grant Option: NONE# Without Grant Option: NONE SQL>1 SQL> -- prevent drop by revoking the privilege/ SQL>  revoke DROP on table * from DOC_READER; SQL> commit;> Example 2: Revoking a privilege granted with the WITH GRANT OPTION clause? When the privilege is revoked from the grantee, rdb_doc, who< received the privilege with the WITH GRANT OPTION clause,@ the privilege is also revoked from all users who received the privilege from that grantee.+ SQL> SHOW PROTECTION ON TABLE EMPLOYEES; [*,*]:# With Grant Option: NONE% Without Grant Option: SEL ECT [SQL,WARRING]:M With Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,D DROP,DBCTRL,OPERATOR,DBADM,REFERENCESM Without Grant Option: SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,; DROP,DBCTRL,DBADM,REFERENCES [RDB,RDB_DOC]:# With Grant Option: SHOW# Without Grant Option: NONE SQL>4 SQL> REVOKE SHOW ON EMPLOYEES FROM [rdb,rdb_doc];% SQL> SHOW PROTECTION ON E MPLOYEES; Protection on Table EMPLOYEES [*,*]:# With Grant Option: NONE% Without Grant Option: SELECT [RDB,RDB_DOC]:# With Grant Option: NONE# Without Grant Option: NONE( Example 3: Revoking column privileges> This example shows how to restrict privileges on a specific@ column by revoking the UPDATE privilege that has been granted for that column.8 SQL> SHOW PROTECTION ON COLUMN EMPLOYEES.EMPLOYEE_ID; [RDB,RDB_DOC] :# With Grant Option: NONE% Without Grant Option: UPDATEI SQL> REVOKE UPDATE ON COLUMN EMPLOYEES.EMPLOYEE_ID FROM [rdb,rdb_doc];8 SQL> SHOW PROTECTION ON COLUMN EMPLOYEES.EMPLOYEE_ID; [RDB,RDB_DOC]:# With Grant Option: NONE# Without Grant Option: NONE@ Example 4: Revoking DROP Privilege from a Sequence for a UserD This example shows the action of REVOKE for a SEQUENCE in an ANSI style database.( SQL> create sequence EMPLOYEE _ID_GEN;; SQL> grant select on sequence EMPLOYEE_ID_GEN to public;C SQL> grant all privileges on sequence EMPLOYEE_ID_GEN to stuart;4 SQL> show protection on sequence EMPLOYEE_ID_GEN;) Protection on Sequence EMPLOYEE_ID_GEN [DOCS,STUART]:# With Grant Option: NONEG Without Grant Option: SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES [DOCS,FREEMAN]:G With Grant Option: SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES# Without Grant Option: NONE [*,*]:# With Grant Option: NONE% Without Grant Option: SELECT< SQL> revoke drop on sequence EMPLOYEE_ID_GEN from stuart;4 SQL> show protection on sequence EMPLOYEE_ID_GEN;) Protection on Sequence EMPLOYEE_ID_GEN [DOCS,STUART]:# With Grant Option: NONEB Without Grant Option: SELECT,SHOW,ALTER,DBCTRL,REFERENCES [DOCS,FREEMAN]:G With Grant Option: SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES# Without Grant Option: NONE  [*,*]:# With Grant Option: NONE% Without Grant Option: SELECT SQL> www1 REVOKE_ROLES+ Revoke a role from another user or role. 2 Environment. You can use the REVOKE statement for roles: o In interactive SQL: o Embedded in host language programs to be precompiled@ o As part of a nonstored procedure in a nonstored SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format F REVOKE ---+--> -+----> FROM --+-+--> --+-+--->B +--> ALL ROLES ---+ | +--> -+ |B +------- , <------+ | +--> PUBLIC ------+ |B +---------- , <-------+ 2 Arguments 3 ALL_ROLES2 Revokes all roles assigned to the users listed. 3 FROMSyntax options:/ FROM username | FROM role-name | FROM PUBLIC> Specifies the user, role, or the PUBLIC user from which the# specified role is to be revoked. 3 role-name< The name of an existing role created with the CREATE ROLE= statement or created automatically by the GRANT statement. 2 Example) Example 1: Granting and Revoking Roles8 SQL> -- Optionally, create three users and two roles.7 SQL> -- Oracle Rdb automatically generates users and3 SQL> -- roles if they are identified externally.3 SQL> CREATE USER ABLOWNEY IDENTIFIED EXTERNALLY;2 SQL> CR EATE USER BGREMBO IDENTIFIED EXTERNALLY;0 SQL> CREATE USER LWARD IDENTIFIED EXTERNALLY;8 SQL> CREATE ROLE SALES_MANAGER IDENTIFIED EXTERNALLY;; SQL> CREATE ROLE DIVISION_MANAGER IDENTIFIED EXTERNALLY;= SQL> -- Grant the SALES_MANAGER role to users ABLOWNEY and< SQL> -- BGREMBO. Also grant the SALES_MANAGER role to the! SQL> -- DIVISION MANAGER ROLE.C SQL> GRANT SALES_MANAGER TO ABLOWNEY, BGREMBO, DIVISION_MANAGER;> SQL> -- Grant the DIVISION_MANAGER role to LWARD. LWARD now A SQL> -- has both the SALES_MANAGER and DIVISION_MANAGER roles.( SQL> GRANT DIVISION_MANAGER TO LWARD;> SQL> -- Revoke the DIVISION_MANAGER role from LWARD. He has SQL> -- left the company.+ SQL> REVOKE DIVISION_MANAGER FROM LWARD;; SQL> -- Grant the DIVISION_MANAGER role to BGREMBO. She1 SQL> -- has been promoted to division manager.* SQL> GRANT DIVISION_MANAGER TO BGREMBO; www 1 ROLLBACK@ Ends a transaction and undoes all changes you mad e since that2 transaction began. The ROLLBACK statement also:> o Closes all open cursors (with the exception of WITH HOLD cursors) o Releases all row locksB o Performs a checkpoint operation if fast commit processing is enabled" The ROLLBACK statement affects:< o All open databases included in the current transactionD o All changes to data made with SQL data manipulation statements" (DELETE, UPDATE, and INSERT)C o All changes to data de finitions made with SQL data definitionA statements (ALTER, CREATE, DROP, RENAME, GRANT, and REVOKE) 2 Environment& You can use the ROLLBACK statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format Rollback-statement = ( ROLLBACK WORK ----+---------------+--->$ +-> AND CHAIN --+  2 Arguments 3 AND_CHAINC Starts a new transaction implicitly using the same attributes as the rolled back transaction. 3 WORKC Specifies an optional keyword that has no effect on the ROLLBACKD statement. It is provided for compatibility with the ANSI/ISO SQL standard. 2 Examples5 Example 1: Rolling back changes in a COBOL program GET-ID-NUMBER.. DISPLAY "Enter employee ID number: " WITH NO ADVANCING.  ACCEPT EMPLOYEE-ID. CHANGE-SALARY.- DISPLAY "Enter new salary amount: " WITH NO ADVANCING. ACCEPT SALARY-AMOUNT.# EXEC SQL UPDATE SALARY_HISTORY3 SET SALARY_AMOUNT = :SALARY-AMOUNT/ WHERE EMPLOYEE_ID = :EMPLOYEE-ID% AND END_DATE IS NULL END-EXEC, DISPLAY EMPLOYEE-ID, SALARY-AMOUNT.5 DISPLAY "Is this figure correct? [Y or N] " WITH NO ADVANCING. ACCEPT AN SWER. IF ANSWER = "Y" THEN$ EXEC SQL COMMIT END-EXEC ELSE& EXEC SQL ROLLBACK END-EXEC> DISPLAY "Please enter the new salary amount again." GO TO CHANGE-SALARY END-IF.( Example 2: Using COMMIT and AND CHAIN@ The following simple example executes SET TRANSACTION once atC the start of the procedure. Then periodically the transaction isB committed and restarted using the COMMIT AND CHAIN syntax. ThisC sim plifies the application since there is only one definition of# the transaction characteristics.# SQL> -- process table in batches SQL>- SQL> set compound transactions 'internal';& SQL> set flags 'transaction,trace'; SQL> SQL> begin& cont> declare :counter integer = 0; cont> declare :emp integer; cont> cont> set transaction cont> read write5 cont> reserving employees for exclusive write; cont> cont> for :emp in 0 to 600 cont> do cont> begin cont> declare :id char(5)F cont> default substring (cast (:emp+100000 as varchar(6))4 cont> from 2 for 5);H cont> if exists (select * from employees where employee_id = :id) cont> then& cont> trace 'found: ', :id;! cont> if :counter > 20 cont> then& cont> commit and chain;& cont> set :counter = 1; cont> else1 cont> s et :counter = :counter + 1; cont> end if; cont> end if; cont> end; cont> end for; cont> cont> commit; cont> end;& ~T Compile transaction (1) on db: 1* ~T Transaction Parameter Block: (len=2)! 0000 (00000) TPB$K_VERSION = 1( 0001 (00001) TPB$K_WRITE (read write)0 ~T Start_transaction (1) on db: 1, db count=1# ~T Rollback_transaction on db: 1& ~T Compile transaction (3) on db: 1+ ~T Transaction Parameter Block: (len=14)! 0000  (00000) TPB$K_VERSION = 1( 0001 (00001) TPB$K_WRITE (read write)H 0002 (00002) TPB$K_LOCK_WRITE (reserving) "EMPLOYEES" TPB$K_EXCLUSIVE0 ~T Start_transaction (3) on db: 1, db count=1 ~Xt: found: 00164 . . . ~Xt: found: 00184 ~Xt: found: 00185! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 12 ~T Restart_transaction (3) on db: 1, db count=1 ~Xt: found: 00186 . . . ~Xt: found: 00205 ~Xt: found: 002 06! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 12 ~T Restart_transaction (3) on db: 1, db count=1 ~Xt: found: 00207 . . . ~Xt: found: 00228 ~Xt: found: 00229! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 12 ~T Restart_transaction (3) on db: 1, db count=1 ~Xt: found: 00230 . . . ~Xt: found: 00249 ~Xt: found: 00267! ~T Commit_transaction on db: 1" ~T Prepare_transaction  on db: 12 ~T Restart_transaction (3) on db: 1, db count=1 ~Xt: found: 00276 . . . ~Xt: found: 00435 ~Xt: found: 00471! ~T Commit_transaction on db: 1" ~T Prepare_transaction on db: 1 SQL> ww  1 SELECT 2 General_FormD Specifies a result table. A result table is an intermediate tableC of values derived from columns and rows of one or more tables or? views that meet conditions specified by a select expressi on.> The tables or views that the columns and rows come from are2 identified in the FROM clause of the statement.= The basic element of a SELECT statement is called a selectA expression. The Select_Expressions HELP topic describes select expressions in detail.D To retrieve rows of a result table in host language programs, youD must use the DECLARE CURSOR statement or a special form of SELECTA statement called a singleton select. See the SELECT Singleton_B Select st atement for more information about a singleton select.C SQL evaluates the clauses of a SELECT statement in the following order: 1. FROM 2. WHERE 3. GROUP BY 4. HAVING 5. Select list 6. ORDER BY 7. OFFSET 8. LIMIT TO (or FETCH FIRST) 9. OPTIMIZEC After each of these clauses, SQL produces an intermediate result4 table that is used in evaluating the next clause. 3 Environment? You can use the general form of the SELEC T statement only in interactive and dynamic SQL. 3 Format select-statement = > select-expr -+->--------------------++--------------------+->< +-> for-update-clause -++-> optimize-clause -+ select-expr = . -+-+-> select-clause ------------+-+------+. | +-> ( select-expr ) -----------+ | |. | +-> TABLE table-ref ----------+ | |. +------ select-merge-clause <-------+ |. +------------------- <-------------------+L +-+----- ---------------+--+------------------+--+--------------------+->J +-> order-by-clause -+ +-> offset-clause -+ +-> limit-to-clause -+ select-merge-clause = > -+-> EXCEPT -+--------------+---+----+-------------------+-->; | +-> DISTINCT --+ | +-> CORRESPONDING --+; +-> INTERSECT -+-------------+-+ +-> NATURAL --------+" | +-> DISTINCT -+ |" +-> MINUS ---------------------+" +-> UNION --+-------------+----+ +-> ALL ------+ +-> DISTINCT -+ select-clause = G SELECT -+-------------+-> select-list -------------------------------+G +-> ALL ------+ |G +-> DISTINCT -+ |G +------------------<-------------------------------------------------+G +-> FROM -+--> table-ref --+-----------------------------------------+G +------ , <------+ |G +-- ------------------------------------------------------------------+G ++--------->-----------------------+-+------------->----------------++G +> WHERE predicate ---------------+ +> GROUP BY -+> -+|G +> value-expr ----+|G +------- ,<-------+|G +--------------------------------------<-----------------------------+H ++---------->----------+----------------------------------------------> +-> HAVING predicate -+ select-list = H -+-+----> * ------------------------------------------------------+-+->F | +-+--> value-expr --+--------------------------------------+-+-+ |F | | +-> AS -+----------------------++ | |F | | +-> edit-using-clause -+ | |F | | | |F | ++-> ------+-> . * ---------------------------+ |F | +-> -------+ |F | +-> + |F +---------------- , <----------------------------------------------+ table-ref = < --+--> --+--+-----------------------------+-->9 +--> --+ +-> correlation-name-clause --+9 +--> derived-table -+ |9 +--> joined-table -----------------------------------+  derived-table = ' ----> ( -+-> select-expr --+-> ) ----> +-> joined-table -+  joined-table = ( --+-------> qualified-join ------+----># +-------> cross-join ----------+# +-> ( --> joined-table --> ) --+  qualified-join = 9 -+-> table-ref -+-------------+--> JOIN --> table-ref -+9 | +> join-type -+ |9 | +---------------------------------------------------+C | ++-> ON predicate -------------------------------+-----------+>B | +-> USING ----> ( -+> +-> ) ------+ |B | +------ , <------+ |B +-> table-ref -> NATURAL -+-------------+-> JOIN -> table-ref -++ +> join-type -+ cross-join = 1 ---> table-ref --> CROSS JOIN --> table-ref ---> join-type = # --+-> INNER ------------------+--> +-> LEFT ---+--> OUTER -----+ +-> RIGHT --+ +-> FULL ---+  correlation-name-clause = B -> AS +------------------------------------+->@ +-> ( -+-> -+-> ) --+8 +-------- , <---------+  order-by-clause = 3 --> ORDER BY -++-> value-expr -++---------+-+-->0 |+-> ----++-> ASC --+ |0 | +-> DESC -+ |0 +------------ , <---------------+  offset-clause = - ---> OFFSET skip-expression -+-> ROW - -+-->* +-> ROWS --+ limit-to-clause = P -+> LIMIT TO -+-> limit-expression -+---------------------------+++---------++>O | | +-> OFFSET skip-expression -+|+-> ROW -+|O | | +-> SKIP skip-expression --+|+-> ROWS -+|O | +-> skip-expression , limit-expression -----------+ |O | |O +> FETCH -+> FIRST -+--+---------------------+--+----------+-> ONLY --------+> +> NEXT --+ +-> limit-expression -+ +-> ROW --+> +-> ROWS -+ for-update-clause = . --> FOR UPDATE -+-------------------------+->, +-+-> OF -+-+* +-------- , <---------+  edit-using-clause = ' --> EDIT USING -+-> edit-string ---+->% +-> -+ optimize-clause  = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B  | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  3 Arguments 4 EDIT_USING Syntax options:0 EDIT USING edit-string|EDIT USING domain-nameA Associates an edit string with a value expression. This clauseD overrides any EDIT STRING defined for the columns or variables in@ the query. This clause is only permitted for intera ctive SQL. 4 FOR_UPDATE_OFC Specifies the columns in a cursor that you or your program mightA later modify with an UPDATE statement. The column names in the@ FOR UPDATE clause must belong to a table or view named in the FROM clause.A You do not have to specify the FOR UPDATE clause of the SELECT= statement to later modify rows using the UPDATE statement:A o If you do specify a FOR UPDATE clause with column names and@ later specify columns in the UPDATE statement that are not@ in the FOR UPDATE clause, SQL issues a warning message and- proceeds with the update modifications.> o If you do specify a FOR UPDATE clause but do not specifyB any column names, you can update any column using the UPDATE1 statement. SQL does not issue any messages.? o If you do not specify a FOR UPDATE clause, you can updateC any column using the UPDATE statement. SQL does not issue any messages.A The FOR UPDATE OF cla use in a SELECT statement provides UPDATE: ONLY CURSOR semantics by locking all the rows selected. 4 OPTIMIZE_AS_query_nameC Assigns a name to the query. You can define the RDMS$DEBUG_FLAGSB logical name or use SET FLAGS with the option 'STRATEGY' to seeC the access methods used to produce the results of the query. The= following example shows how to use the OPTIMIZE AS clause: SQL> DELETE FROM EMPLOYEES E cont> WHERE EXISTS ( SELECT */ cont>  FROM SALARY_HISTORY S< cont> WHERE S.EMPLOYEE_ID = E.EMPLOYEE_ID7 cont> AND S.SALARY_AMOUNT > 75000)" cont> OPTIMIZE AS DEL_EMPLOYEE;' Leaf#01 FFirst RDB$RELATIONS Card=19 . . . ~Query Name : DEL_EMPLOYEE . . . 7 rows deleted 4 OPTIMIZE_FORA Specifies the preferred optimizer strategy for statements thatD specify a select expression. The following options are available: o  FAST FIRSTB A query optimized for FAST FIRST returns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optimization. A good candidate for FAST FIRST> optimization is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST optimization.D If the optimization level is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records inD the query, and performs updates or writes a report, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization.A The following examples illustrate the DECLARE CURSOR syntax0 for setting a preferred optimization mode:% SQL> DECLARE TEMP1 TABLE CURSOR cont> FOR cont> SELECT * cont> FROM EMPLOYEES, cont> WHERE EMPLOYEE_ID > '00400'% cont> OPTIMIZE FOR FAST FIRST; SQL> --% SQL> DECLARE TEMP2 TABLE CURSOR cont> FOR+ cont> SELECT LAST_NAME, FIRST_NAME cont> FROM EMPLOYEES% cont> ORDER BY LAST_NAME% cont> OPTIMIZE FOR TOTAL TIME; o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly: valuable for tables that use the strict partitioning functionality.D When the storage map of a table has the attribute PARTITIONING@ IS NOT UPDATABLE, the mapping of data to a storage area is> strictly enforced. This is known as strict partitioning.< When queries on such tables use sequential access, the? optimizer can eliminate partitions which do not match the9 WHERE restriction rather tha n scan every partition.D The following example shows a query that deletes selected rowsA from a specific partition. This table also includes severalC indexes, which may be chosen by the optimizer. Therefore, the/ OPTIMIZE clause forces sequential access. SQL> delete from PARTS_LOG2 cont> where parts_id between 10000 and 20000+ cont> and expire_date < :purge_date+ cont> optimize for sequential access;< Note that all access performed by such queries will beA sequential. Care should be taken that the I/O being used isA acceptable by comparing similar queries using index access. 4 OPTIMIZE_USING_outline_name@ Explicitly names the query outline to be used with the selectB expression even if the outline ID for the select expression and! for the outline are different.? The following example is the query used to create an outline named WOMENS_DEGREES:Q SQL> SELECT E.LAST_NAME, E.EMPLOYEE_I D, D.DEGREE, D.DEGREE_FIELD, D.YEAR_GIVEN6 cont> FROM EMPLOYEES E, DEGREES D WHERE E.SEX = 'F'* cont> AND E.EMPLOYEE_ID = D.EMPLOYEE_ID cont> ORDER BY LAST_NAME@ By using the OPTIMIZE USING clause and specifying the WOMENS_B DEGREES outline, you can ensure that Oracle Rdb attempts to useB the WOMENS_DEGREES outline to execute a query even if the query; is slightly different as shown in the following example:Q SQL> SELECT E.LAST_NAME, E.EMPLOYEE_ID, D.DEGREE, D.DEGREE_FI ELD, D.YEAR_GIVEN6 cont> FROM EMPLOYEES E, DEGREES D WHERE E.SEX = 'F'* cont> AND E.EMPLOYEE_ID = D.EMPLOYEE_ID cont> ORDER BY LAST_NAME cont> LIMIT TO 10 ROWS' cont> OPTIMIZE USING WOMENS_DEGREES;Q ~S: Outline WOMENS_DEGREES used <-- the query uses the WOMENS_DEGREES outline . . .N E.LAST_NAME E.EMPLOYEE_ID D.DEGREE D.DEGREE_FIELD D.YEAR_GIVENN Boyd 00244 MA Elect. Engrg. 1982N Boyd  00244 PhD Applied Math 1979N Brown 00287 BA Arts 1982N Brown 00287 MA Applied Math 1979N Clarke 00188 BA Arts 1983N Clarke 00188 MA Applied Math 1976N Clarke 00196 BA Arts 1978N Clinton 00235 MA Applied Math 1975N Clinton 00201 BA Arts 1973N Clinton 00201 MA Applied Math 1978 10 rows selectedD See the CREATE OUTLINE statement for more information on creating an outline. 4 OPTIMIZE_WITHB Selects one of three optimization controls: DEFAULT (as used by@ previous versions of Oracle Rdb), AGGRESSIVE (assumes smaller= numbers of rows will be selected), and SAMPLED (which uses= literals in the query to perform preliminary estimation on indices). 4 select-exprC See the Select_Expressions HELP topic for a detailed description of select expressions. 3 Examples( Example 1: Using the SELECT statement; The following SELECT statement returns all rows from the( EMPLOYEES table in no specific order:D SQL> SELECT LAST_NAME, FIRST_NAME, MIDDLE_INITIAL FROM EMPLOYEES;0 LAST_NAME FIRST_NAME MIDDLE_INITIAL# Toliver Alvin A# Smith Terry D& Dietrich Rick NULL& Kilpatrick Janet NULL . . . 100 rows selected = Example 2: Adding an ORDER BY clause to sort rows selectedC An ORDER BY clause added to the same SELECT statement causes SQL6 to sort the rows according to the LAST_NAME column.9 SQL> SELECT LAST_NAME, FIRST_NAME, MIDDLE_INITIAL FROM& cont> EMPLOYEES ORDER BY LAST_NAME;0 LAST_NAME FIRST_NAME MIDDLE_INITIAL# Ames Louie A# Andriola Leslie Q# Babbin Joseph Y# Bartlett Dean G& Bartlett Wes NULL . . . 100 rows selectedD Example 3: Adding a LIMIT TO clause to return a certain number of rows? The same SELECT statement with both an ORDER BY clause and a! LIMIT TO clause causes SQL to:? 1. Sort all the rows of the EMPLOYEES table according to the LAST_NAME column3 2. Return the first five rows in the ordered set9 SQL> SELECT LAST_NAME, FIRST_NAME, MIDDLE_INITIAL FROM6 cont> EMPLOYEES ORDER BY LAST_NAME LIMIT TO 5 ROWS;0 LAST_NAME FIRST_NAME MIDDLE_INITIAL# Ames Louie A# Andriola Leslie Q# Babbin Joseph Y# Bartlett Dean G& Bartlett Wes NULL 5 rows selected C Example 4: Using the optimize clause to specify an outline and a query name? The following select query uses a previously defined outlineB called WOMENS_DEGREES and also names the query. The RDMS$DEBUG_& FLAGS logical has been set to "Ss":4 SQL> SELECT E.LAST_NAME, E.EMPLOYEE_ID, D.DEGREE,% cont> D.DEGREE_FIELD, D.YEAR_GIVEN' cont> FROM EMPLOYEES E, DEGREES D cont> WHERE E.SEX = 'F'0 cont> AND E.EMPLOYEE_ID = D.EMPLOYEE_ID cont> ORDER BY LAST_NAME) cont> OPTIMIZE USING WOMENS_DEGREES' cont> AS WOMENS_DEGREES; ~Query Name : WOMENS_DEGREES" ~S: Outline WOMENS_DEGREES used Sort Cross block of 2 entries Cross block entry 1G Conjunct Get Retrieval by index of relation EMPLOYEES* Index name EMP_EMPLOYEE_ID [0:0] Cross block entry 2' Leaf#01 BgrOnly DEGREES Card=165( BgrNdx1 DEG_EMP_ID [1:1] Fan=17/ -- Rdb Generated Outline : 16-JUN-1994 11:01 create outline WOMENS_DEGREES( id 'D3A5BC351F507FED820EB704FC3F61E8' mode 0 as ( query ( subquery (@ EMPLOYEES 0 access path index EMP_EMPLOYEE_ID join by cross to; DEGREES 1 access path index DEG_EMP_ID ) ) ) compliance optional ;N E.LAST_NAME E.EMPLOYEE_ID D.DEGREE D.DEGREE_FIELD D.YEAR_GIVENN Boyd 00244 MA Elect. Engrg. 1982N Boyd 00244 PhD Applied Math 1979N Brown 00287 BA Arts 1982N Brown 00287 MA Applied Math 1979N Clarke 00188 BA Arts 1983N Clarke 00188 MA Applied Math 1976N Clarke 00196 BA Arts 1978  . . . 61 rows selected@ Example 5: Associating an Edit String with a Value Expression& SQL> CREATE DOMAIN MONEY INTEGER(2)& cont> EDIT STRING '$$$,$$$,$$9.99';< SQL> --Calculate the average salary for all current jobs. SQL> SELECT EMPLOYEE_ID,8 cont> AVG(SALARY_AMOUNT) AS AVERAGE EDIT USING MONEY,8 cont> MAX(SALARY_AMOUNT) AS MAXIMUM EDIT USING MONEY,D cont> MAX(SALARY_START) AS START_DATE EDIT USING 'YYYBDDBMMMBWWW' cont> FROM SALARY_HISTORY ! cont> WHERE SALARY_END IS NULL cont> GROUP BY EMPLOYEE_ID;> EMPLOYEE_ID AVERAGE MAXIMUM START_DATEB 00164 $51,712.00 $51,712.00 983 14 Jan FriB 00165 $11,676.00 $11,676.00 982 1 Jul ThuB 00166 $18,497.00 $18,497.00 982 7 Aug SatB 00167 $17,510.00 $17,510.00 982 21 Aug Sat . . .B 00435 $84,147.00 $84,147.00 982 12 Mar FriB ! 00471 $52,000.00 $52,000.00 982 15 Aug Sun 100 rows selected? Example 6: Using the ORDER BY Clause with a Value Expression SQL> SELECT * FROM EMPLOYEES/ cont> ORDER BY EXTRACT (YEAR FROM BIRTHDAY),. cont> TRIM(FIRST_NAME) || TRIM(LAST_NAME);2 00190 O'Sullivan Rick G.E 78 Mason Rd. NULL FremontF NH 03044 M 12-Jan-1923 1 None4 00231 Cl "airmont Rick NULLF 92 Madiso7 Drive NULL ChocoruaF NH 03817 M 23-Dec-1924 2 None2 00183 Nash Walter V.E 197 Lantern Lane NULL FremontF NH 03044 M 19-Jan-1925 1 None4 00177 Kinmonth Louis NULLB 76 Maple St. NULL EtnaF N#H 03750 M 7-Apr-1926 1 None2 00240 Johnson Bill R.E 20 South St NULL MilfordF NH 03055 M 13-Apr-1927 2 None . . .? Example 7: Using the GROUP BY Clause with a Value Expression6 SQL> SELECT COUNT (*), EXTRACT (YEAR FROM BIRTHDAY) cont> FROM EMPLOYEES/ cont> GROUP BY EXTRACT (YEAR FROM BIRTHDAY); 1 $ 1923 1 1924 1 1925 1 1926 4 1927 2 1928 1 1930 2 1931 . . .? Example 8: Performing an Outer Join with Oracle Server Style Syntax. SQL> SELECT EMPLOYEES.EMPLOYEE_ID, JOB_CODE$ cont> FROM EMPLOYEES, CURRENT_JOBA cont> WHERE EMPLOYEES.EMPLOYEE_ID= CURRENT_JOB.EMPLOYEE_ID(+);%0 EMPLOYEES.EMPLOYEE_ID CURRENT_JOB.JOB_CODE 00164 DMGR 00165 ASCK 00166 DMGR 00167 APGM 00168 DMGR 00169 SPGM 00170 SCTR 00171 PRGM . . . 2 Singleton_SelectD Specifies a result table. A result table is an intermediate tableC of values derived from columns and rows of one or m &ore tables or? views that meet conditions specified by a select expression.> The tables or views that the columns and rows come from are2 identified in the FROM clause of the statement.= The basic element of a SELECT statement is called a selectA expression. The Select_Expressions HELP topic describes select expressions in detail.@ To retrieve rows of a result table in host language programs,A you must use the DECLARE CURSOR statement or a special form ofA SELECT 'statement called a singleton select. A singleton select@ statement specifies a one-row result table, and is allowed inB either precompiled programs or as part of a procedure in an SQLB module. A singleton select includes an additional clause, INTO,B to assign the values in the row to host language variables in a program.C For information on the general form of the SELECT statement, see% the SELECT General_Form statement. 3 Environment, You can use a singleton sel(ect statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 3 Format singleton-select = * SELECT -+-------------+-> select-list --+* +-> ALL ------+ |* +-> DISTINCT -+ |* +-------------------------------------+% +-> into-target -----------------+% +------------------ )--------------+# +> FROM -+--> table-ref -----+-+# +---------- , <-----+ |# +------------------------------+9 +> WHERE predicate -+------------->-----------------++9 +-> GROUP BY -+> ++|9 +------- , <-----+ |9 +--------------------------<-------------------------+9 ++--------------------+-+-----------------------+----+9 +> HAVING predicate -+ +-> limit-to-clause ----+ |9 +----------*------------------------------------------+; +-+---------------------+-+---------------------+------>4 +> for-update-clause -+ +-> optimize-clause --+ into-target =/ ----> INTO --+-+-> -----------++->- | +-> -+|- | +-> ------------+|- +------------- , <------------+  for-update-clause = . --> FOR UPDATE -+-------------------------+->, +-+-> OF -+-++* +-------- , <---------+  optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B , | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  3 Arguments 4 INTO Syntax options: INTO parameter INTO qualified-parameter INTO variable7 Specifies a list of parameters, qualified parameters@ (structures), or variables to receive v -alues from the columnsB of the one-row result table. The variables named must have been@ declared in the host program. If a variable named in the listA is a host structure, SQL considers the reference the same as a; reference to each of the elements of the host structure.@ If the number of variables specified, either explicitly or by> reference to a host structure, does not match the number of@ values in the row of the result table, SQL generates an errorC when it precompil.es the program or compiles the SQL module file.A If columns in the result table from a singleton select includeC null values, the corresponding parameters must include indicator parameters. 4 select-list@ For a description of select lists, see the Select_Expressions HELP topic. wwȔ1 SET@ Changes the characteristics of SQL terminal sessions. You can control the:3 o Currency indicator to be displayed for output: o Display /format for date values, time values, or both. o Default path name in the data dictionary0 o Digit separator to be displayed for outputD o Number of statements to be included in the editing buffer when you type EDIT *@ o Language to be used for month abbreviations, and so on, in% date and time input and display0 o Length of lines to be displayed for output" o Page length for HELP display+ o File in which the session is recordedD o Number o0f rows output, the number of seconds allowed per queryC compilation and execution, or the amount of CPU time expended. for each query compilation and execution9 o Character used to display the radix point in output/ o Display of statements from a command file; o Display of warning messages about deprecated features: o Display of warning messages about nonstandard syntax o Continue character 2 Environment< You can use these SET statements in int1eractive SQL only. 2 Format = SET +> CURRENCY SIGN currency-char ----------------------+->; +> set-date-format ----------------------------------+; +> CONTINUE CHARACTER continue-char -----------------+; |> DICTIONARY --> -----------------------+; +> DIGIT SEPARATOR digit-sep-char -------------------+; +> set-edit -----------------------------------------+; +> EXECUTE ------------------------------------------+; +> NOEXECUTE -------- 2--------------------------------+; +> LANGUAGE language-name ---------------------------+; +> LINE LENGTH --> ------------------------------+; +> set-output ---------------------------------------+; +> PAGE LENGTH ----------------------------------+; +> RADIX POINT radix-char ---------------------------+; +> VERIFY -------------------------------------------+; +> NOVERIFY -----------------------------------------+; +> set-warning ----------------3----------------------+; +> set-flagger --------------------------------------+; +> sql-plus-options ---------------------------------+  set-date-format= E ----> DATE FORMAT +> DATE +-----------------------++->C | +> , TIME +|C +> TIME +-----------------------++B +> , DATE + set-edit= $ --> EDIT ---+--4> KEEP ---> +-->! +--> NOKEEP -------+! +--> PURGE --------+ set-output= I --+--> LOGFILE --+------------------------+-----> quoted-filespec -+--->E | +-> (logfile-options) ---+ |E +--> OUTPUT ----+-----------------+------------------------------+E | +--> -+ |E +--> NOLOGFILE --------------------------------------------------+E +--> NOOUTPUT ---5------------------------------------------------+ logfile-options =  --+-> ECHO ---------+--> +-> NOECHO --------+ set-warning= ( ----> WARNING -+-> DEPRECATE ---+----->" +-> NODEPRECATE -+  set-flagger = 4 ---> FLAGGER --+-> ON ------------------------+-+->2 +-> SQL89 --------+-+--------+-+ |2 +-> SQL92_ENTRY --+ +-> ON --+ |2 +-> MIA ----------+ +-> OFF -+ |2 +-> OFF 6-------------------------+  sql-plus-options = , -+-> ECHO -----+-+-> ON --+------------+->* +-> HEADING -+ +-> OFF -+ |* +-> TIMING --+ |* +-> FEEDBACK -+-> ON ---------------+-+* | +-> OFF --------------+ |* | +-> numeric-literal --+ |* +-> LINESIZE -+-> numeric-literal ----+* +-> PAGESIZE -+ |* +-> NULL -+------------------+--------+! +> literal-string -+ !72 Arguments 3 ALIAS5 For information on SET ALIAS, type HELP SET_ALIAS. 3 ALL_CONSTRAINTS= For information on SET ALL CONSTRAINTS, type HELP SET_ALL_ CONSTRAINTS. 3 ANSI3 For information on SET ANSI, type HELP SET_ANSI. 3 CATALOG9 For information on SET CATALOG, type HELP SET_CATALOG. 3 CHARACTER_LENGTHD For information on SET CHARACTER LENGTH, type HELP SET_CHARACTER_ LENGTH. 3 CONNECT9 For information on SE8T CONNECT, type HELP SET_CONNECT. 3 Control9 For information on SET Control, type HELP SET_Control. 3 CONTINUE_CHARACTER= Defines the continuation character for interactive SQL. By? selecting a seldom used character the database administrator? can avoid problems with the minus sign to use a continuation character in scripts. 3 CURRENCY_SIGN> Specifies the currency indicator to be displayed in output.C (SQL produces currency indicators in output9 when you specify theB dollar sign ($) edit string for the column. See the DATATRIEVE4 HELP topic for more information on edit strings.)? If you do not specify an alternate character, the default isD either the dollar sign ($) or the value specified by the logical name SYS$CURRENCY. 3 DATE_date_number0 Specifies the display format for date values.D You must enter a number for the date-number argument. This numberD corresponds to numbers in the date format l :ogical names listed in8 tables in the OpenVMS run-time library documentation.B For example, LIB$DATE_FORMAT_006 is one of the logical names in@ the table. The logical name specifies the format in which theA eighth day of May in the year 1957 would be displayed as 8 MayB 57. Note that the latter part of the logical name is the number 006.B If you wanted to specify the 8 May 57 format using the SET DATED FORMAT statement, you would use the numeric part of the LIB$DATE_C ; FORMAT_006 logical name, 6. You do not have to enter any leading$ zeros that the number might have.C If you do not specify a date format, the default is dd-mmm-yyyy. 3 DATE_FORMATD Specifies the display format for either date values, time values, or both.= You must specify a numeric argument with the DATE and TIMEC portions of the SET DATE FORMAT statement. This numeric argumentA is the same as the numeric portion of certain OpenVMS Run-TimeB Library forma <ts. The formats are documented in the OpenVMS run-C time library documentation. (This statement only accepts numbers@ that reference OpenVMS format date and time logical names; it; does not support the ANSI/ISO date and time data types.)? The SET DATE FORMAT DATE and SET DATE FORMAT TIME statementsC change only the output for the date or time formats. If you wantA to change the input format, use the logical name LIB$DT_INPUT_A FORMAT. You must run the command procedure SYS$ =MANAGER:LIB$DT_A STARTUP.COM before using any of the run-time library date-timeC routines for input or output formats other than the default. TheC LIB$DT_STARTUP.COM procedure also defines spellings for date andA time elements in languages other than English. See the OpenVMSA run-time library documentation for more information on LIB$DT_ INPUT_FORMAT. 3 DEFAULT_CHARACTER_SET? For information on SET DEFAULT CHARACTER SET, type HELP SET_ DEFAULT_CHARACTER_SET.> 3 DEFAULT_DATE_FORMAT= For information on SET DEFAULT DATE FORMAT, type HELP SET_ DEFAULT_DATE_FORMAT. 3 DIALECT9 For information on SET DIALECT, type HELP SET_DIALECT. 3 DICTIONARYA Changes your default repository path name to the path name you specify. 3 DIGIT_SEPARATOR; Changes the output displaying the digit separator to the> specified character. The digit separator is the symbol thatC separates groups of three digits in val ?ues greater than 999. ForA example, the comma is the digit separator in the number 1,000.@ (SQL produces digit separators in output when you specify theA comma (,) edit string for the column. See the DATATRIEVE HELP/ topic for more information on edit strings.)= You must enclose the digit-sep-char argument within single quotation marks.? If you do not specify an alternate character, the default isC either the comma (,) or the value specified by the logical name@ SYS$DIGIT_SEP. 3 EDITC Controls the size of the editing buffer that you create when you: use the EDIT statement with a wildcard as the argument. o SET EDIT KEEP n? Tells SQL to save the previous n statements. For example,C assume you have specified SET EDIT KEEP 5. When you type EDIT? *, SQL places the previous five statements in the editing> buffer. The number you specify with SET EDIT KEEP is the? maximum number of statements you canA recall with the EDIT# statement. The default is 20. o SET EDIT NOKEEPA This statement is equivalent to SET EDIT KEEP 0. If you useB this form of the statement and you type EDIT or EDIT *, yourD editing buffer will be empty. This form of the statement saves@ system resources when you are running command files rather" than an interactive process. o SET EDIT PURGE@ This statement retains the value of the KEEP parameter butA purges allB previous statements. As with SET EDIT NOKEEP, ifC you use the SET EDIT PURGE statement and then EDIT or EDIT *,C your editing buffer will be empty. Unlike the SET EDIT NOKEEPA statement, however, SET EDIT PURGE causes SQL to accumulateC subsequent statements to place in the editing buffer when you= issue EDIT statements later in the interactive session. 3 execute-clause Syntax options: EXECUTE NOEXECUTE NO EXECUTED Instr Cucts SQL whether to execute the data manipulation statements+ you issue in an interactive SQL session.; You can use the NOEXECUTE option in conjunction with the> SET FLAGS to examine the estimated cost and access strategy= associated with a query. If you specify SET NOEXECUTE, SQLB displays the access strategies without executing the query. SQLA also allows you to specify NO EXECUTE (as two words); this has! the same meaning as NOEXECUTE.= If you do not specify EXECUTED or NOEXECUTE, the default is EXECUTE.D The SET TRANSACTION statement is not executed when SET NO EXECUTEB is active. Start or declare a transaction prior to using SET NO EXECUTE. 3 FLAGGER_OFF> Disables all previously set flaggers indicating nonstandard syntax. This is the default. 3 FLAGGER Syntax options: FLAGGER ON FLAGGER SQL89 FLAGGER SQL92_ENTRY FLAGGER MIA> Controls the output of informational messages tha Et indicateC nonstandard syntax, that is, extensions to the ANSI/ISO standard% syntax or the MIA standard syntax.A If you specify SET FLAGGER ON, which is the same as specifying= SET FLAGGER SQL92_ENTRY ON, SQL sends you an informationalC message if you issue a subsequent interactive SQL statement thatA contains syntax that is an extension to the ANSI/ISO standard.D If you specify SET FLAGGER MIA ON, SQL sends you an informationalC message if you issue a subsequent intFeractive SQL statement that< contains syntax that is an extension to the MIA standard.D The flaggers are independent of each other and any combination of# flaggers can be set at one time.D The default is FLAGGER OFF if you do not explicitly set a flagger on. 3 FLAGS5 For information on SET FLAGS, type HELP SET_FLAGS. 3 HOLD_CURSORSC For information on SET HOLD CURSORS, type HELP SET_HOLD_CURSORS. 3 IDENTIFIER_CHARACTER_SETB For informatiGon on SET IDENTIFIER CHARACTER SET, type HELP SET_ IDENTIFIER_CHARACTER_SET. 3 KEYWORD_RULES? For information on SET KEYWORD RULES, type HELP SET_KEYWORD_ RULES. 3 FEEDBACK> SET FEEDBACK ON is a synonym for the SQL SET DISPLAY NO ROW> COUNTER statement. SQL data manipulation statements such as@ SELECT, DELETE, UPDATE, and INSERT will display the number ofB affected rows. SET FEEDBACK n sets a limit value which turns onB feedback only if more than 'n' roHws are displayed. SET FEEDBACK> 0 is synonymous with SET FEEDBACK ON. SET FEEDBACK OFF is aB synonym for the SQL SET DISPLAY ROW COUNTER statement. SQL dataB manipulation statements no longer display the count of affected rows. SQL> set feedback 2" SQL> select * from work_status;+ STATUS_CODE STATUS_NAME STATUS_TYPE. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2 ACTIVE PART TIME 3 rows selectedI SQL> set feedback 4" SQL> select * from work_status;+ STATUS_CODE STATUS_NAME STATUS_TYPE. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2 ACTIVE PART TIME 3 LANGUAGE= Specifies the language to be used for translation of monthB names and abbreviations in date and time input and display. TheB language-name argument also determines the translation of other@ language-dependent text, such as the tr Janslation for the date+ literals YESTERDAY, TODAY, and TOMORROW.@ If you do not specify a language, the default is the language= specified by the logical name SYS$LANGUAGE. If you requireA different language spellings, you must define the logical name> SYS$LANGUAGES in addition to SYS$LANGUAGE. You must run theB command procedure SYS$MANAGER:LIB$DT_STARTUP.COM after defining SYS$LANGUAGES. For example:1 $ DEFINE SYS$LANGUAGES FRENCH, GERMAN, SPANISH' $ RUN SYS$MANAGKER:LIB$DT_STARTUP.COM $ SHOW LOGICAL SYS$LANGUAGES3 "SYS$LANGUAGES" = "FRENCH" (LNM$SYSTEM_TABLE) = "GERMAN" = "SPANISH" $ SHOW LOGICAL SYS$LANGUAGE2 "SYS$LANGUAGE" = "ENGLISH" (LNM$SYSTEM_TABLE)? If you do not define SYS$LANGUAGES, all translation routines7 default to English. See the OpenVMS run-time library< documentation for more information on LIB$DT_STARTUP.COM.; The SET LANGUAGE statement does not affect the collating< sequencLes used for sorting and comparing data. The CREATE= COLLATING SEQUENCE statement specifies alternate collating sequences. 3 LINE_LENGTH_n___LINESIZE_n5 Specifies an alternate line length for SQL output.> You must enter a number n to designate the line length. The1 number n can be any number up to 65535 octets.A You can use the SET LINE LENGTH (or SET LINESIZE) statement toB specify an alternate width for output that you are sending to a) file or to an alterMnate output device. 3 LITERAL_CHARACTER_SET? For information on SET LITERAL CHARACTER SET, type HELP SET_ LITERAL_CHARACTER_SET. 3 LOGFILE_quoted_filespecC This statement allows the executing SQL script to save output to an OpenVMS file.? Output from interactive SQL will be written to the file-spec? specified. If the "ECHO" logfile-option is used, in addition= to writing the output to the designated file, all commands> and errors generated by intNeractive SQL are also written to@ SYS$OUTPUT. If the "NOECHO" logfile-option is used, output to? SYS$OUTPUT is disabled. All commands and errors generated by7 interactive SQL are only written to the output file.? The SET LOGFILE is functionally equivalent to the SET OUTPUT statement.C A SET LOGFILE command that does not specify a file is equivalent to SET NOLOGFILE. 3 NAMES5 For information on SET NAMES, type HELP SET_NAMES. 3 NATIONAL_CHARACTER_SEOT@ For information on SET NATIONAL CHARACTER SET, type HELP SET_ NATIONAL_CHARACTER_SET. 3 NOLOGFILEB Closes the current output file specified by a prior SET LOGFILE (or SET OUTPUT command). 3 NOOUTPUT' Suspends writing to the output file. 3 NOVERIFYB Does not display indirect command files. The default setting is@ the setting currently in effect for DCL commands. If you haveC not explicitly changed the DCL setting to VERIFY, the default iPs NOVERIFY. 3 OPTIMIZATION_LEVEL< For information on SET OPTIMIZATION LEVEL, type HELP SET_ OPTIMIZATION_LEVEL. 3 OUTPUT_file_specB Names the target file for output. The default file extension is .lis.@ If you specify OUTPUT with a file name, SQL writes its output= to a log file that you specify. The log file contains both? statements and results. If you issue a SET OUTPUT statement,A output is also written to standard output which is usually th Qe terminal.B If you specify OUTPUT without a file name, SQL suspends writing= output to a log file, if any, and writes the output to theD standard output. In other words, the SET OUTPUT statement without; a file name is equivalent to the SET NOOUTPUT statement.? SQL displays certain items (such as the headings produced byC the SHOW statement) in boldface type on your terminal screen. InB log files, however, the boldface items are surrounded by escape@ characters. YRou can ignore these escape characters, edit themB out of your log file, or set your terminal so that SQL does not' display characters in boldface type.@ If you disable boldface type using the following DCL command,4 your log file will not contain escape characters: $ SET TERM/NOANSI_CRT 3 PAGE_LENGTH_n___PAGESIZE_n' Sets the size of a page in SQL help.= The following notes apply to the PAGE LENGTH (or PAGESIZE) clause:= o The integer value must be a Svalue between 10 and 32767.B o SET PAGE LENGTH (or SET PAGESIZE) can be used to effectivelyC disable the paging performed by help by setting the length to! a high value such as 32000.D o The page length is automatically set upon entry to interactive? SQL and is based on the OpenVMS terminal setting for this session.@ o The SHOW DISPLAY command can be used to view the currently defined page length. 3 QUOTING_RULES? For information on SETT QUOTING RULES, type HELP SET_QUOTING_ RULES. 3 RADIX_POINTA Changes the output displaying the radix point to the specified@ character. The radix point is the symbol that separates units? from decimal fractions. For example, in the number 98.6, the period is the radix point.C You must enclose the radix-char argument within single quotation marks.? If you do not specify an alternate character, the default isD either the period (.) or the value speciUfied by the logical name SYS$RADIX_POINT. 3 SCHEMA7 For information on SET SCHEMA, type HELP SET_SCHEMA. 3 sql-plus-optionsC These statements are provided for use with SQL*Plus scripts that are run against Oracle Rdb.. Table 1-5 Supported SQL*Plus SET statements9 SQL*Plus command Equivalent Oracle Rdb statement$ SET ECHO ON SET VERIFY& SET ECHO OFF SET NOVERIFY2 SET HEADING ON SET DISPLAY QUERY HEADER5 SVET HEADING OFF SET DISPLAY NO QUERY HEADER1 SET FEEDBACK ON SET DISPLAY ROW COUNTER4 SET FEEDBACK OFF SET DISPLAY NO ROW COUNTER9 SET NULL SET DISPLAY DEFAULT NULL STRING; SET NULL 'literal' SET DISPLAY NULL STRING 'literal' 3 TIME_time_number0 Specifies the display format for time values.D You must enter a number for the time-number argument. This numberD corresponds to numbers in the time-format logical names listed in8 t Wables in the OpenVMS run-time library documentation.3 For example, the table contains the logical name@ LIB$TIME_FORMAT_020. The logical name specifies the format inD which the eighth hour, fourth minute, and thirty-second second ofC a day would be displayed as 8 h 4 min 32 s. Note that the latter. part of the logical name is the number 020.A If you wanted to specify the 8 h 4 min 32 s format for the SQLA SET DATE FORMAT TIME statement, you would use the numeric partB oXf the LIB$TIME_FORMAT_020 logical name, 20. You do not have to6 enter any leading zeros that the number might have.C If you do not specify a time format, the default is hh:mm:ss.cc. 3 TIMINGD The SET TIMING statement enables a single line report of used CPUA and Elapsed time for each successful SQL statement or command. SQL> start transaction; SQL> set timing on; SQL> select count(*) cont> from employees8 cont> inner join job_history using (employYee_id); cont> inner join salary_history using (employee_id)< cont> inner join departments using (department_code). cont> inner join jobs using (job_code)9 cont> left outer join resumes using (employee_id)9 cont> left outer join degrees using (employee_id); cont> left outer join colleges using (college_code) cont> cont> ; 3871 1 row selected: Timing: Elapsed: 0 00:00:00.82 Cpu: 0 00:00:00.16 SQL> set timing offZ; SQL> commit; 3 TRANSACTIONA For information on SET TRANSACTION, type HELP SET_TRANSACTION. 3 VERIFYD Displays indirect command files at your terminal as you run them. 3 VIEW_UPDATE_RULES@ For information on SET VIEW UPDATE RULES, type HELP SET_VIEW_ UPDATE_RULES. 3 WARNING Syntax options: WARNING DEPRECATE WARNING NODEPRECATE? Specifies whether or not interactive SQL displays diagnostic= messages when you iss [ue statements containing obsolete SQLC syntax. Deprecated or obsolete syntax is syntax that was allowed? in previous versions of SQL but has been changed. Oracle RdbA recommends that you avoid using such syntax because it may not> be supported in future versions. By default, SQL displays aA warning message after any statement containing obsolete syntax (SET WARNING DEPRECATE).C If you specify SET WARNING NODEPRECATE, SQL does not display any" messages about obsolete s\yntax. 2 Examples@ Example 1: Using the SET statement to set up terminal session characteristics9 Using the SET statement as follows, you can set up the, characteristics of your terminal session: SQL> --L SQL> -- You can put the SET statements in your sqlini file, which sets up SQL> -- your SQL session. SQL> -- SQL> SET OUTPUT 'LOG.LIS'& SQL> SET DICTIONARY 'CDD$TOP.DEPT3' SQL> SET EDIT KEEP 10 SQL> --/ SQL> ATTACH 'ALIAS PERS FILENAME person]nel'; SQL> SHOW ALIAS Alias PERS:% Rdb database in file personnel SQL> EXIT6 In the preceding example, the statements set up the characteristics, as follows:A o The SET OUTPUT statement opens a file called LOG.LIS in theB current default path name. From this point on, all the input@ and output, including error messages, appear in this file.A The following example shows what is written to the log file LOG.LIS:$ SET DICTIONARY 'CDD$^TOP.DEPT3' SET EDIT KEEP 10 --- ATTACH 'ALIAS PERS FILENAME personnel'; SHOW ALIAS Alias PERS:( Rdb database in file personnel EXITA o The SET DICTIONARY statement changes the default repository path name.? o The SET EDIT KEEP statement specifies that you get the 10B previous statements in the editing buffer when you type EDIT *.A o The ATTACH statement attaches to the personnel database and0 declares t_he alias PERS for that database.< o The SHOW ALIAS statements tell the user which alias is declared.B Example 2: SET CURRENCY SIGN and SET DIGIT SEPARATOR statements? The following example uses the SET DIGIT SEPARATOR statement> to show the behavior of the SET CURRENCY SIGN and SET DIGIT4 SEPARATOR statements when used with edit strings: SQL> --8 SQL> -- This example shows the edit string 'ZZZ,ZZZ',D SQL> -- which specifies the comma as the default digit sepa`rator. SQL> --$ SQL> ALTER TABLE SALARY_HISTORY -3 cont> ALTER SALARY_AMOUNT EDIT STRING 'ZZZ,ZZZ';1 SQL> SELECT SALARY_AMOUNT FROM SALARY_HISTORY; SALARY_AMOUNT 26,291 51,712 26,291 50,000 . . . SQL> --D SQL> -- Now use the SET DIGIT SEPARATOR statement to specify that< SQL> -- the period will be the digit separator instead of SQL> -- the comma. SQL> -- SQL> SET DIGIT SEaPARATOR '.'1 SQL> SELECT SALARY_AMOUNT FROM SALARY_HISTORY; SALARY_AMOUNT 26.291 51.712 26.291 50.000 . . .@ Example 3: Using the internationalization features of the SET statementD The following example shows how to use the various SET statements) to internationalize your applications: SQL> --9 SQL> -- This first statement specifies the dollar sign; SQL> -- as the currency indicator. bIt does this by using% SQL> -- the edit string '$(9).99'. SQL> --$ SQL> ALTER TABLE SALARY_HISTORY -3 cont> ALTER SALARY_AMOUNT EDIT STRING '$(9).99';2 cont> SELECT SALARY_AMOUNT FROM SALARY_HISTORY; SALARY_AMOUNT $26291.00 $51712.00 $26291.00 $50000.00 . . . SQL> --> SQL> -- The SET CURRENCY statement now changes the currency: SQL> -- indicator to the British pound sign, . Notice SQL> c-- the changed output. SQL> -- SQL> SET CURRENCY SIGN ''1 SQL> SELECT SALARY_AMOUNT FROM SALARY_HISTORY; SALARY_AMOUNT 26291.00 51712.00 26291.00 50000.00 11676.00 . . . SQL> --@ SQL> -- The next examples show the SET DATE FORMAT statement. SQL> --@ SQL> -- The SET DATE FORMAT statement will not override inputB SQL> -- and output formats that you have specified with an editB d SQL> -- string. The following SET DATE FORMAT examples use theA SQL> -- SALARY_START and SALARY_END columns. The SALARY_START; SQL> -- and SALARY_END columns are defined by the domain= SQL> -- DATE_DOM, which uses the edit string 'DD-MMM-YYY'.@ SQL> -- Thus, to test the SET DATE FORMAT statement, you must@ SQL> -- first remove the edit string from the DATE_DOM domain6 SQL> -- using the following ALTER DOMAIN statement: SQL> --- SQL> ALTER DOMAIN DATE_DOM NO EDIT STRINGe; SQL> --B SQL> -- The next statement inserts a row with time information.G SQL> -- The subsequent SET DATE FORMAT statements will use this row: SQL> --" SQL> INSERT INTO SALARY_HISTORY cont> -- list of columns: cont> (EMPLOYEE_ID, cont> SALARY_AMOUNT, cont> SALARY_START, cont> SALARY_END) cont> VALUES cont> -- list of values: cont> ('88339', cont> '22550',# cont> '14-NOV-1967 08:30:00.00',# cont> '25-NOV-1988 16:30:00.00') cont> ; f 1 row inserted SQL> --H SQL> -- Using the row that was just inserted, the following statement2 SQL> -- shows the default date and time output: SQL> --< SQL> SELECT SALARY_START, SALARY_END FROM SALARY_HISTORY-% cont> WHERE EMPLOYEE_ID = '88339';) SALARY_START SALARY_END5 14-NOV-1967 08:30:00.00 25-NOV-1988 16:30:00.00 1 row selected SQL> --< SQL> -- The SET DATE FORMAT DATE statement customizes the% SQL> -- output of the date format.g SQL> --- SQL> -- The output will appear in the formA SQL> -- 14 NOV 67, as specified by the date-number argument 6. SQL> -- SQL> SET DATE FORMAT DATE 6;< SQL> SELECT SALARY_START, SALARY_END FROM SALARY_HISTORY-% cont> WHERE EMPLOYEE_ID = '88339'; SALARY_START SALARY_END 14 NOV 67 25 NOV 88 1 row selected SQL> --8 SQL> -- The SET DATE FORMAT TIME statement customizesA SQL> -- the output of the time format. The output will appear; SQL> h-- in the form 16 h 30 min 0 s, as specified by the# SQL> -- time-number argument 20. SQL> -- SQL> SET DATE FORMAT TIME 20;< SQL> SELECT SALARY_START, SALARY_END FROM SALARY_HISTORY-% cont> WHERE EMPLOYEE_ID = '88339';! SALARY_START SALARY_END& 8 h 30 min 0 s 16 h 30 min 0 s 1 row selected SQL> --: SQL> -- Note that the previous date example has deleted= SQL> -- the time output, and the previous time example has# SQL> -- deleted the date outputi. SQL> --6 SQL> -- If you want the display to continue to show/ SQL> -- BOTH date and time, you must specify6 SQL> -- both arguments with the SET DATE statement. SQL> --( SQL> SET DATE FORMAT DATE 6, TIME 20;= SQL> SELECT SALARY_START, SALARY_END FROM SALARY_HISTORY-% cont> WHERE EMPLOYEE_ID = '88339';+ SALARY_START SALARY_END: 14 NOV 67 8 h 30 min 0 s 25 NOV 88 16 h 30 min 0 s 1 row selected SQL> --G SQL> -- The next example chanjges the digit separator to a period and& SQL> -- the radix point to a comma: SQL> --$ SQL> ALTER TABLE SALARY_HISTORY -6 cont> ALTER SALARY_AMOUNT EDIT STRING 'ZZZ,ZZZ.ZZ'; SQL> -- SQL> SET RADIX POINT ',' SQL> SET DIGIT SEPARATOR '.'1 SQL> SELECT SALARY_AMOUNT FROM SALARY_HISTORY; SALARY_AMOUNT 26.291,00 51.712,00 26.291,00 50.000,00 . . . SQL> --> SQL> -- This example shows how yoku can use the SET LANGUAGEB SQL> -- statement to change the output of dates to a particularC SQL> -- language. This example shows the default English first, SQL> -- followed by French. SQL> --6 SQL> -- Note that the time format is still based on- SQL> -- the SET DATE FORMAT TIME statement/ SQL> -- previously executed in this example. SQL> --0 SQL> SELECT SALARY_START FROM SALARY_HISTORY; SALARY_START 5 JUL 80 0 h 0 min 0 s 14 JAN 83 0 h 0 min 0 s l 2 MAR 81 0 h 0 min 0 s 21 SEP 81 0 h 0 min 0 s 3 NOV 81 0 h 0 min 0 s 1 JUL 82 0 h 0 min 0 s 27 JAN 81 0 h 0 min 0 s 1 JUL 75 0 h 0 min 0 s 29 DEC 78 0 h 0 min 0 s 2 FEB 80 0 h 0 min 0 s 8 APR 79 0 h 0 min 0 s 19 AUG 77 0 h 0 min 0 s . . . SQL> -- SQL> SET LANGUAGE FRENCH0 SQL> SELECT SALARY_START FROM SALARY_HISTORY; SALARY_START 5 jul 80 0 h 0 min 0 s 14 jan 83 0 h 0 min 0 ms 2 mar 81 0 h 0 min 0 s 21 sep 81 0 h 0 min 0 s 3 nov 81 0 h 0 min 0 s 1 jul 82 0 h 0 min 0 s 27 jan 81 0 h 0 min 0 s 1 jul 75 0 h 0 min 0 s 29 dc 78 0 h 0 min 0 s 2 fv 80 0 h 0 min 0 s 8 avr 79 0 h 0 min 0 s 19 ao 77 0 h 0 min 0 s . . . SQL> --? Example 4: Using the SET statement to receive messages about= syntax that contains extensions to the ANSI/ISO SQL or MIA standardsB n This example shows the output when flagging is turned on, first$ for SQL92_ENTRY and then for MIA.F SQL> -- Flagging is off by default. When you enter a statement thatD SQL> -- uses the data type VARCHAR, SQL does not issue a message. SQL> -- SQL> SHOW FLAGGER MODE; The flagger mode is OFF4 SQL> CREATE TABLE TEST1 (TEXT_COL VARCHAR (100)); SQL> --D SQL> -- When you set the flagger to SQL92_ENTRY, SQL generates anI SQL> -- error message because VARCHAR is an extenosion to the standard. SQL> --" SQL> SET FLAGGER SQL92_ENTRY ON4 SQL> CREATE TABLE TEST2 (TEXT_COL VARCHAR (100));* %SQL-I-NONSTADTP, Nonstandard data type SQL> --H SQL> -- With the flagger set to SQL92_ENTRY, SQL does not generate anI SQL> -- error message for the data type CHAR because it is an ANSI/ISO SQL> -- standard data type. SQL> --+ SQL> CREATE TABLE TEST3 (TEXT_COL CHAR); SQL> --F SQL> -- However, when you set the flagger to MIA, SQL generates twoH p SQL> -- error messages because data definition is not part of the MIAD SQL> -- standard. The first error message is caused by the CREATEE SQL> -- keyword; the second is caused by trying to create a table. SQL> --G SQL> -- (Note that the SET FLAGGER statement itself is nonstandard.) SQL> -- SQL> SET FLAGGER MIA ON' %SQL-I-NONSTASYN, Nonstandard syntax+ SQL> CREATE TABLE TEST3 (TEXT_COL CHAR);' %SQL-I-NONSTASYN, Nonstandard syntax' %SQL-I-NONSTASYN, Nonstandard sqyntax SQL>B Example 5: Using the SET statement to check for obsolete syntaxD This example shows the output from an obsolete SQL statement when@ the user specifies WARNING DEPRECATE, and the output from the> same statement when the user specifies WARNING NODEPRECATE. SQL> --O SQL> -- By default, SQL sends warning messages when you use obsolete syntax. SQL> --* SQL> DECLARE SCHEMA FILENAME personnel;B %SQL-I-DEPR_FEATURE, Deprecated Feature: SCHEMA (meaning ALIArS) SQL> DISCONNECT ALL; SQL> --Q SQL> -- When you specify SET WARNING NODEPRECATE, SQL does not display warning SQL> -- messages. SQL> -- SQL> SET WARNING NODEPRECATE;* SQL> DECLARE SCHEMA FILENAME personnel; SQL> DISCONNECT ALL;! Example 6: Setting page lengthC The following example uses the SET PAGE LENGTH command to change! the pagination length of HELP. SQL> set page length 40; SQL> show display( Output of the query header is enabled's Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 40 lines! Line length is set to 80 bytes# Display NULL values using "NULL"- Example 7: Saving the output from a scriptA The following example shows the use of SET LOGFILE to save the4 output from a script without echoing the results. 1. The script being executed. set verify;" start transaction read only;, set logfile (noecho) 'saved_date.log';t) select rdb$flags from rdb$database; set nologfile; show alias; rollback;< 2. The output as seen during the Interactive SQL session.' SQL> start transaction read only; SQL>1 SQL> set logfile (noecho) 'saved_date.log'; SQL> SQL> show alias; Default alias:2 Oracle Rdb database in file SQL$DATABASE SQL> rollback;' 3. The output saved in the log file. SQL>. SQL> select rdb$flags from rdb$duatabase; RDB$FLAGS 0 1 row selected SQL> SQL> set nologfile; wwN@ 1 SET_ALIAS9 Specifies the default alias for an SQL user session in= dynamically prepared and executed or interactive SQL until? another SET ALIAS statement is issued. If you do not specify) an alias, the default is RDB$DBHANDLE. 2 Environment' You can use the SET ALIAS statement: o In interactive SQL: o Embedded in hovst language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format. SET ALIAS ---+-> --+->, +-> -------+, +-> +  2 Arguments 3 alias-parameterD Specifies a host language variable in precompiled SQL or a formalC parameter in an SQL module language procedure that specifies thwe default alias. 3 alias-parameter-markerD Specifies a parameter marker (?) in a dynamic SQL statement. TheB alias parameter marker refers to a parameter that specifies the default alias. 3 alias-string-literalB Specifies a character string literal that specifies the default= alias. The alias string literal must be enclosed in single quotation marks. 2 Examples@ Example 1: Setting a default alias to avoid qualifying object names4x SQL> ATTACH 'ALIAS CORP FILENAME corporate_data';% SQL> SET CATALOG 'ADMINISTRATION'; SQL> SET SCHEMA 'PERSONNEL';( SQL> SELECT LAST_NAME FROM EMPLOYEES;/ %SQL-F-NODEFDB, There is no default database SQL> --N SQL> -- You must qualify the table name because you attached with an alias. SQL> --- SQL> SELECT LAST_NAME FROM CORP.EMPLOYEES; LAST_NAME Ames Andriola Babbin . . . 100 rows selected SQL> SET ALIAS 'CORP'; y SQL> --C SQL> -- Now you do not need to qualify the table name EMPLOYEES. SQL> --( SQL> SELECT LAST_NAME FROM EMPLOYEES; LAST_NAME Ames Andriola Babbin . . . 100 rows selected( Example 2: Changing the default alias@ Use the SHOW DATABASE statement to see the database settings.$ SQL> ATTACH 'FILENAME personnel';4 SQL> ATTACH 'ALIAS corp FILENAME corporate_data'; SQL> --? SQL> -- The default alias, RDB$DBHANDLE, refersz to PERSONNEL= SQL> -- to simplify references to CORPORATE_DATA make this% SQL> -- database the default alias SQL> -- SQL> SET ALIAS 'CORP'; . . . wwN@1 SET_ALL_CONSTRAINTSA Controls checking for constraints that are evaluated at commit> time. (This statement has no effect on constraints that are@ evaluated at verb time. For verb-time evaluation information,A see the SET_TRANSACTION.) The SET ALL CONSTRAINTS statement i{sB used to evaluate deferrable constraints at intervals before the transaction is committed. 2 Environment1 You can use the SET ALL CONSTRAINTS statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format) SET ALL CONSTRAINTS -+-> IMMEDIATE --+->' +-> DEFAULT ----+' | +-> DEFERRED ---+' +-> ON ---------+' +-> OFF --------+ 2 Arguments 3 DEFAULT@ The default constraint mode setting for a session is DEFERREDB unless you have used one of the following to specify otherwise:5 o SET DEFAULT CONSTRAINT MODE IMMEDIATE statement= o SQLOPTIONS=(CONSTRAINTS=IMMEDIATE) qualifier on the SQL precompiler command line@ o CONSTRAINTS=IMMEDIATE qualifier on the SQL module language} command line 3 constraint-evaluation-status Syntax options: OFF | DEFERRED@ This option causes constraint evaluation to be deferred untilA commit time, when the transaction completes. OFF is synonymous with DEFERRED. 3 IMMEDIATE Syntax: IMMEDIATE | ON: This option causes constraint evaluation to be executedC immediately, when the statement completes. ON is synonymous with IMMEDIATE.A When you issue a SET ALL CONSTR ~AINTS IMMEDIATE statement, SQL:? o Evaluates all previously deferred constraints (those that9 would otherwise be evaluated at a COMMIT statement)A o Sets a mode in which SQL evaluates any constraints selectedB for deferred evaluation by the execution of an SQL statement@ at the end of that SQL statement (instead of waiting for a COMMIT statement)B Once the transaction completes, the constraint mode is set back< to the default constraint mode for subsequent statements. 2 ExampleD Example 1: Using the SET ALL CONSTRAINTS statement in interactive SQL$ SQL> att 'file mf_personnel_sql';& SQL> set all constraints immediate; SQL> show constraint;@ Statement constraint evaluation default is DEFERRED (off)8 Statement constraint evaluation is IMMEDIATE (on) SQL> /* ***> Show the constraints ***> */. SQL> show tables (constraints) job_history;$ Information for table JOB_HISTORY% Table constraints for JOB_HISTORY: JOB_HISTORY_FOREIGN1 Foreign Key constraint1 Column constraint for JOB_HISTORY.EMPLOYEE_ID Evaluated on COMMIT Source:> JOB_HISTORY.EMPLOYEE_ID REFERENCES EMPLOYEES (EMPLOYEE_ID) JOB_HISTORY_FOREIGN2 Foreign Key constraint. Column constraint for JOB_HISTORY.JOB_CODE Evaluated on COMMIT Source:3 JOB_HISTORY.JOB_CODE REFERENCES JOBS (JOB_CODE) JOB_HISTORY_FOREIGN3 Foreign Key constraint5 Column constraint for JOB_HISTORY.DEPARTMENT_CODE Evaluated on COMMIT Source:H JOB_HISTORY.DEPARTMENT_CODE REFERENCES DEPARTMENTS (DEPARTMENT_CODE)- Constraints referencing table JOB_HISTORY: No constraints found% SQL> set all constraints deferred; SQL> show constraint;< Statement constraint evaluation default is DEFERRED (off)4 Statement constraint evaluation is DEFERRED (off) SQL> wwN@ 1 SET_ANSI= Specifies whether or not SQL behavior in certain instances? complies with the ANSI/ISO SQL standard. The current default/ behavior in these instances is noncompliant.& NOTEB SQL provides the following new statements to replace the SET ANSI statement:@ o SET DEFAULT DATE FORMAT replaces SET ANSI DATE; see the+ SET DEFAULT DATE FORMAT statement.A o SET KEYWORD RULES replaces SET ANSI IDENTIFIERS; see the% SET_KEYWORD_RULES statement.B o  SET QUOTING RULES replaces SET ANSI QUOTING; see the SET_! QUOTING_RULES statement.? o SET VIEW UPDATE RULES is new; see the SET_VIEW_UPDATE_ RULES statement.< In addition, SQL provides the SET DIALECT statement to> let you specify, with one statement, settings for all of> these statements. See the SET_DIALECT statement for more information.A SQL does not return a deprecated feature message if you use the SET ANSI statement. 2 Environment> You can use the SET ANSI statement only in interactive SQL. 2 Format( SET ANSI -+-> DATE --------+-+> ON -+->& +-> IDENTIFIERS -+ +> OFF + +-> QUOTING -----+ 2 Arguments 3 DATE ON | OFFA Specifies the default interpretation for columns with the DATEB data type, and the data type of the CURRENT_TIMESTAMP function.? The DATE and CURRENT_TIMESTAMP data types, can be either VMSC ADT or ANSI. By default , both data types are interpreted as DATE@ VMS. The VMS format contains YEAR TO SECOND fields, just as a TIMESTAMP does.@ You can change DATE and CURRENT_TIMESTAMP to ANSI format withA the SET DEFAULT DATE FORMAT statement, the precompiler DEFAULTA DATE FORMAT clause in a DECLARE MODULE statement embedded in aB program, or the module language DEFAULT DATE FORMAT clause in aB module file. The ANSI format DATE contains only the YEAR TO DAY fields.< You must use the SET DEFAULT DATE FORMAT statement before? creating domains or tables. You cannot use this statement to@ modify the data type once you have created a column or table. 3 IDENTIFIERS ON | OFFC Specifies whether or not SQL checks statements that use reservedD words as identifiers. If you specify SET ANSI IDENTIFIERS ON, SQLC checks statements for reserved words from the ANSI/ISO standard.? You must enclose reserved words in double quotation marks to? supply them as identifiers in SQL statements. If you do not,A SQL issues an informational message after such statements when@ you enable reserved-word checking. For a list of the reservedD words deprecated as identifiers, see the Oracle Rdb SQL Reference Manual.@ When you specify SET ANSI IDENTIFIERS OFF, SQL does not check; identifiers. By default, SQL does not check identifiers. 3 QUOTING ON | OFF@ Allows you to use double quotation marks to delimit the alias> and cat alog name pair in subsequent statements. By default,@ SQL syntax allows only single quotation marks. To comply withA ANSI/ISO SQL standard naming conventions, ANSI QUOTING must be? on. You must set ANSI QUOTING on to use multischema database naming. 2 Example6 Example 1: Setting CURRENT_TIMESTAMP to ANSI format@ In the following example, SQL issues an error message becauseB CURRENT_TIMESTAMP is an ADT data type by default, and TIMESTAMPC is an ANSI data type. The SET ANSI DATE ON statement changes the, default CURRENT_TIMESTAMP to ANSI format. SQL> begin) cont> declare :logging_date timestamp;/ cont> set :logging_date = current_timestamp; cont> trace :logging_date; cont> end;S %SQL-F-UNSDATASS, Unsupported date/time assignment from to LOGGING_DATE SQL> SET ANSI DATE ON; SQL> begin) cont> declare :logging_date timestamp;/ cont> set :logging_date = current_timestamp; cont> trace :logging_date; cont> end;C Example 2: Using the SET ANSI IDENTIFIERS statement to check for reserved wordsC This example shows the output from an SQL statement that createsB a domain and specifies the ANSI89 reserved word CONTINUE as theB user-supplied name for that domain. The SET ANSI IDENTIFIERS OND statement requires that you use uppercase characters for the name, and enclose it in double quotation marks. SQL> set ansi identifiers on;' SQL> create domain continue char(5);A %SQL-F-RES_WORD_AS_IDE, Keyword CONTINUE used as an identifier) SQL> create domain "CONTINUE" char(5); SQL> wwN@1 SET_Control< Assigns a value to a target parameter or a variable name. 2 EnvironmentA You can use the SET assignment control statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format set-assignment-statement = 7 SET -+-> -----+-> = --+--> value-expr -+->5 +-> -+ +--> NULL -------+ 2 Arguments 3 NULLA Assigns the NULL value to a target parameter or variable name. 3 parameterB Specifies the target where SQL stores a value expression or the NULL value. 3 value-exprC Assigns the value of a value expression to a target parameter or variable name. 3 variable-nameB Specifies the target where SQL stores a value expression or the NULL value. 2 Examples@ Example 1: Assigning a value expression to a target parameter BEGIN. SET :y = (SELECT COUNT (*) FROM employees); END;= Example 2: Assigning the NULL value expression to a target parameter BEGIN SET :z = NULL; END; ww_h1 SET_CATALOG= Specifies the default catalog name for an SQL user session@ in dynamically prepared and executed or interactive SQL until+ another SET CATALOG statement is issued.@ Within one multischema database, tables in different catalogs? can be used in a single SQL statement; tables in catalogs inD different databases cannot. If you omit the catalog name when youD specify an object in a multischema database, SQL uses the default catalog name. 2 Environment) You can use the SET CATALOG statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format3 SET CATALOG ---+-> ---+->1 +-> --------+1 +-> -+ catalog-string-literal = ' --> ' --> catalog-expression --> ' -->  catalog-expression = 0 -+------> ---------------+-->- | |- +-> " -> . --> " -+ 2 Arguments 3 catalog-expression> Specifies the name of the default catalog for a multischemaD database. If you omit the catalog name when you specify an object@ in a multischema database, SQL uses the default catalog name.? If you do not specify a default catalog name, the default is RDB$CATALOG.? If you qualify the catalog name with an alias, the alias andA catalog name pair must be in uppercase characters and you mustB enclose the alias and catalog name pair within double quotation marks.A See the User_Supplied_Names HELP topic for more information on catalogs. 3 catalog-parameterD Specifies a host language variable in precompiled SQL or a formalC parameter in an SQL module language procedure that specifies the@ default catalog. The catalog parameter must contain a catalog expression. 3 catalog-parameter-markerD Specifies a parameter marker (?) in a dynamic SQL statement. The@ catalog parameter marker refers to a parameter that specifiesC the default catalog. The catalog parameter marker must specify a0 parameter that contains a catalog expression. 3 catalog-string-literalB Specifies a character string literal that specifies the default= catalog. The catalog string literal must contain a catalog1 expression enclosed in single quotation marks. 2 ExamplesA Example 1: Setting schema and catalog defaults for the default databaseC In this example, the user attaches to the multischema corporate_< data database, uses SET SCHEMA and SET CATALOG statements> to change the defaults to catalog ADMINISTRATION and schemaC ACCOUNTING of the corporate_data database, and creates the table# BUDGET in the schema ACCOUNTING.) SQL> ATTACH 'FILENAME corporate_data'; SQL> SHOW CATALOGS;4 Catalogs in database with filename corporate_data ADMINISTRATION RDB$CATALOG SQL> SHOW SCHEMAS;3 Schemas in database with filename corporate_data ADMINISTRATION.ACCOUNTING ADMINISTRATION.PERSONNEL ADMINISTRATION.RECRUITING RDB$SCHEMA% SQL> SET CATALOG 'ADMINISTRATION'; SQL> SET SCHEMA 'ACCOUNTING';( SQL> CREATE TABLE BUDGET (COL1 REAL); SQL> SHOW TABLES; BUDGET DAILY_HOURS DEPARTMENTS . .  . SQL> --8 SQL> -- To see the qualified table names, set default) SQL> -- to another schema and catalog. SQL> --" SQL> SET CATALOG 'RDB$CATALOG'; SQL> SET SCHEMA 'RDB$SCHEMA'; SQL> SHOW TABLES7 User tables in database with filename corporate_data( ADMINISTRATION.ACCOUNTING.BUDGET- ADMINISTRATION.ACCOUNTING.DAILY_HOURS- ADMINISTRATION.ACCOUNTING.DEPARTMENTS . . .D Example 2: Setting a default catalog fo r a database with an aliasC In this example, the user attaches to the multischema corporate_B data database using the alias CORP. Setting the default catalogB allows you to shorten the table name because you can qualify it with just the schema.4 SQL> ATTACH 'ALIAS CORP FILENAME corporate_data';8 SQL> CREATE TABLE ACCOUNTING.PROJECT_7 (STATUS REAL);D %SQL-F-DBHANDUNK, ACCOUNTING is not the alias of a known database SQL> --? SQL> -- You cannot qualify the table name wit hout the alias,B SQL> -- so SQL assumes ACCOUNTING is the alias, not the schema.9 SQL> -- Unless you want to qualify the table name with9 SQL> -- both alias and catalog names, you must set the3 SQL> -- default catalog to ADMINISTRATION, whichL SQL> -- contains ACCOUNTING. You must enable ANSI/ISO quoting to do this. SQL> --" SQL> SET QUOTING RULES 'SQL92';, SQL> SET CATALOG '"CORP.ADMINISTRATION"';8 SQL> CREATE TABLE ACCOUNTING.PROJECT_7 (STATUS REAL); SQL> SHOW TABLES;7 User tables in database with filename corporate_data ACCOUNTING.BUDGET . . . ACCOUNTING.PROJECT_7 ACCOUNTING.WORK_STATUS . . . ww_h1 SET_CHARACTER_LENGTH? Specifies whether the length of character string parameters,A columns, domains, and offsets are interpreted as characters or+ octets. (An octet is a group of 8 bits.) 2 Environment2 You can use the SET CHARACTER L ENGTH statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format4 SET CHARACTER LENGTH -----> runtime-options ------>  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterC Specifies the value of runtime-options, which must be one of the following: o OCTETS o CHARACTERSB CHARACTERS specifies the length of character string parameters,: columns, domains, and offsets, which are interpreted as characters.> OCTETS specifies the length of character string parameters,B columns, domains, and offsets, which are interpreted as octets. The default is octets. 3 parameter-markerC Specifies the value of runtime-options, which must be one of the following: o OCTETS o CHARACTERSB CHARACTERS specifies the length of character string parameters,: columns, domains, and offsets, which are interpreted as characters.> OCTETS specifies the length of character string parameters,B columns, domains, and offsets, which are interpreted as octets. The default is octets. 3 'string-literal'C Specifies the value of runtime-options, which must be one of the following: o OCTETS  o CHARACTERSB CHARACTERS specifies the length of character string parameters,: columns, domains, and offsets, which are interpreted as characters.> OCTETS specifies the length of character string parameters,B columns, domains, and offsets, which are interpreted as octets. The default is octets. 2 Examples4 Example 1: Setting the character length to octets& SQL> set character length 'octets'; SQL> show connection current;% Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:. Identifier character set is DEC_MCS+ Default character set is DEC_MCS, National character set is DEC_MCS SQL> /*E ***> Create two domains: one uses LATIN9, a single-octet characterB ***> set, and one uses KANJI a fixed multi-octet character set. ***> */A SQL> create domain LATIN9_DOM char(8) character s et ISOLATIN9;< SQL> create domain KANJI_DOM char(5) character set KANJI;M %SQL-F-CHRUNIBAD, Number of octets is not an integral number of characters SQL> /*E ***> Because KANJI is a fixed multi-octet character set, using twoA ***> octets for each character, you must specify the size as a ***> multiple of two. ***> */< SQL> create domain KANJI_DOM char(8) character set KANJI; SQL> show domains;6 User domains in database with filename MIA_CHAR_SET* KANJI_DOM  CHAR(8)) KANJI 4 Characters, 8 Octets* LATIN9_DOM CHAR(8)- ISOLATIN9 8 Characters, 8 Octets SQL>8 Example 2: Setting the character length to characters* SQL> set character length 'characters'; SQL> show connection current;% Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40% Default character unit: CHARACTERS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:.  Identifier character set is DEC_MCS+ Default character set is DEC_MCS, National character set is DEC_MCS SQL> /*E ***> Create two domains: one uses LATIN9, a single-octet characterB ***> set, and one uses KANJI a fixed multi-octet character set. ***> */A SQL> create domain LATIN9_DOM char(8) character set ISOLATIN9;< SQL> create domain KANJI_DOM char(5) character set KANJI; SQL> show domains;6 User domains in database with filename MIA_CHAR_SET* KANJI_DOM CHAR(5)* KANJI 5 Characters, 10 Octets* LATIN9_DOM CHAR(8)- ISOLATIN9 8 Characters, 8 Octets SQL> ww_h1 SET_COMPOUND_TRANSACTIONS@ Allows you to control the SQL behavior for starting a default( transaction for a compound statement.? By default, if there is no current transaction, SQL starts a> transaction before executing a compound statement or storedB procedure. However, this might conflict with the actions withinB the procedure, or it might start a transaction for no reason if@ the procedure body does not perform any database access. ThisB default is retained for backward compatibility for applicationsB which may expect a transaction to be started for the procedure. 2 Environment7 You can use the SET COMPOUND TRANSACTIONS statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 2 Format* SET COMPOUND TRANSACTION ---> int-ext-val 2 Arguments 3 int-ext-value; A string literal or host variable containing the keyword> 'INTERNAL' or 'EXTERNAL'. These keywords can be in any case@ (uppercase, lowercase, or mixed case). If the value is set to? EXTERNAL, then SQL starts a transaction before executing theB procedure. If the value is set to INTERNAL, then SQL allows the@ procedure to start a transaction as required by the procedure execution. 2 Example9 Example 1: Enabling and Disabling Transaction Starting? In interactive or dynamic SQL, the following SET command can@ be used to disable or enable transactions starting by the SQLB interface. The parameter to the SET command is a string literalD or host variable containing the keyword 'INTERNAL' or 'EXTERNAL'.- SQL> SET COMPOUND TRANSACTIONS 'internal';% SQL> CALL START_TXN_AND_COMMIT ();- SQL> SET COMPOUND TRANSACTIONS 'external';$ SQL> CALL UPDATE_EMPLOYEES (...); wwp1 SET_CONNECT? Selects the named connection from the available connections,B suspends any current connection and saves its context, and usesC the named connection in subsequent procedures in the application, after the SET CONNECT statement executes.A For information about creating and naming connections, see the CONNECT statement. 2 Environment) You can use the SET CONNECT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format* SET CONNECT ---+-> -+->( +-> DEFAULT -----------+  2 Arguments 3 connection-name< Specifies a name for the association between the group ofB databases being attached (the environment) and the database and8 request handles that reference them (the connection).8 You can specify the connection name as the following:; o String literal enclosed within single quotation marks$ o Parameter (in module language)# o Variable (in precompiled SQL) 3 DEFAULT< Specifies one or more databases to be attached as a unit.= Use the DEFAULT keyword to specify the default connection.A The default connection is all the databases that were attachedB interactively, or all those made known to the module at compile) time through DECLARE ALIAS statements. 2 Examples9 Example 1: Creating a default connection and two other connectionsB The following log file from an interactive SQL connection shows? three databases attachments: personnel_northwest, personnel_B northeast, and personnel_southeast. (By not specifying an aliasC for personnel_northwest, the default alias is assigned.) SeveralD connections are established, including EAST_COAST, which includes4 both personne l_northeast and personnel_southeast.@ Use the SHOW DATABASE statement to see the database settings. SQL> --O SQL> -- Attach to the personnel_northwest and personnel_northeast databases.L SQL> -- personnel_northwest has the default alias, so personnel_northeast SQL> -- requires an alias.F SQL> -- All the attached databases comprise the default connection. SQL> --. SQL> ATTACH 'FILENAME personnel_northwest';> SQL> ATTACH 'ALIAS NORTHEAST FILENAME personnel_northeast';  SQL> --0 SQL> -- Add the personnel_southeast database. SQL> --> SQL> ATTACH 'ALIAS SOUTHEAST FILENAME personnel_southeast'; SQL> --; SQL> -- Connect to personnel_southeast. CONNECT does an@ SQL> -- implicit SET CONNECT to the newly created connection. SQL> --A SQL> CONNECT TO 'ALIAS SOUTHEAST FILENAME personnel_southeast'' cont> AS 'SOUTHEAST_CONNECTION'; SQL> --I SQL> -- Connect to both personnel_southeast and personnel_northeast asH SQL> -- EAST_ COAST connection. SQL replaces the current connection toJ SQL> -- the personnel_southeast database with the EAST_COAST connectionK SQL> -- when you issue the CONNECT statement. You now have two different8 SQL> -- connections that include personnel_southeast. SQL> --A SQL> CONNECT TO 'ALIAS NORTHEAST FILENAME personnel_northeast,: cont> ALIAS SOUTHEAST FILENAME personnel_southeast' cont> AS 'EAST_COAST'; SQL> --L SQL> -- The DEFAULT connection still includes all the attached databases. SQL> -- SQL> SET CONNECT DEFAULT; SQL> --B SQL> -- DISCONNECT releases the connection name EAST_COAST, but@ SQL> -- does not detach from the EAST_COAST databases because8 SQL> -- they are also part of the default connection. SQL> -- SQL> DISCONNECT 'EAST_COAST'; SQL> --! SQL> SET CONNECT 'EAST_COAST';C %SQL-F-NOSUCHCON, There is not an active connection by that name SQL> --K SQL> -- If you disconnect from the default connection, and have no otherL SQL> -- current connections, you are no longer attached to any databases. SQL> -- SQL> DISCONNECT DEFAULT; SQL> SHOW DATABASES;J %SQL-F-ERRATTDEF, Could not use database file specified by SQL$DATABASEP -RDB-E-BAD_DB_FORMAT, SQL$DATABASE does not reference a database known to Rdb -RMS-E-FNF, file not found; Example 2: Disconnecting a connection and starting a new$ connection with the same database: In this example, there are two connections: the default@ connection and a current connection, CA. Both connections useD the personnel_ca database. Use the SHOW DATABASE statement to see the database settings. SQL> --J SQL> -- Establish a default connection by attaching to the personnel_ca SQL> -- database. SQL> --' SQL> ATTACH 'FILENAME personnel_ca'; SQL> SHOW CONNECTIONS;! -> RDB$DEFAULT_CONNECTION SQL> --, SQL> -- Start a new connection called CA. SQL> --* SQL> CONNECT TO 'FILENAME personnel_ca' cont> AS 'CA'; SQL> SHOW CONNECTIONS;! RDB$DEFAULT_CONNECTION -> CA SQL> --L SQL> -- The DISCONNECT CURRENT statement releases the connection name CA,J SQL> -- although the database personnel_ca still belongs to the default SQL> -- connection. SQL> -- SQL> DISCONNECT CURRENT; SQL> SHOW CONNECTIONS;! -> RDB$DEFAULT_CONNECTION SQL> --F SQL> -- Even though the database personnel_ca is still attached, CA- SQL > -- is no longer an active connection. SQL> -- SQL> SET CONNECT 'CA';C %SQL-F-NOSUCHCON, There is not an active connection by that name SQL> --J SQL> -- The original ATTACH statement comprises the default connection.L SQL> -- The DISCONNECT DEFAULT statement detaches the default connection. SQL> -- SQL> DISCONNECT DEFAULT; SQL> SHOW DATABASES;J %SQL-F-ERRATTDEF, Could not use database file specified by SQL$DATABASEP -RDB-E-BAD_DB_FORMAT, SQL$DATABASE does not reference a database known to Rdb -RMS-E-FNF, file not found wwp1 SET_DEFAULT_CHARACTER_SET; Specifies the default character set for the SQL session. 2 Environment7 You can use the SET DEFAULT CHARACTER SET statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format6 SET DEFAULT CHARACTER SET ---> runtime-options ----->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterB Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see Oracle Rdb SQL Reference Manual. 3 parameter-markerB Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see the Oracle Rdb SQL Reference Manual. 3 'string-literal'B Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see the Oracle Rdb SQL Reference Manual. 2 ExampleA Example 1: Setting the default character set of an interactive session SQL> show character sets;# Default character set is DEC_MCS$ National character set is DEC_MCS( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS. SQL> set default character set 'DEC_KANJI'; SQL> show character sets;% Default character set is DEC_KANJI$ National character set is DEC_MCS( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS wwp1 SET_DEFAULT_DATE_FORMAT@ Specifies whether columns with the DATE data type or with the@ built-in function CURRENT_TIMESTAMP are interpreted as VMS or SQL99 format. 2 Environment5 You can use the SET DEFAULT DATE FORMAT statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL modul&e> o In dynamic SQL as a statement to be dynamically executed 2 Format2 SET DEFAULT DATE FORMAT --> runtime-options ---->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o VMS 3 parameter-markerC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o VMS 3 SQL99_or_SQL92> Specifies that the DATE data type and the CURRENT_TIMESTAMP= built-in function are interpreted as SQL standard. The SQLA standard format DATE contains only the YEAR TO DAY fields, and3 CURRENT_TIMESTAMP returns a TIMESTAMP data type. 3 'string-literal'C Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o VMS 3 VMS> Specifies that the DATE data type and the CURRENT_TIMESTAMPB built-in function are interpreted as VMS format. The VMS format< DATE and CURRENT_TIMESTAMP contain YEAR TO SECOND fields. 2 Example/ Example 1: Changing the DATE format to SQL99< In the following example, SQL issues an error because, byB default, the DATE data type is in OpenVMS DATE format. That is,C it contains the fields YEAR through SECOND. The SET DEFAULT DATEB FORMAT statement changes the default to ANSI/ISO format so that2 the CURRENT_DATE and DATE types are compatible.& SQL> set default date format 'VMS'; SQL> --" SQL> create domain LOGGING_DATE cont> DATE" cont> default CURRENT_DATE;C %SQL-F-DEFVALINC, You specified a default value for LOGGING_DATE+ which is inconsistent with its data type SQL> --( SQL> set default date format 'SQL99'; SQL> --" SQL> create domain LOGGING_DATE cont> DATE" cont> default CURRENT_DATE;! SQL> show domain LOGGING_DATE;, LOGGING_DATE DATE ANSI$ Oracle Rdb default: CURRENT_DATE wwp1 SET_DIALECT; Specifies the settings of the current connection for the following characteristics:A o Whether the length of character string parameters, columns,C and domains are interpreted as characters or octets. This canD also be specified by using the SET CHA RACTER LENGTH statement.> o Whether double quotation marks are interpreted as stringC literals or delimited identifiers. This can also be specified/ by using the SET QUOTING RULES statement.B o Whether or not identifiers can be keywords. This can also be9 specified by using the SET KEYWORD RULES statement.D o Which views are read-only. This can also be specified by using* the SET VIEW UPDATE RULES statement.B o Whether columns with the DATE or CURRENT _TIMESTAMP data type> are interpreted as VMS or SQL99 format. This can also be? specified by using the SET DEFAULT DATE FORMAT statement.B o Whether character sets change. Character sets can be changedA using the SET DEFAULT CHARACTER SET, SET NATIONAL CHARACTERB SET, SET IDENTIFIER CHARACTER SET, and SET LITERAL CHARACTER SET statements.C The SET DIALECT statement lets you specify several settings with@ one command, instead of specifying each setting individually.: The following table shows the settings for each option. Table 1-6 Dialect Settings> ORACLE@ Characteristic SQL99 MIA SQLV40 DialectsB Character length Characters Characters Octets CharactersA Quoting rules Delimited Delimited Literal DelimitedB identi- identi- identifier% fier fier; Keywords allowe d No No Yes Yes as identifiersD View update ANSI/ISO ANSI/ISO Oracle ANSI/ISO SQL= rules SQL rules SQL rules Rdb rules rules@ Default date DATE ANSI DATE ANSI DATE VMS DATE VMS formatC Default Not KATAKANA Not Not changed3 character set changed changedC National Not KANJI Not Not changed3 character set changed  changedC Identifier Not DEC_KANJI Not Not changed3 character set changed changedC Literal Not KATAKANA Not Not changed3 character set changed changed; Default Not Deferrable Deferrable NotB evaluation for Deferrable Deferrable constraintsB Oracle Corporation recommends that you set the dialect to SQL99> or SQL92, unless you need to maintain compatibility with an earlier dialect. 2 Environment) You can use the SET DIALECT statement: o In interactive SQLD o Embedded in host language programs to be precompiled to effect? the processing of dynamic SQL statements (use the DIALECTA clause to effect dialect changes in the precompiled source)B o As part of a procedure in an SQL module (but may not be in a compound statement)> o In dynamic SQL as a statement to be dynamically executedC However, the ORACLE dialects can be used only in the interactive$ SQL and dynamic SQL environments. 2 Format* SET DIALECT ---> runtime-options ------->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 ORACLE_LEVEL1$ Specifies the following behavior:B o The same dialect rules as SQL92 are in effect minus reserved- word  checking and the DATE ANSI format.< o The ORACLE LEVEL1 dialect allows the use of aliases toC reference (or link) to tables in data manipulation statements; like SELECT, DELETE, INSERT, and UPDATE. For example:; SQL> ATTACH 'ALIAS pers_alias FILENAME mf_personnel';' SQL> SET DIALECT 'ORACLE LEVEL1';- SQL> SELECT * FROM employees@pers_alias( cont> WHERE employee_id = '00164';A EMPLOYEE_ID LAST_NAME FIRST_NAME MIDDLE_INITIAL@  ADDRESS_DATA_1 ADDRESS_DATA_2 CITYB STATE POSTAL_CODE SEX BIRTHDAY STATUS_CODE4 00164 Toliver Alvin AD 146 Parnell Place Chocorua8 NH 03817 M 28-Mar-1947 1 1 row selectedD Alias references are only allowed on the table name and not onB column names. You cannot put a space between the table name,+ the at (@) sign, and the alias name.A If you specify a schema name when referencing an Oracle RdbA database, the schema name is ignored unless the multischema attribute is on.A o The following basic predicate for inequality comparisons is supported: !=D The != basic predicate requires that the ORACLE LEVEL1 dialect@ be set to avoid confusion with the interactive SQL comment character.B o When using dynamic SQL, the client application can specify aD  synonym for the parameter marker (?). For example, :name, :1, :2, and so on.? o The string concatenation operator and the CONCAT function) treat nulls as zero-length strings.C o The default date format is DATE VMS which is capable of doing@ arithmetic in the ORACLE LEVEL1 dialect only. Addition and> subtraction can be done with numeric data types that areB implicitly cast to the INTERVAL DAY data type. Fractions are+ rounded to the nearest whole  integer.> o Zero length strings are null. When using an Oracle RDBMSB database, a VARCHAR of zero length is considered null. While? the Oracle Rdb ORACLE LEVEL1 dialect does not remove zeroC length strings from the database, it does make them difficult3 to create. The following rules are in effect:? - Empty literal strings (for example, '') are considered literal nulls.B - Any function that encounters a zero length string returns?  a null in its place. This includes stored and externalB functions returning a VARCHAR data type regardless of theA dialect under which they were compiled. It also includes3 the TRIM and SUBSTRING built-in functions.C - Parameters with the VARCHAR data type and a length of zero are treated as null.? The best way to avoid zero length strings from being seenB by an Oracle RDBMS application is to only use views compiledA under the ORACLE dialects and to modify tables with VARCHARB columns to remove zero length strings. The following exampleC shows how to remove zero length strings from a VARCHAR column in a table:H SQL> UPDATE tab1 SET col1 = NULL WHERE CHARACTER_LENGTH(col1) = 0;B If modifying the table is not possible or if a view compiledC in another dialect containing VARCHAR functions must be used,B then create a new view under the ORACLE dialect referring toA that t able or view to avoid the zero length VARCHAR string.D The following example shows how to avoid selecting zero lengthD strings from a VARCHAR column in a table or non-Oracle dialect view:' SQL> SET DIALECT 'ORACLE LEVEL1';) SQL> CREATE VIEW view1 (col1, col2)I cont> AS SELECT SUBSTRING(col1 FROM 1 FOR 2000), col2 FROM tab1;D The Oracle Rdb optimizer is more efficient if data is selectedC without the use of functions. Therefore, the previous exampleD is best used only if you suspect zero length strings have been@ inserted into the table and it is necessary to avoid them.D o The ROWNUM keyword is allowed in select expressions and limits= the number of rows returned in the query. The following> example limits the number of rows returned by the SELECT statement to 9 rows:* SQL> ATTACH 'FILENAME mf_personnel';' SQL> SET DIALECT 'ORACLE LEVEL1';= SQL> SELECT last_name FROM EMPLOYEES WHERE ROWNUM < 10; LAST_NAME Toliver Smith Dietrich Kilpatrick Nash Gray Wood D'Amico Peters 9 rows selectedC Conditions testing for ROWNUM values greater than or equal toC a positive integer are always false and, therefore, return no rows. For example:= SQL> SELECT last_name FROM EMPLOYEES WHERE ROWNUM > 10; 0 rows selected= SQL> SELECT last_name FROM EMPLOYEES WHERE ROWNUM = 10; 0 rows selected 3 ORACLE_LEVEL2A This includes all the behavior describe for ORACLE LEVEL1 plus the following changes:B o The same dialect rules as SQL99 are in effect minus reserved- word checking and the DATE ANSI format.A o Concatenate (||) and the CONCAT function allow for all data> types, not just character types (CHAR, and VARCHAR). TheA numeric, or date/time values are converted to VARCHAR prior to the concatenation.A o Date subtraction results in a floating result. Partial days0 are now represented by a fraction portion.A o This is not an exhaustive list. Refer to Oracle Rdb Release> Notes for additional semantic changes for dialect ORACLE LEVEL2. 3 parameterC Specifies the value of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 o ORACLE LEVEL1 3 parameter-markerC Specifies the value of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 o ORACLE LEVEL1 3 SQL89_MIA$ Specifies the following behavior:= o The length of character string parameters, columns, and? domains is interpreted as characters, rather than octets.9 o Double quotation marks are interpreted as delimited identifiers.< o Keywords cannot be used as identifiers unless they are- enclosed within double quotation marks.A o The ANSI/ISO SQL standard for updatable views is applied toD all views created during compilation. Views that do not complyB with the ANSI/ISO SQL standard for updatable views cannot be updated.@ The ANSI/ISO SQL standard for updatable views requires the= following conditions to be met in the SELECT statement:/ - The DISTINCT keyword is not specified.> - Only column names can appear in the select list. EachD column name can appear only once. Functions and expressionsD such as max(column_name) or column_name +1 cannot appear in the select list.B - The FROM clause refers to only one table. This table must> be either a base table, global temporary table, localA temporary table, or a derived table that can be updated.6 - The WHERE clause does not contain a subquery.. - The GROUP BY clause is not specified., - The HAVING clause is not specified.> If you specify MIA, SQL sets the character sets as follows:% o Default character set: KATAKANA# o National character set: KANJI) o Identifier character set: DEC_KANJI% o Literal character set: KATAKANA< o The constraint evaluation time is DEFERRABLE INITIALLY DEFERRED. 3 SQL92$ Specifies the following behavior:= o The length of character string parameters, columns, and? domains is interpreted as characters, rather than octets.9 o Double quotation marks are interpreted as delimited identifiers.< o Keywords cannot be used as identifiers unless they are- enclosed within double quotation marks.A o The ANSI/ISO SQL standard for updatable views is applied toD all views created during compilation. Views that do not complyB with the ANSI/ISO SQL standard for updatable views cannot be updated.@ Th e ANSI/ISO SQL standard for updatable views requires the= following conditions to be met in the SELECT statement:/ - The DISTINCT keyword is not specified.> - Only column names can appear in the select list. EachD column name can appear only once. Functions and expressionsD such as max(column_name) or column_name +1 cannot appear in the select list.B - The FROM clause refers to only one table. This table must> be either a base table, global temporary table, localA temporary table, or a derived table that can be updated.6 - The WHERE clause does not contain a subquery.. - The GROUP BY clause is not specified., - The HAVING clause is not specified.B o The DATE and CURRENT_TIMESTAMP data types are interpreted asC SQL format. The SQL (ANSI) format DATE contains only the YEAR TO DAY fields.@ o Conversions between character data types when storing data@ or retriev ing data raise exceptions or warnings in certainB situations. For further explanation of these situations, see the Data_Types HELP topic.A o You can specify DECIMAL or NUMERIC for formal parameters inB SQL modules and declare host language parameters with packed= decimal or signed numeric storage format. SQL generates= an error message if you attempt to exceed the precision specified.C o The USER keyword specifies the current active user name for a request.C o A warning is generated when a NULL value is eliminated from a SET function.D o The WITH CHECK OPTION clause on views returns a discrete error0 code from an integrity constraint failure.B o An exception is generated with terminated C strings that are not NULL.= o The default on constraint evaluation time is set to NOT% DEFERRABLE INITIALLY IMMEDIATE. 3 SQL99D Specifies that the SQL language conforms to SQL:1999 SQL Database Language Standard.= This includes all the behavior describe for SQL92 plus the following changes:A o The FOREIGN KEY constraint may list the column names in the@ REFERENCES list in any order. In other dialects the columnC names must be in the same order as the referenced PRIMARY KEY or UNIQUE constraint.= o This is not an exhaustive list. Refer to the Oracle Rdb? Release Notes for additional semantic changes for dialect SQL99. 3 SQLV40$ Specifies the following behavior:= o The length of character string parameters, columns, and? domains is interpreted as octets, rather than characters.@ o Double quotation marks are interpreted as string literals.* o Keywords can be used as identifiers.: o The ANSI/ISO SQL standard for updatable views is notC applied. Instead, SQL considers views that meet the following! conditions to be updatable:/ - The DISTINCT keyword is not specified.B - The FROM clause refers to only one table. This table must> be either a base table, global temporary table, localA temporary table, or a derived table that can be updated.6 - The WHERE clause does not contain a subquery.. - The GROUP BY clause is not specified., - The HAVING clause is not specified.B o The DATE and CURRENT_TIMESTAMP data types are interpreted asC VMS format. The VMS format DATE and CURRENT_TIMESTAMP !contain YEAR TO SECOND fields.< o The constraint evaluation time is DEFERRABLE INITIALLY DEFERRED. The default is SQLV40. 3 'string-literal'C Specifies the value of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 o ORACLE LEVEL1 o ORACLE LEVEL2 2 Examples2 Example 1: Setting the characteristics to SQL92R SQL> ATTACH 'ALIAS MIA1 FILENAME MIA_CHAR_SET DISPLAY CHARACTER SET SHIFT_JIS';@ SQL> CONNECT TO 'ALIAS MIA1 FILENAME MIA_CHAR_SET' AS 'TEST'; SQL> SHOW CONNECTIONS TEST; Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS Alias MIA1:0 Identifier character set is DEC_KANJI, Default character set is KATAKANA* National character set is KANJI SQL> --N SQL> -- Change the environment from SQLV40 to MIA. Notice that the session! SQL> -- character sets change. SQL> -- SQL> SET DIALECT 'MIA'; SQL> SHOW CONNECTIONS TEST; Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: MIA% Default character unit: CHARACTERS Keyword Rules: MIA View Rules: ANSI/ISO Default DATE type: DATE ANSI Quoting Rules: ANSI/ISO Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL$ Default character set is KATAKANA" National character set is KANJI( Identifier character set is DEC_KANJI$ Literal character set is KATAKANA% Display character set is SHIFT_JIS Alias MIA1:0 Identifier character set is DEC_KANJI, Default character set is KATAKANA* National character set is KANJI SQL> --E SQL> -- Change the environment from MIA to SQL99. Notice that theB SQL> -- session characters DO NOT change from the MIA settings. SQL> -- SQL> SET DIALECT 'SQL99'; SQL> SHOW CONNECTIONS TEST; Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQL99% Default character unit: CHARACTERS Keyword Rules: SQL99 View Rules: ANSI/ISO Default DATE type: DATE ANSI Quoting Rules: ANSI/ISO Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: ON' Compound transactions mode: EXTERNAL$ Default character set is KATAKANA" National character set is KANJI( Identifier character set is DEC_KANJI$ Literal character set is KATAKANA% Display character set is SHIFT_JIS Alias MIA1:0 Identifier character set is DEC_KANJI, Default character set is KATAKANA* National character set is KANJI = Example 2: Saving and restoring dialect in interactive SQLB This example shows the use of declared variables in interactive> SQL to save (using GET ENVIRONMENT) and restore the dialect: during execution of a script that requires an alternateC dialect. This example simply displays the dialect using the SHOW CONNECTION statement. SQL> set dialect 'sql99'; SQL> -- save current dialect" SQL> declare :dialect char(40);5 SQL> get environment (session) :dialect = DIALECT; SQL> print :dialect; DIALECT SQL99$ SQL> set dialect 'oracle level2';/ SQL> show connection rdb$default_connection;% Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH! Dialect: SQL99 (ORACLE LEVEL2)% Default character unit: CHARACTERS Keyword Rules: SQL99 View Rules: ANSI/ISO Default DATE type: DATE VMS Quoting Rules: ANSI/ISO Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: ON' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED SQL># SQL> -- restore previous dialect SQL> set dialect :dialect;/ SQL> show connection rdb$default_connection;% Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQL99% Default character unit: CHARACTERS Keyword Rules: SQL99 View Rules: ANSI/ISO Default DATE type: DATE ANSI Quoting Rules: ANSI/ISO Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: ON' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED SQL> ww1 SET_DISPLAYB Controls the output of header information. Use the SHOW DISPLAY* statement to view the current settings. 2 EnvironmentA You can use the SET DISPLAY statement in interactive SQL only. 2 Format> SET DISPLAY ---+-+-+-------+-+-> COMMENT --+-------+-+-->; | | +-> NO -+ +-> EDIT STRING -+ | |; | | +-> QUERY HEADER -+ | |; | | +-> ROW COUNTER --+ | |; | +-> DEFAULT NULL STRING --------------+ |; | +-> NULL STRING -+-> -------+ |; | +-> -+ |; +------------------ , <-------------------+    2 Arguments 3 COMMENT Syntax options: COMMENT | NOCOMMENTC Disables or enables the display of of comment text by other SHOW& commands (for example, SHOW TABLE). 3 COUNTER/ Syntax options: ROW COUNTER | NO ROW COUNTERB Enables the total count reported by SELECT, DELETE, INSERT, and@ UPDATE statements. Use NO ROW COUNTER to disable the trailing count message. 3 DEFAULT_NULL_STRING$ Reverts to using the text 'NULL'. 3 EDIT_STRING Syntax options: EDIT STRING | NO EDIT STRINGD Enables the usage of column edit strings to format values for theA SELECT statement. Use NO EDIT STRING to disable the use of the column edit strings. 3 NULL_STRING@ Changes the way NULL values are displayed by interactive SQL. 3 QUERY_HEADER Syntax options:! QUERY HEADER | NO QUERY HEADERC Enables the printed header generated by the SELECT, CALL, FETCH,D and PRINT statements. Use NO QUERY HEADER to disable this header. 2 Example- Example 1: Using the SET DISPLAY Statement< The following example shows the effect of the SET DISPLAYD statement. It uses the SHOW DISPLAY command to report the current settings.' SQL> ATTACH 'FILENAME mf_personnel'; SQL>@ SQL> CREATE DOMAIN money INTEGER(2) EDIT STRING '$$$,$$9.99';6 SQL> CREATE TABLE temp_emp (id INTEGER, sal money); SQL>" SQL> SELECT * FROM work_status;+ STATUS_CODE STATUS_NAME STATUS_TYPE. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2 ACTIVE PART TIME 3 rows selected SQL># SQL> SET DISPLAY NO ROW COUNTER; SQL> SHOW DISPLAY( Output of the query header is enabled( Output of the row counter is disabled' Output using edit strings is enabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL"" SQL> SELECT * FROM work_status;+ STATUS_CODE STATUS_NAME STATUS_TYPE. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2  ACTIVE PART TIME- SQL> INSERT INTO temp_emp (id) VALUES (0);& SQL> INSERT INTO temp_emp (id, sal)/ cont> SELECT employee_id, MAX(salary_amount)4 cont> FROM salary_history GROUP BY employee_id;4 SQL> UPDATE temp_emp SET id = NULL WHERE id <= 0;. SQL> DELETE FROM temp_emp WHERE id IS NULL; SQL> SQL> SET DISPLAY ROW COUNTER; SQL> SHOW DISPLAY( Output of the query header is enabled' Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL" SQL>" SQL> SELECT * FROM work_status;+ STATUS_CODE STATUS_NAME STATUS_TYPE. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2 ACTIVE PART TIME 3 rows selected SQL>$ SQL> SET DISPLAY NO QUERY HEADER; SQL> SHOW DISPLAY) Output of the query header is disabled' Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL" SQL> SQL> DECLARE :res INTEGER; SQL>? SQL> -- This omits the query header for the SELECT statement" SQL> SELECT * FROM work_status;. 0 INACTIVE RECORD EXPIRED) 1 ACTIVE FULL TIME) 2 ACTIVE PART TIME 3 rows selected SQL>> SQL> -- This omits the query header for the PRINT statement SQL> PRINT :res; 0% SQL> PRINT 'This is a print line'; This is a print line SQL>! SQL> CREATE MODULE call_sample cont> LANGUAGE SQL? cont> PROCEDURE add_one (IN :a INTEGER, OUT :b INTEGER); cont> SET :b = :a + 1; cont> END MODULE;L SQL> -- This omits the query header for the OUT/INOUT parameters for CALL! SQL> CALL add_one (100, :res); 101 SQL>7 SQL> DECLARE c CURSOR FOR SELECT * FROM work_status; SQL> OPEN c;A SQL> -- This omits the query headers for the variables fetched SQL> FETCH c;. 0 INACTIVE RECORD EXPIRED! SQL> SET DISPLAY QUERY HEADER; SQL> SHOW DISPLAY( Output of the query header is enabled' Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL"C SQL> -- This outputs the query headers for the variables fetched SQL> FETCH c;+ STATUS_CODE STATUS_NAME STATUS_TYPE) 1 ACTIVE FULL TIME SQL> CLOSE c; SQL> SQL> TRUNCATE TABLE temp_emp;& SQL> INSERT INTO temp_emp (id, sal)3 cont> SELECT employee_id, AVG(salary_amount) cont> FROM salary_history! cont> WHERE salary_end IS NULL cont> GROUP BY employee_id; 100 rows inserted SQL>; SQL> SELECT * FROM temp_emp ORDER BY id LIMIT TO 3 ROWS; ID SAL 164 $51,712.00 165 $11,676.00 166 $18,497.00 3 rows selected SQL># SQL> SET DISPLAY NO EDIT STRING; SQL> SHOW DISPLAY( Output of the query header is enabled' Output of the row counter is enabled( Output using edit strings is disabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL" SQL>; SQL> SELECT * FROM temp_emp ORDER BY id LIMIT TO 3 ROWS; 164 51712.00 165 11676.00 166 18497.00 3 rows selected SQL> SQL> SET DISPLAY EDIT STRING; SQL> SHOW DISPLAY( Output of the query header is enabled' Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 24 lines" Line length is set to 132 bytes# Display NULL values using "NULL" SQL>; SQL> SELECT * FROM temp_emp ORDER BY id LIMIT TO 3 ROWS; ID SAL 164 $51,712.00 165 $11,676.00 166 $18,497.00 3 rows selectedD Example 2: Replacing the NULL values with text to make the output easier to read" SQL> select job_start, job_end,, cont> (select department_name( cont> from departments dC cont> where d.department_code = jh.department_code) cont> from job_history jh% cont> where employee_id = '00164'; JOB_ START JOB_END9 21-Sep-1981 NULL Board Manufacturing North= 5-Jul-1980 20-Sep-1981 Cabinet & Frame Manufacturing 2 rows selected3 SQL> set display null string '(still employeed)'" SQL> select job_start, job_end,, cont> (select department_name( cont> from departments dC cont> where d.department_code = jh.department_code) cont> from job_history jh% cont> where employee_id = '00164'; JOB_START JOB_ENDE 21-Sep-1981 (still employeed) Board Manufacturing NorthI 5-Jul-1980 20-Sep-1981 Cabinet & Frame Manufacturing 2 rows selectedA Example 3: Disabling the comment display to make the output of SHOW easier to read SQL> show domain id_dom* ID_DOM CHAR(5)5 Comment: standard definition of employee id SQL> set display no comment; SQL> show domain id_dom* ID_DOM CHAR(5) SQL>D Example 4: Save the current NULL string using GET ENVIRONMENT and# restore after executing a query.! SQL> declare :ns varchar(100);4 SQL> get environment (session) :ns = NULL_STRING; SQL> set null;" SQL> select job_start, job_end,, cont> (select department_name( cont> from departments dC cont> where d.department_code = jh.department_code) cont> from job_history jh% cont> where employee_id = '00164'; JOB_ START JOB_END9 21-Sep-1981 Board Manufacturing North= 5-Jul-1980 20-Sep-1981 Cabinet & Frame Manufacturing 2 rows selected$ SQL> set display null string :ns;" SQL> select job_start, job_end,, cont> (select department_name( cont> from departments dC cont> where d.department_code = jh.department_code) cont> from job_history jh% cont> where employee_id = '00164'; JOB_START JOB_END9 21-Sep-1981 NULL Board Manufacturing North= 5-Jul-1980 20-Sep-1981 Cabinet & Frame Manufacturing 2 rows selected ww1 SET_DEFAULT_CONSTRAINT_MODE6 Sets the default constraint setting for statements. 2 Environment9 You can use the SET DEFAULT CONSTRAINT MODE statement: o In interactive SQL> o In Dynamic SQL as a statement to be dynamically executed 2 Format8 SET DEFAULT CONSTRAINT MODE -+-> IMMEDIATE ---------+->6  +-> DEFAULT -----------+6 +-> DEFERRED ----------+6 +-> ON ----------------+6 +-> OFF ---------------+6 +-> runtime-options --+ runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 DEFAULT Syntax: DEFAULT | OFF= Requests that during the next transaction, all constraints; defined as DEFERRABLE INITIALLY DEFERRED be evaluated as< originally specified in the constraint definition. OFF is synonymous with DEFAULT. 3 DEFERREDB Synonymous with DEFAULT. However, in a future release of Oracle( Rdb this keyword will change meaning. 3 IMMEDIATE Syntax: IMMEDIATE | ON9 This option requests that during this transaction, allD constraints defined as DEFERRABLE INITIALLY DEFERRED be evaluated= as though defined as DEFERRABLE INITIALLY IMMEDIATE. ON is synonymous with IMMEDIATE. 3 parameterB Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see Oracle Rdb SQL Reference Manual. 3 parameter-markerB Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see Oracle Rdb SQL Reference Manual. 3 'string-literal'B Specifies the default character set for your session. The valueB of runtime-options must be a valid character set. For a list ofB allowable character set names and option values, see Oracle Rdb SQL Reference Manual. 2 ExamplesC Example 1: Using the SET statement to change the current setting for constraint evaluation; The following example shows how to use the SET statement; to change the constraint evaluation mode for the current@ transaction. You can display both the current setting and the default setting.+ SQL> attach 'filename mf_personnel_sql'; SQL> /*< ***> Show settings before starting, set the default mode,% ***> then show the settings again. ***> */ SQL> show constraint mode;@ Statement constraint evaluation default is DEFERRED (off). SQL> set default constraint mode immediate; SQL> show constraint mode;@ Statement constraint evaluation default is IMMEDIATE (on) SQL> start transaction;% SQL> set all constraints deferred; SQL> show constraint mode;@ Statement constraint evaluation default is IMMEDIATE (on)8 Statement constraint evaluation is DEFERRED (off) SQL> commit; SQL> show constraint mode;@ Statement constraint evaluation default is IMMEDIATE (on) SQL># Example 2: Using runtime optionsB If using runtime-options the passed character value must be oneA of the keywords: ON, OFF, IMMEDIATE, DEFERRED, or DEFAULT. TheC following example shows how this can be done in Interactive SQL. SQL> show constraint mode@ Statement constraint evaluation default is DEFERRED (off)/ SQL> declare :c_mode char(10) = 'IMMEDIATE';, SQL> set default constraint mode :c_mode; SQL> show constraint mode@ Statement constraint evaluation default is IMMEDIATE (on) SQL> ww1 SET_DISPLAY_CHARACTER_SET' Specifies the display character set. 2 Environment7 You can use the SET DISPLAY CHARACTER SET statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format3 SET DISPLAY CHARACTER SET ---> runtime-options --> runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameter= Specifies the display character set used for the automatic? translation of text values before the values are returned toD the user application. See the Oracle Rdb SQL Reference Manual for8 a list of allowable character sets and option values. 3 parameter-marker= Specifies the display character set used for the automatic? translation of text values before the values are returned toD the user application. See the Oracle Rdb SQL Reference Manual for8 a list of allowable character sets and option values. 3 'string-literal'= Specifies the display character set used for the automatic? translation of text values before the values are returned toD the user application. See the Oracle Rdb SQL Reference Manual for8 a list of allowable character sets and option values. 2 ExamplesA Example 1: Setting the display character set of an interactive session SQL> show character sets;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED. SQL> set display character set 'SHIFT_JIS'; SQL> show character sets;# Default character set is DEC_MCS$ National character set is DEC_MCS( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS ww 1 SET_FLAGSC Allows enabling and disabling of database system debug flags for the current session.B The literal or host variable passed to this command can contain@ a list of keywords, or negated keywords, separated by commas.< Spaces are ignored. The keywords may be abbreviated to an unambiguous length.& NOTE? Oracle Corporation reserves the right to add new keywords< to the SET FLAGS statement in any release or update to; Oracle Rdb, which may change this unambiguous length.@ Therefore, it is recommended that the full keyword be used in applications. 2 Environment' You can use the SET FLAGS statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 2 FormatK SET --+-> FLAGS -+--------------------------+-+->  ----+-+-->H | +-> (ON ALIAS alias-name) -+ +-> -+ |H +-> NOFLAGS --------------------------------------------------+  2 Arguments 3 FLAGS@ Specifies whether or not a database system debug flag is set.? The following table shows the available keywords that can be specified. Table 1-7 Debug Flag Keywords Debug Flags& Keyword Equivalent CommentD ALTERNATE_   None The optimizer discards literal valuesC OUTLINE_ID when producing an outline identifer.B AUTO_INDEX Xq Allows CREATE TABLE and ALTER TABLE@ to create indices for any PRIMARYD KEY, FOREIGN KEY or UNIQUE constraint2 added to the table.; AUTO_OVERRIDE None Allows a user with the DBADMB (administrator) privilege to in sert< or update a column defined as) AUTOMATIC.B BITMAPPED_SCAN None Enables use of in-memory compressedA DBkey bitmaps for index AND and ORC operations in the dynamic optimizer.A BLR B Displays the binary language (BLR)C representation request for the query8 CARDINALITY K Shows cardinality u pdates@ CARTESIAN_LIMIT None Limits the number of small tables< that are allowed to be placed: anywhere in the join order.D CHRONO_FLAG(n) Xc Forces timestamp-before-dump display.C The value of n can be 0, 1, or 2, orC n can be omitted. CHRONO_FLAG(0) andC NOCHRONO_FLAG are equivalent. If youB   specify CHRONO_FLAG but omit n, theA default is CHRONO_FLAG(1). CHRONO_B FLAG(1) enables an additional trace? message that includes the attachC number and the current time. CHRONO_B FLAG(2) enables an additional trace? message that includes the attachD number and the current date and  time.B If you supply a value for n that isC greater than 2, it is ignored, and a2 value of 1 is used.@ CONTROL_BITS Bc Displays a decoding of the BLR$K_D CONTROL_BITS semantic flags when used4 with the BLR keyword.D COSTING Oc Displays traces on optimizer costing.> COUNT_SCAN None Enables count sca n optimization> on sorted ranked indexes, whereA the optimizer will use cardinalityA information from the sorted rankedC index to determine the count of rows6 that satisfy the query.A CURSOR_STATS Og Displays general cursor statistics1 for the optimizer.> DATABASE_ P Displays the database parameter; PARAMETERS buffer during ATTACH, CREATE? DATABASE, ALTER DATABASE, IMPORTC DATABASE, and DISCONNECT statements.A DDL_BLR D Displays the binary language (BLR)< representation of expressions? within data definitions, such asC the expression for a computed column9  within a table definition.A DETAIL_LEVEL None A debug flag used with other debugB flags to enable additional detailedC information in the debug output. TheC DETAIL_LEVEL keyword can be followedA by a numeric value in parentheses.A For those debug flags that support? it, this indicates the de gree of< aditional detail to be shown.@ ESTIMATES O Displays the optimizer estimates.C EXECUTION E Displays an execution trace from theB dynamic optimizer. For a sequential= retrieval from a table that isB strictly partitioned, this includesA a count and a list of the selected=  partitions each time the query( executes.; The EXECUTION keyword can be= followed by a numeric value in? parentheses. This represents the@ number of lines to display before? stopping the execution trace forC the query execution. There can be noA spa ces between the keyword and the= parameter. The default is 100.> IGNORE_OUTLINE None Ignores outlines defined in theC database. The IGNORE_OUTLINE keywordA has the same action as setting theC RDMS$BIND_OUTLINE_FLAGS logical name$ to 1.? INDEX_COLUMN_ None Enables leading index columns as? GROUP w orkload column groups. This may< increase solution cardinality( accuracy.A INDEX_DEFER_ Xb When this flag is set and an indexA ROOT is created, the index root node is@ created in the database only whenA there is data in the table. If theD table is empty, creation of the indexC  root node is deferred until rows are7 inserted into the table.: INDEX_ Si Displays index partitioning? PARTITIONS information as part of a dynamic/ execution trace.A INDEX_STATS Ai Enables debug flags output for theD progress of an ALTER, CREATE, or DROP/ INDEX statement.= INTERNALS I Enables deb ug flags output forC internal queries such as constraints> and triggers. It can be used inC conjunction with other keywords such? as STRATEGY, BLR, and EXECUTION.D ITEM_LIST H Displays item list information passedA in for the database queries and as9 compile-time query optionsC LAREA_READY  Xr This flag can be used to investigate@ table and index locking behavior.@ This flag is disabled by default.D MAX_RECURSION None Sets the maximum number of recursionsC that can be performed when executing> a match strategy. This preventsD excessive recursion in the processingA of the match st rategy. The defaultC value is 100. The equivalent logical? name is RDMS$BIND_MAX_RECURSION.? MAX_SOLUTION None Enables maximum search space for? possible retrieval solutions. If> enabled, the optimizer will tryC more solutions based on each leadingA segment of the index, and thus mayA  create more solutions than before,D but may find more efficient solutionsB applying multiple segments in index@ retrieval. The equivalent logicalA name is RDMS$DISABLE_MAX_SOLUTION.2 Default is enabled.= MAX_STABILITY None Enables maximum stability; the@ dynamic optimizer is not allowed.@ The MAX_STABILITY keyword has theD same action as the RDMS$MAX_STABILITY, logical name.D MBLR M Displays the metadata binary languageB representation request for the data< definition language statement@ MODE(n) Allows you to specify which queryC outline should be used by  specifyingD the mode value of that query outline.A The value of n can be any positive? or negative integer, or n can be? omitted. If you specify MODE butA omit n, the default is MODE(1). If@ you specify MODE(0) or NOMODE, it? disables the display of the modeB  in the SHOW FLAGS statement output.D MODE(0) is the default for Oracle Rdb2 generated outlines.= NONE Not Used to turn off all currentlyB Applicable defined keywords. Equivalent to SET' NOFLAGS.? OBLR So Displays query outline in Binary= Language Representation (BLR).> OLD_COST_MODEL None E nables the old cost model. TheB OLD_COST_MODEL keyword has the sameD action as the RDMS$USE_OLD_COST_MODEL, logical name.9 OPTIMIZATION_ None Used to change the default> LEVEL optimization level for a query.? If the query explicitly uses theB OPTIMIZE FOR clause, or is compiledD within an environment which overrides> the default using a method suchA as SET OPTIMIZATION LEVEL, then noC change will occur. If the query usesC the default optimization level, thenC the optimization will be modified byB this flag. With no option specifiedB or an empty options list, t his will> default to TOTAL TIME. The flag? NOOPTIMIZATION_LEVEL will revert; to the default Rdb behavior.= OPTIMIZATION_ None Sets FAST FIRST as the default@ LEVEL(FAST_ optimization level for queries in, FIRST) all sessions.= OPTIMIZATION_ None Sets TOTAL TIME as the default@ LEVEL(TOTAL_ optimization level for queries in , TIME) all sessions.> OUTLINE Ss Displays query outline for thisB query (can be used without STRATEGY' keyword)? PREFIX Bn Used with BLR keyword to inhibitD offset numbering and other formatting@ of binary language representation' display.= REBUILD_SPAM_ None The flag !REBUILD_SPAM_PAGES is> PAGES for use in conjunction with the> DDL commands ALTER TABLE, ALTERA STORAGE MAP, and ALTER INDEX. WhenD changing the row length or THRESHOLDS? clause for a table or index, the? corresponding SPAM pages for theC logical area may require rebuilding.= " By default, these DDL commands? update the AIP and set a flag toB indicate that the SPAM pages shouldD be rebuilt. However, this flag may beB set prior to executing a COMMIT forC the transaction and the rebuild willB take place within this transaction.C Use SET FLAGS ' #NOREBUILD_SPAM_PAGES'3 to negate this flag.? REWRITE None When no parameters are provided,B all query rewrite optimizations are' enabled.? NOREWRITE None When no parameters are provided,B all query rewrite optimizations are( disabled.@ REWRITE None Specifying the CONTAINING keyword> (CONTAI $NING) will enable only the CONTAINING> predicate rewrite optimization.@ NOREWRITE None Specifying the CONTAINING keyword? (CONTAINING) will disable only the CONTAINING> predicate rewrite optimization.? REWRITE(LIKE) None Specifying the LIKE keyword will= enable only the LIKE predicate4 rewrite optimization.? NOREW%RITE(LIKE) None Specifying the LIKE keyword will> disable only the LIKE predicate4 rewrite optimization.C REWRITE None Specifying the STARTING_WITH keywordA (STARTING_ will enable only the STARTING WITH> WITH) predicate rewrite optimization.C NOREWRITE None Specifying the STARTING_WITH keywordB (STARTING_ will disable only the START &ING WITH> WITH) predicate rewrite optimization.C REQUEST_NAMES Sn Displays the names of user requests,8 triggers, and constraints= REVERSE_SCAN None Enables the reverse index scan; strategy. The NOREVERSE_SCANA keyword has the same action as the@ RDMS$DISABLE_REVERSE_SCAN logical$ name.D SCR'OLL_ L Disables scrolling for old-style LISTA EMULATION OF BYTE VARYING (segmented string)@ format. The SCROLL_EMULATION flagA has the same action as setting theA RDMS$DIAG_FLAGS logical name to L.A SELECTIVITY None Refers to the methods by which theC static optimizer estimates predicate= sel (ectivity. This flag takes a@ numeric value in parentheses from& 0 to 3.A 0 = standard (non-aggressive, non-3 sampled) selectivity; 1 = aggressive + non-sampled* selectivity; 2 = sampled + non-aggressive* selectivityD 3 = s )ampled + aggressive selectivity.? By default the flag is disabled,A which is the equivalent of setting. its value to 0.> SEQ_CACHE(n) None Adjusts the sequence cache size> for the process issuing the SET@ FLAGS statement. The value n must> be a numeric value greater than= 2 *. (Specifying a value of 1 is> equivalent to specifying NOSEQ_@ CACHE.) Use SEQ_CACHE to overrideB the CACHE setting for all sequences= subsequently referenced by the> application. The new cache size@ does not affect any sequence thatB has already been referenced, or any; + sequence defined as NOCACHE.; SOLUTIONS OsS Displays traces on optimizer) solutions.D SORTKEY_EXT S Reports if ORDER BY (or SORTED BY) isC referencing only external (constant)B value. The SORTKEY_EXT flag has theD same action as setting the RDMS$DIAG_7 FLAGS logical name to S.> SORT_STATISTI ,CS R Displays sort statistics during) execution.A STOMAP_STATS As Displays the processing of storageD maps for any tables that refer to theB dropped storage area. The output is3 prefixed with "~As".? STRATEGY S Shows the optimizer strategy. If? a table is strictly partitioned,? - the text "(partitioned scan#nn)"B appears after the table name, whereA nn indicates the leaf number for aD sequential scan (there may be several6 within a single query).B TEST_SYSTEM None This flag is used by the Oracle Rdb@ testing environment to modify theA output of various functions, trace.A and debugging displays. It is used? to eliminate data in test outputD that would normally cause differences7 between test executions.B TRACE Xt Enables output from TRACE statementA TRANSACTION_ T Displays the transaction parameter= PARAMETERS buffer during SET TRANSACTION,> COMMIT, and / ROLLBACK and during; stored procedure compilation; TRANSITIVITY None Enables transitivity between> selections and join predicates.A The NOTRANSITIVITY keyword has the? same action as the RDMS$DISABLE_9 TRANSITIVITY logical name.9 VALIDATE_ None Enables revalidation of an> ROUTINE invalidated 0 stored procedure orD stored function. The VALIDATE_ROUTINEA keyword has the same action as theB RDMS$VALIDATE_ROUTINE logical name.A VARIANCE_DOF(n) None Sets the default degree of freedom@ (DOF) for calculation of the meanB (average) in small samples (insteadD of using the VARIANCE function). Only> 1 the values 0 and 1 are allowed.? WARN_DDL Xd Sometimes legal data definitions? can have side effects, this flagA allows these warning to be enabledD and disabled. This flag is is enabledA by default, with the exception forB when attached by PATHNAME. The dataB definition 2statement still succeedsC even with the reported warnings. TheC database administrator may choose toC rollback the statement based on this( feedback.A WARN_INVALID Xw Reports invalidated objects during@ the ALTER INDEX, DROP INDEX, DROPA TABLE, and DROP MODULE statements.? WATCH_CALL Xa 3 Traces the execution of queries,@ triggers and stored functions and> procedures. The output includes@ the name of the trigger, function? or procedure or "unnamed" for an? anonymous query. In most cases aD query can be named using the OPTIMIZED AS clause. It also includes the value4C of CURRENT_USER during the executionC of that routine. CURRENT_USER may beB inherited from any module that uses8 the AUTHORIZATION clause.A WATCH_OPEN Xo Traces all queries executed on the= database. This may include SQL? runtime system queries to lookupB table nam 5es, etc as well as queries? executed by the application. The? output includes the 32 digit hexB identifier, the same as used by theC CREATE OUTLINE statement. This valueB uniquely identifies the query being( executed.= If a query is a stored routine? (6function or procedure) then theB notation "(stored)" is appended, ifA the query is named then it will beD classified as "(query)", otherwise itA will be designated as "(unnamed)".> ZIGZAG_MATCH None Enables zigzag key skip on both@ outer and inner match loops. WhenC you specify the ZIGZAG_MATCH keyword7B with the NOZIGZAG_OUTER keyword, itD disables zigzag key skip on the outer? loop (and has the same action asD setting the RDMS$DISABLE_ZIGZAG_MATCH@ logical name to 1). The NOZIGZAG_@ MATCH keyword disables zigzag keyA skip on both outer and inner match@ 8 loops (and has the same action asD setting the RDMS$DISABLE_ZIGZAG_MATCH2 logical name to 2).C ZIGZAG_OUTER None Enables zigzag key skip on the outerC loop. See the entry for ZIGZAG_MATCHB for information on the action taken@ when you specify ZIGZAG_OUTER and5 ZIGZAG_MATCH together. 3 NOFLAGS 9B The SET NOFLAGS statement disables all currently enabled flags.B It is equivalent to SET FLAGS 'NONE'. NOFLAGS is only permitted in Interactive SQL. 3 ON_ALIAS_alias-nameA Using the ON ALIAS clause allows the database administrator toC set flags on just one database alias instead of on all currentlyB attached databases. Use the name of an alias as declared by theC ATTACH or CONNECT statement. If no ALIAS clause is used then the+ alias name will default to RDB$DB:HANDLE. 2 Examples@ Example 1: Enabling and disabling database system debug flags' SQL> ATTACH 'FILENAME MF_PERSONNEL'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX SQL> SQL> SET FLAGS 'TRACE'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX,TRACE SQL> SQL> SET FLAGS 'STRATEGY'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle ;Rdb: STRATEGY,PREFIX,TRACE SQL> SQL> SET FLAGS 'NOTRACE'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: STRATEGY,PREFIX SQL> SQL> SET NOFLAGS; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX SQL>& Example 2: Using the PREFIX keyword' SQL> ATTACH 'FILENAME mf_personnel'; SQL> --= SQL> -- Show that the PREFIX keyword is enabled by default SQL> -- S<QL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX SQL> -- SQL> -- Enable TRACE SQL> -- SQL> SET FLAGS 'TRACE'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX,TRACE SQL> --, SQL> -- Show that the prefix is displayed SQL> -- SQL> BEGIN cont> TRACE 'AAA'; cont> END; ~Xt: AAA SQL> -- SQL> -- Turn off the prefix SQL> -- SQL> SET FLAGS 'NOPREFIX';= SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: TRACE SQL> --6 SQL> -- Show that the prefix is no longer displayed SQL> -- SQL> BEGIN cont> TRACE 'AAA'; cont> END; AAA 5 Example 3: Using Host Variables in Interactive SQLD The example also demonstrates using literal strings with multiple' options to enable and disable flags. SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:> PREFIX< SQL> -- declare a host variable to be used with SET FLAGS SQL> declare :hv char(40);) SQL> -- assign a value to the variable SQL> begin' cont> set :hv = 'strategy, outline'; cont> end;; SQL> -- use the host variable to enable or disable flags SQL> set flags :hv; SQL> show flags Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: STRATEGY,PREFIX,OUTLINEE SQL> -- use a string literal directly with the SET FLAGS statement+ ? SQL> set flags 'noprefix,execution(10)'; SQL> show flags Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:$ STRATEGY,OUTLINE,EXECUTION(10) $ Example 4: Using the MODE(n) Flag& SQL> SET FLAGS 'MODE(10), OUTLINE'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX,OUTLINE,MODE(10)' SQL> SELECT COUNT(*) FROM EMPLOYEES;/ -- Rdb Generated Outline : 30-MAY-1997 16:35. create outline QO_B3F54F772CC05435_000000@0A( id 'B3F54F772CC054350B2B454D95537995' mode 10 as ( query ( -- For loop subquery ( subquery (B EMPLOYEES 0 access path index EMP_EMPLOYEE_ID ) ) ) ) compliance optional ; 100 1 row selected / Example 5: Using the WARN_INVALID Debug Flag! SQL> SET FLAGS 'WARN_INVALID'; SQL> SHOW FLAGS; Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: APREFIX,WARN_INVALID* SQL> -- warning because of dependencies SQL> DROP TABLE T1 CASCADE;# ~Xw: Routine "P3" marked invalid# ~Xw: Routine "P2" marked invalid# ~Xw: Routine "P1" marked invalid SQL>6 SQL> -- Create an outline that references an INDEX./ SQL> CREATE TABLE T1 (A INTEGER, B INTEGER);" SQL> CREATE INDEX I1 ON T1 (A); SQL> CREATE OUTLINE QO1. cont> ID '19412AB61A7FE1FA6053F43F8F01EE6D' cont> MODE 0 cont> AS ( cont> QUERY ( cont> B SUBQUERY (1 cont> T1 0 ACCESS PATH INDEX I1 cont> ) cont> ) cont> ) cont> COMPLIANCE OPTIONAL; SQL>, SQL> -- Warning because of disabled index SQL> ALTER INDEX I1% cont> MAINTENANCE IS DISABLED;: ~Xw: Outline "QO1" marked invalid (index "I1" disabled) SQL> SHOW OUTLINE QO1; QO1% Object has been marked INVALID Source: CREATE OUTLINE QO1( ID '19412AB61A7FE1FA6053F43F8F01EE6D' MODE 0 AS C( QUERY ( SUBQUERY (+ T1 0 ACCESS PATH INDEX I1 ) ) ) COMPLIANCE OPTIONAL;C Example 6: Using the INTERNAL Keyword to Display Trigger ActionsD SQL> -- The following code shows the strategy used by the trigger; SQL> -- actions on the AFTER DELETE trigger on EMPLOYEES7 SQL> SET FLAGS 'STRATEGY, INTERNALS, REQUEST_NAMES'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:- INTERNALS,ST DRATEGY,PREFIX,REQUEST_NAMES: SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID = '00164';/ ~S: Trigger name EMPLOYEE_ID_CASCADE_DELETEI Get Temporary relation Retrieval by index of relation DEGREES! Index name DEG_EMP_ID [1:1]/ ~S: Trigger name EMPLOYEE_ID_CASCADE_DELETEM Get Temporary relation Retrieval by index of relation JOB_HISTORY' Index name JOB_HISTORY_HASH [1:1]/ ~S: Trigger name EMPLOYEE_ID_CASCADE_DELETEP Get Temporary relation E Retrieval by index of relation SALARY_HISTORY% Index name SH_EMPLOYEE_ID [1:1]/ ~S: Trigger name EMPLOYEE_ID_CASCADE_DELETEE Conjunct Get Retrieval by index of relation DEPARTMENTS( Index name DEPARTMENTS_INDEX [0:0]K Temporary relation Get Retrieval by index of relation EMPLOYEES9 Index name EMPLOYEES_HASH [1:1] Direct lookup 1 row deleted2 Example 7: Using the INDEX_COLUMN_GROUP Keyword= SQL> -- The table STUDENTS has an ind Fex on the two columns> SQL> -- STU_NUM and COURSE_NUM. When the INDEX_COLUMN_GROUP9 SQL> -- keyword is not set, the optimizer uses a fixedD SQL> -- proportion of the table cardinality based on the equalityL SQL> -- with the STU_NUM column. In this example, 5134 rows are expected,= SQL> -- when in reality, only 9 are returned by the query.G SQL> CREATE INDEX STUDENT_NDX ON STUDENTS (STU_NUM,COURSE_NUM DESC); SQL> --$ SQL> SELECT STU_NUM FROM STUDENTS# cont> WHERE STU_NUGM = 191270771 cont> ORDER BY OTHER_COLUMN; Solutions tried 2 Solutions blocks created 1 Created solutions pruned 0. Cost of the chosen solution 4.5644922E+031 Cardinality of chosen solution 5.1342500E+03 ~O: Physical statistics used Sort SortId# 7., # Keys 20 Item# 1, Dtype: 2, Order: 0, Off: 0, Len: 11 Item# 2, Dtype: 35, Order: 0, Off: 1, Len: 84 LRL: 32, NoDups:0, Blks:327, EqlKey:0, WkFls: 2' Leaf#01 BgrOnly STUDENTS Card=164296% H BgrNdx1 STUDENT_NDX [1:1] Fan=14 191270771 191270771 191270771 191270771 191270771 191270771 191270771 191270771; SORT(9) SortId# 7, --------------------- Version: V5-0004 Records Input: 9 Sorted: 9 Output: 07 LogRecLen Input: 32 Intern: 32 Output: 324 Nodes in SoTree: 5234 Init Dispersion Runs: 04 Max Merge Order: 0 Numb.of Merge passes: 0 Work File Alloc: 0. MBC for Inp Iut: 0 MBC for Output: 0. MBF for Input: 0 MBF for Output: 0& Big Allocated Chunk: 4606464 busy 191270771 9 rows selected SQL> --: SQL> -- When you use the SET FLAGS statement to set theA SQL> -- INDEX_COLUMN_GROUP keyword, it activates the optimizerE SQL> -- to consider the index segment columns as a workload columnF SQL> -- group, compute the statistics for duplicity factor and nullD SQL> -- factor dynamically, and then apply them in estimating J the' SQL> -- cardinality of the solution. SQL> --' SQL> SET FLAGS 'INDEX_COLUMN_GROUP';M SQL> -- The following is the optimizer cost estimate and sort output traceP SQL> -- for the previous query with INDEX_COLUMN_GROUP enabled. The optimizer= SQL> -- now estimates a lower cardinality of about 8 rows. Solutions tried 2 Solutions blocks created 1 Created solutions pruned 0. Cost of the chosen solution 3.8118614E+011 Cardinality of chosen solution 8.396157K3E+00, ~O: Workload and Physical statistics used Sort SortId# 2., # Keys 20 Item# 1, Dtype: 2, Order: 0, Off: 0, Len: 11 Item# 2, Dtype: 35, Order: 0, Off: 1, Len: 82 LRL: 32, NoDups:0, Blks:7, EqlKey:0, WkFls: 2' Leaf#01 BgrOnly STUDENTS Card=164296% BgrNdx1 STUDENT_NDX [1:1] Fan=14 191270771 191270771 191270771 191270771 191270771 191270771 191270771 191270771; SORT(2) SortId# 2, --------------L------- Version: V5-0004 Records Input: 9 Sorted: 9 Output: 05 LogRecLen Input: 32 Intern: 32 Output: 322 Nodes in SoTree: 114 Init Dispersion Runs: 02 Max Merge Order: 0 Numb.of Merge passes: 0 Work File Alloc: 0, MBC for Input: 0 MBC for Output: 0, MBF for Input: 0 MBF for Output: 0" Big Allocated Chunk: 87552 idle 191270771 9 rows selected- Example 8: Using the AUTO_OVERRIDE KeywordB SQL> -- Suppose that Mafter year 2000 testing was performed on aE SQL> -- production system, the system date and time were not reset; SQL> -- to the correct date. This was not noticed until@ SQL> -- after transactions for a full day had been stored. ToE SQL> -- correct this problem, the database administrator overridesC SQL> -- the READ ONLY characteristic of the AUTOMATIC column and% SQL> -- adjusts the date and time. SQL> SELECT * FROM ACCOUNTS, cont> WHERE LAST_UPDATE > DATE'2001-1-1';J N ACCOUNT_NO LAST_NAME LAST_UPDATE CURRENT_BALANCEF NULL Smith 2001-06-02 100000.000 1 row selected= SQL> -- Attempts to fix the date and time fail because the SQL> -- column is AUTOMATIC. SQL> UPDATE ACCOUNTS= cont> SET LAST_UPDATE = LAST_UPDATE - INTERVAL'1' YEAR0 cont> WHERE LAST_UPDATE > DATE'2000-1-1';L %RDB-E-READ_ONLY_FIELD, attempt to update the read-only field LAST_UPDATE SQL> --" SQL> SET OFLAGS 'AUTO_OVERRIDE'; SQL> SHOW FLAGS Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb: PREFIX,AUTO_OVERRIDE SQL>--! SQL> -- Fix the date and time. SQL> UPDATE ACCOUNTS= cont> SET LAST_UPDATE = LAST_UPDATE - INTERVAL'1' YEAR0 cont> WHERE LAST_UPDATE > DATE'2000-1-1'; 1 row updated SQL> SQL> SELECT * FROM ACCOUNTS;O ACCOUNT_NO LAST_NAME LAST_UPDATE CURRENT_BALANCEO NULL Smith P 1999-06-02 100000.000 1 row selected SQL>$ SQL> SET FLAGS 'NOAUTO_OVERRIDE';) Example 9: Using the AUTO_INDEX option SQL> set dialect 'SQL92';+ SQL> set flags 'AUTO_INDEX,INDEX_STATS'; SQL> create table PERSON/ cont> (employee_id integer primary key,C cont> manager_id integer references PERSON (employee_id),$ cont> last_name char(30),$ cont> first_name char(30),* cont> unique (last_name, first_name));0 Q ~Ai create index "PERSON_PRIMARY_EMPLOYEE_ID" ~Ai larea length is 430& ~Ai storage area (default) larea=57& ~Ai create sorted index, ikey_len=5< Sort Get Retrieval sequentially of relation PERSON/ ~Ai create index partition, node=430 %fill=0% ~Ai create index "PERSON_FOREIGN1" ~Ai larea length is 215' ~Ai storage area is shared: larea=57& ~Ai create sorted index, ikey_len=5< Sort Get Retrieval sequentially of relation PERSON- ~Ai create index partRition, node=0 %fill=0$ ~Ai create index "PERSON_UNIQUE1" ~Ai larea length is 215' ~Ai storage area is shared: larea=57' ~Ai create sorted index, ikey_len=62< Sort Get Retrieval sequentially of relation PERSON- ~Ai create index partition, node=0 %fill=0 SQL>! SQL> show table (index) person Information for table PERSON Indexes on table PERSON:9 PERSON_FOREIGN1 with column MANAGER_ID Duplicates are allowed Type is SortedS' Key suffix compression is DISABLED: PERSON_PRIMARY_EMPLOYEE_ID with column EMPLOYEE_ID No Duplicates allowed Type is Sorted' Key suffix compression is DISABLED Node size 4308 PERSON_UNIQUE1 with column LAST_NAME8 and column FIRST_NAME Duplicates are allowed Type is Sorted' Key suffix compression is DISABLED SQL>* Example 10: Using the WATCH_CALL option< This example Tshows the output of WATCH_CALL for an INSERT@ statement which causes an AFTER INSERT trigger (AFTER_INSERT)A to be executed which calls an SQL function WRITE_TEXT to traceA the input data. It then traces a query named using OPTIMIZE AS clause.- SQL> insert into SAMPLE_T values ('Fred');' ~Xa: routine "(unnamed)", user=SMITH* ~Xa: routine "AFTER_INSERT", user=SMITH( ~Xa: routine "WRITE_TEXT", user=SMITH ~Xt: Fred 1 row inserted SQL> select * from SAMPLE_T) U cont> optimize as LOOKUP_SAMPLE_T;- ~Xa: routine "LOOKUP_SAMPLE_T", user=SMITH NEW_NAME Fred 1 row selected* Example 11: Using the WATCH_OPEN optionB This example shows the output of WATCH_OPEN for the same INSERT# statement as seen in example 10.- SQL> insert into SAMPLE_T values ('Fred');@ ~Xo: Start Request B667E51E3625026EB7FFF3F4D3A16DC3 (unnamed)M ~Xo: Start Request A8568053FE5A1A0852A1BE83A884016F "AFTER_INSERT" (query)L ~Xo: Start Request V08AE59062657299B4768F6C2DFB6928E "WRITE_TEXT" (stored) ~Xt: Fred 1 row inserted SQL> SQL> select * from SAMPLE_T) cont> optimize as LOOKUP_SAMPLE_T;P ~Xo: Start Request F6025FAB1DD36B0DE0E52F3A9641BC5F "LOOKUP_SAMPLE_T" (query) NEW_NAME Fred Fred 2 rows selected : Example 12: Using SET FLAGS from an application programA The SET FLAGS statement can be executed from Dynamic SQL using one of two methods.A o The first method is immediWate execution by passing a string@ literal. The string literal argument to SET FLAGS requiresB that the single quote marks be doubled for correct inclusion: in the string literal argument to EXECUTE IMMEDIATE.D o The second method is to pass the entire SET FLAGS statement in& a parameter to EXECUTE IMMEDIATE exec sql2 execute immediate 'set flags ''strategy''';D The entire SET FLAGS statement could be in a parameter to EXECUTE IMMEDIATE exec Xsql) execute immediate :set_flags_text;@ If SET FLAGS is executed multiple times it can be prepared asA a dynamic statement (PREPARE) and then the statement name usedB for multiple executions. The input marker (?) is substituted on@ different calls to EXECUTE the previously prepared statement. #include  #include  void main () { int SQLCODE; char myflags[40]; exec sql1 prepare set_flags_stmt from 'set flagYs ?'; if (SQLCODE != 0) sql_signal ();- strcpy (myflags, "transaction,item_list"); exec sql- execute set_flags_stmt using :myflags; if (SQLCODE != 0) sql_signal (); exec sql start transaction; if (SQLCODE != 0) sql_signal ();1 strcpy (myflags, "notransaction,noitem_list"); exec sql- execute set_flags_stmt using :myflags; if (SQLCODE != 0) sql_signal (); exec sql rollback; if (SZQLCODE != 0) sql_signal (); }+ Example 13: Using the CHRONO_FLAG option. SQL> set flags 'chrono_fla(2),transaction'; SQL> start transaction;& ATTACH #1, 29-NOV-2003 10:08:37.51& ~T Compile transaction (1) on db: 1* ~T Transaction Parameter Block: (len=2)! 0000 (00000) TPB$K_VERSION = 1( 0001 (00001) TPB$K_WRITE (read write)& ATTACH #1, 29-NOV-2003 10:08:37.580 ~T Start_transaction (1) on db: 1, db count=1 SQL> rollback;& ATTACH #1, 29-NOV-20[03 10:08:46.74' ~T Rollback_transaction (1) on db: 1 SQL> rollback;& ATTACH #1, 29-NOV-2003 10:08:46.74' ~T Rollback_transaction (1) on db: 1 SQL>2 Example 14: Using the REBUILD_SPAM_PAGES option@ When changing the row length or THRESHOLDS clause for a table> or index, the corresponding SPAM pages for the logical area@ may require rebuilding. By default, these DDL commands update@ the AIP and set a flag to indicate that the SPAM pages shouldA be rebuilt. How\ever, this flag may be set prior to executing aD COMMIT for the transaction and the rebuild will take place within this transaction.? The following example shows a simple change to the EMPLOYEESC table (mapped in this example to set of UNIFORM areas). The flagA STOMAP_STATS is used to enable more trace information from the ALTER and COMMIT statements.# SQL> set transaction read write; SQL>! SQL> set flags 'stomap_stats'; SQL> SQL> alter table EMPLOYEE]S7 cont> add column MANAGERS_COMMENTS varchar(300);9 ~As: reads: async 0 synch 94, writes: async 18 synch 1 SQL>' SQL> alter storage map EMPLOYEES_MAP cont> store$ cont> using (EMPLOYEE_ID)" cont> in EMPIDS_LOW* cont> (thresholds (34,76,90))0 cont> with limit of ('00200')" cont> in EMPIDS_MID* cont> (thresholds (34,76,90))0 cont> with limit of ('00400')- cont> ^ otherwise in EMPIDS_OVER+ cont> (thresholds (34,76,90));+ ~As locking table "EMPLOYEES" (PR -> PU)1 ~As: removing superseded routine EMPLOYEES_MAPB ~As: creating storage mapping routine EMPLOYEES_MAP (columns=1): ~As: reads: async 0 synch 117, writes: async 56 synch 0 SQL>' SQL> set flags 'rebuild_spam_pages'; SQL> SQL> commit;7 %RDMS-I-LOGMODVAL, modified record length to 423Q %RDMS-I-LOGMODVAL, modified space management thresholds _ to (34%, 76%, 90%)7 %RDMS-I-LOGMODVAL, modified record length to 423Q %RDMS-I-LOGMODVAL, modified space management thresholds to (34%, 76%, 90%)7 %RDMS-I-LOGMODVAL, modified record length to 423Q %RDMS-I-LOGMODVAL, modified space management thresholds to (34%, 76%, 90%) SQL>A The message LOGMODVAL will appear for each logical area in the" storage map, one per partition.D This rebuild action only applies to UNIFORM storage areas and mayA incur sig`nificant I/O as SPAM pages and data pages are read to% allow the SPAM page to be rebuilt.0 Example 15: Using the OPTIMIZATION_LEVEL flagB The following example shows how the behavior of a query changesD using the dynamic optimizer with the OPTIMIZATION_LEVEL flag set.: SQL> -- show with default behavior (FFirst tactic used) SQL> select * cont> from xtest. cont> where col2 between 999980 and 1000000 cont> and col1 > 0 cont> ; Tables: 0 = XTEST! a Leaf#01 FFirst 0:XTEST Card=10F Bool: (0.COL2 >= 999980) AND (0.COL2 <= 1000000) AND (0.COL1 > 0)# BgrNdx1 XTEST_IDX [1:0] Fan=17 Keys: 0.COL1 > 0 0 rows selected SQL> SQL> -- use SET FLAGS3 SQL> set flags 'optimization_level(total_time)'; SQL>3 SQL> -- show that BgrOnly is used for TOTAL TIME SQL> select * cont> from xtest. cont> where col2 between 999980 and 1000000 cont> and col1 > 0 cont> ; Tables: 0 = XTEST" Leaf#b01 BgrOnly 0:XTEST Card=10F Bool: (0.COL2 >= 999980) AND (0.COL2 <= 1000000) AND (0.COL1 > 0)# BgrNdx1 XTEST_IDX [1:0] Fan=17 Keys: 0.COL1 > 0 0 rows selected SQL>( Example 16: Using the ON ALIAS Clause> The default behavior for SET FLAGS is to establish the flag< settings on all currently attached databases. This clauseA will allow the database administrator to set flags on just one database alias.A The following example shows a case where the en cabling of AUTO_C OVERRIDE required DBADM privilege on the target database but notC on the source database. It may be that the current user does not: have (or really need) DBADM privilege on that database.8 SQL> -- Now enable AUTO_OVERRIDE on only one database3 SQL> set flags (on alias abc_a) 'auto_override';* SQL> set flags (on alias abc_b) 'none';I SQL> insert into abc_a.SAMPLE_TABLE select * from abc_b.SAMPLE_SOURCE; SQL> commit;* Example 17: Using the NOREWRITEd keyword SQL> set line length 70 SQL> show flags; Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:H PREFIX,WARN_DDL,INDEX_COLUMN_GROUP,MAX_SOLUTION,MAX_RECURSION(100)? ,REWRITE(CONTAINING),REWRITE(LIKE),REWRITE(STARTING_WITH)- ,REFINE_ESTIMATES(127),NOBITMAPPED_SCAN SQL> SQL> set flags 'norewrite'; SQL> show flags; Alias RDB$DBHANDLE:& Flags currently set for Oracle Rdb:H PREFIX,WARN_DDL,INDEX_COLUMN_GROUP,MAX_SOLUTION,MAX_REeCURSION(100)- ,REFINE_ESTIMATES(127),NOBITMAPPED_SCAN SQL> wwX1 SET_HOLD_CURSORS@ Specifies the session default attributes for holdable cursors) that have not been previously defined. 2 Environment. You can use the SET HOLD CURSORS statement: o In interactive SQLD o Embedded in host language programs to be precompiled to change% the behavior of dynamic cursors- o As part of a procedure in an SQL module> o In dfynamic SQL as a statement to be dynamically executed 2 Format* SET HOLD CURSORS -+-> variable -------+->( +-> string-literal -+  2 Arguments 3 variable Syntax options: variable | string-literal> Specifies the attribute for the holdable cursor. Values can include: o ON COMMITD All cursors declared without a WITH HOLD clause or with a WITH8 HOLD ON COMMIT clause remain open when you commit. o ON ROLLBgACKD All cursors declared without a WITH HOLD clause or with a WITH= HOLD ON ROLLBACK clause remain open when you roll back. o ALLB All cursors remain open with the exception of those declared with a WITH HOLD clause. o NONEC All cursors close with the exception of those declared with a WITH HOLD clause.B This is the default if you do not specify a SET HOLD CURSORS statement. 2 Example= Example 1: Setting sesshion default attributes for holdable cursors' SQL> ATTACH 'FILENAME mf_personnel'; SQL> --% SQL> -- Define the session default SQL> --' SQL> SET HOLD CURSORS 'ON ROLLBACK'; SQL> -- SQL> -- Declare the cursor SQL> -- SQL> DECLARE curs1 CURSOR FOR5 cont> SELECT first_name, last_name FROM employees; SQL> OPEN curs1; SQL> FETCH curs1; FIRST_NAME LAST_NAME Terry Smith SQL> FETCH curs1; FIRST_NAME LAST_NAME Rick i O'Sullivan5 SQL> DELETE FROM employees WHERE CURRENT OF curs1; 1 row deleted SQL> ROLLBACK; SQL> FETCH curs1; FIRST_NAME LAST_NAME Stan Lasch SQL> COMMIT; SQL> FETCH curs1;/ %SQL-F-CURNOTOPE, Cursor CURS1 is not openedD Example 2: Overriding the session default attributes for holdable cursors" SQL> -- Set the session default SQL> -- SQL> SET HOLD CURSORS 'ALL'; SQL> --8 SQL> -- Declare the cursor without a WITH HOLD cljause SQL> -- SQL> DECLARE curs2 CURSOR FOR5 cont> SELECT first_name, last_name FROM employees; SQL> OPEN curs2; SQL> FETCH curs2; FIRST_NAME LAST_NAME Terry Smith SQL> FETCH curs2; FIRST_NAME LAST_NAME Rick O'Sullivan SQL> ROLLBACK; SQL> FETCH curs2; FIRST_NAME LAST_NAME Stan Lasch SQL> COMMIT; SQL> FETCH curs2; FIRST_NAME LAST_NAME Susan Gray SQL> CLOSE curs2; SQL> FETCH kcurs2;/ %SQL-F-CURNOTOPE, Cursor CURS2 is not opened SQL> --? SQL> -- Declare the cursor overriding the session default by* SQL> -- specifying the WITH HOLD clause SQL> -- SQL> DECLARE curs3 CURSOR% cont> WITH HOLD PRESERVE ON COMMIT9 cont> FOR SELECT first_name, last_name FROM employees; SQL> OPEN curs3; SQL> FETCH curs3; FIRST_NAME LAST_NAME Terry Smith SQL> FETCH curs3; FIRST_NAME LAST_NAME Rick O'Sullivan SQL> lCOMMIT; SQL> FETCH curs3; FIRST_NAME LAST_NAME Stan Lasch SQL> ROLLBACK; SQL> FETCH curs3;/ %SQL-F-CURNOTOPE, Cursor CURS3 is not opened wwր1 SET_IDENTIFIER_CHARACTER_SET; Specifies the identifier character set for the module or interactive SQL session. 2 Environment: You can use the SET IDENTIFIER CHARACTER SET statement: o In interactive SQL: o Embedded in host language programs to be precompiled-m o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format7 SET IDENTIFIER CHARACTER SET --> runtime-options ---->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterB Specifies the character set used for database object names such@ as table names and column names. The value of runtimen-optionsB must be a valid character set. See the Oracle Rdb SQL ReferenceC Manual for a list of allowable character sets and option values. 3 parameter-markerB Specifies the character set used for database object names such@ as table names and column names. The value of runtime-optionsB must be a valid character set. See the Oracle Rdb SQL ReferenceC Manual for a list of allowable character sets and option values. 3 'string-literal'B Specifies the charactero set used for database object names such@ as table names and column names. The value of runtime-optionsB must be a valid character set. See the Oracle Rdb SQL ReferenceC Manual for a list of allowable character sets and option values. 2 ExampleD Example 1: Setting the identifier character set of an interactive session SQL> show character sets;% Default character set is DEC_KANJI& National character set is DEC_KANJI( Identifier character set is SHIFT_JIS% Litperal character set is SHIFT_JIS% Display character set is SHIFT_JIS1 SQL> set identifier character set 'DEC_KANJI'; SQL> show character sets;% Default character set is DEC_KANJI& National character set is DEC_KANJI( Identifier character set is DEC_KANJI% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS wwր1 SET_KEYWORD_RULESB Specifies whether or not you can use identifiers as keywords in the current attach. q2 Environment/ You can use the SET KEYWORD RULES statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format1 SET KEYWORD RULES -----> runtime-options ------>  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arg'ruments 3 parameterC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 parameter-markerC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 MIAA Specifies that SQL returns an error if statements use keywordsD (reserved words) as identifierss, unless the keywords are enclosed in double quotation marks. 3 'string-literal'C Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 SQL89A Specifies that SQL returns an error if statements use keywordsD (reserved words) as identifiers, unless the keywords are enclosed in double quotation marks. 3 SQL92A Specifies that SQL returns an errort if statements use keywordsD (reserved words) as identifiers, unless the keywords are enclosed! within double quotation marks. 3 SQL99A Specifies that SQL returns an error if statements use keywordsD (reserved words) as identifiers, unless the keywords are enclosed! within double quotation marks. 3 SQLV40A Specifies that SQL returns an error if statements use keywordsD (reserved words) as identifiers, unless the keywords are enclosed! within double quoutation marks. 2 Examples? Example 1: Setting the keyword rule characteristics to SQL99" SQL> SET KEYWORD RULES 'SQL99'; SQL> --G SQL> -- Because NATIONAL is a keyword, SQL returns an error message. SQL> --( SQL> CREATE DOMAIN NATIONAL CHAR (2);A %SQL-F-RES_WORD_AS_IDE, Keyword NATIONAL used as an identifier SQL> --6 SQL> -- Enclose NATIONAL in double quotation marks. SQL> --* SQL> CREATE DOMAIN "NATIONAL" CHAR (2); SQL> --@ Example 2: Settinvg the keyword rule characteristics to SQLV40# SQL> SET KEYWORD RULES 'SQLV40'; SQL> --2 SQL> -- You can use a keyword as an identifier. SQL> --( SQL> CREATE DOMAIN NATIONAL CHAR (2);R %SQL-I-DEPR_FEATURE, Deprecated Feature: Keyword national used as an identifier SQL> -- wwր1 SET_LITERAL_CHARACTER_SETD Specifies the literal character set for the module or interactive SQL session. 2 Environment7 You can use the SET LITERAL CHARA wCTER SET statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format4 SET LITERAL CHARACTER SET --> runtime-options ---->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterB Specifies t xhe character set for literals that are not qualified= by a character set or national character set. The value of@ runtime-options must be a valid character set. See the OracleA Rdb SQL Reference Manual for a list of the allowable character sets and option values. 3 parameter-markerB Specifies the character set for literals that are not qualified= by a character set or national character set. The value of@ runtime-options must be a valid character set. See the OracleyA Rdb SQL Reference Manual for a list of the allowable character sets and option values. 3 'string-literal'B Specifies the character set for literals that are not qualified= by a character set or national character set. The value of@ runtime-options must be a valid character set. See the OracleA Rdb SQL Reference Manual for a list of the allowable character sets and option values. 2 ExampleA Example 1: Setting the literal character set of an interactivez session SQL> show character sets;% Default character set is DEC_KANJI& National character set is DEC_KANJI( Identifier character set is DEC_KANJI% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS. SQL> set literal character set 'DEC_KANJI'; SQL> show character sets;% Default character set is DEC_KANJI& National character set is DEC_KANJI( Identifier character set is DEC_KANJI% Literal character set is DEC_KANJI% Display charact{er set is SHIFT_JIS wwր 1 SET_NAMESD Specifies the default, identifier, and literal character sets forD the session. The SET NAMES statement also specifies the character& parameters for SQL module language. 2 Environment' You can use the SET NAMES statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically |executed 2 Format' SET NAMES ---> runtime-options ------>  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameter@ Specifies the character set used for the default, identifier,C and literal character set for the session. The value of runtime-@ options must be a valid character set. See the Oracle Rdb SQL> Reference Manual for a list of allowabl}e character sets and option values. 3 parameter-marker@ Specifies the character set used for the default, identifier,C and literal character set for the session. The value of runtime-@ options must be a valid character set. See the Oracle Rdb SQL> Reference Manual for a list of allowable character sets and option values. 3 'string-literal'@ Specifies the character set used for the default, identifier,C and literal character set for the session. The va~lue of runtime-@ options must be a valid character set. See the Oracle Rdb SQL> Reference Manual for a list of allowable character sets and option values. 2 ExampleD Example 1: Setting the default, identifier, and literal character! sets of an interactive session SQL> show character sets;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED SQL> -- SQL> set names 'DEC_KANJI'; SQL> show character sets;% Default character set is DEC_KANJI$ National character set is DEC_MCS( Identifier character set is DEC_KANJI% Literal character set is DEC_KANJI' Display character set is UNSPECIFIED SQL> --7 SQL> -- Specifying a different default character set SQL> --/ SQL> set default character set 'DEC_KOREAN'; SQL> show character sets;& Default character set is DEC_KOREAN$ National character set is DEC_MCS( Identifier character set is DEC_KANJI% Literal character set is DEC_KANJI' Display character set is UNSPECIFIED SQL> wwր1 SET_NATIONAL_CHARACTER_SET9 Specifies the national character set for the module or interactive SQL session. 2 Environment8 You can use the SET NATIONAL CHARACTER SET statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format5 SET NATIONAL CHARACTER SET --> runtime-options ---->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterC Specifies the national character set for your session. The valueC of runtime-options must be a valid character set. See the OracleD Rdb SQL Reference Manual for more information about the supported character sets. 3 parameter-markerC Specifies the national character set for your session. The valueC of runtime-options must be a valid character set. See the OracleD Rdb SQL Reference Manual for more information about the supported character sets. 3 'string-literal'C Specifies the national character set for your session. The valueC of runtime-options must be a valid character set. See the OracleD Rdb SQL Reference Manual for more information about the supported character sets. 2 ExampleC Example 1: Setting the national character set for an interactive session SQL> show character sets;% Default character set is DEC_KANJI$ National character set is DEC_MCS( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS/ SQL> set national character set 'DEC_KANJI'; SQL> show character sets;% Default character set is DEC_KANJI& National character set is DEC_KANJI( Identifier character set is SHIFT_JIS% Literal character set is SHIFT_JIS% Display character set is SHIFT_JIS ww稖1 SET_OPTIMIZATION_LEVEL@ Allows the current session defaults to be specified for query optimization characteristics.B This statement can reset the session defaults using DEFAULT, orD can specify one or more keywords for SELECTIVITY or FAST FIRST or TOTAL TIME optimization.: This statement affects all subsequent query compiles in; interactive SQL, or queries specified using dynamic SQL.= See the Oracle Rdb SQL Reference Manual for information on? setting the optimization level in SQL module and precompiler languages. 2 Environment4 You can use the SET OPTIMIZATION LEVEL statement: o In interactive SQL: o Embedded in host language programs to be precompiled> o In dynamic SQL as a statement to be dynamically executed 2 Format2 SET OPTIMIZATION LEVEL ---> runtime-options ----> runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ optimization-level=) -+-> DEFAULT -----------------------+-->& ++-+-> AGGRESSIVE SELECTIVITY --+--+& | +-> FAST FIRST --+ |& | +-> SAMPLED SELECTIVITY ----+ |& | +-> TOTAL TIME ------------+ |& +-------------, <-----------------+  2 Arguments 3 optimization-level? Specifies the optimizer strategy to be used to reset session; defaults. The passed string or parameter value must be a> formatted list of keyword values. Select from the following options:C o AGGRESSIVE SELECTIVITY option if you expect a small number of rows to be selected.B o DEFAULT option to accept the Oracle Rdb defaults: FAST FIRST and DEFAULT SELECTIVITY.B o FAST FIRST option if you want your program to return data toC the user as quickly as possible, even at the expense of total throughput.@ o SAMPLED SELECTIVITY option to use literals in the query to0 perform preliminary estimation on indexes.> o TOTAL TIME option if you want your program to run at theA fastest possible rate, returning all the data as quickly asC possible. If your application runs in batch, accesses all theA records in a query, and performs updates or writes reports,$ you should specify TOTAL TIME.D Only one of the TOTAL TIME or FAST FIRST options can be selected.@ Only one of the AGGRESSIVE SELECTIVITY or SAMPLED SELECTIVITYD options can be selected. Use a comma to separate the keywords andD enclose the list in parentheses. No other options may be included if DEFAULT is selected. 3 parameterC Specifies the value of the runtime-options, which must be a list$ of keywords, separated by commas. 3 parameter-markerC Specifies the value of the runtime-options, which must be a list$ of keywords, separated by commas. 3 'string-literal'C Specifies the value of the runtime-options, which must be a list$ of keywords, separated by commas.D Only one of the options TOTAL TIME or FAST FIRST may be selected.< Only one of the options AGGRESSIVE SELECTIVITY or SAMPLED@ SELECTIVITY may be selected. No other options may be included if DEFAULT is selected. 2 Example, Example  1: Setting the optimization level@ The dynamic optimizer can use either FAST FIRST or TOTAL TIMEB tactics to return rows to the application. The default setting,@ FAST FIRST, assumes that applications, especially those using@ interactive SQL, will want to see rows as quickly as possible@ and possibly abort the query before completion. Therefore, ifA the FAST FIRST tactic is possible the optimizer will sacrifice@ overall retrieval time to initially return rows quickly. This<  choice can be affected by setting the OPTIMIZATION LEVEL.@ The following example contrasts the query strategies selected@ when FAST FIRST versus TOTAL TIME is in effect. Databases andC queries will vary in their requirements. Queries should be tuned? to see which setting best suits the needs of the application@ environment. For the MF_PERSONNEL database there is little orA no difference between these tactics, but for larger tables the# differences could be noticeable.$  SQL> set flags 'STRATEGY,DETAIL'; SQL> --A SQL> -- No optimization level has been selected. The optimizer> SQL> -- selects the FAST FIRST (FFirst) retrieval tactic to< SQL> -- retrieve the rows from the EMPLOYEES table in the SQL> -- following query: SQL> --% SQL> select EMPLOYEE_ID, LAST_NAME cont> from EMPLOYEES1 cont> where EMPLOYEE_ID IN ('00167', '00168'); Tables: 0 = EMPLOYEES& Leaf#01 FFirst 0:EMPLOYEES Card=100A Bool: (0.EMPLOYEE_ID = '00167') OR (0.EMPLOYEE_ID = '00168')* BgrNdx1 EMPLOYEES_HASH [(1:1)2] Fan=1( Keys: r0: 0.EMPLOYEE_ID = '00168'( r1: 0.EMPLOYEE_ID = '00167' EMPLOYEE_ID LAST_NAME 00167 Kilpatrick 00168 Nash 2 rows selected SQL> --C SQL> -- Use the SET OPTIMIZATION LEVEL statement to specify thatB SQL> -- you want the TOTAL TIME (BgrOnly) retrieval strategy to SQL> -- be used. SQL> --, SQL> SET OPTIMIZATION LEVEL 'TOTAL TIME';% SQL> select EMPLOYEE_ID, LAST_NAME cont> from EMPLOYEES1 cont> where EMPLOYEE_ID IN ('00167', '00168'); Tables: 0 = EMPLOYEES' Leaf#01 BgrOnly 0:EMPLOYEES Card=100A Bool: (0.EMPLOYEE_ID = '00167') OR (0.EMPLOYEE_ID = '00168')* BgrNdx1 EMPLOYEES_HASH [(1:1)2] Fan=1( Keys: r0: 0.EMPLOYEE_ID = '00168'( r1: 0.EMPLOYEE_ID = '00167' EMPLOYEE_ID LAST_NAME 00167 Kilpatrick 00168 Nash 2 rows selected SQL> --> SQL> --  When the SET OPTIMIZATION LEVEL 'DEFAULT' statementI SQL> -- is specified the session will revert to the default FAST FIRST SQL> -- optimizer tactic. SQL> --) SQL> SET OPTIMIZATION LEVEL 'DEFAULT';% SQL> select EMPLOYEE_ID, LAST_NAME cont> from EMPLOYEES1 cont> where EMPLOYEE_ID IN ('00167', '00168'); Tables: 0 = EMPLOYEES& Leaf#01 FFirst 0:EMPLOYEES Card=100A Bool: (0.EMPLOYEE_ID = '00167') OR (0.EMPLOYEE_ID = '00168')* BgrNdx1 EMPLOYEES_HASH [(1:1)2] Fan=1( Keys: r0: 0.EMPLOYEE_ID = '00168'( r1: 0.EMPLOYEE_ID = '00167' EMPLOYEE_ID LAST_NAME 00167 Kilpatrick 00168 Nash 2 rows selected SQL>' Example 2: Using sampled selectivityC This example shows the use of the SET OPTIMIZATION LEVEL command? and the resulting use of "Estim" prior to query compile. TheD estimate (34 rows) is quite close to the final result of 37 rows.+SQL> set flags 'strategy,detail,execution' ;>SQL> set optimization level 'total time, sampled selectivity';KSQL> select * from employees where employee_id between '00000' and '00200';9~Estim EMP_EMPLOYEE_ID Sorted: Split lev=2, Seps=2 Est=349~Estim EMP_EMPLOYEE_ID Sorted: Split lev=2, Seps=2 Est=34~S#0005Tables: 0 = EMPLOYEES$Leaf#01 BgrOnly 0:EMPLOYEES Card=100@ Bool: (0.EMPLOYEE_ID >= '00000' AND (0.EMPLOYEE_ID <= '00200')& BgrNdx1 EMP_EMPLOYEE_ID [1:1] Fan=17B Keys: (0:EMPLOYEE_ID >= '00000') AND 0.EMPLOYEE_ID <= '00200')9~Estim EMP_EMPLOYEE_ID Sorted: Split lev=2, Seps=1 Est=17)~E#0005.01(1) Estim Index/Estimate 1/17J~E#0005.01(1) Bgrndx1 EofData DBKeys=37 Fetches=0+0 RecsOut=0 #Bufs=30c EMPLOYEE_ID LAST_NAME FIRST_NAME MIDDLE_INITIAL ADDRESS_DATA1 ADRESS_DATA_2N CITY STATE POSTAL_CODE SEX BIRTHDAY STATUS_CODE[ 00190 O'Sullivan Rick G. 78 Mason Rd. NULLD Fremont NH 03044 M 12-Jan-1923 1 . . .A~E#005.01(1) Fin Buf DBKeys=37 Fetches=0+32 RecsOut=37[ 00174 Myotte Daniel V. 95 Princeton Rd. NULLD Bennington MA 03442 M 17-Jan-1948 1 37 rows selectedSQL> ww稖1 SET_PAGE_LENGTH: Used to size a page. Currently this is only used by the. pagination control in the SQL HELP command. 2 Environment? You can use the SET PAGE LENGTH (or SET PAGESIZE) statement: o In interactive SQL( o Embedded in host language programs? o As part of a procedure in an SQL module or other compound statement> o In dynamic SQL as a statement to be dynamically executed 2 Format' SET PAGE LENGTH -----> integer ------>  2 Examples> This example uses the SET PAGE LENGTH command to change the pagination length of HELP. SQL> set page length 40; SQL> show display( Output of the query header is enabled' Output of the row counter is enabled' Output using edit strings is enabled! Page length is set to 40 lines! Line length is set to 80 bytes# Display NULL values using "NULL" ww稖 1 SET_QUERYD The SET QUERY statement is used to control query execution within a SQL session. 2 Environment' You can use the SET QUERY statement: o In interactive SQL: o Embedded in host languagu<SET_LITERAL_CHARACTER_SETz& SET_NAMESSET_NATIONAL_CHARACTER_SETSET_OPTIMIZATION_LEVELHSET_PAGE_LENGTH SET_QUERYnSET_QUIET_COMMITSET_QUOTING_RULES SET_SCHEMANSET_SESSION_AUTHORIZATION^ SET_SQLDASET_TRANSACTION SET_VIEW_UPDATE_RULESSHOWSIGNAL_ControlfSimple_StatementSQLCASQLDASQLSTATEB SQL_standardsSTART_TRANSACTION$Stored_FunctionsStored_Procedurese programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executedD Note that some options for the SET QUERY command may only be used in interactive SQL. 2 Format set-query =d --> SET QUERY -+-> CONFIRM ------------------------------------------------------------------+-->a +-> NOCONFIRM ------------------------------------------------------------------+a +-> LIMIT -+--> ROWS ----------------------+-----------------------+a | +--> TIME -----+-+------------+-+ |a | +--> CPU TIME -+ +-> SECONDS -+ |a | +-> MINUTES -+ |a +-> NOLIMIT -+--> ROWS -----+---------------------------------------------------+a | +--> TIME -----+ |a | +--> CPU TIME -+ |a +-> EXECUTION LIMIT -+-> CPU -----+---> TIME ---> -+------------+--+a | +-> ELAPSED -+ +-> SECONDS -+ |a | +-> MINUTES -+ |a +-> EXECUTION NOLIMIT -+-> CPU -----+-> TIME -----------------------------------+5 +-> ELAPSED -+ 2 Arguments 3 CONFIRMD Lets you preview the cost of a query, in terms of I/O, before any+ rows are actually returned. For example: SQL> SELECT * FROM EMPLOYEES;9 Estimate of query cost: 52 I/O s, rows to deliver: 100- Do you wish to cancel this query (No)? YES5 %SQL-F-QUERYCAN, Query cancelled at user s requestB Some queries can result in Oracle Rdb performing a large numberA of I/O operations, retrieving a large number of rows, or both.B The SET QUERY CONFIRM statement causes SQL to display estimatedA query costs. If the cost appears excessive, you can cancel the2 query by answering No; to continue, answer Yes.D The SET QUERY CONFIRM statement is only available for interactive SQL. 3 EXECUTION_LIMIT? This option imposes elapsed and CPU time limits on executing@ queries. This command aff ects all subsequent queries executedD within the Rdb server process. You must be attached to a databaseA to execute this statement. This statement affects all attaches< for the current process, not just the current connection./ o CPU TIME time_value [ SECONDS | MINUTES ]3 o ELAPSED TIME time_value [ SECONDS | MINUTES ]B You can restrict the amount of elapsed time or CPU time used toC execute a query. If the query is not complete before the elapsed> or CPU time limit  is reached, an error message is returned.@ The default is unlimited time for the query execution. If youD omit the SECONDS and MINUTES keyword then SECONDS is the default.C Dynamic SQL options are inherited from the compilation qualifier for the module.& NOTEA Specifying a query time limit can cause application failureA in certain circumstances. For instance, an application that? runs successfully during off-peak hours may fail  when run8 during peak hours due to the load on the database.? Use a positive integer for the number of seconds or minutes;@ negative integers are invalid and zero means no limits. If anD established limit is exceeded, the query is canceled and an errorD message is displayed. When you set a CPU time limit, elapsed timeD limit and a row limit (using SET QUERY LIMIT), whichever value is! reached first stops the query.< Database administraors and application developers can use? this feature to prevent users from overloading the system byA executing long running, and probably unproductive queries. TheB database administrator can manage system performance and reduce7 unnecessary resource usage by setting option limits. 3 EXECUTION_NOLIMITA This option removes a limit imposed by the SET QUERY EXECUTION LIMIT command.$ Use one of the following options. o ELAPSED TIME o CPU TIMEB EXECUTION NOLIMIT is equivalent to assigning a limit of zero to6 any of the options using SET QUERY EXECUTION LIMIT. 3 LIMIT; Sets limits to restrict the output generated by a query.= The mechanism used to set these limits is called the queryC governor. The following gives you three ways to set limits using the query governor: o ROWS rows_valueD You can restrict output by limiting the number of rows a query? can return. The optimizer counts each row returned by the> query and stops execution when the row limit is reached.D The default is an unlimited number of row fetches. Dynamic SQLC defaults are inherited from the compilation qualifier for the module.+ o TIME time_value [ SECONDS | MINUTES ]B You can restrict the amount of time used to optimize a queryC for execution. If the query is not optimized and prepared forB execution before the total elapsed time limit is reached, an error message is returned.A Th e default is unlimited time for the query compilation. IfB you omit the SECONDS and MINUTES keyword then SECONDS is the default.) NOTE< Specifying a query time limit can cause application; failure in certain circumstances. For instance, anA application that runs successfully during off-peak hours? may fail when run during peak hours due to the load on the database./ o CPU TIME time_value [ SE CONDS | MINUTES ]> You can restrict the amount of CPU time used to optimize> a query for execution. If the query is not optimized andB prepared for execution before the CPU time limit is reached,# an error message is returned.B The default is unlimited CPU time for the query compilation.= If you omit SECONDS and MINUTES keyword then SECONDS is= the default. Dynamic SQL options are inherited from the+ compilation qualifier for the module.B U se a positive integer for the number of rows and the number ofC seconds; negative integers are invalid and zero means no limits.A If an established limit is exceeded, the query is canceled andD an error message is displayed. When you set both a time limit andD the row limit, whichever value is reached first stops the output.D Application developers can use this feature to prevent users from@ overloading the system. The database administrator can manage> system performance and reduce unnecessary resource usage by setting option limits. 3 NOCONFIRM@ Disables the query confirm dialog that was previously enabled@ using SET QUERY CONFIRM. The SET QUERY NOCONFIRM statement is& only available for interactive SQL. 3 NOLIMIT= This option removes a limit imposed by the SET QUERY LIMIT command.$ Use one of the following options. o ROWS o TIME o CPU TIMEC NOLIMIT is equivalent to assigning a limit of zero to any of the! options using SET QUERY LIMIT. 3 rows_value@ This argument represents the number of rows specified for theD SET QUERY argument. It can be a numeric literal, a parameter nameB (for interactive SQL), or a parameter-marker (for dynamic SQL). 3 time_value< This argument represents the number of seconds or minutes= specified for the SET QUERY statement. It can be a numericC literal, a parameter name (for interactive SQL), or a parameter- market (for dynamic SQL). 2 ExamplesB Example 1: Shows the syntax for establishing a row limit within an interactive SQL session.# SQL> set query limit rows 10000; SQL> show query limit; Query limit Time is OFF& Query limit Row count is 10000 rows Query limit CPU time is OFF" Execution limit CPU time is OFF& Execution limit Elapsed time is OFF# Execution limit Row count is OFF SQL> set query nolimit rows; SQL> show query limit; Query limit Time is OFF Query limit Row count is OFF Query limit CPU time is OFF" Execution limit CPU time is OFF& Execution limit Elapsed time is OFF# Execution limit Row count is OFFC Example 2: Uses SET QUERY to establish a two second elapsed timeD limit for a query, and shows the error message that is displayed.9 SQL> set query execution limit elapsed time 2 seconds; SQL> delete from EMPLOYEES;4 %RDB-E-EXQUOTA, Oracle Rdb runtime quota exceededE -RDMS-E-MAXTIMLIM, query go vernor maximum timeout has been reached1 SQL> set query execution nolimit elapsed time; wwЖ1 SET_QUIET_COMMITC Allows you to control the error reporting behavior when a COMMIT@ or ROLLBACK statement is executed although there is no activeB transaction. By default, if there is no active transaction, SQLC raises an error when a COMMIT or ROLLBACK statement is executed.C If the SET QUIET COMMIT statement is set to ON, then a COMMIT orA ROLLBACK statement executes successfully even when there is no active transaction. 2 Environment. You can use the SET QUIET COMMIT statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 2 Format& SET QUIET COMMIT ---> on-or-off-value 2 Arguments 3 on-or-off-value= Specifies a string literal or host variable containing the keyword ON or OFF.; The 'ON' argument specifies that if a COMMIT or ROLLBACKB s tatement is executed when there is no active transaction, thenA SQL will not raise an error. The 'OFF' argument specifies that> if a COMMIT or ROLLBACK statement is executed when there is? no active transaction, then SQL will raise an error. You canB specify the 'ON' and 'OFF' arguments using any case (uppercase, lowercase, or mixed case).? By default, if there is no active transaction, SQL raises an@ error when the COMMIT or ROLLBACK statement is executed. ThisB default is retained for backward compatibility for applications& that want to detect this situation. 2 Example8 Example 1: Setting the QUIET COMMIT Option On and Off SQL> COMMIT;/ %SQL-F-NO_TXNOUT, No transaction outstanding SQL> SET QUIET COMMIT 'ON'; SQL> ROLLBACK; SQL> SET QUIET COMMIT 'OFF'; SQL> ROLLBACK;/ %SQL-F-NO_TXNOUT, No transaction outstanding wwЖ1 SET_QUOTING_RULES> Specifies whether strings within double quotation marks areA interpreted as string literals or delimited identifiers in the current connection. 2 Environment/ You can use the SET QUOTING RULES statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format, SET QUOTING RULES --> runtime-options ---->  runtime-options ' --+---> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 MIA@ Specifies that SQL interprets strings within double quotationA marks as delimited identifiers. Delimited identifiers are case sensitive.? To comply with the ANSI/ISO standard naming conventions, youD should use one of these options. In addition, you must use one of4 these options to use multischema database naming. 3 parameterDSpecifies the va#lue of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 parameter-markerC Specifies the value of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 SQL89@ Specifies that SQL interprets strings within double quotationA marks as delimited identifiers. Delimited identifiers are case sensitive.? To comply with the ANSI/ISO standard naming conventions, youD should use one of these options. In addition, you must use one of4 these options to use multischema database naming. 3 SQL92_or_SQL99@ Specifies that SQL interprets strings within double quotationA marks as delimited identifiers. Delimited identifiers are case sensitive.? To comply with the ANSI/ISO standard naming conventions, youD should use one of these options. In addition, you must use on e of4 these options to use multischema database naming. 3 SQLV40@ Specifies that SQL interprets strings within double quotation marks as string literals. The default is SQLV40. 3 'string-literal'C Specifies the value of the runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 2 Examples0 Example 1: Setting the quoting rules to SQL99" SQL> SET QUOTING RULES 'SQL99'; SQL> --J SQL> -- SQL interprets double quotation marks as delimited identifiers. SQL> --& SQL> CREATE TABLE "Employees_Table"! cont> ("Employee_ID" CHAR(6),' cont> "Employee_Name" CHAR (30)); SQL> --N SQL> -- SQL retains the upper- and lowercase letters within the identifier. SQL> --" SQL> SHOW TABLE EMPLOYEES_TABLE No tables found$ SQL> SHOW TABLE "Employees_Table"( Information for table Employees_Table% Columns for table Employees_Table:: Column Name Data Type Domain: ----------- --------- ------* Employee_ID CHAR(6)+ Employee_Name CHAR(30) . . . 1 Example 2: Setting the quoting rules to SQLV40# SQL> SET QUOTING RULES 'SQLV40'; SQL> --J SQL> -- When you set the quoting rules to SQLV40, SQL interprets double. SQL> -- quotation marks as string literals. SQL> --& SQL> CREATE TAB LE "Employees_Table"J %SQL-I-DEPR_FEATURE, Deprecated Feature: " used instead of ' for string literal! CREATE TABLE "Employees_Table" ^2 %SQL-W-LOOK_FOR_STT, Syntax error, looking for:. %SQL-W-LOOK_FOR_CON, name, FROM,8 %SQL-F-LOOK_FOR_FIN, found Employees_Table instead SQL> --O SQL> -- Although you can use double quotation marks for string literals, SQL0 SQL> -- returns a deprecated feature message. SQL> -- SQL> INSERT INTO EMPLOYEES4 cont> (EMPLOYEE_ID, LAST_NAME, STATUS_CODE) cont> VALUES) cont> ("00500", 'Toliver', '1');J %SQL-I-DEPR_FEATURE, Deprecated Feature: " used instead of ' for string literal 1 row inserted SQL> -- wwЖ 1 SET_SCHEMA? Specifies the default schema name for an SQL user session inB dynamically prepared and executed or interactive SQL statements0 until another SET SCHEMA statement is issued.C Within one multischema database, tables in different schemas canD be used in a single SQL statement; tables in schemas in differentA databases cannot. If you omit the schema name when you specifyC an object in a multischema database, SQL uses the default schema name. 2 Environment( You can use the SET SCHEMA statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format2 SET SCHEMA ---+-> schema-string-literal ------+->0 +-> ---------+0 +-> --+ schema-string-literal = & --> ' --> schema-expression --> ' -->  schema-expression = 1 --+------------------------------------------+-+1 +------> ------------+-> . -+ |1 +-> " -> . ->"-+ |1 | +----------------------------------------+2 | +--------------> ------+->0 +-> " -> . --> " ----+  2 Arguments 3 schema-expression= Specifies the name of the default schema for a multischemaC database. If you omit the schema name when you specify an objectB in a multischema database, SQL uses the default schema name. IfA you do not specify a default schema name, the default uses the! user name of the current user.A See the User_Supplied_Names HELP topic for more information on schemas. 3 schema-parameterD Specifies a host language variable in precompiled SQL or a formal? parameter in an SQL module language procedure that specifiesA the default schema. The schema parameter must contain a schema expression. 3 schema-parameter-marker@ Specifies a parameter marker (?) in a dynamic SQL statement.C The schema parameter marker refers to a parameter that specifiesA the default schema. The schema parameter marker must specify a/ parameter that contains a schema expression. 3 schema-string-literal: Specifies a character string literal that specifies theB default schema. The schema string literal must contain a schema5 expression enclosed within single quotation marks. 2 ExampleC Example 1: Setting schema and catalog defaults to create a table in a multischema databaseD In this example, user ELLINGSWORTH attaches to two databases: theB default dat abase, personnel, and the multischema corporate_dataA database with alias CORP. User ELLINGSWORTH attempts to create@ a table in the corporate_data database, and receives an error@ message because the default schema is ELLINGSWORTH, which hasB not been created in the default catalog. User ELLINGSWORTH usesB SET SCHEMA and SET CATALOG statements to change the defaults toA catalog ADMINISTRATION and schema ACCOUNTING of the corporate_ data database.@ Use the SHOW DATABASE statement to see the database settings.$ SQL> ATTACH 'FILENAME personnel';4 SQL> ATTACH 'ALIAS CORP FILENAME corporate_data'; SQL> SHOW SCHEMAS;. Schemas in database with filename personnel No schemas found Schemas in database CORP' "CORP.ADMINISTRATION".ACCOUNTING& "CORP.ADMINISTRATION".PERSONNEL' "CORP.ADMINISTRATION".RECRUITING$ "CORP.RDB$CATALOG".RDB$SCHEMA- SQL> CREATE TABLE CORP.BUDGET (COL1 REAL);B %SQL-F-SCHNOTDEF, Schema "CORP.RDB$ CATALOG".CORP is not defined SQL> --> SQL> -- SQL interprets CORP as schema name, and there is no/ SQL> -- CORP schema in the default database. SQL> --G SQL> -- Add quotation marks to designate qualifier CORP as an alias, SQL> -- not the schema name. SQL> --" SQL> SET QUOTING RULES 'SQL92';/ SQL> CREATE TABLE "CORP.BUDGET" (COL1 REAL);J %SQL-F-SCHNOTDEF, Schema "CORP.RDB$CATALOG".ELLINGSWORTH is not defined SQL> --= SQL> -- The default schema in the databas e with alias CORP9 SQL> -- is the user name ELLINGSWORTH, but there is no% SQL> -- schema named ELLINGSWORTH. SQL> --? SQL> -- Set the default schema to ACCOUNTING, and qualify itD SQL> -- with a delimited identifier containing the alias CORP and> SQL> -- the catalog ADMINISTRATION. Now you can create theC SQL> -- table BUDGET within schema ACCOUNTING without qualifying SQL> -- the table name. SQL> --6 SQL> SET SCHEMA '"CORP.ADMINISTRATION".ACCOUNTING';( SQL> CREATE TABLE BUDGET (COL1 REAL); SQL> SHOW TABLES;2 User tables in database with filename personnel CANDIDATES COLLEGES . . ./ User tables in database with alias CORP/ "CORP.ADMINISTRATION".ACCOUNTING.BUDGET . . . ww 1 SET_SESSION_AUTHORIZATION@ Allows you to transfer the current database attach to another user. 2 Environment7 You can use the SET SESSION AUTHORIZATION statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format9 SET SESSION AUTHORIZATION -+-> host-variable -------+-->6 +-> 'literal-user-auth' -+ literal-user-auth = 6 ---> USER '' -+------------------------+-->3 +-> USING ''  -+  2 Arguments 3 host-variable> Specifies the name of the user and the password to whom the@ database attach is being transferred as a string literal or aB host variable. If a host-variable is specified, it must contain- the literal-user-auth as a string literal. 3 USER_'username'A A character string literal that specifies the operating systemB user name that the database system uses for privilege checking. 3 USING_'password'D A character string literal that specifies the user's password for. the user name specified in the USER clause. 2 Usage_Notes? o You must have the SELECT privilege on the database to set session authorization.C o The specified user and password (in the USING clause) must be) a valid OpenVMS user authorization.C o If the operation is successful, the SESSION_USER and SESSION_@ UID will be changed to reflect the specified OpenVMS user.D o No transaction can be active when the session authorization is! modified by this statement. 2 ExamplesB Example 1: Reusing the Current Database Attach for Another User( SQL> ATTACH 'FILENAME db$:personnel';E SQL> SET SESSION AUTHORIZATION 'USER ''SMITH'' USING ''SECRET1''';* SQL> SHOW PRIV ON DATABASE RDB$DBHANDLE# Privileges on Alias RDB$DBHANDLEO (IDENTIFIER =[RDB,SMITH],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+I ALTER+DROP+DBCTRL+OPERATOR+DBADM+REFERENCE S+SECURITY+DISTRIBTRAN)D SQL> SET SESSION AUTHORIZATION 'USER ''JAIN'' USING ''SECRET2''';* SQL> SHOW PRIV ON DATABASE RDB$DBHANDLE# Privileges on Alias RDB$DBHANDLEN (IDENTIFIER =[RDB,JAIN],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+I ALTER+DROP+DBCTRL+OPERATOR+DBADM+REFERENCES+SECURITY+DISTRIBTRAN) ww  1 SET_SQLDAC Allows a programmer using Dynamic SQL to alter the way the SQLDAB (and SQLDA2) and Dynamic SQL statements are processed by Oracle Rdb. 2 Environment' You can use the SET SQLDA statement:> o In Dynamic SQL as a statement to be dynamically executed 2 Format) SET SQLDA -+-> literal ---------+-----># +-> host-variable ---+ sqlda_options =  --+-> sqlda_option --+--> +----- , <---------+ sqlda_option = % --+-> PADDING n CHARACTERS -----+-># +-> NOPADDING ----------------+# +-> ENABLE enable-option -----+# +-> DISABLE enable-option ----+# +-> dialect-name -------------+ enable-option =  --+-> INSERT RETURNING ---+-> +-> NAMED MARKERS ------+ +-> ROWID TYPE ---------+ dialect-name =  --+-> SQL99 -----------+-> +-> SQL92 -----------+ +-> SQL89 -----------+ +-> MIA -------------+ +-> SQLV40 ----------+ +-> ORACLE LEVEL1 ---+ +-> ORACLE LEVEL2 ---+ 2 Arguments 3 Literal|Host-VariableA Parameter passed to the statement. Must be a literal or a host< variable containing one or more SQLDA options (see sqlda_? options syntax diagram for details). If more than one option2 is specified, they must be separated by commas. 3 sqlda_options: One or more keyword clauses. If more than one clause is/ specified, they must be separated by commas. 3 ENABLEA The ENABLE clause activates one of the following behaviors for Dynamic SQL.; - INSERT RETURNING - The default behavior of INSERT ...C  RETURNING when executed by dynamic SQL is to place parameters@ from the RETURNING INTO clause in to the INPUT SQLDA. ThisD behavior is maintained for backward compatibility. This option> allows the programmer to force different (and corrected): behavior for the non-compound use of this statement.) NOTE; If the INSERT RETURNING statement is included in a; compound statement then the parameters are handled  correctly.? - NAMED MARKERS - as well as traditional parameters markersA (?). Dynamic SQL will now accept named, host-variable styleD parameter markers. See the Usage Notes for further details and examples.A - ROWID TYPE - returns DBKEY values as a special type (SQLDA_@ ROWID, 455) to make processing of the DBKEY values easier.D For instance, in prior releases the SQLDA name field (SQLNAME)D for DBKEY entries in the SQLDA was the only way to d istinguishC these values from other CHAR or VARCHAR columns - it would beA either DBKEY or ROWID. If a query renamed the DBKEY column,= then the application had no information in the SQLDA toA indicate that the CHAR or VARCHAR value was binary data. InB all respects, the SQLDA_ROWID type appears as a fixed lengthD string of octets (possibly containing octets of zero which the@ C language would treat as a NULL terminator for a string). 3 DISABLED The DISABLE clause deactivates one of the specified behaviors for8 Dynamic SQL. See ENABLE clause for a list of options. 3 ORACLE_LEVEL1|ORACLE_LEVEL2@ Either of these options will set the SQLDA to supply enhanced> semantics. These options are currently reserved for the useA of the OCI Services for Rdb product that is part of Oracle Rdb? SQL/Services component. This setting also implicitly enables NAMED MARKERS. 3 PADDING_n_CHARACTERS= This option direc ts SQL to configure the SQLDA with largerC CHARACTER VARYING strings than would normally be seen. The valueC of n is an unsigned numeric literal that specifies the number ofC characters that are added to the estimated length. Any CHARACTERB (CHAR) types are converted to CHARACTER VARYING (VARCHAR). ThisC rule is applied to comparison operators <, <=, >, >=, =, <>, and0 string functions (STARTING WITH, CONTAINING). 3 NOPADDINGD This option sets the number of padding characters to 0. This alsoC implies that derived CHARACTER (CHAR) types are not converted toD CHARACTER VARYING (VARCHAR) when PADDING CHARACTERS is used. This is the default setting.& NOTEA Oracle recommends that applications always check for SQLDA_A CHAR and SQLDA_VARCHAR so that the correctly formatted data is made available to SQL. 3 SQL99|SQL92|MIA|SQL89|SQLV40C Any of these options will revert to the default semantic for the0 SQLDA which includes disabling NAMED MARKERS. 2 Example- Example 1: Using the NAMED MARKERS featureB This example shows that enabling the NAMED MARKERS feature willC allow SQL to promp tfor one value and the displayed Rdb strategy( shows that only one variable is used.' -> SET SQLDA 'ENABLE NAMED MARKERS';Q -> SELECT LAST_NAME FROM EMPLOYEES WHERE FIRST_NAME = :F_NAME AND LAST_NAME <> :F_NAME; in: [0] typ=449 len=46 out: [0] typ=453 len=14 [SQLDA - reading 1 fields] -> Alvin Tables: 0 = EMPLOYEES@ Conjunct: (0.FIRST_NAME = ) AND (0.LAST_NAME <> )9 Get Retrieval sequentially of relation 0:EMPLOYEES& 0/FIRST_NAME/Varchar(42/46): Alvin [SQLDA - displaying 1 fields] 0/LAST_NAME: Toliver [SQLDA - displaying 1 fields] 0/LAST_NAME: Dement' Example 2: Using the PADDING featureB The following example shows that the derived type for the namedA parameter MI is a S QLDA_CHAR (453) of length 1. The input dataB ('AA') is truncated on assignment and the incorrect results areD returned. By adding a small padding the type is changed to SQLDA_C VARCHAR (449) of length 3 and a correct comparison is performed.% -> ATTACH 'filename sql$database';2 -> SET SQLDA 'enable named markers, nopadding';A -> SELECT LAST_NAME FROM EMPLOYEES WHERE MIDDLE_INITIAL = :MI; in: [0] typ=453 len=1 out: [0] typ=449 len=18 [SQLDA - reading 1 fields]  -> AA [SQLDA - displaying 1 fields] 0/LAST_NAME: Toliver [SQLDA - displaying 1 fields] 0/LAST_NAME: Lengyel [SQLDA - displaying 1 fields] 0/LAST_NAME: Robinson [SQLDA - displaying 1 fields] 0/LAST_NAME: Ames' -> SET SQLDA 'padding 2 characters';A -> SELECT LAST_NAME FROM EMPLOYEES WHERE MIDDLE_INITIAL = :MI; in: [0] typ=449 len=7 out: [0] typ=449 len=18 [SQLDA - reading 1 fields] -> AA -> EXIT; Enter statement:A Note that the VARCHAR requires an extra 4 bytes for the length< information in the SQLDA2 used by the Dynamic SQL testing program. ww 1 SET_TRANSACTION< Starts a transaction and specifies its characteristics. AA transaction is a group of statements whose changes can be made& permanent or undone only as a unit.A A transaction ends with a COMMIT or ROLLBACK statement. If youA end the transaction with the COMMIT statement, all the changesD made to the d atabase by the statements are made permanent. If youB end the transaction with the ROLLBACK statement, the statements do not take effect.C You must end the transaction with a COMMIT or ROLLBACK statementB before starting or declaring another transaction. If you try toB start or declare a transaction while another one is active, SQL generates an error message.= Besides the SET TRANSACTION statement, you can specify the= characteristics of a transaction in one of two othe r ways:; o If you specify the DECLARE TRANSACTION statement, theA declarations in the statement take effect when SQL starts a@ new transaction that is not started by the SET TRANSACTION< statement. SQL starts a new transaction with the first? executable data manipulation or data definition statement< following the DECLARE TRANSACTION, COMMIT, or ROLLBACK statement.B o If you omit both the DECLARE and SET TRANSACTION statements,B SQL automatica lly starts a transaction (using the read/writeA option) with the first executable data manipulation or dataD definition statement following a COMMIT or ROLLBACK statement.A Thus, you can retrieve and update data without declaring or' setting a transaction explicitly.C See the Oracle Rdb SQL Reference Manual for examples of when youA would want to use the DECLARE TRANSACTION statement instead of! the SET TRANSACTION statement.C You can specify many options with the SET TRANSACTION statement, including:- o Transaction mode (READ ONLY/READ WRITE)3 o Lock specification clause (RESERVING options)< o Horizontal partition specification (RESERVING options) o Wait mode (WAIT/NOWAIT) o Isolation level0 o Constraint evaluation specification clauseB o Multiple sets of all the preceding options for each database3 involved in the transaction (ON . . . AND ON)? The Arguments section explains these options in more detail. 2 Environment- You can use the SET TRANSACTION statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format& SET TRANSACTION --+---------------+->$ +-> tx-options -+$ +-> db-txns ----+ tx-options = 3 --+-+---------------------------------------- +-+->1 | +-> NAME 'quoted-string' ----------------+ |1 | +-> EVALUATING -+- evaluating-clause --+-+ |1 | | +-------> , <----------+ | |1 | +-> RESERVING --+-> reserving-clause --+-+ |1 | | +-------- , <----------+ | |1 | +-> isolation-level ---------------------+ |1 | +-> transaction-mode --------------------+ |1 | +-> wait-option -------------------------+ |1 +----------------+-------+-------------------+ +-- , <-+ transaction-mode =  --+-> READ ONLY ----+-> +-> READ WRITE ---+ +-> BATCH UPDATE -+ wait-option =( --+-> WAIT -+---------------------+-+->& | +-> --+ |& +-> NOWAIT -----------------------+ isolation-level = 3 ---> ISOLATION LEVEL --+-> READ COMMITTED ----+-->0 +-> REPEATABLE READ ---+0 +-> SERIALIZABLE ------+ evaluating-clause = B -+-------------+-> -> AT -+-> VERB TIME ---+-->? +-> -+ +-> COMMIT TIME -+  reserving-clause = I -+-+-> ------------------------------------------------+-+-+I | +-> -+-------------------------------------------+-+ | |I | +-> PARTITION --> ( -+-> -+-> ) -+ | |I | +------ , <-----+ | |I +----------------------------------- , <----------------------------+ |I +---------------------------------------------------------------------+I +-> FOR -+--------------+--+-> READ ------------+--------------------->3 +-> EXCLUSIVE -+ +-> WRITE -----------+3 +-> PROTECTED -+ +-> DATA DEFINITION -+ +-> SHARED ----+ db-txns = F --+--------------------------------------------------------------+-->C ++-> ON -+-> -+-> USING --> ( +-> tx-options --+-> ) -++B | +---- , <----+ +-> DEFAULTS ----+ |B +-------------------------- AND <----------------------------+  2 Arguments 3 alias( Specifies the alias for a constraint. 3 BATCH_UPDATE? Specifies the batch-update mode to reduce overhead in large-C load operations. To speed update operations, Oracle Rdb does not? write to snapshot or recovery-unit journal files in a batch-> update transaction. For more information about batch-update@ transactions, see the Oracle Rd b Guide to SQL Programming and' the Oracle Rdb SQL Reference Manual.' CAUTION9 Before you begin a batch-update transaction in your? programs, you should create a backup copy of the database> using the RMU Backup command. If an error occurs in your= program that would normally result in a rollback of the< transaction, Oracle Rdb marks the database as corrupt.= To recover from a corrupt database, you must create the@ database again from the backup copy of the database. AfterA correcting the error condition, you can restart the program? from the beginning. You should back up the database after4 completing a batch-update transaction as well. 3 constraint-name& Specifies the name of a constraint. 3 db-txns> Specifies different transaction options. When you attach toC more than one database and want to specify different transaction. options for each database, use this clause. 3 evaluating-clauseC Specifies the point at which the named constraint or constraintsC are evaluated. If you specify VERB TIME, they are evaluated whenC the data manipulation statement is issued. If you specify COMMITA TIME, the constraint evaluation is based on the setting of theB SET ALL CONSTRAINTS statement. For read-only transactions, this$ clause is allowed but is ignored. 3 FOR_share_modes Syntax options: FOR EXCLUSIVE FOR PROTECTED FOR SHAREDC Specifies the SQL share modes. The keyword you choose determinesA which operations you allow others to perform on the tables youA are reserving. While you can specify an EXCLUSIVE or PROTECTEDA share mode when declaring a read-only transaction, SQL ignoresB these entries and specifies SHARED mode. The default is SHARED.A For more information, see the Oracle Rdb SQL Reference Manual. 3 ISOLATION_LEVEL Syntax options:$ ISOLAT ION LEVEL READ COMMITTED% ISOLATION LEVEL REPEATABLE READ" ISOLATION LEVEL SERIALIZABLE< Defines the degree to which database operations in an SQLB transaction are affected by database operations in concurrently@ executing transactions. It determines the extent to which the2 database protects the consistency of your data.B Oracle Rdb supports isolation levels READ COMMITTED, REPEATABLE; READ, and SERIALIZABLE. When you use SQL with Oracle RdbA databases, by defau lt, SQL executes a transaction at isolation? level SERIALIZABLE. The higher the isolation level, the more; isolated a transaction is from other currently executingA transactions. Isolation levels determine the type of phenomena? that are allowed to occur during the execution of concurrent@ transactions. Two phenomena define SQL isolation levels for a transaction: o Nonrepeatable read< Allows the return of different results within a single= transaction when  an SQL operation reads the same row in? a table twice. Nonrepeatable reads can occur when anotherB transaction modifies and commits a change to the row between transaction reads. o Phantom< Allows the return of different results within a singleA transaction when an SQL operation retrieves a range of data> values (or similar data existence check) twice. Phantoms@ can occur if another transaction inserted a new record and= committed the insertion between executions of the range retrieval.? Each isolation level differs in the phenomena it allows. TheB following table shows the phenomena permitted for the isolationB levels that you can explicitly specify with the SET TRANSACTION statement.8 Table 1-8 Phenomena Permitted at Each Isolation Level Nonrepeatable- Isolation Reads Phantoms- Level Allowed? Allowed?( READ Yes  Yes COMMITTED( REPEATABLE No Yes READ' SERIALIZABLE No No@ For read-only transactions, which always execute at isolationC level SERIALIZABLE if snapshots are enabled, the database system@ guarantees that you will not see changes made by another user' before you issue a COMMIT statement.: See the Oracle Rdb Guide to SQL Programming for furtherA information about specifying isolation levels in transactions. 3 NAME_transaction-name< Supplies a title for the transaction. This information is2 displayed by the SET FLAGS TRANSACTION keyword. 3 ON Syntax options: ON alias | AND ON aliasC Specifies the alias for a database for which you want to specifyB transaction options. An alias is a name for a particular attach to a database.B Use the ON clause when you attach to more than one database andC want to specify different transaction options for each database.< (If you omit the ON clause, the single set of transactionC options in the SET TRANSACTION statement applies to all attached databases.)@ You can include multiple sets of transaction options, one for? each database, in multiple ON clauses separated with the AND keyword. 3 PARTITION_(part-num)A PARTITION When used with the RESERVING clause specifies a listC of numeric partition numbers so that only a subset of the tablesD partitions are reserved. For example, an application could submitB several processing jobs that each reserved a separate partitionA of the table for EXCLUSIVE access. The default, if this clauseD is omitted, is to reserve all partitions. An error is reported ifC the application references a partition if the table that was not reserved. 3 part-numC The numeric identifier for the partition. Partition are numbered@ from 1. The CREATE INDEX statement allocates these values and@ records them in the RDB$STORAGE_MAP_AREAS table in the column RDB$ORDINAL_POSITION. 3 reserved_lock_types Syntax options: READ WRITE DATA DEFINITIONB Specifies the lock type. These keywords declare what you intend+ to do with the tables you are reserving.D Use READ when you only want to read data from the tables. This is* the default for read-only transactions.? Use WRITE when you want to insert, update, or delete data inC the tables. This is the default for read/write transactions. You3 cannot specify WRITE for read-only transactions.C Use DATA DEFINITION when you want to create or alter metadata atB the same time as other users on the same table. This clause can+ be used only in read/write transactions. 3 READ_ONLYC Retrieves a snapshot of the database at the moment the read-only? transaction starts. Other users can update rows in the tableA you are using, but your transaction retrieves the rows as theyB existed a t the time the transaction started. You cannot update,@ insert, or delete rows, or execute data definition statements? in a read-only transaction with the exception of declaring aC local temporary table or modifying data in a created or declaredC temporary table. Read-only transactions are implicitly isolation level serializable.C Because a read-only transaction uses the snapshot (.snp) version@ of the database, any changes that other users make and commitA during the tr ansaction are invisible to you. Using a read-onlyC transaction lets you read data without incurring the overhead ofD row locking. (You do incur overhead for keeping a snapshot of theC tables you specify in the RESERVING clause, but this overhead is: less than that of a comparable read/write transaction.)D Because of the limited nature of read-only transactions, they are# subject to several restrictions. 3 READ_WRITE> Signals that you want to use the lock mechanisms of SQL for> consistency in data retrieval and update. Read/write is the@ default transaction. Use the read/write transaction mode when you need to:$ o Insert, update, or delete dataB o Retrieve data that is guaranteed to be correct at the moment of retrieval( o Use SQL data definition statementsC When you are reading a row in a read/write transaction, no otherC user can update that row. Under some circumstances, SQL may lock, rows that you are not explicitly reading.C o If your query is scanning a table without using an index, SQLC locks all the rows in the record stream to maintain isolation level serializable.@ o If your query uses indexes, SQL may lock part of an index,3 which has the effect of locking several rows. 3 RESERVING Syntax options: RESERVING table-name RESERVING view-name@ Lists the tables to be locked during the transaction. IncludeC all the persistent base tables your transaction will access. You7 cannot reserve created or declared temporary tables.D If you use the RESERVING clause to specify tables, you can accessC only the tables you have reserved. However, specifying a view inB a RESERVING clause is the same as specifying the base tables on which the view is based. 3 timeout-valueB Specifies the number of seconds for a given transaction to waitB for other transactions to complete. This interval is only validB f or the transaction specified in the SET TRANSACTION statement.A Subsequent transactions return to the database default timeout3 interval. A timeout value of 0 specifies NOWAIT.@ When starting a transaction, there are three different values@ that are used to determine the lock timeout interval for that! transaction. Those values are:: 1. The value specified in the SET TRANSACTION statement@ 2. The value stored in the database as specified in CREATE or ALTER DATABASEB 3. The value of the logical name RDM$BIND_LOCK_TIMEOUT_INTERVAL? The timeout interval for a transaction is the smaller of theA value specified in the SET TRANSACTION statement and the value= specified in CREATE DATABASE. However, if the logical name? RDM$BIND_LOCK_TIMEOUT_INTERVAL is defined, the value of thisA logical name overrides the value specified in CREATE DATABASE. 3 USING Syntax options: USING (tx-options) USING DEFAULTS> Specifies the transaction options you want for the database? referred to by the alias in the preceding ON clause. You can? explicitly specify the transaction, wait mode, and isolationD level option, or you can use the DEFAULTS keyword. Using DEFAULTSD is equivalent to specifying READ WRITE WAIT. For more information8 on DEFAULTS, see the Oracle Rdb SQL Reference Manual. 3 WAIT Syntax options: WAIT |NOWAITD Determines what your transaction does when it encounters a locked row. The default is WAIT.: o If you specify WAIT, the transaction waits for other@ transactions to complete and then proceeds. If you prefer,C you can specify that the transaction proceeds after a certain@ time interval instead of waiting for other transactions to@ complete. You can specify the timeout interval value afterB the WAIT keyword. The timeout interval value is expressed in seconds.> o If you specify NOWAIT, your transaction returns an error. message when it encounters a locked row. 2 Examples. Example 1: Starting a read-only transaction" SQL> SET TRANSACTION READ ONLY;> This statement lets you read data from the database but not= insert or update data. When you retrieve data, you see the? database records as they existed at the time SQL started the? transaction. You do not see any updates to the database made after that time. @ Example 2: Reserving specific tables with the SET TRANSACTION statementC The following statement lets you specify the intended action for! each table in the transaction:' SQL> ATTACH 'FILENAME mf_personnel';, SQL> SET TRANSACTION READ WRITE RESERVING, cont> EMPLOYEES FOR PROTECTED WRITE,3 cont> JOBS, SALARY_HISTORY FOR SHARED READ;D Assume that this transaction updates the EMPLOYEES table based on= values found in two other tables: JOBS and SALARY_HISTORY.C o The transaction must update the EM PLOYEES table, so EMPLOYEES, is readied for protected write access.A o The program will only read values from the JOBS and SALARY_= HISTORY tables, so there is no need for write access or> protected write access. However, you do intend to update? records in the transaction, so a read-only transaction is not appropriate.@ Example 3: Specifying multiple databases in a SET TRANSACTION statement9 You can access multiple databases from within the same C transaction. This example explains how you can benefit from this feature.A Read-only transactions use a snapshot version of the data, and> therefore you might encounter older values in the data your= application retrieves. because another transaction using a4 read/write transaction might be updating a table.> The snapshot file represents a before-image of the database> rows that the other program is updating. If you require TheB very latest data, you should specif y read/write access for bothA databases, and permit other users to read one of the databases? by including the shared read mode. In this way, you maintainD data consistency during updates, while permitting concurrent data7 retrieval from the database that your program reads.= However, any read/write transaction you set offers reduced@ concurrent access when compared to read-only access. For that; reason, use read/write transactions only when necessary.> Before you can use the multiple database feature of the SETB TRANSACTION statement, you must issue a DECLARE ALIAS statementA that specifies each database you intend to access. The DECLARED ALIAS statement must include an alias. For example, the followingA DECLARE ALIAS statements identify two databases required by an update application: EXEC SQL, DECLARE DB1 ALIAS FOR FILENAME PERSONNEL; END EXEC EXEC SQL+ DECLARE DB2 ALIAS FOR FILENAME benefits; END EXEC@ Becau se the program needs to only read the EMPLOYEES table ofB the PERSONNEL database but needs to change values in two tablesD (TUITION and STATUS) in the BENEFITS database, the update program9 might contain the following SET TRANSACTION statement: EXEC SQL SET TRANSACTION( ON DB1 USING ( READ ONLY; RESERVING DB1.EMPLOYEES FOR SHARED READ ) AND) ON DB2 USING ( READ WRITE8 RESERVING DB2.TUITION FOR SHARED WRITE: DB2.STATUS FOR SHARED WRITE ) END EXECD Example 4: Specifying a multischema database in a SET TRANSACTION statement@ If one of the databases you access is a multischema database,B you must specify it using a delimited identifier. The following: example shows how to access the single-schema personnelB database and the multischema corporate_data database. The tableB EMPLOYEES is located within the schema PERSONNEL in the catalog5 A DMINISTRATION within the CORPORATE_DATA database.4 SQL> ATTACH 'ALIAS CORP FILENAME corporate_data';/ SQL> ATTACH 'ALIAS PERS FILENAME personnel';" SQL> SET QUOTING RULES 'SQL92';, SQL> SET CATALOG '"CORP.ADMINISTRATION"';5 SQL> SET SCHEMA '"CORP.ADMINISTRATION".PERSONNEL'; SQL> --0 SQL> SET TRANSACTION ON CORP USING (READ ONLY7 cont> RESERVING "CORP.EMPLOYEES" FOR SHARED READ)3 cont> AND ON PERS USING (READ WRITE RESERVING- cont> PERS.EMPLOYEES FOR SHARED WRITE); 9 Example 5: Specifying evaluation at verb time in a SET TRANSACTION statementD The following example shows an insert into the DEGREES table of aD newly acquired degree for EMPLOYEE_ID 00164. The new degree, MME,C is evaluated and, because it is not one of the acceptable degree3 codes, an error message is returned immediately.$ SQL> ATTACH 'FILENAME personnel';" SQL> SET TRANSACTION READ WRITE4 cont> EVALUATING DEGREES_FOREIGN1 AT VERB TIME,) cont> DEGREES_FOREIGN2 AT VERB TIME,) cont> DEG_DEGREE_VALUES AT VERB TIME1 cont> RESERVING DEGREES FOR PROTECTED WRITE,/ cont> COLLEGES, EMPLOYEES FOR SHARED READ; SQL> SHOW TRANSACTION Transaction information:- Statement constraint evaluation is off On the default alias Transaction characteristics: Read Write> Evaluating constraint DEGREES_FOREIGN1 at verb time> Evaluating constraint DEGREES_FOREIGN2 at verb time?  Evaluating constraint DEG_DEGREE_VALUES at verb time6 Reserving table DEGREES for protected write3 Reserving table COLLEGES for shared read4 Reserving table EMPLOYEES for shared read3 Transaction information returned by base system:* a read-write transaction is in progress& - updates have not been performed/ - transaction sequence number (TSN) is 153= - snapshot space for TSNs less than 153 can be reclaimed - session ID number is 21 SQL> INSERT INTO DEGREES2 cont> (EMPLOYEE_ID, COLLEGE_CODE, YEAR_GIVEN,! cont> DEGREE, DEGREE_FIELD) cont> VALUES# cont> ('00164', 'PRDU', 1992," cont> 'MME', 'Mech Enging');F %RDB-E-INTEG_FAIL, violation of constraint DEG_DEGREE_VALUES caused operation to failC -RDB-F-ON_DB, on database DISK1:[JONES.PERSONNEL]PERSONNEL.RDB;1 SQL> ROLLBACK; B Example 6: Explicitly setting isolation levels in a transaction? This statement lets you read data from and write data to the= database. It also sets the transaction to run at isolationB level READ COMMITTED, not at the higher default isolation level SERIALIZABLE.C SQL> SET TRANSACTION READ WRITE ISOLATION LEVEL REPEATABLE READ;) Example 7: Creating index concurrentlyB The following example shows how to reserve the table for shared. data definition and how to create an index:" SQL> SET TRANSACTION READ WRITE; cont> RESERVING EMPLOYEES FOR SHARED DATA DEFINITION; SQL> --= SQL> CREATE INDEX EMP_LAST_NAME1 ON EMPLOYEES (LAST_NAME); SQL> --. SQL> -- Commit the transaction immediately. SQL> -- SQL> COMMIT;# Example 8: Reserving a Partition: SQL> -- This example locks only the second partition of7 SQL> -- the EMPLOYEES table in exclusive write mode.@ SQL> -- The advantage of this is that the process can insert,A SQL> -- update, or delete from this partition without writingB SQL> -- to the snapshot (.snp ) file, and in general, uses fewer6 SQL> -- resources for operations on the partition." SQL> SET TRANSACTION READ WRITE? cont> RESERVING EMPLOYEES PARTITION (2) FOR EXCLUSIVE WRITE;= Example 9: Interaction between RESERVING clause and column DEFAULT values> This example examines the interaction between the RESERVINGC clause and DEFAULT values that reference tables (either directlyB and indirectly). The RESERVING clause of SET TRANSACTION limitsC the transaction to just those tables listed for the transaction.@ Tables directly referenced by constraints, triggers, COMPUTEDB BY columns, AUTOMATIC columns and DEFAULT values are implicitlyD reserved for SHARED READ. However, if these definitions referenceD the table indirectly via a stored function then that table is not( considered for automatic reservation.> This example uses DEFAULT value to contrast three different? mechanisms and their interactions with the RESERVING clause.C The s ame technique could be applied to other definitions such as triggers and constraints.A The DEFAULT value is derived from a secondary table (DEFAULTS)@ that holds one value for each valid user of the database. TheB DEFAULT is retrieved based on the value of CURRENT_USER. In theC three tables below the value is either directly fetched (SAMPLE_@ TABLE2), or via a stored function (SAMPLE_TABLE1, and SAMPLE_ TABLE3).C The SQL function GET_DEFAULT3 includes a LOCK TABLE statement toA ensure that the table is correctly reserved. Oracle recommendsD this approach since it relieves the programmer from knowing which@ tables might be required when coding a RESERVING clause for a transaction. SQL> set dialect 'sql99'; SQL> SQL> create table DEFAULTS7 cont> (user_id rdb$object_name primary key,$ cont> valid_number integer);3 SQL> insert into DEFAULTS values ('SMITH', 100); 1 row inserted SQL> SQL> create module UTL1% cont> function GET_DEFAULT1 () cont> returns integer cont> not deterministic;6 cont> return (select valid_number from DEFAULTS3 cont> where user_id = CURRENT_USER); cont> end module; SQL>" SQL> create table SAMPLE_TABLE1* cont> (id integer identity, cont> quantity integer0 cont> default GET_DEFAULT1 () cont> ); SQL>" SQL> create table SAMPLE_TABLE2* cont> (id   integer identity, cont> quantity integerC cont> default (select valid_number from DEFAULTS? cont> where user_id = CURRENT_USER) cont> ); SQL> SQL> create module UTL3% cont> function GET_DEFAULT3 () cont> returns integer cont> not deterministic; cont> begin6 cont> lock table DEFAULTS for shared read mode;6 cont> return (select valid_number from DEFAULTS3 cont> w here user_id = CURRENT_USER); cont> end; cont> end module; SQL>" SQL> create table SAMPLE_TABLE3* cont> (id integer identity, cont> quantity integer0 cont> default GET_DEFAULT3 () cont> ); SQL> SQL> commit;A The following transactions succeed or fail as explained in the example. SQL> /*H ***> Fails because the module references a table that is not reserved ***> */" SQL> set transaction read  write6 cont> reserving SAMPLE_TABLE1 for shared write;1 SQL> insert into SAMPLE_TABLE1 default values;D %RDB-E-UNRES_REL, relation DEFAULTS in specified request is not a- relation reserved in specified transaction SQL> rollback; SQL> SQL> /*D ***> Succeeds because direct access to the table from the DEFAULT@ ***> is implicitly added to the reserving list as SHARED READ ***> */" SQL> set transaction read write6 cont> reserving SAMPLE_TABLE2 for share d write;1 SQL> insert into SAMPLE_TABLE2 default values; 1 row inserted SQL> rollback; SQL> SQL> /*C ***> Succeeds because the routine adds the table to the reserved$ ***> table list using LOCK TABLE. ***> */" SQL> set transaction read write6 cont> reserving SAMPLE_TABLE3 for shared write;1 SQL> insert into SAMPLE_TABLE3 default values; 1 row inserted SQL> rollback; SQL> ww+I1 SET_VIEW_UPDATE_RULESA Specifies  whether or not SQL applies the ANSI/ISO SQL standard9 for updatable views to views created during a session. 2 Environment3 You can use the SET VIEW UPDATE RULES statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format0 SET VIEW UPDATE RULES --> runtime-options ---->  runtime-options ' --+--'-> 'string-literal' ------+----->! +---> parameter -------------+! +---> parameter-marker ------+ 2 Arguments 3 parameterC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 parameter-markerC Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 3 SQL99_or_SQL92> Specifies that the ANSI/ISO standard for updatable views isA applied to all views created during compilation. Views that doB not comply with the ANSI standard for updatable views cannot be updated.C The ANSI/ISO standard for updatable views requires the following0 conditions to be met in the SELECT statement:, o The DISTINCT keyword is not specified.B o Only column names can appear in the select list. Each columnB name can appear only once. Functions and expressions such asD max(column_name) or column_name +1 cannot appear in the select list.B o The FROM clause refers to only one table. This table must beA either a base table or a derived table that can be updated.3 o The WHERE clause does not contain a subquery.+ o The GROUP BY clause is not specified.) o The HAVING clause is not specified. 3 SQLV40B Specifies that the ANSI/ISO SQL standard for updatable views is not applied.? SQL considers views that meet the following conditions to be updatable:, o The DISTINCT keyword is not specified.B o The FROM clause refers to only one table. This table must beA either a base table or a derived table that can be updated.3 o The WHERE clause does not contain a subquery.+ o The GROUP BY clause is not specified.) o The HAVING clause is not specified. The default is SQLV40. 3 'string-literal'C Specifies the value of runtime-options, which must be one of the following: o SQL99 o SQL92 o SQL89 o MIA o SQLV40 2 ExampleC Example 1: Setting the view characteristics from SQLV40 to SQL991 SQL> ATTACH 'ALIAS ENV1 FILENAME ENVIRONMENT';? SQL> CONNECT TO 'ALIAS ENV1 FILENAME ENVIRONMENT' AS 'TEST'; SQL> SHOW CONNECTIONS TEST Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias ENV1:. Identifier character set is DEC_MCS+ Default character set is DEC_MCS* National character set is KANJI SQL> --E SQL> -- Change the environment for view rules from SQLV40 to SQL99 SQL> --& SQL> SET VIEW UPDATE RULES 'SQL99'; SQL> SHOW CONNECTIONS TEST Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: ANSI/ISO Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias ENV1:. Identifier character set is DEC_MCS+ Default character set is DEC_MCS* National character set is KANJI ww show-params-1 --------------+-->, +-> show-params-2 --------------+, +-> show-session-information ---+ show-params-1 = ) ----+-> show-aliases --------------+--->% +-> show-cache ----------------+% +-> show-catalogs -------------+% +-> CHARACTER SETS ------------+% +-> show-collating-sequence ---+% +-> show-connections ----------+% +-> CURSORS -------------------+% +-> show-databases ------------+% +-> DISPLAY -------------------+% +-> show-domains --------------+% +-> FLAGS ---------------------+% +-> show-functions ------------+% +-> show-indexes --------------+% +-> show-journals -------------+% +-> show-modules --------------+% +-> show-outlines -------------+ show-params-2 = % --+-> show-profiles -------------+-># +-> show-privileges -----------+# +-> show-procedures -----------+# +-> QUERY CONFIRM -------------+# +-> QUERY LIMIT ---------------+# +-> show-roles ----------------+# +-> show-schemas --------------+# +-> show-sequences ------------+# +-> show-storage-areas --------+# +-> show-storage-maps ---------+# +-> show-synonyms -------------+# +-> show-tables ---------------+# +-> show-triggers -------------+# +-> show-users ----------------+# +-> show-users-granting -------+# +-> show-users-with -----------+# +-> VARIABLES -----------------+# +-> show-views ----------------+ show-aliases = % --> ALIASES --+----------------+-->" +-+-> -+-+"  | +----- , <---+ |" +---> * ---------+ show-cache = ' ---> CACHE -+---------------------+-->$ +---> ----+ show-catalogs = & ---> CATALOGS --+-----------------+->$ +-> name-list ----+  show-collating-sequence = / ---> COLLATING SEQUENCE --+---------------+-->, +-> name-list --+  show-connections = 0 ---> CONNECTIONS -+-+---------------------+-+->. | +-> DEFAULT ----------+ |. | +-> CURRENT ----------+ |. | +-> + |. +------------- , <--------+  show-databases = & --> DATABASES --+----------------+--># +-+-> -+-+# | +----- , <---+ |# +---> * ---------+  show-domains = / -+-----------+-> DOMAINS -+---------------+-->, +-> SYSTEM -+ +-> name-list --+ +-> ALL ----+  show-functions = P -+------------+-> FUNCTIONS +-----------------------------+-+---------------+->N +-> SYSTEM -+ +> ( ++-> COMMENT -----++> ) -+ +-> name-list -+6 +-> ALL -----+ |+-> ID ----------+|6 |+-> LANGUAGE ----+|6 |+-> MODULE ------+|6 |+-> OWNER -------+|6 |+-> PARAMETER ---+|6  |+-> SOURCE ------+|6 +------- , <-------+  show-indexes = I -+-----------++-> INDEXES -+-+---------------------------------------+->G +-> SYSTEM -++-> INDICES -+ +-> ON -+> ----------------+G +-> ALL ----+ | +----- , <----------------------+G +-> name-list --------------------------+G +-> ( -+-> CARDINALITY +> name-list ) -+7 +-- PARTITIONS |7 +------- , ------+ show-journals % ---> JOURNALS -+----------------+-->" +--> name-list --+  show-modules = O -+------------+-> MODULES -+----------------------------+-+---------------+->M +-> SYSTEM -+ +> ( ++> COMMENT ----++> ) --+ +-> name-list -+4 +-> ALL -----+ |+> FUNCTIONS --+|4 |+> ID ---------+|4 |+> NAME -------+|4 ||> OWNER ------+|4 |+> PROCEDURES -+|4 |+> VARIABLES --+|4 +------ , <------+   show-outlines $ ---> OUTLINES -+---------------+-->! +-> name-list --+  show-profiles = # --> PROFILES -+---------------+--> +-> name-list --+   name-list = - -+-+---------------++- * --------------+-+->+ | +-> . --++-> -+ |+ | |+ +----------------- , <------------------+  show-privileges = E --+-> PROTECTION ON -++-> TABLES ----+-> +----------+->C | || +------- , <-----+ |C +-> PRIVILEGES ON -++-> VIEWS -----+-> -+----------+C | +------- , <---- !-+ |C +-> COLUMNS ---+-> -+--------+C | +------- , <-------+ |C +-> DATABASE --+-> +---------------+C | +---- , <---+ |C +-> FUNCTION --+-> ----+---+C | +----------- , <--------+ |C +-> PROCEDURE -+-> -----+-+C " | +----------- , <----------+ |C +-> MODULE ----+-> +---------+C | +------- , <------+ |C +-> SEQUENCE --+-> -+------+< +------------ , <----+ show-procedures = N -+-----------+--> PROCEDURES +--------------------------++---------------+->L +-> SYSTEM -+ +> ( ++> COMMENT ----++#> ) ++-> name-list --+6 +-> ALL ----+ |+> ID ---------+|6 |+> LANGUAGE ---+|6 |+> MODULE -----+|6 |+> OWNER ------+|6 |+> PARAMETER --+|6 |+> SOURCE -----+|6 +------ , <------+  show-roles =  ---> ROLES -+--------------+-> +-> name-$list -+  show-schemas = ! --> SCHEMAS -+---------------+-> +-> name-list --+  show-sequences= $ ---> SEQUENCES -+---------------+->" +-> name-list --+  show-storage-areas = @ --> STORAGE AREAS --+---------------------------------------+->> +-> name-list --------------------------+> +-> ( ++> USAGE -------++> ) name-list -+. |+> ATTRIBUTES --+|. % +----- , <--------+ show-storage-maps = I -+-----------+-> STORAGE MAPS -+----------------+--------------------+->G +-> SYSTEM -+ +-> name-list ---+ |G +-> ALL ----+ +-> ( PARTITIONS -> ) -> name-list --+  show-synonyms = $ ---> SYNONYMS -+---------------+-->! +-> name-list --+ show-tables = I -+-----------+-> TABLES -+-------------------------------------------+->G &+-> SYSTEM -+ +-> name-list ------------------------------+G +-> ALL ----+ +-> ( -++-> COLUMNS -----++-> ) name-list --+5 |+-> COMMENT -----+|5 |+-> CONSTRAINTS -+|5 |+-> INDEXES -----+|5 |+-> STORAGE MAPS +|5 |+-> TRIGGERS ----+|5 +-------- , <------+  show-triggers' = 0 -+-----------+-> TRIGGERS -+---------------+-->- +-> SYSTEM -+ +-> name-list --+ +-> ALL ----+  show-users = " ---> USERS --+---------------+--> +-> name-list --+  show-users-granting =  --> USERS GRANTING ---+ +---------------------+I ++> db-privs-ansi ------> ON DATABASE -+-> +-----------------++I | +---- , <---+ ||I +> table-privs-ansi ----> ON TABLE( -+-> +--------------+|I | +------- , <-----+ ||I +> column-privs-ansi ---> ON COLUMN -+-> --+-----------+|I | +------- , <--------+ ||I +> ext-routine-privs-ansi +-> ON FUNCTION +> ON PROCEDURE +> module-privs-ansi ---> ON MODULE --+-> --+----------+|I | +----- , <----------+ ||I +> sequence-privs-ansi --> ON SEQUENCE -+> -+--------+|I +--- , <------------+ |I +-------------------------------------------------------------------+0 +---> TO -+-> identifier-ansi-style ---+--->, * +-> PUBLIC ------------------+ show-views = < --+-----------+-> VIEWS -+------------------------------+-+< +-> SYSTEM -+ +-> ( -+-+-> COLUMNS -+-+-> ) -+ |< +-> ALL ----+ | +-> COMMENT -+ | |< | +-> SOURCE --+ | |< +------ , <------+ |< +--------------------------<-----------------------------+# +-+---------------+-------------> +-> name-list --+ + db-privs-ansi = % ----+---+-+-> SELECT -----+-+----+-># | | +-> INSERT -----+ | |# | | +-> OPERATOR ---+ | |# | | +-> DELETE -----+ | |# | | +-> CREATE -----+ | |# | | +-> ALTER ------+ | |# | | +-> DROP -------+ | |# | | +-> DBCTRL -----+ | |# | | +-> DBADM ------+ | |# | | +-> SHOW -------+ | |# | | +-> REFERENCES -+ | |# | | +-> UPDATE -----+ | |# | | +-> SECURITY --,-+ | |# | | +-> DISTRIBTRAN + | |# | +------- , <--------+ |# +-------> ALL PRIVILEGES ----+ table-privs-ansi = 8 -+--+-+-> SELECT -------------------------------+-+-+->6 | | +-> INSERT -------------------------------+ | |6 | | +-> OPERATOR -----------------------------+ | |6 | | +-> DELETE -------------------------------+ | |6 | | +-> CREATE -------------------------------+ | |6 | | +-> ALTER --------------------------------+ | |6 | | +-> - DROP ---------------------------------+ | |6 | | +-> DBCTRL -------------------------------+ | |6 | | +-> SHOW ---------------------------------+ | |6 | | +-> REFERENCES +--------------------------+ | |6 | | | +> ( +> +> ) + | |6 | | | +----- , <-------+ | | |6 | | +-> UPDATE +---------------------- ------+ | |6 | | +> ( +> -+---> ) + | |6 | | +----- , <--------+ | |6 | +------.------------- , <----------------------+ |6 +------> ALL PRIVILEGES ---------------------------+ column-privs-ansi = ! ---+-+-+-> UPDATE -----+-+--+--> | | +-> REFERENCES -+ | | | +------- , <--------+ | +-----> ALL PRIVILEGES --+ ext-routine-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ---------------/-------------+ | |5 | | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ module-privs-ansi = 8 -+--+-+-> ALTER ------------------------------+-+--+-->5 | | +-> DBCTRL -----------------------------+ | |5 | | +-> DROP -------------------------------+ | |5 | | +-> EXECUTE ----------------------------+ | |5 0| | +-> REFERENCES -------------------------+ | |5 | | +-> SHOW -------------------------------+ | |5 | +------------------- , <--------------------+ |5 +------> ALL PRIVILEGES --------------------------+ identifier-ansi-style = " ------> user-identifier -------->  show-users-with =  --> USERS WITH -------+ +---------------------+J ++> db-privs-ansi -------> ON DATABASE -+-> +-----------------++J | +---- , 1<---+ ||J +> table-privs-ansi -----> ON TABLE -+-> +--------------+|J | +------- , <-----+ ||J +> column-privs-ansi ----> ON COLUMN -+-> -+------------+|J | +------- , <-------+ ||J +> ext-routine-privs-ansi -+> ON FUNCTION -+> ----+---+|J | | +--------- , <---------+ ||J | 2 +-> ON PROCEDURE -+> ----++|J | +--------- , <----------+||J +> module-privs-ansi ----> ON MODULE --+-> +------------+|J | +----- , <--------+ ||J +> sequence-privs-ansi --> ON SEQUENCE -+-> -+--------+|J +---- , <------------+ |J +--------------------------------------------------------------------+30 +--> FROM +-> identifier-ansi-style ---+--->, +-> PUBLIC ------------------+ sequence-privs-ansi =  -+-+-+-> ALTER -----+-+-+--> | | +-> DBCTRL ----+ | | | | +-> DROP ------+ | | | | +-> SELECT ----+ | | | +------- , <-------+ | +--> ALL PRIVILEGES ---+ show-session-information = # -+-> ANSI DATE MODE -----------+->! +-> ANSI IDENTIFIERS MODE ----+! +-> ANSI QUOTING MODE --------+! +-> AUTOMATIC TRANSLATION ----+! +-> CONSTRAINT4 MODE ----------+! +-> CONTINUATION CHARACTER ---+! +-> CURRENCY SIGN ------------+! +-> DATE FORMAT --------------+! +-> DICTIONARY ---------------+! +-> DIGIT SEPARATOR ----------+! +-> DISPLAY ------------------+! +-> EXECUTION MODE -----------+! +-> FLAGGER MODE -------------+! +-> HOLD CURSORS MODE --------+! +-> LANGUAGE -----------------+! +-> RADIX POINT --------------+! +-> SQLCA --------------------+! +-> TRANSACTION --------------+! +-> VERSIONS ---5--------------+! +-> WARNING MODE -------------+ 2 Arguments 3 ALIASESA Displays information about aliases for all attached databases.A For each alias, SQL displays the path name or file name of the? current default database, and the file specification for the database file.; If you specify aliases by name, SQL displays information? about whether or not multischema mode, snapshots, carry-over@ locks, adjustable lock granularity, global buffers, com 6mit toA journal optimization, and journal fast commit are enabled. SQLD displays the character sets of the alias if the database default,C national, or identifier character set differs from the session'sD default, national, or identifier character set. SQL also displaysD the journal fast commit checkpoint and transaction intervals, the? lock timeout interval, the number of users, number of nodes,> buffer size, number of buffers, number of recovery buffers,? ACL-based protect7ions, storage areas, and whether or not the repository is required. 3 ALLA Controls whether SQL displays system-defined domains, indexes,; storage maps, tables, or views in the SHOW DOMAINS, SHOWA FUNCTIONS, SHOW INDEXES, SHOW MODULES, SHOW STORAGE MAPS, SHOW4 TABLES, SHOW TRIGGERS, and SHOW VIEWS statements.= o If you do not specify either SYSTEM or ALL, the display* includes only user-defined elements.> o If you specify SYSTEM, the display includes on8ly system- defined elements.D o If you specify ALL, the display includes both user-defined and system-defined elements. 3 ANSI_DATE_MODEC Displays the default interpretation for columns with the DATE or CURRENT_TIMESTAMP data type.C The DATE and CURRENT_TIMESTAMP data types, can be either OpenVMS> or ANSI/ISO. By default, both data types are interpreted as OpenVMS format.B Use the SET DEFAULT DATE FORMAT statement to change the default dat9e. 3 ANSI_IDENTIFIERS_MODEC Displays whether or not identifier checking is enabled. You must? enclose reserved words from the ANSI/ISO SQL standard within> double quotation marks to supply them as identifiers in SQL> statements. When you enable identifier checking, SQL issuesA an informational message after statements that misuse ANSI/ISOC reserved words. For a list of the reserved words, see Oracle Rdb SQL Reference Manual.A By default, identifier checking is :disabled. To enable it, use# the SET KEYWORD RULES statement. 3 ANSI_QUOTING_MODEA Displays whether or not you must use double quotation marks toD delimit the alias and catalog name pair in subsequent statements.= By default, SQL syntax allows only single quotation marks.C Use the SET QUOTING RULES statement to change the quoting rules. 3 AUTOMATIC_TRANSLATIONB Displays the current setting as established using SET AUTOMATIC TRANSLATION. 3 CACHE;? Displays information about the specified cache. For example: SQL> SHOW CACHE1 Cache Objects in database with filename sample CACHE1 CACHE2 SQL> SHOW CACHE cache1 CACHE1+ Cache Size: 1000 rows+ Row Length: 256 bytes) Row Replacement: Enabled) Shared Memory: Process* Large Memory: Disabled% Window Count: 100$ R<eserved Rows: 20& Sweep Rows: 3000 No Sweep Thresholds, Allocation: 100 blocks, Extent: 100 blocks 3 CATALOGSC Displays information about the specified catalogs. If you do notA specify any aliases in the catalog names that you specify, SQL: displays this information about all attached databases. 3 CHARACTER_SETSB Displays information about the specified character sets for the&= session and all attached databases. 3 COLLATING_SEQUENCE< Displays the collating sequences for schemas and domains. 3 CONNECTIONS Syntax options: CONNECTIONS DEFAULT CONNECTIONS CURRENT! CONNECTIONS connection-name> Displays database information for the specified connection. 3 CONSTRAINT_MODEA Displays the default setting for constraint evaluation for anyC transactions starting after the current transaction. If there isA > a current transaction, displays the constraint evaluation mode for the current transaction.C When the constraint mode is IMMEDIATE, SQL evaluates all commit-D time constraints at the end of each statement and at commit time,B until the transaction completes or until you set the constraintA mode to OFF. When the constraint mode is DEFERRED (the defaultA setting), constraint evaluation is deferred until commit time. 3 CONTINUE_CHARACTERD Displays the value for th?e continuation character, as established using SET CONTINUE CHARACTER. 3 CURRENCY_SIGN@ Displays the currency indicator, such as the dollar sign ($),( that will be used in output displays. 3 CURSORS Displays current cursors. 3 DATABASES? Displays information about the specified databases. For each> database, SQL displays the alias, the type of database, anyA defined collating sequence, and the file specification for the database file.A I @f the database was declared using a repository path name, SQLB also displays that path name. If you do not specify any aliasesC with the SHOW DATABASES statement, SQL displays this information about all declared databases.B SQL displays the character sets of the database if the default,C national, or identifier character set differs from the session's2 default, national, or identifier character set.< If you do specify an alias, SQL also displays information? about whethAer or not multischema mode, snapshots, carry-over@ locks, adjustable lock granularity, global buffers, commit to@ journal optimization, journaling, and journal fast commit are@ enabled. SQL also displays the journal fast commit checkpointC and transaction intervals, the lock timeout interval, the numberC of unused storage areas, the number of unused journal files, theD number of users, number of nodes, buffer size, number of buffers,D number of recovery buffers, ACL-based proteBctions, storage areas,1 and whether or not the repository is required. 3 DATE_FORMATD Displays the values for the date-number and time-number argumentsC of the SET DATE FORMAT DATE date-number and SET DATE FORMAT TIME time-number statements. 3 DICTIONARY@ Displays the current default dictionary directory in the data dictionary. 3 DIGIT_SEPARATORB Displays the character that will be used as the digit separator> in output displays. (The digit se Cparator is the symbol thatC separates groups of three digits in values greater than 999. ForB example, the comma is the digit separator in the number 1,000.) 3 DISPLAYB Displays the current settings as established using SET DISPLAY,@ SET FEEDBACK, SET HEADING, SET LINE LENGTH (or SET LINESIZE),C SET PAGE LENGTH (or SET PAGESIZE), SET TIMING and SET NULL. Some@ values (such as line and page length) are determined from theB OpenVMS terminal characteristics when starting Dinteractive SQL. 3 DOMAINSB Displays the names, data types, and character sets of specifiedA domains. If you specify the SHOW DOMAINS statement without anyC arguments, SQL displays names, data types, and character sets of) all domains in all attached databases. 3 EXECUTION_MODEB Shows whether or not SQL executes the statements that you issueA in your interactive SQL session. The default is to execute the> statements as you issue them. However, if you have Eissued a@ SET NOEXECUTE statement in your session, SQL will not execute subsequent statements.< You can use the SET NOEXECUTE statement to display access@ strategies and check for syntax errors. For more information, see the SET statement. 3 FLAGGER_MODEC Shows whether or not SQL flags statements containing nonstandardD syntax for all set flaggers. If you specify SET FLAGGER ON, which@ is equivalent to SET FLAGGER SQL92_ENTRY ON, the SHOW FLAGGER@ statementF informs you that flagging for the ANSI/ISO standard@ is set. If you specified SET FLAGGER MIA ON, the SHOW FLAGGERC statement informs you that flagging for the MIA standard is set. 3 FLAGSD Displays the database system debug flags that are enabled for the current session. 3 FROM Syntax options:# {identifier ansi style | PUBLIC}; Specifies the identifiers for the new or modified access< privilege set entry. Specifying PUBLIC is equivalent to a2 G wildcard specification of all user identifiers. 3 FUNCTIONSC Displays information about a specified function; either externalA or stored. When you enter the SHOW FUNCTIONS statement withoutA any arguments, SQL displays the name of the function only. TheC following table lists the information that you can display using7 a set of keywords with the SHOW FUNCTIONS statement: You Specify. This: SQL Displays Information About:? COMMENT The descripti Hon of the function. If none exists, nothing displays.B ID The unique identification assigned to the function.@ LANGUAGE The host language in which the function is coded.> MODULE The name of the module in which the function is defined.) OWNER The owner of the function.> PARAMETER Information about the parameters, including the? number of arguments, the data type, return type,/ and how the parameterI is passed.@ SOURCE Displays the source definitions for the specified functions. 3 HOLD_CURSORS_MODE; Displays the default mode for hold cursors. For example: SQL> SHOW HOLD CURSORS MODE0 Hold Cursors default: WITH HOLD PRESERVE NONE 3 INDEXESA Displays information about specified indexes. SQL displays the? name of the index, the associated column and table, the sizeB of the index key, if the definition allows duplicate values for@ J the column, the type of index (sorted or hashed), and whetherD index compression is enabled or disabled. If you specify the SHOWD INDEXES statement without any arguments, SQL displays definitions, of all indexes in all declared databases. You Specify( This: SQL Performs This Action:B CARDINALITY Adds the index and column prefix cardinality values" to the SHOW output.B PARTITIONS Displays the index partitions showing the partitionD nKame and number the name of the storage area used for the partition. 3 JOURNALSC Displays information about specified journal files. SQL displaysA the name of the file specification and, if created, the backup file specification. 3 LANGUAGE< Displays the language to be used for translation of monthB names and abbreviations in date and time input and display. TheC language name also determines the translation of other language-@ dependent tLext, such as the translation for the date literals" YESTERDAY, TODAY, and TOMORROW. 3 MODULES0 Displays information about specified modules.B If you do not specify any of the SHOW MODULES options listed in@ the following table, SQL displays information about all these options: You Specify. This: SQL Displays Information About:= COMMENT The description of the module. If none exists, nothing displays.< FUNCTIONS The stored fu Mnctions contained in the module.@ ID The unique identification assigned to the module.& NAME The name of the module.D OWNER The owner of the module. If the module is a definer's? rights module, the definer's user name displays,B otherwise for an invoker's rights module the output will be blank.= PROCEDURES The stored procedures contained in the module.0 VARIABLES Displays module global variables. 3 name-li Nst> Most SHOW statements accept an optional name-list which canB specify the name of the object, or a wildcard (*) to indicate aD summary of all such objects. The wildcard or name can be prefixed? by an alias name, or for multischema databases a catalog and schema.? Names are by default in uppercase. If the object was defined@ in mixed or lower case, or with other special characters thenA use the SET DIALECT, or SET QUOTING RULES statements to enableD delimited identOifers. Then use quotes ("") around the name in the SHOW statement. 3 object-name? Specifies the name of an object whose definition you want to display. 3 ON_DATABASE_alias? Specifies the databases for which you want to display access= privilege set information with the SHOW PRIVILEGES or SHOWC PROTECTION statement. You can specify a list of aliases, but youC must specify at least one. To display privileges for the default( database, use the alias RDBP$DBHANDLE. 3 ON_syntax_options List of syntax options: ON TABLES ON VIEWS ON COLUMNS ON FUNCTIONS ON PROCEDURES ON MODULES ON SEQUENCES sequence-name< Specifies the object for which you want to display access= privilege set information with the SHOW PRIVILEGES or SHOW= PROTECTION statement. You can specify a list of names, butA you must specify at least one item to display a list. You mustA qualify a column name wit Qh at least the associated table name.? In an ANSI/ISO-style database, the SHOW PROTECTION statement@ displays which privileges have the option of being granted toA other users and which privileges are without the grant option.@ See the SHOW USERS WITH and SHOW USERS GRANTING statements in@ this section for more information about displaying privileges1 granted directly or indirectly to other users. 3 ON_table_name: Specifies the table or tables for which you want toR see associated index definitions. 3 OUTLINESA Displays the definition of the specified outline. SQL displaysD the outline name, ID number, mode, query, compliance, and comment if one exists.@ If you issue the SHOW OUTLINE statement without the name of a@ specific outline, the names of all the outlines stored in the@ database are displayed. However, the invalid outlines are not marked as invalid. 3 PRIVILEGES Syntax options: PRIVILEGES | SPROTECTIONC Displays current user identifier and available access rights for the specified object.= o The SHOW PRIVILEGES statement displays the current user= identifier and available access rights to the specified< databases, tables, views, columns, external functions,1 external procedures, modules, or sequences.> This statement displays not only the privileges that are= explicitly granted to the user, but also any privilegesB that the user in Therits from database access or the operating system.D In a client/server environment, the entry shows the identifier@ of the client. For example, if a user attaches to a remote> database using the USER and USING clauses, SQL shows the9 privileges for the user specified in those clauses.C In an environment that is not client/server, such as when youC attach to a local database, SQL shows not only the privileges= of the database user, but of the l Uogged-on process. ForA example, if user heleng, with the OpenVMS privilege BYPASS,B uses the USER and USING clauses to attach to the database as@ user rhonda, SQL shows that user rhonda has the privileges= inherited from the logged-on process heleng, as well as! privileges for user rhonda.B o The SHOW PROTECTION statement displays all of the entries inC the access privilege set for the specified databases, tables,> views, columns, external functionsV, external procedures, modules, or sequences. 3 PROCEDURESD Displays information about a specified procedure; either external or stored.> If you do not specify any of the SHOW PROCEDURES attributes@ (COMMENT, ID, LANGUAGE, MODULE, OWNER, SOURCE, or PARAMETER),= by default you will see the display for all these options. You Specify. This: SQL Displays Information About:? COMMENT The description of the stored procedure. If none( W exists, nothing displays.C ID The unique identification assigned to the procedure.C LANGUAGE The language in which the procedure source is coded.A MODULE The identification number of the module to which a! procedure belongs.* OWNER The owner of the procedure.> PARAMETER Information about the parameters; including the> number of arguments, the data type, and how the# parameter is passed.@ SOURCE DisXplays the source definitions for the specified procedures. 3 PROFILESB Displays the definition of the specified profile. If you do not@ specify a wildcard or list of profile names, SQL displays the7 names of all the profiles in all attached databases. 3 PROTECTIONB Displays access privilege set entries for the specified tables,A columns, database, external functions, external procedures, or modules.@ The SHOW PROTECTION statement displayYs all the entries in theC access privilege set for the specified databases, tables, views,@ columns, external functions, external procedures, or modules. 3 QUERY_CONFIRMC Shows whether or not SQL displays the cost estimates for a query before executing that query. 3 QUERY_LIMITC Displays information about the number of rows a query can returnA and the amount of time used to optimize a query for execution. 3 RADIX_POINTA Displays the character thZat will be used as the radix point inA output displays. (The radix point is the symbol that separatesA units from decimal fractions. For example, in the number 98.6," the period is the radix point.) 3 ROLESB Displays the definition of the specified role. SQL displays theB role name, ID number, and any comments associated with the role definition. 3 SCHEMASD Displays the names of specified schemas. If you do not specify anB alias as part of a schema name, [ SQL displays schema information@ for all the attached databases. For each database that is notA multischema, SQL displays the message, "No schemas found". ForC each multischema database, SQL displays the alias, followed by aB list of schemas contained in that database. Each schema name in7 the list is preceded by the catalog and alias names. 3 SEQUENCESB Displays the definition of the specified sequence. SQL displays= the sequence name, ID number, and the sequence at\tributes. 3 SQLCA@ Displays the contents of the SQL Communications Area (SQLCA).B The SQLCA is a collection of variables that SQL uses to provideC information about the execution of SQL statements to application; programs. In interactive SQL, you can use the SHOW SQLCAA statement to learn about the different variables in the SQLCA.? See the Oracle Rdb SQL Reference Manual for more information about the SQLCA. 3 STATISTICSC Displays simple process] statistics for the current process. ThisB command is used primarily to compare resource usage and elapsed time for different queries.D The following example shows the output after performing a typical query: SQL> select count (*)< cont> from employees natural full outer join job_history; 274 1 row selected SQL> show statistics;A process statistics at 5-MAR-2006 05:57:48.28P elapsed time = 0 00:00:00.16 C^PU time = 0 00:00:00.05G page fault count = 430 pages in working set = 22768D buffered I/O count = 26 direct I/O count = 83F open file count = 12 file quota remaining = 7988J locks held = 138 locks remaining = 16776821E CPU utilization = 31.2% AST quota remaining = 995< The statistics are reset after each execution of the SHOW STATISTICS command. 3 STORAGE_AREASD _ Displays information about storage areas. If you do not specify aD wildcard or list of storage area names, SQL displays the names of3 all the storage areas in all attached databases. You Specify. This: SQL Displays Information About:? USAGE Usage, object name, storage map, and storage map? partition number for the specified storage area.A Partition numbers are always shown in parentheses,@ and may be accompanied by a ` storage map name. ForD example, for an index there is no special map becauseB it is part of the index. For a table, the map is an6 extra object and therefore is reported.A ATTRIBUTES Storage area type, access, page format, page size,B storage area file, storage area allocation, storageC area extent minimum and maximum, storage area extentD percent, snapshot file, snapshot allocation, snapshotC a extent minimum and maximum, snapshot extent percent,? whether extents are enabled or disabled, and the< locking level for the specified storage area. 3 STORAGE_MAPSC Displays information about storage maps. If you do not specify aC wildcard or list of storage map names, SQL displays the names of2 all the storage maps in all attached databases. You Specify. This: SQL Displays Information About:A PARTITIONS Storage map parbtitions showing the partition name,C number and the name of the storage area used for the partition 3 SYNONYMSC Displays information about the specified synonyms. If you do notA specify any aliases in the synonym names that you specify, SQLC displays this information about all attached databases. The name@ of the target object, possibly another synonym, is displayed. 3 SYSTEMA Controls whether SQL displays system-defined domains, c indexes,; storage maps, tables, or views in the SHOW DOMAINS, SHOWA FUNCTIONS, SHOW INDEXES, SHOW MODULES, SHOW STORAGE MAPS, SHOW4 TABLES, SHOW TRIGGERS, and SHOW VIEWS statements.= o If you do not specify either SYSTEM or ALL, the display* includes only user-defined elements.B o If you specify SYSTEM, the display includes elements createdB for use by the database system, or layered applications such4 as the OCI Services component of SQL/Services.D o dIf you specify ALL, the display includes both user-defined and system-defined elements. 3 TABLES= Displays information about tables and views. If you do notC specify a wildcard or list of table and view names, SQL displaysC the names of all the tables and views in all attached databases.A If you do not specify any of the SHOW TABLES options (COLUMNS,@ COMMENT, CONSTRAINTS, INDEXES, STORAGE MAPS, or TRIGGERS), byC default you will see the display for all these eoptions including< the character set for each column of the specified table. You Specify. This: SQL Displays Information About:C COLUMNS Each column name, data type, and domain name for the specified tables.1 COMMENT Comments for the specified tables.; CONSTRAINTS Constraints for the specified tables and the@ constraints referencing the specified tables. TheB display shows the name and type of each constraint,>f its evaluation time, and its source definition. 3 TO_option Syntax options:# {identifier ansi style | PUBLIC}; Specifies the identifiers for the new or modified access< privilege set entry. Specifying PUBLIC is equivalent to a2 wildcard specification of all user identifiers. 3 TRANSACTIONA Displays the characteristics of the current transaction or, ifC there is no active transaction, the characteristics specified inC the last DECLARE gTRANSACTION statement. For each database within< the scope of the transaction, SQL displays the following: o Transaction= o Tables specified in the RESERVING clause of the DECLARE. TRANSACTION or SET TRANSACTION statement7 o Share mode and lock type for each of those tables* o If fast commit processing is enabledC In addition, the SHOW TRANSACTION statement displays transaction= information returned by the base database system about theA transaction, hsuch as whether or not the transaction is active. 3 TRIGGERSB Displays information about the specified trigger. If you do not@ specify a wildcard or list of trigger names, SQL displays the7 names of all the triggers in all attached databases. 3 USERS> Displays the definition of the specified database user. SQLA displays the database user name (such as defined by the CREATEB USER statement), how the user will be authenticated (currently,= only through the opierating system), whether the account is@ locked or unlocked, and any comments associated with the user definition. 3 USERS_GRANTING> Displays all the users who gave a particular privilege to a? particular user. This statement displays the privileges thatD need to be revoked to take a privilege away from the user, either directly or indirectly. 3 USERS_WITHD Displays all the users who received a particular privilege from aC particular user, including aljl the users who indirectly receivedC privileges. This is also the list of users who lose a particularA privilege when it is taken away from any users who granted the privilege. 3 VARIABLES1 Displays information about declared variables. 3 VERSIONS: Displays the version of SQL and the underlying software components. 3 VIEWS< Displays information about views. If you do not specify a@ wildcard or list of view names, SQL displays the names of akll' the views in all attached databases.? If you do not specify any of the SHOW VIEW options (COLUMNS,C COMMENT, or SOURCE), by default you will see the display for all these options. You Specify. This: SQL Displays Information About:: SOURCE Source definitions for the specified views. 3 WARNING_MODE@ Displays the default setting for warning messages. If WARNINGB MODE is set to ON, SQL flags statements containing obsolete SQLA syntax.l Obsolete syntax is syntax that was allowed in previousB versions of SQL but has changed. Oracle Rdb recommends that youD avoid using such syntax because it may not be supported in futureA versions. By default, SQL displays a warning message after any: statement containing obsolete syntax (WARNING MODE ON).B To suppress messages about obsolete syntax, use the SET WARNING NODEPRECATE statement. 2 Examples/ Example 1: Using the SHOW statement displays9 The follomwing log file from an interactive SQL session< illustrates some of the arguments for the SHOW statement:+ SQL> -- Show the session character sets. SQL> -- SQL> SHOW CHARACTER SETS;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED SQL> --C SQL> -- Attach to the database and show database character sets. SQL> --' SQL> ATTACH 'nFILENAME MIA_CHAR_SET'; SQL> SHOW CHARACTER SETS;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI SQL> --I SQL> -- Attach to the second database and show character sets of botho. SQL> --2 SQL> ATTACH 'ALIAS MIA1 FILENAME MIA_CHAR_SET'; SQL> SHOW CHARACTER SETS;# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI Alias MIA1:0 Identifier charpacter set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI SQL> -- SQL> -- SHOW ALIAS examples. SQL> -- SQL> SHOW ALIAS; Default alias:/ Oracle Rdb database in file MIA_CHAR_SET Alias MIA1:/ Oracle Rdb database in file MIA_CHAR_SET SQL> SHOW ALIAS MIA1; Alias MIA1:/ Oracle Rdb database in file MIA_CHAR_SET' Multischema mode is disabled- Default character set is DEC_qKANJI* National character set is KANJI0 Identifier character set is DEC_KANJI, Number of users: 50, Number of nodes: 16+ Buffer Size (blocks/buffer): 6, Number of Buffers: 20, Number of Recovery Buffers: 20* Snapshots are Enabled Immediate . . . ACL based protections, Storage Areas in database with alias MIA1E RDB$SYSTEM r Default and list storage area' Journals in database with alias MIA1 No Journals Found! Cache Objects in database MIA1 No Caches Found SQL> --% SQL> -- SHOW CONNECTIONS examples. SQL> --@ SQL> CONNECT TO 'ALIAS MIA1 FILENAME MIA_CHAR_SET' AS 'TEST'; SQL> SHOW CONNECTIONS; RDB$DEFAULT_CONNECTION -> TEST! SQL> SHOW CONNECTIONS DEFAULT;% Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE& Default csatalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40 . . .# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias RDB$DBHANDLE:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI Alias MIA1:0 Itdentifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI SQL> SHOW CONNECTIONS TEST; Connection: TEST Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT0 Hold Cursors udefault: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default character set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias MIA1:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI SQL> --A SQL> CONNECT TO 'ALIAS MIA1 FvILENAME MIA_CHAR_SET' AS 'test1'; SQL> --F SQL> -- You must set quoting rules to the SQL99 environment and useE SQL> -- double quotation marks (") to display the settings of the> SQL> -- 'test1' connection or use SHOW CONNECTIONS CURRENT. SQL> -- SQL> SHOW CONNECTIONS; RDB$DEFAULT_CONNECTION TEST -> test1 SQL> SHOW CONNECTIONS test1; Connection: TEST1C %SQL-F-NOSUCHCON, There is not an active connection by that name" SQL> SET QUOTING RULES 'SQL99w';! SQL> SHOW CONNECTIONS "test1"; Connection: test1 Default alias is RDB$DBHANDLE& Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40! Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: ANSI/ISO Optimization Level: DEFAULT0 Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF' Compound transactions mode: EXTERNAL# Default charactxer set is DEC_MCS$ National character set is DEC_MCS& Identifier character set is DEC_MCS# Literal character set is DEC_MCS' Display character set is UNSPECIFIED Alias MIA1:0 Identifier character set is DEC_KANJI- Default character set is DEC_KANJI* National character set is KANJI SQL> SET CONNECT DEFAULT; SQL> --# SQL> -- SHOW DATABASES examples. SQL> -- SQL> SHOW DATABASES;@ %SQL-I-SPELLCORR, identifier DATABASES replacyed with DATABASE Default alias:/ Oracle Rdb database in file MIA_CHAR_SET Alias MIA1:/ Oracle Rdb database in file MIA_CHAR_SET# SQL> SHOW DATABASE RDB$DBHANDLE; Default alias:/ Oracle Rdb database in file MIA_CHAR_SET' Multischema mode is disabled- Default character set is DEC_KANJI* National character set is KANJI0 Identifier character set is DEC_KANJI, Number of users: 50, Numzber of nodes: 16+ Buffer Size (blocks/buffer): 6, Number of Buffers: 20, Number of Recovery Buffers: 20* Snapshots are Enabled Immediate . . . ACL based protections7 Storage Areas in database with filename MIA_CHAR_SETE RDB$SYSTEM Default and list storage area2 Journals in database with filename MIA_CHAR_SET No Journals Found7 Cache Objects i{n database with filename MIA_CHAR_SET No Caches Found SQL> -- SQL> -- SHOW DOMAINS example. SQL> -- SQL> SHOW DOMAINS;6 User domains in database with filename MIA_CHAR_SET No Domains Found+ User domains in database with alias MIA1 No Domains Found SQL> -- SQL> -- SHOW TABLES example. SQL> -- SQL> SHOW TABLES;5 User tables in database with filename MIA_CHAR_SET COLOURS* User tables in database with alias MIA1 MI|A1.COLOURS% SQL> SHOW TABLE (COLUMNS) COLOURS; Information for table COLOURS Columns for table COLOURS:" Column Name Data Type Domain" ----------- --------- ------* ENGLISH CHAR(8)$ DEC_MCS 8 Characters, 8 Octets* FRENCH CHAR(8)& ISOLATIN9 8 Characters, 8 Octets* JAPANESE CHAR(8)& SHIFT_JIS 4 Characters, 8 Octets+ ROMAJI CHAR(16)* KATAKANA } CHAR(8)% KATAKANA 8 Characters, 8 Octets* HINDI CHAR(8)' DEVANAGARI 8 Characters, 8 Octets* GREEK CHAR(8)* ISOLATINGREEK 8 Characters, 8 Octets* ARABIC CHAR(8)+ ISOLATINARABIC 8 Characters, 8 Octets* RUSSIAN CHAR(8)- ISOLATINCYRILLIC 8 Characters, 8 Octets SQL> -- SQL> -- SHOW INDEXES example. SQL> -- SQL> SHOW INDEXES;6~ User indexes in database with filename MIA_CHAR_SET COLOUR_INDEX+ User indexes in database with alias MIA1 MIA1.COLOUR_INDEX" SQL> SHOW INDEXES COLOUR_INDEX; Indexes on table COLOURS:7 COLOUR_INDEX with column JAPANESE Duplicates are allowed Type is Sorted' Key suffix compression is DISABLED B Example 2: Showing features that internationalize your terminal session: The following example displays SHOW statements that let9 you see the values for the SET statements dealing with internationalization: SQL> --E SQL> -- First, use the SET statement to specify nondefault values. SQL> -- SQL> SET CURRENCY SIGN '' SQL> -- SQL> SET DATE FORMAT TIME 15 SQL> -- SQL> SET DIGIT SEPARATOR '.' SQL> -- SQL> SET LANGUAGE GERMAN SQL> -- SQL> SET RADIX POINT ',' SQL> --) SQL> -- Now look at the SHOW displays. SQL> -- SQL> SHOW CURRENCY SIGN Currency sign is ''. SQL> -- SQL> SHOW DATE FORMAT Date format is TIME 15. SQL> -- SQL> SHOW DIGIT SEPARATOR Digit separator is '.'. SQL> -- SQL> SHOW LANGUAGE Language is GERMAN.A Example 3: Showing the setting for nonstandard syntax flagging SQL> SHOW FLAGGER MODE The flagger mode is OFF" SQL> SET FLAGGER SQL92_ENTRY ON SQL> SHOW FLAGGER MODE< %SQL-I-NONSTASYN92E, Nonstandard SQL92 Entry-level syntax+ The SQL92 Entry-level flagger mode is ON / Example 4: Showing after-image journal files6 The following example displays journal information:! SQL> ATTACH 'FILENAME SAMPLE'; SQL> SHOW JOURNAL, Journals in database with filename SAMPLE AIJ_ONE AIJ_TWO SQL> SHOW JOURNAL *, Journals in database with filename SAMPLE AIJ_ONE2 Journal File: DISK1:[DOCS]AIJ1.AIJ;16 Backup File: DISK1:[DOCS.AIJS]AIJ1.AIJ; AIJ_TWO2 Journal File:  DISK1:[DOCS]AIJ2.AIJ;16 Backup File: DISK1:[DOCS.AIJS]AIJ2.AIJ;H Edit String: ('$'+HOUR+MINUTE+'_'+MONTH+DAY+'_'+SEQUENCE)B Example 5: Showing storage area usage and attribute information; The following example displays storage area information:? SQL> -- Display the usage of storage area TEST_AREA and JOBS SQL> --, SQL> SHOW STORAGE AREAS (USAGE) TEST_AREA1 No database objects use Storage Area TEST_AREA' SQL> SHOW STORAGE AREAS (USAGE) JOBS, Database objects using Storage Area JOBS:C Usage Object Name Map / PartitionS ---------------- ------------------------------- -------------------------------@ Storage Map JOBS JOBS_MAP (1) SQL> --7 SQL> -- Display the attributes of storage area JOBS. SQL> --, SQL> SHOW STORAGE AREAS (ATTRIBUTES) JOBS JOBS& Access is: Read write! Page Format: Mixed$ Page Size: 2 blocks7 Area File: DISK1:[DOCS.WORK]JOBS.RDA;1/ Area Allocation: 402 pages# Extent: Enabled. Area Extent Minimum: 99 pages0 Area Extent Maximum: 9999 pages0 Area Extent Percent: 20 percent7 Snapshot File: DISK1:[DOCS.WORK]JOBS.SNP;1/ Snapshot Allocation: 100 pages. Snapshot Extent Minimum: 99 pages0 Snapshot Extent Maximum: 9999 pages0 Snapshot Extent Percent: 20 percent Locking is Row Level1 No Cache Associated with Storage Area' Thresholds are (70, 85, 95)/ Example 6: Showing query outline information< The following example displays query outline information: SQL> SHOW OUTLINE MY_OUTLINE MY_OUTLINE Source: create outline MY_OUTLINE( id '09ADFE9073AB383CAABC4567BDEF3832' mode 0 as ( query ( subquery (> EMPLOYEES 0 access path index EMP_LAST_NAME join by cross to; DEGREES 1 access path index DEG_EMP_ID ) ) ) compliance optional ; Example 7: Showing privilegesD The following example demonstrates the SHOW PRIVILEGES statement:4 SQL> ! Attach as the logged on user, [sql,heleng]% SQL> ATTACH 'FILENAME personnel';0 SQL> SHOW PRIVILEGES ON DATABASE RDB$DBHANDLE# Privileges on Alias RDB$D BHANDLEO (IDENTIFIER=[sql,heleng],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+J ALTER+DROP+DBCTRL+OPERATOR+DBADM+REFERENCES+SECURITY+DISTRIBTRAN) SQL> ! SQL> ! Attach as user rhonda.L SQL> ATTACH 'FILENAME personnel USER ''rhonda'' USING ''newhampshire''';+ SQL> ! User rhonda has SELECT privilege.0 SQL> SHOW PRIVILEGES ON DATABASE RDB$DBHANDLE# Privileges on Alias RDB$DBHANDLE. (IDENTIFIER=[sql,rhonda],ACCESS=SELECT) SQL> EXIT $ !? $ ! On OpenVMS, give the process the BYPASS privilege, which/ $ ! gives you access to any database object. $ SET PROC/PRIVILEGES=BYPASS $ SQL$ SQL> ! Attach as user rhonda.L SQL> ATTACH 'FILENAME personnel USER ''rhonda'' USING ''newhampshire'''; SQL> !J SQL> ! User rhonda now has all privileges, inherited from the logged-on SQL> ! process.0 SQL> SHOW PRIVILEGES ON DATABASE RDB$DBHANDLE# Privileges on Alias RDB$DBHANDLEO (IDENTIFIER=[sql,rhonda],ACCESS=SELECT+INSERT+UPDATE+DELETE+SHOW+CREATE+J ALTER+DROP+DBCTRL+OPERATOR+DBADM+REFERENCES+SECURITY+DISTRIBTRAN)< Example 8: Showing modules, stored procedures, and stored functions SQL> --, SQL> -- Show the modules in the database. SQL> --' SQL> ATTACH 'FILENAME mf_personnel'; SQL> SHOW MODULES1 Modules in database with filename mf_personnel% Module name is: UTILITY_FUNCTIONS& SQL> SHOW MODULES utility_functions% Module name is: UTILITY_FUNCTIONS Header: utility_functions$ language sql No description found. Owner is: Module ID is: 1" Functions/Procedures in Module: Function ABS Function MDY Procedure TRACE_DATE SQL> --; SQL> -- Show the procedures and functions of the module. SQL> --3 SQL> SHOW MODULES (PROCEDURES) utility_functions% Module name is: UTILITY_FUNCTIONS" Functions/Procedures in Module: Function ABS  Function MDY Procedure TRACE_DATE! SQL> SHOW PROCEDURE trace_date Procedure name is: TRACE_DATE Procedure ID is: 3 Source: trace_date (:dt date); begin" trace :dt; end No description found.% Module name is: UTILITY_FUNCTIONS Module ID is: 1 Number of parameters is: 1, Parameter Name Data Type, -------------- ---------+ DT DATE VMS" Parameter position is 1! Parameter is IN (read)+ Parameter is passed by REFERENCE SQL> SHOW FUNCTIONS abs Function name is: ABS Function ID is: 2 Source:) abs (in :arg integer) returns integerK comment 'Returns the absolute value of an integer'; begin# return case1 when :arg < 0 then - :arg! else :arg end; end; Comment: Returns the absolute value of an integer% Module name is: UTILITY_FUNCTIONS Module ID is: 1 Number of parameters is: 1, Parameter Name Data Type, -------------- ---------* INTEGER# Function result datatype* Return value is passed by VALUE* ARG  INTEGER" Parameter position is 1! Parameter is IN (read)+ Parameter is passed by REFERENCED Example 9: Showing a storage map that defines both horizontal and vertical record partitioning* SQL> SHOW STORAGE MAP EMPLOYEES_1_MAP2 EMPLOYEES_1_MAP2 For Table: EMP2$ Partitioning is: UPDATABLEM Store clause: STORE COLUMNS (EMPLOYEE_ID, LAST_NAME, FIRST_NAME,7 MIDDLE_INITIAL, S TATUS_CODE)" USING (EMPLOYEE_ID): IN ACTIVE_AREA_A WITH LIMIT OF ('00399'): IN ACTIVE_AREA_B WITH LIMIT OF ('00699'), OTHERWISE IN ACTIVE_AREA_C@ STORE COLUMNS (ADDRESS_DATA_1, ADDRESS_DATA_2, CITY,. STATE, POSTAL_CODE)" USING (EMPLOYEE_ID)< IN INACTIVE_AREA_A WITH LIMIT OF ('00399')< IN INACTIVE_AREA_B WITH LIMIT OF ('00699').  OTHERWISE IN INACTIVE_AREA_C STORE IN OTHER_AREA" Compression is: ENABLED1 Partition 2: Compression is Enabled1 Partition 3: Compression is Enabled$ Example 10: Displaying a Sequence SQL> SHOW SEQUENCE EMPIDS EMPIDS Sequence Id: 3 Initial Value: 1 Minimum Value: 1& Maximum Value: 9223372036854775787 Next Sequence Value: 1 Increment by: 1 Cache Size: 20 Order No Cycle No Randomize- Comment: Sequence for employee IDs. Example 11: Displaying a Role SQL> SHOW ROLE SECRETARY SECRETARY Identified Externally1 Comment: Role for the secretarial staff Example 12: Displaying a User SQL> SHOW USER NSTEWART NSTEWART Identified Externally Account Unlocked# Comment: Nicholas Stewart* Example 13: Show Details of One Profile SQL> SHOW PROFILE2 Profiles in database with filename SQL$ DATABASE DECISION_SUPPORT% SQL> SHOW PROFILE DECISION_SUPPORT DECISION_SUPPORT< Comment: limit transactions used by report writers4 Transaction modes (read only, no read write)& SQL> ALTER PROFILE DECISION_SUPPORT) cont> default transaction read only;% SQL> SHOW PROFILE DECISION_SUPPORT DECISION_SUPPORT< Comment: limit transactions used by report writers% Default transaction read only4 Transaction modes (read only, no read write) SQL>C Example 14: Show the Use of Delimited Identifiers for Mixed-Case Names) SQL> CREATE PROFILE "Decision_Support"? cont> COMMENT IS 'limit transactions used by report writers'6 cont> TRANSACTION MODES (NO READ WRITE, READ ONLY); SQL> SHOW PROFILE2 Profiles in database with filename SQL$DATABASE Decision_Support% SQL> SHOW PROFILE Decision_Support No Users found' SQL> SHOW PROFILE "Decision_Support" Decision_Support<  Comment: limit transactions used by report writers4 Transaction modes (read only, no read write)" Example 15: Displaying Synonyms SQL> SHOW SYNONYMS2 Synonyms in database with filename SQL$DATABASEK C_SAL View CURRENT_SALARYA E Table synonym EMPSF EMPS Table EMPLOYEESC ID_NUMBER Domain  ID_DOM SQL> SHOW SYNONYMS ID_NUMBER ID_NUMBER for domain ID_DOM7 Comment: support the old name for this domain SQL> SHOW VIEWS5 User tables in database with filename SQL$DATABASE/ CURRENT_INFO A view./ CURRENT_JOB A view./ CURRENT_SALARY A view.I C_SAL A synonym for view CURRENT_SALARY1 Example 16: Using Synonyms to Identify Objects D This example creates a sequence and a synonym for a sequence, and3 uses the SHOW SEQUENCE command with the synonym./ SQL> create sequence department_id_sequence;< SQL> create synonym dept_id_s for department_id_sequence; SQL> show sequence0 Sequences in database with filename personnel DEPARTMENT_ID_SEQUENCEU DEPT_ID_S A synonym for sequence DEPARTMENT_ID_SEQUENCE SQL> show sequence DEPT_ID_SU DEPT_ID_S  A synonym for sequence DEPARTMENT_ID_SEQUENCE Sequence Id: 1 Initial Value: 1 Minimum Value: 1& Maximum Value: 9223372036854775787 Next Sequence Value: 1 Increment by: 1 Next Sequence Value: 1 Increment by: 1 Cache Size: 20 No Order No Cycle No Randomize Wait SQL> ww1 Simple_Statement> Includes a single SQL statement in a module procedure or inA an embedded host language program. The statement can include aB single executable SQL statement. A module procedure or embeddedA procedure that contains a simple statement is called a simple- statement procedure. 2 Environment> A simple statement is valid either in a procedure of an SQL? module file or in an embedded host language program prefixed by the keywords EXEC SQL: o Module SQLC See the Oracle Rdb SQL Reference Manual for information aboutC using simple statements in module procedures in an SQL module file. o Embedded SQL= See the Oracle Rdb SQL Reference Manual for informationB about using simple statements in embedded procedures in host language programs. 2 Format simple-statement =  ----> SQL statement ----> 2 Arguments 3 SQL_statement/ Specifies a single executable SQL statement.= Executable SQL statements undergo processing during module> compile time but do not execute until the program  runs. SQL? executes the simple statement when the procedure in which itB is embedded is called by a host language module. (NonexecutableA SQL statements are those that SQL processes completely when itD compiles an SQL module but are not executed at run time.) See theB Oracle Rdb SQL Reference Manual for information about which SQL statements are executable.@ The SQL statement must use names specified in the procedure's6 formal parameters wherever it refers to parameters. 2 Examples6 Example 1: A simple statement using interactive SQL, SQL> ALTER DATABASE FILENAME mf_personnel cont> JOURNAL IS DISABLED; ww1 SIGNAL_Control< Passes the signaled SQLSTATE status parameter back to theB application or SQL interface and terminates the current routine and all calling routines. 2 Environment< You can use the SIGNAL statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format4 SIGNAL -+-> value-expr ---------------------+-----+4 +-> SQLSTATE VALUE 'string-literal'-+ |4 +-----------------------<-----------------------+5 ++----------------------------+------------------>" +-> ( --> signal-arg --> ) --+ 2 Arguments 3 signal-argD Specifies a value expression. The specified value is converted to@ a CHARACTER(80) CHARACTER SET UNSPECIFIED string and returned; as a secondary message to the client application. If theA value expression converts to a character string longer than 80 characters, it is truncated.D You can use the sql_get_error_text routine to extract the signal- arg text in an application. 3 string-literal? A quoted string literal which represents the SQLSTATE value. 3 value_expr< Expects a character value expression which is used as the> SQLSTATE status parameter. Any provided value expression is: converted to a CHAR(5) value which is passed to SIGNAL.C See Value Expressions for more information on value expressions.1 See SQLCA for more information about SQLSTATE. 2 Examples? Example 1: Using the SIGNAL and RETURN statements, multiline! comments, and stored functions? The example uses a table, NEXT_KEY_TABLE, to maintain a list? of key names and th eir current values. In this example, only? a single key is created with the name EMPLOYEE_ID. Each timeB the function is called, it fetches the value from the NEXT_KEY_C TABLE and returns the next value. If the named key is not found,> an error is returned (SQLSTATE 22023 is defined as "invalid parameter value"). SQL> CREATE DOMAIN key_name cont> CHAR(31)$ cont> CHECK (VALUE IS NOT NULL) cont> NOT DEFERRABLE; SQL> --% SQL> CREATE TABLE next_key_table () cont> next_key_val INTEGER NOT NULL,* cont> next_key_name key_name UNIQUE); SQL> --@ SQL> INSERT INTO next_key_table (next_key_name, next_key_val)% cont> VALUES ('EMPLOYEE_ID', 0); 1 row inserted SQL> -- SQL> CREATE MODULE tools cont> LANGUAGE SQL4 cont> FUNCTION next_key (IN :key_name key_name) cont> RETURNS INTEGERF cont> COMMENT IS 'This routine fetches the next value of the'/G cont> 'specified entry in the s equence table. The'/H cont> 'passed name is converted to uppercase before'/J cont> 'retrieval (see the DEFAULT clause for compound'/L cont> 'statements). The UPDATE ... RETURNING statement'/L cont> 'is used to fetch the new value after the update.'/J cont> 'If no entry exists, then an error is returned.'; cont> BEGIN8 cont> DECLARE :rc, :new_val INTEGER DEFAULT 0;J cont> DECL ARE :key_name_upper key_name DEFAULT UPPER(:key_name);F cont> DECLARE :invalid_parameter CONSTANT CHAR(5) = '22023'; cont> --% cont> UPDATE next_key_table3 cont> SET next_key_val = next_key_val + 15 cont> WHERE next_key_name = :key_name_upper& cont> RETURNING next_key_val cont> INTO :new_val; cont> --0 cont> GET DIAGNOSTICS :rc = ROW_COUNT;R cont> TRACE 'NEXT_KEY is ', COALESCE(:new_val, 'NULL'), ', RC is ', :rc; cont> -- cont> IF :rc = 0 THENL cont> TRACE 'No entry exists for KEY_NAME: ', :key_name_upper;. cont> SIGNAL :invalid_parameter; cont> ELSEP cont> TRACE 'Returning new value for ', :key_name_upper, :new_val;$ cont> RETURN :new_val; cont> END IF; cont> -- cont> END; cont> END MODULE; SQL> -- SQL> CREATE TABLE employee (' cont> employee_id INTEGER,( cont> last_name CHAR(20),% cont> birthday DATE); SQL> --E SQL> -- Turn on the TRACE flag so we can see the function working. SQL> -- SQL> SET FLAGS 'TRACE'; SQL> --? SQL> INSERT INTO employee (employee_id, last_name, birthday)E cont> VALUES (next_key('EMPLOYEE_ID'), 'Smith', DATE'1970-1-1');( ~Xt: NEXT_KEY is 1 , RC is 1@ ~Xt: Returning new value for EMPLOYEE_ID 1 1 row inserted SQL> --? SQL> INSERT INTO em ployee (employee_id, last_name, birthday)C cont> VALUES (next_key('EMPLOYEE_ID'), 'Lee', DATE'1971-1-1');( ~Xt: NEXT_KEY is 2 , RC is 1@ ~Xt: Returning new value for EMPLOYEE_ID 2 1 row inserted SQL> --? SQL> INSERT INTO employee (employee_id, last_name, birthday)F cont> VALUES (next_key('EMPLOYEE_ID'), 'Zonder', DATE'1972-1-1');( ~Xt: NEXT_KEY is 3 , RC is 1@ ~Xt: Returning new value for EMPLOYEE_ID 3 1 r ow inserted SQL> --4 SQL> SELECT * FROM employee ORDER BY EMPLOYEE_ID;1 EMPLOYEE_ID LAST_NAME BIRTHDAY3 1 Smith 1970-01-013 2 Lee 1971-01-013 3 Zonder 1972-01-01 3 rows selected SQL> --< SQL> -- Show the error if the unknown key_name is passed. SQL> --? SQL> INSERT INTO employee (employee_id, last_name, birthday)E cont> VALUES (next_key('EMPLOYEEID'), 'Zonder', DATE'1972-1-1');( ~Xt: NEXT_KEY is 0 , RC is 00 ~Xt: No entry exists for KEY_NAME: EMPLOYEEIDG %RDB-E-SIGNAL_SQLSTATE, routine "NEXT_KEY" signaled SQLSTATE "22023"* Example 2: Specifying a Secondary Error SQL> BEGIN? SQL> SIGNAL SQLSTATE 'RR000' (' Compound Statement Failed'); cont> END;H %RDB-E-SIGNAL_SQLSTATE, routine "(unnamed)" signaled SQLSTATE "RR000"* -RDB-I-TEXT, Compound Statement Failed ww1 START_TRANSACTIONB Starts a transaction using the specified attributes. If DEFAULT@ is specified, then the attributes are derived from the user's profile. 2 Environment/ You can use the START TRANSACTION statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format? START --+-> DEFAULT TRANSACTION --------------------------+-->< +-> TRANSACTION -+------------------------------+-+: +--+-+-> transaction-mode -+-+-+8 | +-> isolation-level --+ |8 +---------- , <-----------+ transaction-mode =  --+-> READ ONLY ---+--> +-> READ WRITE --+ isolation-level = 3 ---> ISOLATION LEVEL --+-> READ COMMITTED ----+-->0 +-> REPEATABLE READ ---+0 +-> SERIALIZABLE ------+ 2 Arguments 3 DEFAULT< If the keyword DEFAULT is used, the user-specific defaultA transaction is started. This default is defined in the profileB for the current session user. If none is specified, a READ ONLY transaction will be started.! SQL> CREATE PROFILE READ_USERS1 cont> DEFAULT TRANSACTION READ ONLY WAIT 10;, SQL> ALTER USER JONES PROFILE READ_USERS;? A START DEFAULT TRANSACTION statement executed by JONES will) start a READ ONLY WAIT 10 transaction.? For information on profiles see the ALTER and CREATE PROFILE statements. 3 ISOLATION_LEVEL Syntax options:$ ISOLATION LEVEL READ COMMITTED% ISOLATION LEVEL REPEATABLE READ" ISOLATION LEVEL SERIALIZABLE< Defines the degree to which database operations in an SQLB transaction are affected by database operations in concurrently@ executing transactions. It determines the extent to which the2 database protects the consist ency of your data.B Oracle Rdb supports isolation levels READ COMMITTED, REPEATABLE; READ, and SERIALIZABLE. When you use SQL with Oracle RdbA databases, by default, SQL executes a transaction at isolation? level SERIALIZABLE. The higher the isolation level, the more; isolated a transaction is from other currently executingA transactions. Isolation levels determine the type of phenomena? that are allowed to occur during the execution of concurrent@ transactions. Two phenomena define SQL isolation levels for a transaction: o Nonrepeatable read< Allows the return of different results within a single= transaction when an SQL operation reads the same row in? a table twice. Nonrepeatable reads can occur when anotherB transaction modifies and commits a change to the row between transaction reads. o Phantom< Allows the return of different results within a singleA transaction when an SQL operation retrieve s a range of data> values (or similar data existence check) twice. Phantoms@ can occur if another transaction inserted a new record and= committed the insertion between executions of the range retrieval.? Each isolation level differs in the phenomena it allows. TheB following table shows the phenomena permitted for the isolationD levels that you can explicitly specify with the START TRANSACTION statement.8 Table 1-9 Phenomena Permitted at Each Isolation Level Nonrepeatable- Isolation Reads Phantoms- Level Allowed? Allowed?( READ Yes Yes COMMITTED( REPEATABLE No Yes READ' SERIALIZABLE No No@ For read-only transactions, which always execute at isolationC level SERIALIZABLE if snapshots are enabled, the database system@ guarantees that you will not see changes made by another user' before you issue a COMMIT statement.: See the Oracle Rdb Guide to SQL Programming for furtherA information about specifying isolation levels in transactions. 3 READ_ONLYC Retrieves a snapshot of the database at the moment the read-only? transaction starts. Other users can update rows in the tableA you are using, but your transaction retrieves the rows as theyB existed at the time the transaction started. You cannot update,@ insert, or delete rows, or execute data definit ion statements? in a read-only transaction with the exception of declaring aC local temporary table or modifying data in a created or declaredC temporary table. Read-only transactions are implicitly isolation level serializable.C Because a read-only transaction uses the snapshot (.snp) version@ of the database, any changes that other users make and commitA during the transaction are invisible to you. Using a read-onlyC transaction lets you read data without incurring the overhead ofD row locking. (You do incur overhead for keeping a snapshot of theC tables you specify in the RESERVING clause, but this overhead is: less than that of a comparable read/write transaction.)D Because of the limited nature of read-only transactions, they are# subject to several restrictions. 3 READ_WRITE> Signals that you want to use the lock mechanisms of SQL for> consistency in data retrieval and update. Read/write is the@ default transaction. Use the read/write transaction mode when you need to:$ o Insert, update, or delete dataB o Retrieve data that is guaranteed to be correct at the moment of retrieval( o Use SQL data definition statementsC When you are reading a row in a read/write transaction, no otherC user can update that row. Under some circumstances, SQL may lock, rows that you are not explicitly reading.C o If your query is scanning a table without using an index, SQLC locks all the rows in the record stream to maintain isolation level serializable.@ o If your query uses indexes, SQL may lock part of an index,3 which has the effect of locking several rows. 2 Examples@ Example 1: Starting a Default Transaction in a Multistatement% Procedure or as a Single Statement" SQL> START DEFAULT TRANSACTION; SQL> SQL> BEGIN cont> COMMIT;# cont> START DEFAULT TRANSACTION; cont> END; SQL> SQL> ROLLBACK;B Example 2: Starting Several Variations of the START TRANSACTION Statement% SQL> START TRANSACTION READ WRITE,* cont> ISOLATION LEVEL READ COMMITTED; SQL> COMMIT; SQL># SQL> -- Defaults to serializable% SQL> START TRANSACTION READ WRITE; SQL> COMMIT; SQL>! SQL> -- Defaults to read write9 SQL> START TRANSACTION ISOLATION LEVEL READ COMMITTED; SQL> ROLLBACK; SQL>. SQL> -- Defaults to read write serializable SQL> START TRANSACTION; SQL> SQL> BEGIN cont> COMMIT; cont> START TRANSACTION, cont> ISOLATION LEVEL READ COMMITTED, cont> READ WRITE; cont> END; SQL> COMMIT; ww91 TRACE_Control? Writes values to the trace log file after the trace extendedB debug flag is set. The TRACE control statement lets you specifyB multiple value expressions. It stores a value in a log file for& each value expression it evaluates.: Trace logging can help you debug complex multistatement procedures. 2 EnvironmentC You can use the TRACE control statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format trace-statement = $ ----> TRACE --+-> value-expr --+-->! +----- , <-------+ 2 Arguments 3 value-expr? Specifies a symbol or string of symbols used to represent or calculate a single value.B See the Value_Expressions HELP topic for a complete description9 of the variety of value expressions that SQL provides. 2 Examples0 Example 1: Tracing a multistatement procedure' SQL> ATTACH 'FILENAME MF_PERSONNEL'; SQL> SET FLAGS 'TRACE'; SQL> DECLARE :i INTEGER; SQL> BEGIN cont> WHILE :i <= 10 cont> LOOP# cont> TRACE ':i is', :i; cont> SET :i = :i +1; cont> END LOOP; cont> END; ~Xt: :i is 0 ~Xt: :i is 1 ~Xt: :i is 2 ~Xt: :i is 3 ~Xt: :i is 4 ~Xt: :i is 5 ~Xt: :i is 6 ~Xt: :i is 7 ~Xt: :i is 8 ~Xt: :i is 9 ~Xt: :i is 10D Example 2: Generating a query outline when the TRACE statement is disabled SQL> DECLARE :LN CHAR(40); SQL> SET FLAGS 'NOTRACE'; SQL> BEGIN cont> TRACE 'Jobs Held: ', cont> (SELECT COUNT(*)! cont> FROM JOB_HISTORY. cont> WHERE EMPLOYEE_ID = '00201'); cont> SELECT LAST_NAME cont> INTO :LN cont> FROM EMPLOYEES) cont> WHERE EMPLOYEE_ID = '00201'; cont> END;$ -- Oracle Rdb Generated Outline :. create outline QO_A17FA4B41EF1A68B_00000000( id 'A17FA4B41EF1A68B966C1A0B083BFDD4' mode 0 as ( query ( -- Select subquery (? EMPLOYEES 0 access path index EMPLOYEES_HASH ) ) ) compl iance optional ; SQL>= If the query outline is generated with TRACE enabled, thenA two queries appear; the first is for the subquery in the TRACEA statement and the other is for the singleton SELECT statement.B If this second query outline is used at run time with the TRACE> statement disabled, then it cannot be applied to the query.@ Because the outline was created with compliance optional, theB query outline is abandoned and a new strategy is calculated. If@ compliance is mandatory, then the query fails. See Example 3. SQL> DECLARE :LN CHAR(40); SQL> SET FLAGS 'TRACE'; SQL> BEGIN cont> TRACE 'Jobs Held: ', cont> (SELECT COUNT(*)! cont> FROM JOB_HISTORY. cont> WHERE EMPLOYEE_ID = '00201'); cont> SELECT LAST_NAME cont> INTO :LN cont> FROM EMPLOYEES) cont> WHERE EMPLOYEE_ID = '00201'; cont> END;$ -- Oracle Rdb Generated Outline :. create outline QO_A17FA4B41EF1A68B_00000000( id 'A17FA4B41EF1A68B966C1A0B083BFDD4' mode 0 as ( query ( -- Trace subquery (A JOB_HISTORY 0 access path index JOB_HISTORY_HASH ) ) query ( -- Select subquery (? EMPLOYEES 0 access path index EMPLOYEES_HASH ) ) ) compliance optional ; ~Xt: Jobs Held: 4 SQL>D Example 3: Using an Outline with Tracing Enabled That Was Created with Tracing DisabledB This example shows that enabling the TRACE statement may affect2 query outlines defined when TRACE was disabled. SQL> DECLARE :LN CHAR(40); SQL> SQL> BEGIN cont> TRACE 'Jobs Held: ', cont> (SELECT COUNT(*)! cont> FROM JOB_HISTORY. cont> WHERE EMPLOYEE_ID = '00201'); cont> SELECT LAST_NAME cont> INTO :LN cont> FROM EMPLOYEES) cont> WHERE EMPLOYEE_ID = '00201'; cont> END;0 ~S: Outline QO_A17FA4 B41EF1A68B_00000000 usedL ~S: Outline/query mismatch; assuming JOB_HISTORY 0 renamed to EMPLOYEES 08 ~S: Full compliance with the outline was not possible3 Get Retrieval by index of relation EMPLOYEES9 Index name EMPLOYEES_HASH [1:1] Direct lookup ww91 TRUNCATE_TABLEC Deletes the data in a table while still maintaining the metadata@ definitions of the table. Advantages include fast deletion of; data in uniform areas, and no change to d ependency data. 2 Environment, You can use the TRUNCATE TABLE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format' TRUNCATE TABLE ---> ---->  2 Arguments 3 table-name8 Specifies the name of the table you want to truncate. 2 ExamplesD Example 1: Deleting data from a table while still maintaining the metadata definitions> The following example shows how to delete the data from theD SALARY_HISTORY table and still maintain the metadata definitions:& SQL> TRUNCATE TABLE salary_history; SQL> --< SQL> -- The table still exists, but the rows are deleted. SQL> --% SQL> SELECT * FROM salary_history; 0 rows selected+ SQL> SHOW TABLE (COLUMN) salary_history;' Information for table SALARY_HISTORY$ Columns for table SALARY_HISTORY:: Column Name Data Type Domain: ----------- --------- ------: EMPLOYEE_ID CHAR(5) ID_DOM2 Foreign Key constraint SALARY_HISTORY_FOREIGN1> SALARY_AMOUNT INTEGER(2) SALARY_DOM< SALARY_START DATE VMS DATE_DOM< SALARY_END DATE VMS DATE_DOM ww91 UNDECLARE_VariableA Deletes a variable definition from interactive and dynamic SQL? that was used for invoking stored procedures and for testing2 procedures in modules or embedded SQL programs. 2 Environment' You can use the UNDECLARE statement: o In interactive SQL> o In dynamic SQL as a statement to be dynamically executed 2 Format, UNDECLARE --+-> ------+--->( +---------- , <-----------+  2 Arguments 3 variable-name- Specifies the name of the local variables. 2 Example6 Example 1: Undeclaring variables in interactive SQL$ SQL> ATTACH 'FILENAME personnel'; SQL> SQL> DECLARE :X INTEGER; SQL> DECLARE :Y CHAR(10); SQL> SQL> BEGIN cont> SET :X = 100; cont> SET :Y = 'Active'; cont> END; SQL> PRINT :X, :Y; X Y 100 Active SQL> SHOW VARIABLES* X INTEGER+ Y CHAR(10) SQL> UNDECLARE :X, :Y; ww9 1 UPDATE% Modifies a row in a table or view. 2 Environment$ You can use the UPDATE statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format6 UPDATE -+-> -+-+---------------------+-+6 +-> --+ +> + |6  +-------------------------------------------------+5 +-> SET -+> = -+-> value-expr -+-+-+5 | +-> NULL -------+ | |5 | +-> DEFAULT ----+ | |5 +--------------- , <------------------+ |5 +------------------------- <---------------------+@ ++--------------------------------------------------------+-+@ +-> WHERE -+-> predicate -+---------------------------+-++ |@ | +> optimize-clause ---------+ | |@ +-> CURRENT OF ----------------+ |@ +------------------------- <--------------------------------+A ++----------------------+------------------------------------> +-> returning-clause --+  optimize-clause = H --+---------------------------------------------------------------+--->D +-> OPTIMIZE --+-+-> FOR -+-> FAST FIRST --------+----------+-+-+B | | +-> TOTAL TIME --------+ | |B  | | +-> SEQUENTIAL ACCESS -+ | |B | +-> USING ------------------+ |B | +-> WITH -+-> DEFAULT --+-> SELECTIVITY -+ |B | | +-> SAMPLED --+ | |B | | +-> AGGRESSIVE + | |B | +-> AS -----------------------+ |B +---------------- <----------------------------+  returning-clause= A --+------------------------------+-+-------------------------+->? +-> RETURNING +-> value-expr +-+ +-> INTO +> +-+= +------ , <----+ +------ , <----+  2 Arguments 3 column-nameA Specifies the name of a column whose value you want to modify. 3 correlation-nameD Specifies a name you can use to identify the table or view in theA predicate of the UPDATE statement. See the User_Supplied_Names; HELP topic for more information about correlation names. 3 CURRENT_OF_cursor_name@ If the WHERE clause uses CURRENT OF cursor-name, SQL modifiesC only the row on which the named cursor is positioned. The cursor; named in an UPDATE statement must meet these conditions:D o The cursor must have been named previously in a DECLARE CURSOR! statement or FOR statement. o The cursor must be open." o The cursor must be on a row.@ o The FROM clause of the SELECT statement within the DECLAREB CURSOR statement must refer to the table or view that is the% target of the UPDATE statement. 3 DEFAULTB SQL assigns the DEFAULT defined for the column or domain. If no, DEFAULT is defined, then NULL is assumed.C If the DEFAULT clause is used in an UPDATE statement then one of! the following will be applied:@ o If a DEFAULT attribute is present for the column then that* value will be applied during UPDATE.C o Else if an AUTOMATIC attribute is present for the column thenD that value will be applied during UPDATE. This can only happenB if the SET FLAGS 'AUTO_OVERRIDE' is used since during normal- processing these columns are read-only.5 o Otherwise a NULL will be applied during UPDATE. 3 INTO_parameter8 Inserts the value specified to a specified parameter.D The INTO parameter clause is optional in interactive SQL. In this* case the returned values are displayed. 3 NULLD Specifies a NULL keyword. SQL assigns a null value to columns forC which you specify NULL. Any column assigned a null value must beC defined to allow null values (defined in a CREATE or ALTER TABLE* statement without the NOT NULL clause). 3 OPTIMIZE_AS Assigns a name to the query. 3 OPTIMIZE_FOR< The OPTIMIZE FOR clause specifies the preferred optimizer@ strategy for statements that specify a select expression. The# following options are available:  o FAST FIRSTB A query optimized for FAST FIRST returns data to the user asC quickly as possible, even at the expense of total throughput.A If a query can be cancelled prematurely, you should specify> FAST FIRST optimization. A good candidate for FAST FIRST> optimization is an interactive application that displaysB groups of records to the user, where the user has the option< of aborting the query after the first few screens. For@ example, singleton SELECT statements default to FAST FIRST optimization.C If optimization strategy is not explicitly set, FAST FIRST is the default. o TOTAL TIMED If your application runs in batch, accesses all the records inD the query, and performs updates or writes a report, you should@ specify TOTAL TIME optimization. Most queries benefit from TOTAL TIME optimization. o SEQUENTIAL ACCESS? Forces the use of sequential access. This is particularly: valuable for tables that use the strict partitioning functionality. 3 OPTIMIZE_USING@ Explicitly names the query outline to be used with the UPDATE= statement even if the outline ID for the query and for the outline are different. 3 OPTIMIZE_WITHA Selects one of three optimzation controls: DEFAULT (as used byD previous versions of Rdb), AGGRESSIVE (assumes smaller numbers ofB rows will be selected), and SAMPLED (which uses literals in the7 query to perform preliminary estimation on indices). 3 predicate@ If the WHERE clause includes a predicate, all the rows of the= target table for which the predicate is true are modified.C The columns named in the predicate must be columns of the target> table or view. The target table cannot be named in a column* select expression within the predicate.D See the Predicates HELP topic for more information on predicates. 3 RETURNING_value_expr9 R eturns the value of the column specified in the valueB expression. If DBKEY is specified, SQL returns the database keyC (dbkey) of the row being updated. When the DBKEY value is valid,? subsequent queries can use the DBKEY value to access the row directly.A The RETURNING DBKEY clause is not valid in an UPDATE statementC used to assign values to the segments in a column of the LIST OF BYTE VARYING data type.= Only one row can be updated when you specify the RETURNING clause. 3 SETD Specifies which columns in the table or view get what values. ForC each column you want to modify, you must specify the column nameB and either a value expression, the NULL keyword, or the DEFAULTA keyword. SQL assigns the value following the equal sign to the' column that precedes the equal sign. 3 table-nameB Specifies the name of the target table that you want to modify. 3 value-exprD Specifies the new value for the modified column. Columns named inB the value expression must be columns of the table or view named@ after the UPDATE keyword. The values can be specified through? parameters, qualified parameters, column select expressions,, value expressions, or the default values. 3 view-nameA Specifies the name of the target view that you want to modify. 3 WHERE> Specifies the rows of the target table or view that will be@ modified according to the values indicated in the SET clause.D If you omit the WHERE clause, SQL modifies all rows of the target@ table or view. You can specify either a predicate or a cursor name in the WHERE clause. 2 Examples; Example 1: Using the UPDATE statement in interactive SQLC The following interactive SQL example changes the address of the; employee with EMPLOYEE_ID 00164 and confirms the change: SQL> UPDATE EMPLOYEES. cont> SET ADDRESS_DATA_1 = '16 Ridge St.'' cont> WHERE EMPLOYEE_ID = '00164'; 1 row updatedA SQL> SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, ADDRESS_DATA_1 cont> FROM EMPLOYEES' cont> WHERE EMPLOYEE_ID = '00164';> EMPLOYEE_ID FIRST_NAME LAST_NAME ADDRESS_DATA_1< 00164 Alvin Toliver 16 Ridge St. 1 row selected 5 Example 2: Using the UPDATE statement in a programC The following example illustrates using a host language variableD in an embedded SQL statement to update an employee's status code:? DISPLAY "Enter employee's ID number: " WITH NO ADVANCING. ACCEPT ID.: DISPLAY "Enter new status code: " WITH NO ADVANCING. ACCEPT STATUS-CODE. EXEC SQL) DECLARE TRANSACTION READ WRITE END-EXEC EXEC SQL UPDATE EMPLOYEES1 SET STATUS_CODE = :STATUS-CODE* WHERE EMPLOYEE_ID = :ID END-EXEC EXEC SQL COMMIT END-EXEC wwa 1 WHENEVERA Specifies the execution path a host language program will takeD when any embedded SQL statement results in one of these following exception conditions: o Row not found o An error condition o A warning condition> For these conditions, the WHENEVER statement specifies thatB the program continue execution or branch to another part of the program. 2 Environment= You can issue the WHENEVER statement only in host language programs. 2 Format# WHENEVER --+-> NOT FOUND --+----+# +-> SQLERROR ---+ |# +-> SQLWARNING -+ |# +------------------------------+7 +-+-> CONTINUE ----------------------------------+->5 +-> GOTO --+-+-+-------+-> --+5 +-> GO TO -+ | +-> : --+ |5 +-----------> +  2 Arguments 3 CONTINUE> Specifies that the program continue execution with the nextA sequential statement following the statement that generated an error. 3 GOTO Syntax options:& host-label-name | host-label-number@ Specifies that the program branch to the statement identified? by the host label. The form of the host label depends on the> host language. You can use a colon (:) before a host labelA represented by a name, but not before a host label represented by a number. 3 NOT_FOUNDD Indicates the exception condition returned when SQL processes all  the rows of a result table:= o When a cursor referred to in a FETCH, UPDATE, or DELETE0 statement is positioned after the last row2 o When a query specifies an empty result tableA This is the same condition identified by a value of 100 in theC SQLCODE variable, the value of '02000' in the SQLSTATE variable,$ and by the RDB$_STREAM_EOF error. 3 SQLERROR> Indicates any error condition. For the SQLERROR argument of@ the WHENEVER statement, SQL defines an error condition as any6 condition that returns a negative value to SQLCODE. 3 SQLWARNING# Indicates any warning condition. 2 Example9 Example 1: Using WHENEVER statements in a PL/I program& /* When an SQL statement results in an RDB$_STREAM_EOF error, the* program branches to LABEL_NOT_FOUND: */4 EXEC SQL WHENEVER NOT FOUND GOTO LABEL_NOT_FOUND;( /* When an SQL statement results in a( warning severity error condition, the& program branches to LABEL_ERROR: */1 EXEC SQL WHENEVER SQLWARNING GOTO LABEL_ERROR;& /* When an SQL statement results in- an error severity exception condition, the& program branches to LABEL_ERROR: *// EXEC SQL WHENEVER SQLERROR GOTO LABEL_ERROR; wwa1 WHILE_ControlC Allows the repetitive execution of one or more SQL statements in@ a compound statement based on the truth value of a predicate. 2 EnvironmentC You can use the WHILE control statement in a compound statement: o In interactive SQL: o Embedded in host language programs to be precompiled- o As part of a procedure in an SQL module> o In dynamic SQL as a statement to be dynamically executed 2 Format while-statement= : -+-----------------------+--> WHILE ---> predicate -----+: +-> : -+ |: +-------------------------------------------------------+: +-+-> DO -+-> compound-use-statement -+--> END WHILE -+-+: | +-------------<-------------+ | |: +-> LOOP -+> compound-use-statement -+-> END LOOP --+ |: +-------------<------------+ |: +-------------------------<-----------------------------+> +-+--------------------+------------------------------------> +-> --+ 2 Arguments 3 beginning-label:D Assigns a name to a control loop. A beginning label used with theD LEAVE statement lets you perform a controlled exit from the WHILED loop. If you include an ending label, it must be identical to itsB corresponding beginning label. A beginning label must be unique- within the procedure containing the label. 3 compound-use-statement@ Identifies the SQL statements allowed in a compound statement: block. See the Compound Statement for the list of valid statements. 3 DO% Marks the start of a control loop. 3 END_LOOP_ending-label9 Marks the end of a LOOP control loop. If you choose to? include the optional ending label, it must match exactly its@ corresponding beginning label. An ending label must be unique8 within the procedure in which the label is contained.: The optional ending-label argument makes multistatement8 procedures easier to read, especially in very complex# multistatement procedure blocks. 3 END_WHILE_ending-labelC Marks the end of a DO control loop. If you choose to include theA optional ending label, it must match exactly its corresponding= beginning label. An ending label must be unique within the- procedure in which the label is contained.: The optional ending-label argument makes multistatement8 procedures easier to read, especially in very complex# multistatement procedure blocks. 3 LOOP% Marks the start of a control loop. 3 WHILE_predicateD Specifies a search condition that controls how many times SQL can execute a compound statement.? SQL evaluates the WHILE search condition. If it evaluates toC TRUE, SQL executes the associated sequence of SQL statements. IfD SQL does not encounter an error exception, control returns to theA WHILE clause at the top of the loop for subsequent evaluation.? Each time the search condition evaluates to TRUE, the WHILE-? DO statement executes the SQL statements embedded within itsA DO . . . END WHILE block. If the search condition evaluates toB FALSE or UNKNOWN, SQL bypasses the DO . . . END WHILE block and( passes control to the next statement. 2 Examples; Example 1: Using the While Statement to Count Substrings SQL> DECLARE :SUB_STR CHAR;" SQL> DECLARE :SRC_STR CHAR(50); SQL> BEGIN cont> SET :SUB_STR='l';F cont> SET :SRC_STR='The rain in Spain falls mainly on the plain'; cont> END; SQL> SET FLAGS 'TRACE'; SQL> BEGIN= cont>-- This procedure counts the occurrence of substrings( cont> DECLARE :STR_COUNT INTEGER=0;F cont> DECLARE :CUR_POS INTEGER = POSITION (:SUB_STR IN :SRC_STR); cont> WHILE :CUR_POS >0 DO, cont> SET :STR_COUNT=:STR_COUNT + 1;R cont> SET :CUR_POS = POSITION (:SUB_STR IN :SRC_STR FROM :CUR_POS + 1); cont> END WHILE;L cont> TRACE 'FOUND ', :STR_COUNT, ' OCCURRENCES OF "', :SUB_STR, '"'; cont> END;+ ~Xt: Found 4 occurrences of "l" ww1 Error_Message_DocumentationB Because error messages are updated frequently, documentation is( provided in the following text files: o SQL messages: In SYS$HELP:SQL$MSGnn.DOC< where nn is the current version number for Oracle Rdb.D This file contains the same text as the Help Errors help topic in interactive SQL. o RDB messages: In SYS$HELP:RDB_MSGnn.DOC< where nn is the current version number for Oracle Rdb. o RDMS messages: In SYS$HELP:RDMS_MSG.DOC o COSI messages: In SYS$HELP:COSI_MSG.DOC o SQL/Services messages: In SYS$HELP:SQLSRV$MSG.DOC o Repository messages: In SYS$HELP:CDD_MSG.DOCD The message documentation for all the facilities follows the same@ format, with messages alphabetized by message name. After theC message name and text, the documentation includes an explanation and suggested user action.@ The online message documentation files may be updated even if> you do not install a new version of SQL. In particular, anyC installation of Oracle Rdb databases may replace the RDB_MSG.DOC) file with one that is more up-to-date.; You can print the online message documentation files forC reference. In addition, you can search the files for the message information you need. ww1 SQL_standardsB Appendix B of the Oracle Rdb SQL Reference Manual describes the. SQL standards to which Oracle Rdb conforms. ww1 SQL CA@ The SQLCA and message vector are two separate host structuresD that SQL declares when it precompiles an INCLUDE SQLCA statement.A Both the SQLCA and the message vector provide ways of handling errors:> o The SQLCA is a collection of parameters that SQL uses to? provide information about the execution of SQL statementsA to application programs. The SQLCODE parameter in the SQLCAC shows if a statement was successful and, for some errors, the: particul ar error when a statement is not successful.D To illustrate how the SQLCA works in applications, interactive= SQL displays its contents when you issue the SHOW SQLCA statement.@ o The message vector is also a collection of parameters thatA SQL updates after it executes a statement. It lets programsC check if a statement was successful, but provides more detailB than the SQLCA about the type of error if a statement is notD successful. The message vector, for example, provides a way toC access any follow-on messages in addition to those containing# the facility code RDB or SQL.< You can use the following steps to examine the message vector:B - Assign any value to the logical name SQL$KEEP_PREP_FILES.@ - Precompile any program that contains the line "EXEC SQL@ INCLUDE SQLCA". (You can use the programs in the sample directory.)5 - Examine the generated host language program .? SQL updates the contents of the SQLCA and the message vectorD after completion of every executable SQL statement (nonexecutableA statements are the DECLARE, WHENEVER, and INCLUDE statements).B You do not have to use the INCLUDE SQLCA statement in programs.B However, if you do not, you must explicitly declare the SQLCODE> parameter to receive values from SQL. SQLCODE is explicitly4 declared as an unscaled, signed longword integer.? SQLCODE is a deprecated feature of the ANSI/ISO SQL standard; and is replaced by SQLSTATE. To comply with the ANSI/ISO= SQL standard, you should explicitly declare either SQLCODE> or, preferably, SQLSTATE instead of using the INCLUDE SQLCAA statement. SQLCA (and the INCLUDE SQLCA statement) is not partC of the ANSI/ISO SQL standard. If you declare SQLCODE or SQLSTATE; but use the INCLUDE SQLCA statement, SQL uses the SQLCA.< Programs that do not use the INCLUDE SQLCA statement will@ not have the message vector declared by the precompiler. Such? programs must explicitly declare the message vector if they:@ o Use the RDB$LU_STATUS field of the message vector in their error checking) o Use system calls such as SYS$PUTMSG? The message vector is not part of the ANSI/ISO SQL standard.@ When the SQLCA structure is explicitly declared by a program,B SQL does not update the SQLERRD fields. If you want the SQLERRD? fields updated, include the SQLCA definitions in the program. using the EXEC SQL INCLUDE SQLCA statement.@ See the Oracle Rdb SQL Reference Manual for more information. ww 1 SQLSTATEA SQL defines a set of status parameters that can be part of theC parameter list for a procedure definition in a nonstored module.= They are SQLSTATE, SQLCODE, and SQLCA. An SQL procedure isA required to contain at least one of these status parameters inB its parameter list. All status parameters are implicitly output  parameters.D The purpose of these status parameters is to return the status ofC each SQL statement that is executed. Each status parameter givesA information that allows you to determine whether the statementA completed execution or an exception has occurred. These statusA parameters differ in the amount of diagnostic information they/ supply, when an exception occurs as follows:@ o SQLCODE-This is the original SQL error handling mechanism.A It is an integer val ue. SQLCODE differentiates among errorsA (negative numbers), warnings (positive numbers), successful? completion (0), and a special code of 100, which means no? data. SQLCODE is a deprecated feature of the ANSI/ISO SQL standard.> o SQLCA-This is an extension of the SQLCODE error handling; mechanism. It contains other context information that= supplements the SQLCODE value. SQLCA is not part of the@ ANSI/ISO SQL standard. However, many databases such as DB2D and ORACLE RDBMS have defined proprietary semantics and syntax to implement it.D o SQLSTATE-This is the error handling mechanism for the ANSI/ISOD SQL standard. The SQLSTATE value is a character string that is- associated with diagnostic information.< See the Oracle Rdb SQL Reference Manual for more detailed information. ww1 SQLDAD An SQL Descriptor Area (SQLDA) is a collection of parameters usedC only in dynamic  SQL programs. SQL provides two descriptor areas: SQLDA and SQLDA2.A Dynamic SQL lets programs accept or generate SQL statements at? run time, in contrast to SQL statements that are part of the> source code for precompiled programs or SQL module language< procedures. Unlike precompiled SQL or SQL module language? statements, such dynamically executed SQL statements are notD necessarily part of a program's source code, but can be generated? while the program is running. D ynamic SQL is useful when youB cannot predict the type of SQL statement your program will need to process.A To use an SQLDA, host languages must support pointer variablesA that provide indirect access to storage by storing the address@ of data instead of directly storing data in the variable. The? languages supported by the SQL precompiler that also supportD pointer variables are PL/I, C, BASIC, and Ada. Any other language= that supports pointer variables can use an SQLDA, but must? call SQL module procedures containing SQL statements instead; of embedding the SQL statements directly in source code.< See the Oracle Rdb SQL Reference Manual for more detailed information. ww 1 LogicalsB The following table lists the logical names that SQL recognizes for special purposes.* Table 1-10 Summary of SQL Logical Names' Logical Name FunctionA RDB$LIBRARY Specifies a protected  library thatD you can use to store external routineB images, such as external functions.D Oracle Rdb recommends that you manageC public or sensitive external routine? images using a protected library@ that is referenced by the logicalB name RDB$LIBRARY. You should define?  RDB$LIBRARY as an executive modeA logical name in the system logicalB name table. If the external routine@ image is located in the protectedD area, you can ensure that the desired> image is used by specifying the? RDB$LIBRARY logical name with anA explicit file name in the LOCATIONC clause plus the WITH SYSTEM LOGICAL_B NAME TRANSLATION clause in a CREATE2 FUNCTION statement.? RDB$RDBSHR_EVENT_FLAGS Can be used to override the fourC event flag numbers that are assignedB to RDB$SHARE at startup time by the9 LIB$GET_EF system service.? RDB$REMOTE_BUFFER_SIZE Cha nges the default buffer size,A up to your system quota limits, ofA network transfers. This can reduceC the number of network I/O operations; used during large transfers.? Restrictions apply, depending onB which version of Oracle Rdb you are% using.> RDB$REMOTE_MULTIPLEX_OFF Disables the multiplex feature.D RDB$ROUTINES Specifies the location of an externalC routine image. If you do not specify< a location clause in a CREATED FUNCTION, CREATE PROCEDURE, or CREATEB MODULE statement, or if you specifyD the DEFAULT LOCATION clause, SQL usesC the RDB$ROUTINES logical name as the6 default image location.A RDMS$BIND_OUTLINE_MODE When multiple outlines exist for aB query, this logical name is defined> to select which outline to use.D RDMS$BIND_QG_CPU_TIMEOUT Specifies the amount of CPU time usedA to optimize a query for execution.@ RDMS$BIND_QG_REC_LIMIT Specifies the number of rows thatD SQL fetch es before the query governor, stops output.C RDMS$BIND_QG_TIMEOUT Specifies the number of seconds thatB SQL spends compiling a query beforeD the query governor aborts that query.C RDMS$BIND_SEGMENTED_ Allows you to reduce the overhead ofB STRING_BUFFER I/O operations at run time when youC are manipulating a segmented string.D RDMS$DEBUG_FLAGS Allows you to examine database accessC strategies and the estimated cost ofA those strategies when your program$ runs.D RDMS$SET_FLAGS Allows you to examine database accessC strategies and the estimated cost ofA those strategies when your programD runs. See the SET FLAGS statement f orC a list of valid keywords that can be; used with this logical name.@ RDMS$DIAG_FLAGS When defined to 'L', prevents theB opening of a scrollable list cursorA when the online format of lists is' chained.? RDMS$RTX_SHRMEM_PAGE_CNT Specifies the size of the shared= memory area used to manipulat eB server site-bound, external routine? parameter data and control data.= RDMS$USE_ Allows applications to use the@ OLD_CONCURRENCY isolation-level behavior that was2 in effect for V4.1.? RDMS$USE_OLD_SEGMENTED_ When defined to YES, the defaultA STRING online format for lists (segmented3 strings) is chained. C RDMS$VALIDATE_ROUTINE Controls the validation of routines.> SQL$DATABASE Specifies the database that SQL@ declares if you do not explicitly2 declare a database.< SQL$DISABLE_CONTEXT Disables the two-phase commit? protocol. Useful for turning off< distributed transactions when; you want to run batch-update,  transactions.D SQL$EDIT Specifies the editor that SQL invokesC when you issue the EDIT statement in/ interactive SQL.B SQLINI Specifies the command file that SQLC executes when you invoke interactive# SQL.? SYS$CURRENCY Specifies the character that SQLB  substitutes for the dollar sign ($)A symbol in an EDIT STRING clause of@ a column or domain definition, or@ the EDIT USING clause of a SELECT) statement.? SYS$DIGIT_SEP Specifies the character that SQLC substitutes for the comma symbol (,)C in an EDIT STRING clause of a column@  or domain definition, or the EDITB USING clause of a SELECT statement.C SYS$LANGUAGE Specifies the language that SQL usesD for date and time input and displays,C or the EDIT USING clause of a SELECT) statement.? SYS$RADIX_POINT Specifies the character that SQL@ substitutes for the decimal pointB  symbol (.) in an EDIT STRING clause@ of a column or domain definition,C or the EDIT USING clause of a SELECT) statement.@ The following table shows the valid equivalence names for the" logical name RDB$CHARACTER_SET.C Table 1-11 Valid Equivalence Names for RDB$CHARACTER_SET Logical Name' Name of Character9 Character Set  Set Equivalence Name2 MCS DEC_MCS Undefined3 Korean and ASCII DEC_KOREAN DEC_HANGUL2 Hanyu and ASCII DEC_HANYU DEC_HANYU2 Hanzi and ASCII DEC_HANZI DEC_HANZI2 Kanji and ASCII DEC_KANJI DEC_KANJIA For more information on these and other logical names, see the8 Oracle Rdb7 Guide to Database Performance and Tuning. ww1 Oracle_SQL_Functions> SQL functions h ave been added to the OpenVMS Oracle Rdb SQLC interface for convergence with Oracle SQL. Complete descriptionsD of these functions can be found in the Oracle Server SQL Language Reference Manual. 2 Optional_Oracle_SQL_FunctionsCOptionally, you can install the functions listed in Optional OracleCSQL Functions in your database from interactive SQL as shown in thefollowing examples.C The file is named SQL_FUNCTIONSnn.SQL, where "nn" is the version4 number. For example, us e the following statement:% SQL> ATTACH 'FILENAME mydatabase';( SQL> @SYS$LIBRARY:SQL_FUNCTIONS72.SQLA If you wish to use a character set other than DEC_MCS with the? installable functions, you must first define the RDB$ORACLE_A SQLFUNC_VCHAR_DOM domain as a character type using the desired; character set before executing the preceding statements.A Similarly, if you wish to use a date data type other than DATE@ VMS with the installable functions, you must first define the@ RDB$ORACLE_SQLFUNC_DATE_DOM domain as a date data type before& executing the preceding statements. For example,% SQL> ATTACH 'FILENAME mydatabase';@ SQL> CREATE DOMAIN RDB$ORACLE_SQLFUNC_VCHAR_DOM VARCHAR(2000) cont> CHARACTER SET KANJI;< SQL> CREATE DOMAIN RDB$ORACLE_SQLFUNC_DATE_DOM DATE ANSI;( SQL> @SYS$LIBRARY:SQL_FUNCTIONS72.SQLD If you choose, you may remove the installable functions from yourB database at a later time. However, you must release any  dynamic@ SQL statements and disconnect any sessions that reference anyB of these functions before you can remove the functions. Use theB following statements from interactive SQL if you wish to remove0 the installable functions from your database:% SQL> ATTACH 'FILENAME mydatabase';- SQL> @SYS$LIBRARY:SQL_FUNCTIONS_DROP72.SQLC The file SYS$LIBRARY:SQL_FUNCTIONS_DROPnn.SQL, where "nn" is the version number.= Optional Oracle SQL Functions gives a brief description o f@ each of the functions that you can optionally install in your database.+ Table 1-12 Optional Oracle SQL Functions0 Function Name Description RestrictionsC ADD_MONTHS Returns the d must be of the same date dataC (d,n) date d plus n type as the RDB$ORACLE_SQLFUNC_C months. DATE_DOM domain, which is boundC when you install the Oracle SQL. func tions.C ACOS (n) Returns the n must be in the range of -1 toA arc cosine of 1, and the function returns aA n. DOUBLE PRECISION value in the? range of 0 to pi, expressed= in radians. If the passedC expression results in NULL thenD the result of ACOS will be NULL.6 The following exa mple returns the arc cosine of .3:7 SQL> SELECT ACOS(.3) "Arc_Cosine" FROM Rdb$DATABASE; Arc_Cosine 1.266103672779499E+000 1 row selectedA ACOSH (n) Returns the n must be equal to or greater@ hyperbolic arc than 1. The function returns@ cosine of n. a DOUBLE PRECISION value. IfD either passed expression resultsD in NULL then the resul t of ACOSH1 will be NULL.D SQL> SELECT ACOSH(1.0) "Hyperbolic Arc Cosine" FROM Rdb$DATABASE; Hyperbolic Arc Cosine 0.000000000000000E+000 1 row selected; ASCII (str) Returns str must be of the sameD the decimal character set as the RDB$ORACLE_C representation SQLFUNC_VCHAR_DOM domain, whichA of the first is bound when you install the9  character of Oracle SQL functions.! its argument.? ASIN (n) Returns the n must be in the range of -@ arc sine of n. 1 to 1. The function returns? a DOUBLE PRECISION value in? the range of -pi/2 to pi/2,@ expressed in radians. If the@ passed expression results in@  NULL then the result of ASIN1 will be NULL.4 The following example returns the arc sine of .3:5 SQL> SELECT ASIN(.3) "Arc_Sine" FROM Rdb$DATABASE; Arc_Sine 3.046926540153975E-001 1 row selectedA ASINH (n) Returns the The function returns a DOUBLE> hyperbolic arc PRECISION value. If either@ sine of n. passed expression results inA  NULL then the result of ASINH1 will be NULL. SQL> SELECT ASINH (-1 90.0) "Hyperbolic Arc Sine" FROM Rdb$DATABASE; Hyperbolic Arc Sine -5.192987713658941E+000 1 row selectedB ATAN (n) Returns the n can be in an unbounded rangeD arc tangent of and returns a value in the range? n. of -pi/2 to pi/2, expressed=  in radians. If the passedC expression results in NULL thenD the result of ATAN will be NULL.7 The following example returns the arc tangent of .3:8 SQL> SELECT ATAN(.3) "Arc_Tangent" FROM Rdb$DATABASE; Arc_Tangent 2.914567944778671E-001 1 row selected? ATANH (n) Returns the n must be in the range of -@ hyperbolic arc 1 to 1. The function returns@ tangent of n a DOUBLE PRECISION value. IfD (in radians). either passed expression resultsD in NULL then the result of ATANH1 will be NULL.M SQL> SELECT ATANH(0.905148254) "Hyperbolic Arc Tangent" FROM Rdb$DATABASE; Hyperbolic Arc Tangent 1.500000001965249E+000 1 row selectedB ATAN2 (n,m) Returns the n can be in an unbounded rangeD  arc tangent of and returns a value in the rangeB n and m. of -pi to pi, depending on theB signs of n and m, expressed inC radians. ATAN2(n,m) is the sameB as ATAN(n/m). If either passedC expression results in NULL then? the result of ATAN2 will be)  NULL.> SQL> SELECT ATAN2(.3, .2) "Arc_Tangent2" FROM Rdb$DATABASE; Arc_Tangent2 9.827937232473291E-001 1 row selectedB BITAND BITAND This function is commonly used@ (expr1,expr2) computes an with the DECODE function. IfA AND operation the passed expression resultsB on the bits in NULL then the result of the8 of expr1 and BITAND will be null.  expr2, both! of which must resolve to! integers, and returns an integer. CEIL (n) Returns the smallest integer greater than" or equal to n.A CHR (n) Returns the The returned value is of typeA character RDB$ORACLE_SQLFUNC_VCHAR_DOM,>  having the character set of which= the binary is bound when you install@ equivalent to the Oracle SQL functions. InD n. addition, only 1 octet (byte) of4 data is encoded. COS (n) Returns the cosine of n (an angle expressed in radians). COSH (n) Returns the  hyperbolic cosine of n (an angle expressed in radians).A COT (n) COT returns The function returns a DOUBLE> the cotangent PRECISION value. If either@ of n. passed expression results inD NULL then the result of COT will, be NULL.F SQL> SELECT COT (3.14159265358979/4) "Cotangent" FROM Rdb$DATABASE; Cotangent 1.000000000000002E+000 1 row selected EXP (n) Returns e raised to! the nth power' (e=2.71828183 . . . ). FLOOR (n) Returns the largest! integer equal to or less than n.; HEXTORAW (str) Converts its str mu st be of the sameD argument character set as the RDB$ORACLE_C containing SQLFUNC_VCHAR_DOM domain, whichA hexadecimal is bound when you install theC digits to a Oracle SQL functions. The valueC raw character returned is of type RDB$ORACLE_6 value. SQLFUNC_VCHAR_DOM.; INITCAP (str) Returns str must be of the sameD  the string character set as the RDB$ORACLE_C argument, SQLFUNC_VCHAR_DOM domain, whichA with the first is bound when you install theC letter of Oracle SQL functions. The valueC each word in returned is of type RDB$ORACLE_6 uppercase, all SQLFUNC_VCHAR_DOM.! other letters! in lowercase. Words are  delimited by non- alphanumeric characters.A INSTR Searches s1 s1 and s2 must be of the sameD (s1,s2[,n[,m]]) beginning character set as the RDB$ORACLE_C with its nth SQLFUNC_VCHAR_DOM domain, whichA character and is bound when you install theC returns the Oracle SQL functions. If eitherC character n or m is omitted, they default) position to 1. of the mth occurrence! of s2 or 0 if s2 does not" occur m times.! If n < 0, the! search starts! at the end of s1.A INSTRB Searches s1 s1 and s2 must be of the sameD (s1,s2[,n[,m]]) beginning character set as the RDB$O RACLE_C with its nth SQLFUNC_VCHAR_DOM domain, whichA octet and is bound when you install theC returns the Oracle SQL functions. If eitherC octet position n or m is omitted, they default) of the mth to 1. occurrence! of s2 or 0 if s2 does not" occur m times.! If n < 0, the!  search starts! at the end of s1.C LAST_DAY (d) Returns the d must be of the same date dataC last day of type as the RDB$ORACLE_SQLFUNC_C the month that DATE_DOM domain, which is boundC contains d. when you install the Oracle SQLD functions. The value returned isD of type RDB$ORACLE_SQLFUNC_DATE_( DOM. LN (n) Returns the natural logarithm of n where n is greater than 0. LOG (m,n) Returns the" logarithm base m of n. The! base m can be any positive number other than 0 or 1  and n can be any positive number.? LPAD (s,l,p) Returns s s and p must be of the sameD left-padded to character set as the RDB$ORACLE_C length l with SQLFUNC_VCHAR_DOM domain, whichA the sequence is bound when you install theC of characters Oracle SQL functions. The valueC in p. If s is returned is of type RDB$ORACLE_B ! longer than l, SQLFUNC_VCHAR_DOM. There is noA this function default for p as with Oracle. returns that portion of s that fits in l.A LTRIM Removes s1 and s2 must be of the sameD (s1[,s2]) characters character set as the RDB$ORACLE_C from the SQLFUNC_VCHAR_DOM domain, whichA left of s1, is bou "nd when you install theC with initial Oracle SQL functions. The valueC characters returned is of type RDB$ORACLE_D removed up SQLFUNC_VCHAR_DOM. If omitted,s26 to the first defaults to space.! character not in s2. MOD (m,n) Returns the" remainder of m! divided by n." Returns m if n # is 0.< MONTHS_BETWEEN Returns the d1 and d2 must be of the> (d1,d2) number of same date data type as the? months between RDB$ORACLE_SQLFUNC_DATE_DOM? dates d1 and domain, which is bound when> d2. you install the Oracle SQL. functions.D NEW_TIME Returns the d1 must be of the same date dataC (d1,z1,z2) date and time type$ as the RDB$ORACLE_SQLFUNC_C in time zone DATE_DOM domain, which is boundC z2 when the when you install the Oracle SQL@ date and time functions. z1 and z2 must be@ in time zone of the same character set asA z1 is d. Time the RDB$ORACLE_SQLFUNC_VCHAR_C zones z1 and DOM domain, which is also boundC z2 can be: when you install the Oracle SQ %LD AST, ADT, BST, functions. The value returned isD BDT, CST, CDT, of type RDB$ORACLE_SQLFUNC_DATE_( EST, EDT, GMT, DOM." HST, HDT, MST," MDT, NST, PST, PDT, YST, or YDT.C NEXT_DAY Returns the d must be of the same date dataC (d,dayname) date of the type as the RDB$ORACLE_SQLFUNC_C first weekday DATE_DOM d &omain, which is boundC named by when you install the Oracle SQLA dayname that functions. dayname must be ofA is later than the same character set as the@ the date d. RDB$ORACLE_SQLFUNC_VCHAR_DOM? domain, which is also boundC when you install the Oracle SQLD functions. The value returned isD ' of type RDB$ORACLE_SQLFUNC_DATE_( DOM. POWER (m,n) Returns m! raised to the nth power." The base m and the exponent n can be any! number but if" m is negative, n must be an integer.; RAWTOHEX (str) Converts its str must be of the ( sameD raw argument character set as the RDB$ORACLE_C to a character SQLFUNC_VCHAR_DOM domain, whichB value is also bound when you install= containing its the Oracle SQL functions.A hexadecimal The value returned is of typeA equivalent. RDB$ORACLE_SQLFUNC_VCHAR_DOM.A REPLACE Returns s1 s1, s2, and s3 must be of the= (s1[,s2[,s3]]) )with every same character set as the@ occurrence of RDB$ORACLE_SQLFUNC_VCHAR_DOM? s2 replaced by domain, which is bound when> s3. you install the Oracle SQLA functions. The value returnedB is of type RDB$ORACLE_SQLFUNC_D VCHAR_DOM. If omitted, s2 and s3? default to an empty stri *ng.? RPAD Returns s s and p must be of the sameD (s[,l[,p]]) left-padded to character set as the RDB$ORACLE_C length l with SQLFUNC_VCHAR_DOM domain, whichB the sequence is also bound when you installA of characters the Oracle SQL functions. The= in p. If s is value returned is of typeA longer than l, RDB$ORACLE_SQLFUNC_VCHAR_DOM.? this + function If omitted, p defaults to a* returns that space. portion of s that fits in l.A RTRIM Returns s2 s1 and s2 must be of the sameD (s1[,s2]) with final character set as the RDB$ORACLE_C characters SQLFUNC_VCHAR_DOM domain, whichB after the last is also bound when you installA character not the Oracle SQL, functions. The= in s2. value returned is of typeA RDB$ORACLE_SQLFUNC_VCHAR_DOM.@ If omitted, s2 defaults to a* space. SIN (n) Returns the sine of n (an angle expressed in radians). SINH (n) Returns the hyperbolic - sine of n (an angle expressed in radians). SQRT (n) Returns the" square root of n. The value of n cannot be negative. SQRT returns a double precision result.C SUBSTR Returns a s must be of the same characterB (s[,p[,l]]) . portion of s, set as the RDB$ORACLE_SQLFUNC_> l characters VCHAR_DOM domain, which isC long, also bound when you install theC beginning Oracle SQL functions. The valueC at character returned is of type RDB$ORACLE_D position p. If SQLFUNC_VCHAR_DOM. If omitted, l9 p is negative, defaults to zero (0).! SUBSTR counts! / backward from! the end of s.C SUBSTRB Same as s must be of the same characterB (s[,p[,l]]) SUBSTR, except set as the RDB$ORACLE_SQLFUNC_> p and l are VCHAR_DOM domain, which isC expressed in also bound when you install theC octets (bytes) Oracle SQL functions. The valueC rather than returned is of type RDB$ORACLE_D characters. 0 SQLFUNC_VCHAR_DOM. If omitted, l9 defaults to zero (0). TAN (n) Returns the tangent of n (an angle expressed in radians). TANH (n) Returns the hyperbolic tangent of n (an angle expressed in radians). wwı1 Oracle_St 1yle_Outer_Join@ Oracle Rdb supports the SQL Database Language Standard syntax? for performing outer join between two or more tables, namely@ the LEFT, RIGHT, and FULL OUTER JOIN clauses. Oracle Rdb also< supports alternative syntax and semantics that conform to= those available in Oracle RDMS SQL language to enhance theA compatibility between these two products. The special operator@ (+) can be placed in the WHERE clause to instruct SQL to join% tables using outer join seman 2tics.> An outer join extends the result of a simple join. An outerB join returns all rows that satisfy the join condition and thoseC rows from one table for which no rows from the other satisfy theB join condition. Such rows are not returned by a simple join. ToB write a query that performs an outer join of tables A and B andD returns all rows from A, apply the outer join operator (+) to allB columns of B in the join condition. For all rows in A that have@ no matching rows 3in B, Oracle Rdb returns NULL for any select, list expressions containing columns of B.< Outer join queries are subject to the following rules and restrictions:B o The (+) operator can appear only in the WHERE clause and can5 be applied only to a column of a table or view.A o If A and B are joined by multiple join conditions, you must@ use the (+) operator in all of these conditions. If you do@ not, Oracle Rdb will return only the rows resulting from aD 4 simple join, but without a warning or error to advise you that3 you do not have the results of an outer join.A o The (+) operator can be applied only to a column, not to an@ arbitrary expression. However, an arbitrary expression can4 contain a column marked with the (+) operator.@ o A condition containing the (+) operator cannot be combined; with another condition using the OR logical operator.D o A condition cannot use the IN comparison operator to compa 5re a= column marked with the (+) operator with an expression.? o A condition cannot compare any column marked with the (+) operator with a subquery.B If the WHERE clause contains a condition that compares a columnD from table B with a constant, the (+) operator must be applied toB the column so that Oracle Rdb returns the rows from table A forA which it has generated NULLs for this column. Otherwise Oracle5 Rdb will return only the results of a simple join.> 6 In a query that performs outer joins of more than two pairs@ of tables, a single table can be the NULL-generated table forB only one other table. For this reason, you cannot apply the (+)A operator to columns of B in the join condition for A and B and" the join condition for B and C. 2 Outer_Join_Examples@ The examples in this section extend the results of this inner/ join (Equijoin) between EMP and DEPT tables.- SQL> SELECT ename, job, dept.deptno, dname cont> 7 FROM emp, dept) cont> WHERE emp.deptno = dept.deptno;6 EMP.ENAME EMP.JOB DEPT.DEPTNO DEPT.DNAME6 King President 10 Accounting1 Blake Manager 30 Sales6 Clark Manager 10 Accounting4 Jones Manager 20 Research4 Ford Analyst 20 Research4 Smith Clerk 20 Research1 Allen Salesman 30 Sales1 Ward 8 Salesman 30 Sales1 Martin Salesman 30 Sales4 Scott Analyst 20 Research1 Turner Salesman 30 Sales4 Adams Clerk 20 Research1 James Clerk 30 Sales6 Miller Clerk 10 Accounting 14 rows selectedB The following query uses an outer join to extend the results of this Equijoin example above:- SQL> SELECT e 9name, job, dept.deptno, dname cont> FROM emp, dept- cont> WHERE emp.deptno (+) = dept.deptno;6 EMP.ENAME EMP.JOB DEPT.DEPTNO DEPT.DNAME6 King President 10 Accounting6 Clark Manager 10 Accounting6 Miller Clerk 10 Accounting4 Jones Manager 20 Research4 Ford Analyst 20 Research4 Smith Clerk 20 Research4 Scott : Analyst 20 Research4 Adams Clerk 20 Research1 Blake Manager 30 Sales1 Allen Salesman 30 Sales1 Ward Salesman 30 Sales1 Martin Salesman 30 Sales1 Turner Salesman 30 Sales1 James Clerk 30 Sales6 NULL NULL 40 Operations 15 rows selected> In this outer joi ;n, Oracle Rdb returns a row containing the> OPERATIONS department even though no employees work in thisC department. Oracle Rdb returns NULL in the ENAME and JOB columns< for this row. The join query in this example selects only# departments that have employees.B The following query uses an outer join to extend the results of the preceding example:- SQL> SELECT ename, job, dept.deptno, dname cont> FROM emp, dept, cont> WHERE emp.deptno (+) = dept.deptno# cont> < AND job (+) = 'Clerk';6 EMP.ENAME EMP.JOB DEPT.DEPTNO DEPT.DNAME6 Miller Clerk 10 Accounting4 Smith Clerk 20 Research4 Adams Clerk 20 Research1 James Clerk 30 Sales6 NULL NULL 40 Operations 5 rows selected> In this outer join, Oracle Rdb returns a row containing the; OPERATIONS department even though no clerks work in thisC = department. The (+) operator on the JOB column ensures that rowsB for which the JOB column is NULL are also returned. If this (+)C were omitted, the row containing the OPERATIONS department would8 not be returned because its JOB value is not 'CLERK'.- SQL> SELECT ename, job, dept.deptno, dname cont> FROM emp, dept, cont> WHERE emp.deptno (+) = dept.deptno cont> AND job = 'Clerk';6 EMP.ENAME EMP.JOB DEPT.DEPTNO DEPT.DNAME6 Miller Clerk > 10 Accounting4 Smith Clerk 20 Research4 Adams Clerk 20 Research1 James Clerk 30 Sales 4 rows selected? This example shows four outer join queries on the CUSTOMERS,D ORDERS, LINEITEMS, and PARTS tables. These tables are shown here: SQL> SELECT custno, custname cont> FROM customers cont> ORDER BY custno; CUSTNO CUSTNAME 1 Angelic Co ? 2 Believable Co 3 Cables R Us 3 rows selected SQL>) SQL> SELECT orderno, custno, orderdate cont> FROM orders cont> ORDER BY orderno;) ORDERNO CUSTNO ORDERDATE* 9001 1 1999-10-13* 9002 2 1999-10-13* 9003 1 1999-10-20* 9004 1 1999-10-27* 9005 2 1999-10-31 5 rows selected SQL>0 SQL> SELECT orderno, lineno @, partno, quantity cont> FROM lineitems# cont> ORDER BY orderno, lineno;9 ORDERNO LINENO PARTNO QUANTITY9 9001 1 101 159 9001 2 102 109 9002 1 101 259 9002 2 103 509 9003 1 101 159 9004 1 102 109 A 9004 2 103 20 7 rows selected SQL> SQL> SELECT partno, partname cont> FROM parts cont> ORDER BY partno; PARTNO PARTNAME 101 X-Ray Screen 102 Yellow Bag 103 Zoot Suit 3 rows selectedB The customer Cables R Us has placed no orders, and order number 9005 has no line items.D The following outer join returns all customers and the dates theyD placed orders. The (+B) operator ensures that customers who placed no orders are also returned:" SQL> SELECT custname, orderdate cont> FROM customers, orders4 cont> WHERE customers.custno = orders.custno (+)6 cont> ORDER BY customers.custno, orders.orderdate;) CUSTOMERS.CUSTNAME ORDERS.ORDERDATE# Angelic Co 1999-10-13# Angelic Co 1999-10-20# Angelic Co 1999-10-27# Believable Co 1999-10-13# Believable Co 1999-10-31 Cables C R Us NULL 6 rows selected@ The following outer join builds on the result of the previous@ one by adding the LINEITEMS table to the FROM clause, columnsC from this table to the select list, and a join condition joiningA this table to the ORDERS table to the where_clause. This queryA joins the results of the previous query to the LINEITEMS tableC and returns all customers, the dates they placed orders, and theD part number and quantity of each part they ordered. D The first (+)A operator serves the same purpose as in the previous query. TheA second (+) operator ensures that orders with no line items are also returned:4 SQL> SELECT custname, orderdate, partno, quantity+ cont> FROM customers, orders, lineitems4 cont> WHERE customers.custno = orders.custno (+)7 cont> AND orders.orderno = lineitems.orderno (+)H cont> ORDER BY customers.custno, orders.orderdate, lineitems.partno;N CUSTOMERS.CUSTNAME ORDERS.ORDERDATE LINEEITEMS.PARTNO LINEITEMS.QUANTITYN Angelic Co 1999-10-13 101 15N Angelic Co 1999-10-13 102 10N Angelic Co 1999-10-20 101 15N Angelic Co 1999-10-27 102 10N Angelic Co 1999-10-27 103 20N Believable Co 1999-10-13 101 F 25N Believable Co 1999-10-13 103 50N Believable Co 1999-10-31 NULL NULLN Cables R Us NULL NULL NULL 9 rows selected@ The following outer join builds on the result of the previousA one by adding the PARTS table to the FROM clause, the PARTNAMEB column from this table to the select list, and a join conditionA joining this table to the LINEI GTEMS table to the where_clause.B This query joins the results of the previous query to the PARTSC table to return all customers, the dates they placed orders, andA the quantity and name of each part they ordered. The first twoB (+) operators serve the same purposes as in the previous query.B The third (+) operator ensures that rows with NULL part numbers are also returned:6 SQL> SELECT custname, orderdate, quantity, partname2 cont> FROM customers, orders, lineitems, par Hts4 cont> WHERE customers.custno = orders.custno (+)7 cont> AND orders.orderno = lineitems.orderno (+)4 cont> AND lineitems.partno = parts.partno (+)D cont> ORDER BY customers.custno, orders.orderdate, parts.partno;O CUSTOMERS.CUSTNAME ORDERS.ORDERDATE LINEITEMS.QUANTITY PARTS.PARTNAMEM Angelic Co 1999-10-13 15 X-Ray ScreenK Angelic Co 1999-10-13 10 Yellow BagM Angelic Co 1I999-10-20 15 X-Ray ScreenK Angelic Co 1999-10-27 10 Yellow BagJ Angelic Co 1999-10-27 20 Zoot SuitM Believable Co 1999-10-13 25 X-Ray ScreenJ Believable Co 1999-10-13 50 Zoot SuitE Believable Co 1999-10-31 NULL NULLE Cables R Us NULL NULL NULLJ 9 rows selected 2 Oracle_Server_Predicate; The following notes apply when you use the Oracle server predicate:D o If tables A and B are joined by multiple join conditions, thenA the plus (+) operator must be used in all these conditions.B o The plus operator can be applied only to a column, not to an@ arbitrary expression. However, an arbitrary expression can5 contain a column marked with the plus operator.A o A condition containing the plus Koperator cannot be combined; with another condition using the OR logical operator.D o A condition cannot use the IN comparison operator to compare aA column marked with the plus operator to another expression.> o A condition cannot compare a column marked with the plus operator to a subquery.> o If the WHERE clause contains a condition that compares a? column from table B to a constant, then the plus operatorC must be applied to the column such thaLt the rows from table AB for which Oracle Rdb has generated NULLs for this column are returned.A o In a query that performs outer joins of more than two pairsD of tables, a single table can only be the null-generated table@ for one other table. For this reason, you cannot apply theB plus operator to the column of table B in the join conditionC for tables A and B and the join condition for tables B and C.ww٘1 ErrorsF The follo Mwing topics document messages returned with the SQL facility9 code. The OpenVMS online files SYS$HELP:SQL$MSG.DOC andC SYS$HELP:COSI_MSG.DOC contain the same text. Print those files if- you need hardcopy SQL message documentation.E The Appendix on error messages in the SQL Reference Manual describesB how to use this file and files documenting related error messages with other facility codes. 2 SQL_ERRORS 3 ABMCOLNAME= Column name matches simple function ; column value used@ N Explanation: You have given a column the name of a SQL builtinA function and SQL will use the column value instead of evaluating= the function. This ambiguous reference has been resolved in favor or the user define name.@ User Action: This is just a warning. However, you may want toA consider changing the column name, adding delimiters ("UID"), orA qualifying with table, view or correlation name (E.UID). If the@ function result is desired then you can use an alternate format8 for O the function (e.g. adding the fractional precision; CURRENT_TIME(2), using an equivalent function CURRENT_UID,< instead of UIC, or writing a SQL function which has its own query scope) 3 ABSACTIVE> AIJ backup active or backup operations suspended on this nodeA Explanation: After-image journal backup operations have already been suspended from this node.> User Action: Examine the secondary message(s) or look in the9 database monitor log file (SYS$SYSTEM:*MON.LOG) for more infPormation.3 ABSNSUSPENDED1 AIJ backup operations not suspended on this node= Explanation: After-image journal backup operations have not been suspended from this node.> User Action: Examine the secondary message(s) or look in the9 database monitor log file (SYS$SYSTEM:*MON.LOG) for more information.3 ABSSUSPENDED5 AIJ backup operations already suspended on this nodeA Explanation: After-image journal backup operations have already been suspended from this node.> UseQr Action: Examine the secondary message(s) or look in the9 database monitor log file (SYS$SYSTEM:*MON.LOG) for more information.3 ACCVIO/ access violation on read/write of user address? Explanation: A readable parameter is not readable by the DBCS7 or a writeable parameter is not writeable by the DBCS.0 User Action: Pass good parameters to the DBCS. 3 ACENOTFND' No matching access control entry foundA Explanation: In a protection command that refers to an existing= acces Rs control entry, you specified identifiers that did not match any existing entry.A User Action: Use SHOW PROTECTION to see what the access control5 list currently looks like, and correct your command. 3 ACE_ID_OVFL1 ACE identifier stack overflow during ACE parsing6 Explanation: You included too many identifiers in an? expression. The identifier stack for the access control entry! (ACE) overflowed during parsing.@ User Action: Simplify the access control entry that caused theS error. 3 ACE_ID_UNFL2 ACE identifier stack underflow during ACE parsing> Explanation: The access control entry (ACE) identifier stack? underflowed during ACE parsing. This happens when identifiers+ are not stored in the stack appropriately.: User Action: Contact your Oracle support representative.( Retain the Oracle Rdb interchange file. 3 ACTMISMATCH6 journal is for database activation

: += %facility-severity-text, The exceptionA line will be followed by one or more additional errors that willA help you to determine what caused the replication server process; to fail. Typically, the problem is caused by insufficient< quotas or system reso urces. However, other possible causesA include misdefined or undefined filename logicals. Depending on? the cause of the problem, take the appropriate action. If you9 are uncertain of what to do, contact your Oracle support representative for assistance. 3 NOAIJSLOTS0 no more after-image journal slots are available= Explanation: The number of after-image journals that can be? created is "reserved" in advance. An attempt has been made to/ create more journals than the number reserved.A User Action: Either remove an existing AIJ file or reserve more/ AIJ slots before creating additional journals. 3 NOALTER( No attributes specified for ALTER A Explanation: The user specified an ALTER DOMAIN statement or an< ALTER TABLE ALTER column-name clause without specifying any attributes.+ User Action: Specify something to change. 3 NOANYALL9 ANY and UNIQUE are not allowed in a MOVE RELATION clause@ Explanation: You entered a MOVE RELATION clause contai ning ANY> or UNIQUE. The MOVE RELATION clause only allows an operator, literal value, or field name.? User Action: Check the Replication Option for Rdb for details; on the MOVE RELATION clause. Re-enter the CREATE TRANSFER/ statement with a correct MOVE RELATION clause. 3 NOAREASLOTS) no more storage area slots are availableA Explanation: The number of storage areas that can be created is@ "reserved" in advance. An attempt has been made to create more( storage areas than the number reserved.A User Action: Either delete an existing storage area, or reserve5 more storage area slots before creating the area(s).3 NOAUDITSERVER7 VMS AUDIT_SERVER process is not running on this systemA Explanation: You attempted to generate a database audit record;= however, the VMS AUDIT_SERVER process is not running on this system.4 User Action: Restart the VMS AUDIT_SERVER process.3 NOBATCHUPDATE= BATCH UPDATE is not allowed without setting of logical nam eA Explanation: BATCH UPDATE transactions are not allowed with 2PC? turned on. 2PC is only turned off by setting the logical name named in the message to "TRUE".A User Action: If you want to migrate the application without the< use of of context items (i.e. 2PC/DDTM) and allowing BATCH8 UPDATE transactions, define the logical name to "TRUE".@ Otherwise, you should change the BATCH UPDATE option to another transaction option. 3 NOBATUPDA BATCH_UPDATE is not supported in the SQL interface to Oracle Rdb< Explanation: A DECLARE TRANSACTION statement specified the@ BATCH_UPDATE transaction mode. The SQL interface to Oracle Rdb does not support BATCH_UPDATE.A User Action: Replace BATCH_UPDATE with READ_WRITE reserving the8 tables you want to update with EXCLUSIVE WRITE locking. 3 NOBCKFIL export file not created; Explanation: An error has occurred during creation of the EXPORT file.? User Action: Follow actions directed by the corresponding RMS error. 3 NOBCKTRNS7 you cannot EXPORT a database from within a transaction: Explanation: You typed EXPORT from inside a transaction.1 User Action: End the transaction and try again. 3 NOBUCTXPARM= BATCH UPDATE not allowed in procedure with CONTEXT parameter? Explanation: Your source contains a SET TRANSACTION statement@ in a procedure which will have a context parameter added to it. This is not allowed.> User Action: Change the transaction options to use something:  other than BATCH UPDATE or compile the module without theA /CONTEXT=ALL qualifier or remove the name of this procedure from7 the list of procedures to receive a context parameter.3 NOBUUSINGCTX9 BATCH UPDATE not allowed in statement with USING CONTEXT? Explanation: Your source contains a SET TRANSACTION statement3 with a USING CONTEXT clause. This is not allowed.> User Action: Change the transaction options to use something@ other than BATCH UPDATE or remove the USING CONTEXT cla use from the statement. 3 NOCASING6 not supported for character set - ignoredA Explanation: The predicate LIKE ... IGNORE CASE, and functions> UPPER and LOWER require character sets that include upper and= lower case characters. This character does not support this functionality.@ User Action: This is a warning and the function or clause willA be discarded by SQL. This character set does not require IGNORE> CASE, UPPER or LOWER functions. They can be removed from the query. 3 NOCATRES Unable to import catalog - Explanation: Could not import this catalog.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NOCAT_DECL@ The table "" cannot be qualified by a catalog name ""? Explanation: A local temporary table (DECLARE LOCAL TEMPORARYA TABLE) is not associated with a catalog and schema, but with its containing module.> User Action: The correct way to refer to the local temporary@ table is alias-name.MODULE.table-name. Note that alias-name is optional. 3 NOCCHSLOTS) no more record cache slots are available? Explanation: The number of record caches that can be added is= "reserved" in advance. An attempt has been made to add more( record caches than the number reserved.@ User Action: Either delete an existing record cache definition5 or reserve more slots before creating the caches(s).3 NOCDD@ There is no repository on this system. Specify FILENAME in the" DECLARE ALIAS or ATTACH statement: Explanation: You declared or attach to a database with aA repository path name, but there is no repository running on thisA system. You must declare or attach to the database using a file name.> User Action: Declare or attach to the database by file name. 3 NOCDDALT@ There is no repository on this system. Specify FILENAME in the ALTER DATABASE statement< Explanation: You altered a database with a repository path> name, but there is no repository running on this system. You) must alter a database using a file name.> User Action: Alter the database with the database file name. 3 NOCDDRES# The repository will not be updated? Explanation: You cannot store the database information in the( repository. See the following message.? User Action: Correct the problem and try the operation again. 3 NOCDDUPDATA Database invoked by filename, the repository will not be updated; Explanation: You issued a data definition statement after invoking by file name> User Action: This is a warning. You can ROLLBACK and invoke= the database by specifying the path name. This ensures that? data definitions are updated both in the repository and in the database itself.3 NOCHAR! no character after '' in pattern@ Explanation: A MATCH operation was in progress and the pattern; was exhausted with the pattern quote character as the last character in the pattern.A User Action: Rewrite the expression in error to have the proper format. 3 NOCMPBYRES4 computed field in relation not imported> Explanation: You specified a computed field in your database@ that could not be imported. Perhaps the field references other? fields and relations that were deleted from the database by an? older version of the software that would have permitted such a thing.= User Action: You must investigate the problem further. The? table should have been properly imported except for the listed column. 3 NOCMPINTDY@ Day-time intervals are not compatible with year-month intervals< Explanation: You tried to compare a value of type INTERVAL= day-time (which may include the fields DAY, HOUR, MINUTE, or< SECOND) with a value of type INTERVAL year-month (which may< include the fields YEAR or MONTH). These two types are not compatible.> User Action: Use the CAST function and compare values of the same interval class. 3 NOCOLALL8 i nterpreted as column name where none are allowedA Explanation: An expression included a string SQL interpreted as< a column name where a column name does not make sense. For= example, specifying a column name in the VALUES clause of an< INSERT statement generates this error. Or, omitting quotes6 around a string literal can also generate this error.? User Action: Replace the string with a quoted literal or host> variable, or use a different form of the statement which will allow column names. 3 NOCOLCLAUSE3 Vertical row partitioning requires COLUMNS clauses 3 NOCOLLST? Specifying a column list is incompatible with WHERE CURRENT OF> Explanation: It is illegal to specify both a column list and WHERE CURRENT OF.) User Action: Remove one of the clauses. 3 NOCOLNAM7 This view definition must explicitly list column names> Explanation: You must specify names for all the columns in a: view if the select expression in the view definition uses@ aggregate functions or arithmetic expressions to create columns not in the source tables.7 User Action: Explicitly name each coulumn in the view definition. 3 NOCOLRES* Unable to import collating sequence A Explanation: SQL could not import this collating sequence. See the following message.? User Action: Correct the problem and try the operation again. 3 NOCONNAM4 Cannot create constraint name for table A Explanation: SQL tried to create a unique name for a CHECK type@ constraint on the named table. SQL could not generate a unique name for this table.> User Action: You can either delete all CHECK constraints for? this table and then recreate all of the constraints or you can; specify the DIAGNOSTIC parameter to give the constraint an explicit name. 3 NOCONRES" unable to import constraint : Explanation: Could not import this constraint -- see the message that follows.? User Action: Correct the problem and try the operation again. 3 NOCORRCOL@ There are no matching columns in the corresponding select lists7 Explanation: You specified a UNION CORRESPONING query? expression in which there were no corresponding columns in the; two select lists. There must be at least one column which matches.@ User Action: Either omit the CORRESPONDING keyword, or specify* at least one pair of columns which match. 3 NOCPRIRES< Unable to import privileges on column . for ? Explanation: SQL could not import these privileges -- see the message that follows.? User Action: Correct the problem and try the operation again. 3 NOCREMBX can't create mailbox? Explanation: An error occurred when you attempted to create a: mailbox. See the secondary message for more information.3 User Action: Correct the condition and try again.3 NOCSET# character set does not existA Explanation: You specified a character set that does not exist.@ For lack of a better choice, the database default character set is assumed.3 User Action: Specify a character set that exists. 3 NOCUROF9 A list specification must have a WHERE CURRENT OF clause? Explanation: A list specification requires a WHERE CURRENT OF! clause and one wasn't specified.3 User Action: Specify the WHERE CURRENT OF clause. 3 NODATDIV) No DATA DIVISION found in COBOL program.> Explanation: Every COBOL program that uses embedded SQL must> have a DATA DIVISION statement. None was found in your input file.= User Action: Add a DATA DIVISION statement to your program. 3 NODATRES1 remaining data for this relation will be ignoredA Explanation: An error occurred while you attempted to store the! data; see the following message.? User Action: Correct the problem and try the operation again. 3 NODBFILE% Alias is missing a declaration> Explanation: You have declared an alias as EXTERNAL in every= module in your application (thus, no filename is provided at runtime).@ User Action: Change one module to declare the alias as GLOBAL. 3 NODBHALW; database handles are not allowed in a MOVE RELATION clause= Explanation: You specified a database handle for the record@ selection expression (RSE) in a MOVE RELATION clause. Inside a? MOVE RELATION clause, database handles are not allowed for the RSE.> User Action: Re-enter the CREATE TRANSFER statement omitting the database handle name.3 NODBK2 :: does not point to a data record; Explanation: An attempt was made to fetch a record by its5 database-key value, but the record has been deleted.3 User Action: Correct the condition and try again. 3 NODBKALL; database key references are not allowed in a MOVE RELATION clause@ Explanation: You entered a MOVE RELATION clause that contained= a database key or a host variable. The MOVE RELATION clause7 only allows an operator, literal value, or field name.? User Action: Check the Replication Option for Rdb for details; on the MOVE RELATION clause. Re-enter the CREATE TRANSFER/ statement with a correct MOVE RELATION clause. 3 NODBKDRVTBL, DBKEY can't be returned for a derived-table= Explanation: You attempted to return a dbkey from a derived table which is not allowed.9 User Action: Return only fields from the derived table. 3 NODBKGRO> There is no DBKEY for a row in a result table with a GROUP BY9 Explanation: A SELECT expression with a group by clause? requested the DBKEY. There is no DBKEY for a row in a grouped table.* User Action: Remove the DBKEY reference. 3 NODBNAME? A database name was not specified on a DECLARE ALIAS or ATTACH statement= Explanation: You issued a DECLARE ALIAS or ATTACH statement9 that did not specify a database by file specification or repository path name.> User Action: Check the syntax of the DECLARE ALIAS or ATTACH statement. 3 NODBSINTXN, No databases specified for this transactionA Explanation: You executed an embedded SET TRANSACTION, but none; of the aliases declared at compiletime were present in the current environment.@ User Action: Issue a dynamic SET TRANSACTION statement to pick4 up dynamically attached aliases in the environment. 3 NODECLMOD+ DECLARE MODULE is valid only in plan filesA Explanation: A Module Language module contains a DECLARE MODULE@ statement. In Module Language, DECLARE MODULE is restricted to plan files.? User Action: Put the DECLARE MODULE statement in a plan file.3 NODEFAULTCONN$ Default connection is not attached.? Explanation: The default connection must be attached for this operation to succeed.0 User Action: Attach to the default connection. 3 NODEFDB There is no default database> Explanation: You specified a table name without an alias but there is no default database.? User Action: Either attach a default database, or include the: alias for a database you have attached in the table name. 3 NODELSYS+ System tables and views may not be deleted= Explanation: A system table or view was specified in a DROP TABLE or DROP VIEW statememt.< User Action: Check the spelling of the name of the object. 3 NODEVDIR/ filename does not include device and directory> Explanation: The file you specified did not include a device and directory.@ User Action: For maximum protection, you should always includeA a device and directory in the file specification, preferably one, that is different from the database device. 3 NODISTINCT; DISTINCT columns are not valid in an INSERT or LIST CURSOR@ Explanation: It is illegal to specify DISTINCT in an INSERT or LIST CURSOR.* User Action: Remove the DISTINCT clause. 3 NODROPPROC@ Procedure is within a stored module and cannot be dropped@ Explanation: The specified procedure is a stored procedure and= cannot be dropped. Only external procedures can be dropped.= User Action: Drop the stored module if you wish to drop the procedure.3 NODROPSYSCAT! Catalog may not be dropped> Explanation: The named catalog may not be dropped because it contains system relations.A User Action: Drop individual schemas or objects instead of this catalog.3 NODROPSYSSCH Schema may not be dropped= Explanation: The named schema may not be dropped because it contains system relations.> User Action: Drop individual objects instead of this schema. 3 NODUPLIVIEW< view cannot be specified more than once in a transfer definition7 Explanation: You have specified a view name in both a2 move-relations-clause and in a move-views-clause.8 User Action: Re-enter the CREATE TRANSFER statement by> specifying the view either in a move-relations-clause or in a# move-views-clause but not in both. 3 NOENTRYPT3 Older SQL version not compatible with compiled SQLA Explanation: 1 - You tried to run an SQL program with a version8 of SQL that is older than the version with wh ich it was@ compiled. The program also required SQL features not availableA from the older version of SQL. -OR- 2 - You tried to run an SQL= program with a shareable image without installing RDB$SHR or SQL$INT.A User Action: 1 - Re-compile the program under the older version< of SQL or run it under the newer version. -OR- 2 - Install RDB$SHR or SQL$INT images. 3 NOEUACCESS/ unable to acquire exclusive access to databaseA Explanation: Exclusive access to the database was not possible.? Therefore, the requested database operation was not performed. User Action: Try again later. 3 NOEXTCUR2 cannot extract, AIJ file is the current AIJ8 Explanation: The current AIJ file cannot be extracted.% User Action: Use a backup AIJ file.3 NOEXTLMNOENA? cannot extract - AIJ file does not have LogMiner enabled> Explanation: This AIJ file came from a database that did not< have LogMiner enabled at the time the AIJ file was created.@ User Action:  No user action is required. This AIJ file cannot be extracted.3 NOEXTNOQUIET? cannot extract - AIJ file backed up via a no-quiet-point backup6 Explanation: An AIJ file, which was backed up with a5 no-quiet-point backup, cannot beextracted, because a> no-quiet-point backup can leave incomplete transactions in an@ AIJ file. AIJ extraction cannot handle incomplete transactions within an AIJ file.7 User Action: No user action. This AIJ file cannot be extracted. 3 NOEXTOPT- cannot extract - AIJ file is optimized9 Explanation: An optimized AIJ file cannot be extracted.@ User Action: No user action is required. This AIJ file cannot be extracted.3 NOEXTPRVNOQUIETA cannot extract - AIJ file had its previous AIJ file backed up via a no-quiet-point backup> Explanation: An AIJ file for which the previous AIJ file was> backed up with a no-quiet-point backup, cannot be extract. A> no-quiet-point backup can leave incomplete transactions in an6 AIJ file, and AIJ extraction cannot handle incomplete! transactions within an AIJ file.@ User Action: No user action is required. This AIJ file cannot be extracted. 3 NOEXTUNRES; cannot extract, AIJ file has unresolved transactions: Explanation: The AIJ file being extracted has unresolved8 distributed transactions. AIJ extraction cannot handle+ unresolved transactions, so it must abort.9 User Action: Use a complete AIJ file with no unresolved distributed transactions. 3 NOFILLIST$ SQL does not support lists of files? Explanation: You specified a list of module language files on@ the module language command line, or a list of context files on= the precompiler command line. SQL does not support lists of files.= User Action: Specify only one language file and one context file on a command line. 3 NOFLDRES unable to import domain ? Explanation: Could not import this domain. See the following message.? User Action: Correct the problem and try the operation again. 3 NOFLOAT' has no floating point qualifiers; Explanation: The language does not support a command line% qualifier such as /FLOAT or /G_FLOATA User Action: The qualifier has no effect on the source language= compiler but may be needed for Dynamic SQL SQLDA parameters. 3 NOFOR_UPD- FOR UPDATE clause is ignored in this context< Explanation: You specified a FOR UPDATE clause on a SELECT. statement that ignores the FOR UPDATE clause.; User Action: Remove the FOR UPDATE clause from the SELECT statement. 3 NOFSTINREPT9 FIRST clause is not allowed in MOVE RELATION clause of a REPLICATION transfer; Explanation: In the MOVE RELATION clause of a REPLICATION5 TRANSFER definition you have entered a FIRST clause.A User Action: Re-enter the CREATE TRANSFER statement without the* FIRST clause in the MOVE RELATION clause. 3 NOGROUP9 GROUP BY clause is not valid in an INSERT or LIST CURSOR? Explanation: It is illegal to specify a GROUP BY clause in an INSERT or LIST CURSOR.* User Action: Remove the GROUP BY clause. 3 NOIDXRES unable to import index > Explanation: Could not import this index. See the following message.? User Action: Correct the problem and try the operation again. 3 NOIMPTXN. no implicit transaction to commit or rollback@ Explanation: The commit or rollback statement was used without? there being a valid implicit transactin outstanding. Explicit* transactions must be terminated via DDTM.A User Action: Do not use the commit or rollback statement unless. there is an implicit transaction outstanding. 3 NOINCDIC= The INCLUDE statement with the FROM DICTIONARY clause is not supported in = Explanation: The INCLUDE statement with the FROM DICTIONARY; clause is not supported for languages which do not have an= equivalent statement in the language. An example of this is Ada.@ User Action: Remove the INCLUDE statement with FROM DICTIONARY clause. 3 NOINCLEXT? You cannot use the EXTERNAL keyword with the INCLUDE statement0 in this host language; EXTERNAL keyword ignored? Explanation: SQL does not support the use of INCLUDE EXTERNAL" statements in this host language.; User Action: Remove the EXTERNAL keyword from the INCLUDE statement. 3 NOIOCHAN) no more I/O channels available on system@ Explanation: The process has attempted to exceed the number of= I/O channels that can be assigned at one time; this value is "per node".; User Action: Check the VMS SYSGEN parameter CHANNELCNT to7 ensure that it is large enough to properly service the application. 3 NOITEMDEF0 unable to define item "" from command line> Explanation: Could not define an item from the command line.@ See the following messages which will report the reason for the failure.? User Action: Correct the problem and try the operation again. 3 NOJOINHERE4 outer join operator (+) not allowed in this context= Explanation: Outer join operator (+) can only appear in the; WHERE clause not in the select list. Oracle7 has the same( rules, but generates no compiler error.! User Action: Rewrite the query. 3 NOJOINTBL< A joined table specification is required within parentheses= Explanation: Within a table-reference, parentheses denote a? joined table or a derived table. This set of parentheses does< not specify a correlation name so it must be a joined table2 However, no joined table specification was found.4 User Action: Specify a joined table specification. 3 NOLANGFIL No input file specified> Explanation: You did not specify a file for the precompiler.8 User Action: Enter the precompiler command line again, specifying a file this time. 3 NOLICENSE No license found6 Explanation: This system is not licensed for the SQL programming interface5 User Action: Install a valid license and try again. 3 NOLISTQUAL" /MACHINE qualifier requires /LIST: Explanation: The /MACHINE qualifier was specified on the? command line without specifying the /LIST qualifier. /LIST is required with /MACHINE: User Action: Add the /LIST qualifer to the command line. 3 NOLOCKSOUT4 no locks on this node with the specified qualifiersA Explanation: No locks were found on the current node that match? the specified command qualifiers. This usually indicates that@ either no monitors are active on this node, or no databases are' c urrently being accessed on this node.? User Action: If databases are active on the node, try using a, less restrictive set of command-qualifiers. 3 NOMAPIMPOA Mapping Values on CREATE INDEX within an IMPORT is not supported= Explanation: The data type of the columns used in the indexA must be checked for validation of the mapping values. Since the= tables do not exist at this time, their data types cannot be checked.> User Action: Remove the mapping values from the create index- and apply them after the import is complete. 3 NOMAPRES# unable to import storage map : Explanation: Could not import this storage map. See the following message.? User Action: Correct the problem and try the operation again. 3 NOMATCHKEY7 has no matching UNIQUE or PRIMARY KEY constraint@ Explanation: You specified a referenced column list which does= not match the columns specified as the key for any UNIQUE or? PRIMARY KEY constraint. The referenced colum n list must be an. exact match for the key of such a constraint.> User Action: Specify a referenced column list that matches a> key for a UNIQUE or PRIMARY KEY column, or define a UNIQUE or? PRIMARY KEY constraint that matches the referenced column list you specified. 3 NOMBLR_V2< MBLR Version 2 required for preserving upper and lower case> Explanation: Submessage for UNSUPVER. You have used a lower? case name, but the database does not support it. This is most@ likely to be from a CREATE statement on a remote node running a" version of Rdb earlier than V4.2.? User Action: Upgrade the remote node or use upper case names. 3 NOMLTIMV2 attempt to move the relation multiple times> Explanation: You attempted to specify the same relation name7 more than once in the MOVE clause of a CREATE TRANSFER@ statement. In a CREATE TRANSFER statement, you cannot move the same relation more than once.> User Action: Re-enter the CREATE TRANSFER statement omitting$ the duplicate MOVE RELATION clause. 3 NOMLTIMVIEW. attempt to move the view multiple times= Explanation: You attempted to move the named view more than9 once in a CREATE TRANSFER statement. This action is not permitted.A User Action: Re-enter the CREATE TRANSFER statement, specifying each view only once. 3 NOMODFIL) No module file specified on command line; Explanation: A module language compiler command line mustA include the name of a module file to compile. This command line did not.@ User Action: Repeat the command line with the name of a module file you wish to compile. 3 NOMODRES unable to import module ? Explanation: Internal error: the named module has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error.3 NOMONHOMEDIR$ monitor home directory is not valid? Explanation: The directory from which the monitor was invoked@ is no longer valid.  Typically, this occurs when the monitor is> invoked by the installation IVP procedure, which subsequently@ deletes the invocation directory. However, this can also occur? during day-to-day operations whenever directories are deleted.? When the monitor home directory does not exist, the monitor is> unable to invoke other server processes, such as the database= recovery process ("DBR") or the AIJ Backup Server ("ABS") toA name a few. When the monitor home directory does not exist, the@ s erver processes will be unable to create temporary work files.< User Action: Stop the monitor, and restart it from a valid directory. 3 NOMONITOR database monitor is not runningA Explanation: The database monitor process is not running or has= abnormally terminated. There may also be a problem with the7 mailbox used to communicate with the database monitor.? User Action: Check the system to determine whether or not theA database monitor process is actually running on your sy stem. IfA the database monitor process does not appear to be running, have> your database administrator start the monitor, and try again.@ If the database monitor process appears to be running properly,= then the problem may be related to the mailbox by which user? processes communicate with the monitor process. Make sure the> logical $MAILBOX_CHANNEL resides in a logical name table= accessible to all users, typically the LNM$PERMANENT_MAILBOX> name table. If the monitor abnormall y terminated, a bugcheck> dump will normally be written to the monitor log. Search the= monitor log for a string of five asterisks (*****) using the: SEARCH/WINDOW command. You will see a line with a format< similar to this: ***** Exception at
: module name> + %facility-severity-text, > The exception line will be followed by one or more additional? errors that will help you to determine what caused the monitor6 process to fail. Typically, the pr oblem is caused by9 insufficient quotas or system resources. However, other9 possible causes include misdefined or undefined filename; logicals. Depending on the cause of the problem, take theA appropriate action. If you are uncertain of what to do, contact3 your Oracle support representative for assistance. 3 NOMOREGB> global buffers not available to bind; free out of : Explanation: Your attempt to bind to the database failed: because there are not enough global  buffers to allow your! process to bind to the database.= User Action: There are four ways to alleviate this problem.? 1)Try to bind to the same database on another node, if you areA using a VAXcluster. 2)Wait untill another user unbinds from the> database and retry the bind. 3)Increase the number of globalA buffers used for the database. 4)Decrease the maximum number of< global buffers any one user can use, in order to allow more> users to bind to the database. Please see your DBA for help. 3 NOMOVESYS" System relations may not be movedA Explanation: A system relation was specified in the MOVE TABLES clause.A User Action: Reenter the transfer definition without the system relation. 3 NOMVRALLA MOVE RELATIONS ALL clause is not allowed in an EXTRACTION ROLLUP transfer> Explanation: In a CREATE TRANSFER statement of an EXTRACTIONA ROLLUP transfer, you have specified a MOVE RELATIONS ALL clause.8 User Action: Re-enter the CREATE TRANSFER statement by? specifying each relation explicitly in a MOVE RELATION clause. 3 NOMVVROL9 MOVE VIEWS clause is not allowed in an EXTRACTION ROLLUP transfer> Explanation: In a CREATE TRANSFER statement of an EXTRACTION9 ROLLUP transfer, you have specified a MOVE VIEWS clause.A User Action: Re-enter the CREATE TRANSFER statement without the MOVE VIEWS clause. 3 NONCONARR$ Noncontiguous arrays not supported.4 Explanation: You have passed a parameter that is a: noncontiguous array to the module language. SQL does not support noncontiguous arrays.? User Action: Use contiguous arrays to pass data to the module language.3 NONODE2 no node name is allowed in the file specification? Explanation: A node name was found in the file specification. Node names cannot be used.< User Action: Use a file name without a node specification. 3 NONOVAL' Negated qualifiers may not have values= Explanation: You specified a value for a qualifier that was preceded by NO.A User Action: Correct the command line syntax error, removing NO or the value.3 NONSINGLE_INTO5 An INTO clause is only allowed on a singleton select7 Explanation: An INTO clause is not allowed on a query specification.9 User Action: Remove the INTO clause and reissue the SQL statement. 3 NONSTAAMB2 Host variable is ambiguous in the host file? Explanation: The ANSI and ISO SQL standards require that host@ variable names be unique in the entire file being prepr ocessed.A The SQL interface to Oracle Rdb only requires it to be unique in= its language scope. This host variable is not unique in the file.@ User Action: If it is important to have only standard features9 in your program, you should change the name of this host( variable to make it unique in the file.3 NONSTAANSPARM9 Nonstandard omission of colons in module lang parametersA Explanation: The /ANSI_PARAMS qualifier was not used to enforce< the use of colons in module language parameters. Using theA default /NOANSI_PARAMS does not conform to the ANSI-89 standard.A User Action: If it is important to have your program conform to: ANSI standard semantics, use the appropriate qualifier to enforce use of colons. 3 NONSTACAS Nonstandard use of lowercase= Explanation: This token contains lowercase characters. The@ ANSI and ISO SQL standards only supports lowercase character in quoted strings.A User Action: If it is important to have only standard syntax in. your program, you should correct this syntax. 3 NONSTACOB COBOL file is not ANSI format8 Explanation: The file being processed by the COBOL SQL@ precompiler is not in ANSI format, or, if it is in ANSI format,> you did not specified the /ANSI switch. The ANSI and ISO SQLA standards require that all precompiled COBOL programs be in ANSI format.; User Action: If it is important to have your program in aA standard format, you should convert your program to ANSI format.A See  the COBOL Reference Manual for a definition of what ANSI and6 TERMINAL formats are and how to convert between them. 3 NONSTACOL) Column has a nonstandard data type> Explanation: You referred to a column whose data type is not, included in the ANSI and ISO SQL standards.@ User Action: If it is important to have only standard features; in your program, you should change the data types of these% columns to be an standard data type.3 NONSTACOLQUAL, Nonstandard qualifier used with column name@ Explanation: Additional qualifiers were supplied with a column@ name. In certain statements the standard does not allow column names to be qualified.A User Action: If it is important to have your program conform to6 ANSI standard semantics, remove the extra qualifiers. 3 NONSTACON7 The standard does not permit this data type conversion: Explanation: You are comparing, assigning or unioning to> expressions with different data types. These two expressions? mus t be converted to a common data type. The ANSI and ISO SQL* standards do not support this conversion.@ User Action: If it is important to have only standard features9 in your program, you should change your statement to use supported conversions. 3 NONSTACUC; The standard requires columns merged by UNION be identical: Explanation: The ANSI and ISO SQL standards require that@ columns which are being merged into a single result column by aA UNION clause must have identical definiti ons; that is, they must? have the same data type, length, scale, and so on. The columnA pointed to is not identical to the column with which it is being merged.@ User Action: If it is important to have only standard features; in your program, you should change the data types of these@ columns to be identical, or remove the UNION from your program. 3 NONSTACUR$ Cursor has a nonstandard typeA Explanation: You referred to a cursor of a type not included in the ANSI and ISO SQL standards.@ User Action: If it is important to have only standard features9 in your program, you should not use this type of cursor. 3 NONSTADEF: Significant digits of default clause literal will be lost? Explanation: Differences in scale between the datatype of the= column and the default value cause significant digits of theA default clause value to be lost. The ANSI/ISO standard requires$ that no significant digits be lost.A User Action: To be ANSI conformant, make sure the default value" does not lose significant digits. 3 NONSTADIS: The standard only permits one DISTINCT clause in a select expression? Explanation: You entered a select expression which either hasA two aggregate functions with DISTINCT clauses, or has a DISTINCTA clause for the entire select list and a DISTINCT in an aggregate9 function. The ANSI and ISO SQL standards do not support multiple distinct clauses.@ User Action: If it is important to have only standard features@ in your program, you should remove one of the distinct clauses. 3 NONSTADTP Nonstandard data type> Explanation: The data type indicated or the data type of the= column indicated is not included in the current ANSI and ISO standards for SQL.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTADYN8 The SQL standard does not include the dynamic interface: Explanation: The syntax indicated is not included in the ? current ANSI and ISO standards for SQL. The standard does not define the dynamic interface.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTAHV2 Host variable has a nonstandard declarationA Explanation: The ANSI and ISO SQL standards only require that a> small subset of host language data declarations be supported.> The declaration for this host variable uses language features$ which the standards do no t require.@ User Action: If it is important to have only standard features? in your program, you should change the definition of this host variable.3 NONSTAINVOKER" Invoker not restricted to definer' Explanation: The /RESTRICT_INVOKER or@ /SQLOPTIONS=RESTRICT_INVOKER qualifier was not used to restrict> the invoker to be the definer of a module. That is, any user> may invoke this module, but in order to conform to ANSI, only9 the definer of the module may invoke it. The definer is< considered to be the user who compiles a module or the user> specified by the AUTHORIZATION clause of the module language.A User Action: If it is important to have your program conform to: ANSI standard semantics, use the appropriate qualifier to invoker restricting. 3 NONSTAMOD2 The SQL standard does not include Module Language= Explanation: Module language is not allowed in the standard that is being flagged.* User Action: Do not use module language. 3 NONSTANAM Nonstandard name@ Explanation: This name is not a valid name in the ANSI and ISO: SQL standards. It is either longer than 18 characters or contains a $.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTAOKW9 Nonstandard syntax -- required keyword or clause omitted: Explanation: The syntax indicated is not included in theA current ANSI and ISO standards for SQL. The standard requires a< clause or keyword which  is optional in the SQL interface to6 Oracle Rdb. You have omitted that clause or keyword.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTAPHY8 The SQL standard does not specify the physical database: Explanation: The syntax indicated is not included in the? current ANSI and ISO standards for SQL. The standard does not define physical objects.A User Action: If it is important to have only standard syntax i n- your program, you should remove this syntax. 3 NONSTAQUO Nonstandard quote character@ Explanation: This informational message is generated by eitherA of two situations: - The ANSI and ISO SQL standards require the: single quotation mark (') character. You used the double? quotation mark (") character. - ANSI requires continuation beA done by language rules, which in COBOL means the first characterA on the line being continued must be a double quotation mark (").& You used a single quotation mark (').A User Action: If it is important to have only standard syntax in# your program, correct this syntax. 3 NONSTARSW> is a SQL reserved keyword: its use as an identifier is non-standard< Explanation: According to SQL89 and SQL92, no nondelimited? (unquoted) identifier can be a SQL reserved keyword. If a SQL= keyword must be used, it must be delimited by double quotes./ This bypasses keyword checking in the scanner.@ User Action: If it is import ant to have only standard features? in your program, change the identifier so that it is not a SQL? keyword. If the identifier must be the same as a SQL keyword,> delimit it with double quotes (e.g. DOUBLE becomes "DOUBLE") 3 NONSTASCL= Nonstandard scale. Your scale () exceeds the precision ()= Explanation: The scale specfied exceeds the precision. TheA current ANSI and ISO standards for SQL require a scale less than or equal to the precision.A User Action: If it is important to have only standard syntax in: your program, you should have scale less than or equal to precision. 3 NONSTASM6 The SQL standard does not include schema manipulation: Explanation: The syntax indicated is not included in the? current ANSI and ISO standards for SQL. The standard does not) define the schema manipulation language.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTASYN Nonstandard syntax: Explanation: The syntax indicated is not included in the( current ANSI and ISO standards for SQL.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTASYN89 Nonstandard SQL89 syntax? Explanation: The syntax specified is not included in the ANSI and ISO standards for SQL89.A User Action: If it is important to have only standard syntax in" your program, remove this syntax.3 NONSTASYN92E% Nonstandard SQL92 Entry-level syntax? Explanation: The syntax specified is not included in the ANSI) and ISO standards for SQL92 Entry-level.A User Action: If it is important to have only standard syntax in" your program, remove this syntax.3 NONSTASYN92F$ Nonstandard SQL92 Full-level syntax? Explanation: The syntax specified is not included in the ANSI( and ISO standards for SQL92 Full-level.A User Action: If it is important to have only standard syntax in" your program, remove this syntax.3 NONSTASYN92I, Nonstandard SQL92 Intermediate-level syntax? Explanation: The syntax specified is not included in the ANSI0 and ISO standards for SQL92 Intermediate-level.A User Action: If it is important to have only standard syntax in" your program, remove this syntax.3 NONSTASYN92T, Nonstandard SQL92 Transitional-level syntax? Explanation: The syntax specified is not included in the ANSI0 and ISO standards for SQL92 Transitional-level.A User Action: If it is important to have only standard syntax in" your program, remove this syntax. 3 NONSTATXN= The SQL standard does not specify how to control transaction characteristics: Explanation: The syntax indicated is not included in the? current ANSI and ISO standards for SQL. The standard does not; specify how transaction characteristics are to be defined.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSTAUNIA The sta ndard only permits UNION outside of subqueries in DECLARE CURSOR> Explanation: You have included a UNION in a context in which= the ANSI and ISO SQL standards do not support. Only DECLARE4 CURSOR statements may have a UNION in the standard.@ User Action: If it is important to have only standard features6 in your program, you should remove this UNION clause. 3 NONSTAVIA> Nonstandard feature for integration with Digital(tm) products: Explanation: The syntax indicated is not included in theA current ANSI and ISO standards for SQL. This is a feature which@ is provided for compatability with Digital(tm) products such as DATATRIEVE and CDD/Plus.A User Action: If it is important to have only standard syntax in- your program, you should remove this syntax. 3 NONSUPPKEY! option not supported9 Explanation: The precompiler does not support the value' supplied with the specified qualifier.> User Action: Omit the qualifier or choose a different va lue. 3 NOOJFORMEDA no outer join has been formed -- outer join operator (+) ignored? Explanation: A column was marked with the outer join operator= (+) and compared to a simple expression that doesn't contain= another table and column reference. Since no outer join has@ been formed between two tables Oracle Rdb will ignore the outer join notation.> User Action: If this Boolean expression appears before other@ AND comparisions then you should reorder the AND expressions so7 that comparisions with literal values and other simple expressions appear last. 3 NOONUSING5 The ON clause is illegal within a compound statement? Explanation: The ON clause was specified in a SET TRANSACTION? statement within a compound statement. This clause is illegal= because the compound statement must be in a single database.9 User Action: Do not use the ON clause within a compound? statement. Issue the SET TRANSACTION statement outside of the compound statement. 3 NOOPENCUR, There is no OPEN procedure for cursor ? Explanation: There are no OPEN procedures for this cursor. A@ module must have exactly one procedure which opens a particular cursor.7 User Action: Add a procedure which opens this cursor.3 NOOPTCMTJRNL= cannot optimize -- commit-to-journal optimization is enabled< Explanation: The 'commit-to-journal' database parameter is; enabled. When this parameter is enabled, AIJ optimization cannot be performed.A User Action: Use the original, non-optimized AIJ file if needed@ for recovery. As an alternative, disable the commit-to-journal feature. 3 NOOPTCUR: cannot optimize -- AIJ file is the current AIJ file@ Explanation: The current AIJ file cannot be optimized, because> the optimized AIJ file would not be equivalent to the current9 AIJ file if more journaling was done after optimization.> User Action: Start a new AIJ file, and then optimize the AIJ file in question.3 NOOPTNOQUIETA cannot optimize -- AIJ file backed up via a no-quiet-point backup6 Explanation: An AIJ file, which was backed up with a6 no-quiet-point backup, cannot be optimized, because a> no-quiet-point backup can leave incomplete transactions in an5 AIJ file. AIJ optimization cannot handle incomplete! transactions within an AIJ file.7 User Action: No user action. This AIJ file cannot be optimized. 3 NOOPTOPT7 cannot optimize -- AIJ file is already optimized? Explanation: An optimized AIJ file cannot be optimized again.* User Action: No user action is required. 3 NOOPTPOS9 Optimizer clauses are not legal in positioned statementsA Explanation: You have specified one of the optimizer clauses in> a positioned update or delete statement. This is meaningless and is, therefore, ignored.A User Action: You can remove the clause or choose to ignore this message.3 NOOPTPRVNOQUIET< cannot optimize -- AIJ file had its previous AIJ file& backed up via a no-quiet-point backup> Explanation: An AIJ file for which the previous AIJ file was@ backed up with a no-quiet-point backup, cannot be optimized. A> no-quiet-point backup can leave incomplete transactions in an8 AIJ file, and AIJ optimization cannot handle incomplete! transactions within an AIJ file.@ User Action: No user action is required. This AIJ file cannot be optimized. 3 NOOPTTRI6 Optimizer clauses are not legal in trigger statementsA Explanation: You have specified one of the optimizer clauses in? a data manipulation statement within a trigger. The optimizer5 clause is not supported in triggers, and is ignored.A User Action: You can remove the clause or choose to ignore this message. 3 NOOPTUNRES? cannot optimize -- AIJ file has unresolved transactions,: Explanation: The AIJ file being optimized has unresolved: distributed transactions. AIJ optimization cannot handle+ unresolved transactions, so it must abort.A User Action: Use the original, non-optimized AIJ file if needed for recovery. 3 NOORDER9 ORDER BY clause is not valid in an INSERT or LIST CURSOR? Explanation: It is illegal to specify a ORDER BY clause in an INSERT or LIST CURSOR.* User Action: Remove the ORDER BY clause. 3 NOORINJOIN; outer join operator (+) not allowed in operand of OR or IN@ Explanation: Outer join operator (+) not allowed in operand of9 OR or IN The (+) notation must not be specified in an ORA expression, unless the expression is parenthesized or appears in some type of sub-expression.% User Action: Rewrite the predicate. 3 NOOUTLRES Unable to IMPORT outline @ Explanation: Internal error: the named outline has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NOPARTCOL& partitioning column not in viewA Explanation: A name for partitioning a view was specified which is not in the list of columns.@ User Action: Check the spelling of the partitioning column and! of the column names of the view. 3 NOPASQLDA! SQLDA is not supported in Pascal@ Explanation: The Pascal precompiler does not support the SQLDA) data structure or the dynamic interface.> User Action: Remove all references to SQLDA in your program.> If the SQL Dynamic interface is required with Pascal, use the SQL module language. 3 NOPGPRES3 unable to import granted profile for grantee = Explanation: Internal error: the named Granted PROFILE has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error.3 NOPHYSMULSCH= The physical multischema attribute was not specified for the database: Explanation: You attempted to attach to a database using? multischema naming but the database was not physically enabled for it.? User Action: Either ALTER the database and enable multischema7 or do not attempt to attach it for multischema naming. 3 NOPOSCUR= Positioned (cursor) insert not allowed in compound or stored module? Explanation: Insert cursor is not allowed in a begin ... end! block or CREATE MODULE statementA User Action: Recode the module to use a FOR loop to process the rows.3 NOPRECOMPSEL No precompiler selectedA Explanation: You invoked the precompiler without specifying the language option desired.2 User Action: Specify a switch or file extension. 3 NOPREPCONN> This statement may not be prepared within a shared connection= Explanation: You have attempted to prepare a statement that< would change the connection or the files attached to in the9 current connection. This is not allowed within a shared connection.8 User Action: Do not prepare statements that effect the- connection from with in a shared connection. 3 NOPRFRES unable to import profile @ Explanation: Internal error: the named PROFILE has been lost.: Use r Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NOPRIMKEY Table has no primary key: Explanation: You omitted the referenced column list in a= referential constraint for which the referenced table has no> PRIMARY KEY. If the referenced table has no primary key, youA must specify a column list which matches the columns in a UNIQUE constraint.@ User Action: Add a referenced column list, or define a PRIMARY  KEY for the referenced table.3 NOPRIV% no privilege for attempted operation; Explanation: You attempted an operation that requires VMS: privileges, and you do not have those privileges enabled.5 User Action: Examine the secondary message for more information.3 NOPROC3 SQL statements must follow a procedure declaration9 Explanation: SQL statements must come after a procedure: statement. This statement was found before any procedure statement.: User Action: Put you r SQL statements inside a procedure. 3 NOPRVMVIEW2 insufficient privilege to transfer the view ? Explanation: You attempted to transfer the named view withoutA READ privilege on the view. You must have READ privilege on the: view to be able to transfer the view in a CREATE TRANSFER statement.? User Action: Re-enter the CREATE TRANSFER statement excluding? the named view. Check the Oracle Rdb SQL Reference Manual for" details on PROTECTION statements. 3 NOPRVMVREL6 insuffi cient privilege to transfer the relation A Explanation: You specified a relation for which you do not haveA READ privilege. You must have READ privilege on the relation to6 transfer the relation in a CREATE TRANSFER statement.? User Action: Re-enter the CREATE TRANSFER statement excluding? the named relation. Check the Oracle Rdb SQL Reference Manual9 for details on PROTECTION statements. Also consult your database administrator. 3 NOPRVREPLI8 insufficient privilege to CRE ATE a replication transfer= Explanation: You attempted to CREATE a replication transfer> without CREATE privilege on the source database. To CREATE a< replication transfer, you must have CREATE privilege on the source database.< User Action: Check the Oracle Rdb SQL Reference Manual for5 details on PROTECTION statements. See your database* administrator to obtain CREATE privilege. 3 NOPRVROLMVR< insufficient privilege to transfer the relation .A Explanation: You spe cified a relation for which you do not have> READ privilege in the specified database. You must have READ? privilege on the relation to transfer the relation in a CREATE TRANSFER statement.? User Action: Re-enter the CREATE TRANSFER statement excluding? the named relation. Check the Oracle Rdb SQL Reference Manual9 for details on PROTECTION statements. Also consult your database administrator. 3 NOQUALNM7 Column name must be qualified by at least a table name= Explanation: Y ou queried SQL to show protection on a columnA name but did not indicate the table in which the column resides.> User Action: Reenter the statement qualifing the column name with the table name. 3 NORDBPRIV6 GRANT or REVOKE specified only unsupported privileges9 Explanation: A GRANT or REVOKE statement specified only/ unsupported DB2 privileges. It has no effect.= User Action: None. SQL ignores the statement. However, to< avoid this message, either remove the statement or add some supported privileges to it. 3 NOREDINREPT: REDUCE clause is not allowed in MOVE RELATION clause of a REPLICATION transfer; Explanation: In the MOVE RELATION clause of a REPLICATION6 TRANSFER definition you have entered a REDUCE clause.A User Action: Re-enter the CREATE TRANSFER statement without the+ REDUCE clause in the MOVE RELATION clause. 3 NORELFOU No relation found for map A Explanation: The map name given has no table in the database or schema.( User Action: Use the correct map name. 3 NORELRES unable to import table > Explanation: Could not import this table. See the following message.? User Action: Correct the problem and try the operation again. 3 NOREMVER@ remote node or version number is not allowed in a log file name> Explanation: You used a node name or a version number in the7 log file specification of a CREATE TRANSFER statement.A User Action: Re-enter the CREATE TRANSFER statement using a log: fil e specification that does not contain a node name or a version number. 3 NOREPSQLDA Cannot represent using SQLDA> Explanation: An SQLDA was used, and either the length of the> derived column name was greater than 30 octets, the data typeA was DATETIME or INTERVAL, or the data type was character and theA character set was not the default one-octet character set or the( maximum length in octets excedes 32767.A User Action: Use an SQLDA2 or change the code to conform to the limitat ions of an SQLDA. 3 NOREQIDT? reached internal maximum number of simultaneous timer requests< Explanation: All allocated timer request ID slots, used to= uniquely identify timers, are in use. Therefore, this timer, request could not be serviced at this time. 3 NORESET# Parser unable to reset parse stack> Explanation: A syntactic error occurred and the parser spent? too much time trying to recover the parse stack. In the past,; some of these recoveries seemed to be in an infinite loop,% though they do terminate eventually.A User Action: Previous syntactic errors were diagnosed. Correct them and retry the compilation. 3 NORETURN@ Specifying a RETURNING clause is incompatible with a positioned insert statementA Explanation: It is illegal to specify a RETURNING clause with a positioned insert.+ User Action: Remove the RETURNING clause. 3 NOROCOLA Read only column expressions are not allows in an INSERT or LIST CURSORA Explanation: A colum n expression specified something other than1 a simple column reference such as an expression.0 User Action: Limit usage to only column names. 3 NORTNPRIV< GRANT and REVOKE are invalid on routines in a stored module= Explanation: The specified routine was created as part of a? CREATE MODULE statement. Privileges are managed at the module level for such routines.> User Action: Use GRANT or REVOKE on the module to change the< privileges for any SQL or external routines in that module. 3 NORTNRES unable to import routine @ Explanation: Internal error: the named routine has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NORTPARM) is not declared in procedure @ Explanation: You used the parameter as a runtime parameter for< a filename or pathname in a DECLARE SCHEMA statement. Such> parameters must be declared in every procedure in the module,< and must be character data types. You did not declare this paramter in this procedure.? User Action: Declare the parameter as a character variable in< the procedure. The use of DECLARE SCHEMA is deprecated and4 should be changed to use DECLARE ALIAS and connect. 3 NORTUPB1 no more user slots are available in the database@ Explanation: The maximum number of users are already accessing your database. User Action: Try again later. 3 NOSCHALT, Nothing altered in ALTER DATABASE statement> Explanation: There was nothing altered in the ALTER DATABASE query.> User Action: Remove the query or modify it to alter database characteristics. 3 NOSCHRES Unable to import schema , Explanation: Could not import this schema.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error.3 NOSEGSTRAREA' list storage area is not defined? Explanation: You specified a storage area in the LIST STORAGE! AREA clause that does not exist.A User Action: Specify a storage area which is already defined in the CREATE DATABASE statement. 3 NOSELALL@ SELECT FIELDS ALL clause is not allowed in an EXTRACTION ROLLUP transfer> Explanation: In a CREATE TRANSFER statement of an EXTRACTION@ ROLLUP transfer, you have specified a SELECT FIELDS ALL clause.8 User Action: Re-enter the CREATE TRANSFER statement by> specifying each field explicitly in the SELECT FIELDS clause. 3 NOSELXPRA Specifying a SELECT expression is incompatible with a positioned insert statement@ Explanation: It is illegal to specify a SELECT expression with a positioned insert., User Action: Specify only a VALUES clause. 3 NOSEQENT6 sequence id has no valid entry in the root file> Explanation: Sequence with the sequence id is present in the@ RDB$SEQUENCES table but does not have a valid entry in the root? file. Either the seq is not marked as being used in root file= or the condition minvalue <= next value <= maxvalue is false 3 NOSEQRES unable to import sequence A Explanation: Internal error: the named sequence has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NOSEQROW> sequence id has an entry in the root file but no row in RDB$SEQUENCES? Explanation: Sequence with id indicated has a root file entry6 but not corresponding row in the table RDB$SEQUENCES. 3 NOSHUTDOWN@ database shutdown not allowed while backup processes are active? Explanation: One or more database or AIJ backup utilities areA active. Database shutdown is not permitted while these types of utilities are active.> User Action: Wait for the utilities to complete, or shutdown0 the database using the /ABORT=DELPRC qualifier.3 NOSIP* transaction is not a snapshot transactionA Explanation: You have already started a transaction that is not a snapshot transaction.? User Action: Use COMMIT or ROLLBACK to terminate your current@ transaction. Use READY BATCH RETRIEVAL to start a new snapshot transaction. 3 NOSNAPS8 snapshots are not allowed or not enabled for area @ Explanation: Snapshots are not allowed or not enabled for this area.A User Action: This is a normal situation created by the database> definition or by a change- or modify-database command. Check8 with your DBA to make sure this situation is desirable.3 NOSORTINREPT8 SORT clause is not allowed in MOVE RELATION clause of a REPLICATION transfer; Explanation: In the MOVE RELATION clause of a REPLICATION4 TRANSFER definition you have entered a SORT clause.A User Action: Re-enter the CREATE TRANSFER statement without the) SORT clause in the MOVE RELATION clause. 3 NOSPRIRES/ Unable to import database privileges for = Explanation: SQL could not import these privileges; see the message that follows.? User Action: Correct the problem and try the operation again. 3 NOSQLCA) No INCLUDE SQLCA statement was specifiedA Explanation: Every precompiled SQL program must have an INCLUDE7 SQLCA statement in it. This program did not have one.. User Action: Add an INCLUDE SQLCA statement. 3 NOSQLCODE2 Neither SQLCA, SQLCODE nor SQLSTATE were declared: Explanation: All precompiled SQL programs must include a< definition for an SQL status variable. This can be done by@ specifying an INCLUDE SQLCA statement or by defining an integerA host variable name SQLCODE or by defining a 5 character SQLSTATE/ variable. This program did none of the above.A User Action: Add either an SQLCODE variable or an INCLUDE SQLCA# statement or an SQLSTATE variable. 3 NOSTATS% statistics are not enabled for ; Explanation: An attempt was made to show statistics for a= database that currently has statistics' collection disabled./ User Action: Enable statistics and try again. 3 NOSTRDEF7 Host variable i s based on an undefined structure@ Explanation: The FORTRAN RECORD host variable declaration uses, a structure name which has not be declared.@ User Action: Either change the name of the structure this host< variable is based on, or define a structure with that name. 3 NOSTRNAM= RECORD host variable does not specify a structure name@ Explanation: The FORTRAN RECORD host variable declaration does= not specify the structure name which the record is based on.? User Action: A!dd the name of the structure this host variable is based on. 3 NOSUCHAIJ no such AIJ journal ""? Explanation: The specified AIJ journal does not exist for the database.A User Action: You may select an AIJ journal using either the AIJA name or the default or current AIJ file specification. The list> of valid AIJ journals can be obtained by dumping the database header information. 3 NOSUCHCON4 There is no active connection with the name ""? Explanation: A conne"ction with the name given does not exist.3 User Action: Pass the name of a known connection. 3 NOSUCHCUR# Cursor has not been declared? Explanation: You must declare a cursor before you refer to it7 in an OPEN, CLOSE, FETCH, UPDATE, or DELETE statement.> User Action: Declare the cursor, or use the name of a cursor which is already declared.3 NOSUCHDATEFMT! Format DATE does not exist= Explanation: You entered DATE date-number where the logical$ LIB$DATE_FO#RMAT_nnn does not exist.9 User Action: Contact system manager to install the dateA formats. Make sure that these logical names are defined in EXEC/ mode as required by the OpenVMS documentation. 3 NOSUCHLANG Language does not exist.: Explanation: You entered SET LANGUAGE statement, but the4 logical name table LNM$LANGUAGE_xxx does not exist.7 User Action: Contact your system manager to make sure= everything has been set up properly; the language may not be supported.$ 3 NOSUCHPROC, Procedure in CONTEXT list not defined> Explanation: The value of the /CONTEXT qualifier specified a; procedure which was not defined in the body of the module.A User Action: Either add the procedure to the module or omit theA offending procedure name from the /CONTEXT qualifier value list. 3 NOSUCHSTMT/ is not the name of an prepared statement@ Explanation: A prepared statement with the name given does not exist.2 User Action: Pass the name of a %known statement.3 NOSUCHTIMEFMT! Format TIME does not exist= Explanation: You entered TIME time-number where the logical$ LIB$TIME_FORMAT_nnn does not exist.> User Action: Contact system manager to install the date/timeA formats. Make sure that these logical names are defined in EXEC/ mode as required by the OpenVMS documentation. 3 NOSUCHUSER unknown user ""? Explanation: An attempt was made to access information with a@ user name unknown to the database (for &example, sending mail toA the monitor or attempting to execute a database recovery process@ (DBR)) or to access information with a user name unknown to the; operating system (for example, no record in the UAF file).? User Action: Make sure the user name is spelled correctly and; has been properly identified to either the database or the? operating system. Do not attempt to run DBR from DCL; this is: not allowed, because the system will automatically manage? database recovery. Be sure' the monitor user name is correctly specified. 3 NOSUPREPLI? replication transfer is not supported for this source database@ Explanation: You attempted to create a replication transfer on5 a source database that is not a Oracle Rdb database.9 Replication transfers can be created only for Oracle Rdb? databases. For other databases you can create only extraction transfers.: User Action: If your source database is not a Oracle Rdb) database, create an extraction transfer. 3 NO(SYNRES unable to import synonym @ Explanation: Internal error: the named synonym has been lost.: User Action: Contact your Oracle support representative.> Retain the Oracle Rdb interchange file that caused the error. 3 NOTALSAUTO@ AIJ Log Server is not automatically invoked by database monitor? Explanation: In order to initiate database replication on the; master database, it is required that the AIJ Log Server be/ automatically invoked by the database monitor.= User Ac)tion: Change the AIJ Log Server invocation mode from "MANUAL" to "AUTOMATIC". 3 NOTAVIEW is not a view? Explanation: The name you specified in a MOVE VIEWS clause is not the name of a view.: User Action: Retype the CREATE TRANSFER command with the correct view name. 3 NOTBOOL0 expression in AND, OR, or NOT was not a BooleanA Explanation: The Boolean evaluator was processing an expression> or subexpression of the form "A AND B", "A OR B", or "NOT A".A Either the "A *" or the "B" expression was not in the proper form.@ The correct forms are "NOT X", "X EQ Y", "X NE Y", "X LT Y", "X= GT Y", "X LE Y", "X GE Y", "X CONTAINS Y", or "X MATCHES Y".> The operand of NOT, and both sides of AND and OR expressions, must be Boolean expressions.@ User Action: Rewrite the expression to have the proper format. 3 NOTCATOBJA The object "" cannot be qualified by a catalog name ""A Explanation: The object cannot be associated with a catalog and/ schem+a, but only with its containing database.8 User Action: The correct way to refer to the object is? alias-name.object-name. Note that the alias-name is optional.3 NOTDB2? "" is a DB2 feature not supported by the SQL interface to Oracle Rdb.> Explanation: This is a feature supported by DB2 that the SQL* interface to Oracle Rdb does not support.1 User Action: Remove references to this feature. 3 NOTDB2DUR; Labelled durations are a DB2 feature not supported by SQL.? Exp,lanation: The SQL interface to Oracle Rdb does not support labelled durations.7 User Action: Remove references to labelled durations. 3 NOTDB2FN# DB2 function not supported by SQL.? Explanation: This is a function supported by DB2 that the SQL* interface to Oracle Rdb does not support.2 User Action: Remove references to this function. 3 NOTDSKFIL+ filename does not specify disk device typeA Explanation: A file name was specified which does not reference a disk oriented- device type.A User Action: Check the file name for a proper disk device type. 3 NOTENUFBUF= requested number of global buffers () is more than USER LIMIT ()> Explanation: The user has requested more global buffers than are allowed for a single user.; User Action: Either reduce the number of requested globalA buffers or increase the number of global buffers that a user may< allocate. See documentation for descriptions of USER LIMIT5 clause used when creating and/o.r opening a database. 3 NOTEXTENDED/ area cannot be extended to page(s)> Explanation: The extension of the specified storage area was? not possible. This condition is possible if the specified new= size is less than the current storage area allocation. ThisA condition can also occur when attempting to change the size of a WORM device.? User Action: Specify a new page count that is larger than the current area allocation. 3 NOTFOUND& No rows were found for this/ statement9 Explanation: No rows were found for an UPDATE or DELETE/ statement, or a query produced an empty table.0 User Action: None. This is a warning message. 3 NOTGROFLDA Column cannot be referred to in the select list, ORDER BY,: or HAVING clause because it is not in the GROUP BY clause> Explanation: In the select list and HAVING clauses of select? expressions containing the GROUP BY clause, you can refer only/ to those columns named in the GROUP BY clause.@ Use0r Action: Either add the column named in the message to the: GROUP BY clause, or delete from the select list or HAVING clause. 3 NOTHVDECL is not a host variableA Explanation: The object referenced as a host variable was not a host variable.( User Action: Refer to a host variable. 3 NOTIMPLYET feature is not implemented yet> Explanation: You attempted to access a feature that has been* planned but has not been implemented yet." User Action: Avoid this feature. 13 NOTIMPSES1 Implicit session required for rollback or commit= Explanation: You called a procedure that tried to commit or> rollback the implicit session's implicit transaction when the? current session was one other than the implicit session. This9 could be accomplished by calling a procedure that does a@ rollback or commit that was compiled without session support or from an RDML/RdbPRE module.< User Action: Define an SQL module procedure to Rollback or1 Commit and compile with2 session support enabled. 3 NOTINPARAM? Parameter is referenced as an IN parameter, but declared as OUT> Explanation: The parameter named in the message was declared> with an explicit parameter mode, but its usage conflicts with the declaration.> User Action: Make the parameter INOUT or change the usage in the procedure. 3 NOTINRANGE6 value not within specified range of acceptable valuesA Explanation: The value of the translated logical name is not in the range of 3acceptable values.= User Action: Delete the logical name, or redefine it with a value in the acceptable range. 3 NOTINSCUR* Cursor is not an INSERT ONLY cursorA Explanation: In a positioned INSERT statement, the cursor named wasn't an INSERT ONLY CURSORA User Action: Restrict usage of INSERT statements to INSERT ONLY CURSORS. 3 NOTINTBLCUR4 Column, , not specified in table cursor, @ Explanation: The list column specifed for a list cursor wasn't' speci4fied in the related table cursor.@ User Action: Modify the table cursor to add the list column to= the select list or modify the list cursor to use a different column.3 NOTIP no transaction in progress@ Explanation: You attempted to execute a DML verb, but there is no transaction in progress yet.= User Action: Execute a READY statement before executing any other DML statements. 3 NOTLISTCOL& Column is not of data type LIST? Explanation: The column named in the e5rror message has a data type other than LIST.: User Action: Specify a column with the proper data type. 3 NOTLSTCUR" Cursor is not a list cursorA Explanation: An attempt was made to use a list INSERT statement into a table cursor.4 User Action: Use the INSERT INTO CURSOR statement. 3 NOTOUTPARAM@ Parameter is referenced as an OUT parameter, but declared as IN> Explanation: The parameter named in the message was declared> with an explicit parameter mode, but 6its usage conflicts with the declaration.> User Action: Make the parameter INOUT or change the usage in the procedure. 3 NOTPRIRES5 Unable to import privileges on table for ? Explanation: SQL could not import these privileges -- see the message that follows.? User Action: Correct the problem and try the operation again. 3 NOTRANAPP- no transactions in this journal were applied; Explanation: This journal file contains transactions that; cannot be applied t7o the specified backup of the database.@ User Action: Be sure you are using the correct database backup and journal file. 3 NOTRGRES Unable to IMPORT trigger A Explanation: SQL could not import this trigger; see the message that follows.? User Action: Correct the problem and try the operation again. 3 NOTROOT not a root file> Explanation: The specified file is not a database root file.: User Action: Specify a database root file and try again. 3 NOTROWNUM( ROW 8NUM is not available in this context@ Explanation: You have used ROWNUM and have violated one of the? restrictions. The restrictions are, ROWNUM: can only be used= in ORACLE LEVEL1 dialect can only be used in a comparison of; select expression predicate cannot be used with a LIMIT TO@ clause cannot appear more than once in the predicate of a WHERE? clause can only appear in SELECT statements cannot be comparedA to a column cannot be used in a compound statement cannot appear? on eith 9er side of an OR boolean operator cannot be selected or used in a function callA User Action: Re-issue the query and adhere to the restrictions.3 NOTSAMESCOPE< You cannot override a database attach with different scopes@ Explanation: The database scope (GLOBAL or LOCAL) in an ATTACH> statement differs from the one already attached with the same8 alias. The scope of the both aliases must be the same.= User Action: Either choose a different alias or specify the! same scope for th:e new database. 3 NOTSAMETBL< List cursor is based on a different than table cursor A Explanation: The table cursor named in the message references a> table cursor that is based on a different table from the LIST cursor.: User Action: Base the list cursor on a table cursor that references that same table. 3 NOTSNBLK1 no more user slots are available in the database@ Explanation: The maximum number of users are already accessing your database. User Action: T;ry again later.3 NOTSYSCONCEAL- non-system concealed device name in filename= Explanation: A concealed device name must be defined in the system logical table.; User Action: If the device name has to be concealed, then' define it in the system logical table. 3 NOTTBLCUR# Cursor is not a table cursor@ Explanation: You must declare list cursor to be the current of> a table cursor. The cursor specified in the WHERE CURRENT OF clause is another list cursor.( User <Action: Reference a table cursor. 3 NOTUSEIND2 Cannot use indicator variables in WHERE or HAVING: Explanation: You cannot use indicator variables in WHERE clauses or HAVING clauses.? User Action: Use the NULL keyword to test if a value is null. 3 NOTYPES? Domain reference in column is illegal in a DECLARE TABLE statementA Explanation: You referred to a user defined domain in a DECLARE= TABLE statement. All domains in the DECLARE TABLE statement must be SQL predefi=ned types.? User Action: Substitute the predefined equivalent of the user defined domain. 3 NOT_A_DB3 is not the name of a DSRI-compliant database@ Explanation: You supplied the name of a database that does not> exist under this repository directory, or you supplied a name' that is not a DSRI-compliant database.3 User Action: Supply the name of a valid database. 3 NOT_BOUND database is not bound@ Explanation: You have not bound to a database yet, or you have< unbou>nd the database and have not bound to another one yet.4 User Action: Bind to a database before continuing. 3 NOT_CDD_DB@ Database was not declared using PATHNAME. Repository access is illegal.> Explanation: You tried to include a repository entity in the= schema, but the database itself is not using the repository.5 User Action: Attach to the database using PATHNAME. 3 NOT_LARDY4 area for :: not in proper ready mode? Explanation: You attempted to access a log?ical area for which' you have not declared your intentions.- User Action: Retry a ready operation later. 3 NOT_READY storage area not readiedA Explanation: You attempted to access an area for which you have not declared your intentions.A User Action: If the area is included in your subschema, you can6 use the READY statement to prepare it for processing.3 NOT_SAME_CONTEXT< The being defined must be in the same database as the it references@ Explanati @on: When creating an item, the item was named as part@ of one database, but it was being created from items of another9 database. For example, trying to create an index in one@ database from a table in another database generates this error.> User Action: Create the item naming only items from the same database. 3 NOT_SCH_ID> Alias not permitted within definition of database < Explanation: You specified an alias of a database that was3 other than the one for the database bAeing defined.@ User Action: Create defintions only for a single database in aA CREATE DATABASE statement. Use the standalone CREATE statements for accessing other databases. 3 NOT_UPDATE4 storage area not readied in update usage mode> Explanation: You attempted to modify the contents of an area) without having declared your intentions.< User Action: If you have not readied the area yet, you can< READY for UPDATE. If you have already readied it, you must> abort your tranBsaction by executing a ROLLBACK before you can READY for UPDATE. 3 NOUNION= UNION or derived table not valid in an INSERT or LIST CURSOR? Explanation: It is illegal to specify a UNION expression or a2 derived table as the target for an INSERT CURSOR.2 User Action: Limit usage to only a single table. 3 NOVAL_TRIG8 NOVALIDATE must not be specified when enabling Triggers; Explanation: In the ALTER TABLE statement, if you specify@ enable novalidate, you cannot specify triggers. IfC you wish to? enable triggers, do not specify either VALIDATE or NOVALIDATE.2 User Action: Respecify the ALTER TABLE statement 3 NOVIERES unable to import view A Explanation: Could not import this view -- see the message that follows.? User Action: Correct the problem and try the operation again.3 NOVIEWINREPT7 view is not allowed in MOVE RELATION clause of a REPLICATION transfer; Explanation: In the MOVE RELATION clause of a REPLICATION/ TRANSFER definitiDon you have specified a view.A User Action: Re-enter the CREATE TRANSFER statement without the> view in the MOVE RELATION clause. The view definition can be7 moved by specifying the view in the MOVE VIEWS clause. 3 NOWHERE6 WHERE clause is not valid in an INSERT or LIST CURSOR< Explanation: It is illegal to specify a WHERE clause in an INSERT or LIST CURSOR.' User Action: Remove the WHERE clause.3 NOWILD4 no wild cards are allowed in the file specification@ Explanation: E Wild-card characters ("*" and "%") cannot be used in that file specification.9 User Action: Use a file specification without wild-card characters. 3 NOWORMSPT WORM areas are not supported? Explanation: An attempt was made to declare an area as having> the WORM attribute. At this time, there is no longer support for this attribute.= User Action: Contact your Oracle support representative for assistance. 3 NO_CDDACC No access to the repository.9 Explanation: AccesFs is not permitted to the repository.3 Previous error message should indicate the reason.; User Action: Correct problem from previous error message. 3 NO_COMMAND/ An empty command string was passed to PREPARE.; Explanation: A null command string was passed to PREPARE.: User Action: Pass a string to PREPARE that is not empty. 3 NO_DCLTXN@ You cannot declare a transaction while a transaction is active.A Explanation: There is a currently transaction in progress. YouA cannot Gdeclare a transaction while a transaction is in progress.@ User Action: Commit or rollback the current transaction before/ issuing another DECLARE TRANSACTION statement. 3 NO_DECIMAL0 is being converted from DECIMAL to .9 Explanation: DECIMAL is not a supported data type. SQL= converts DECIMAL columns and types to a supported data type.< User Action: None. This is an informational message only.3 NO_DESCENDING0 DSRI does not support descending index segments= ExpHlanation: You specified that a descending index segment;1 DSRI does not support descending index segments.4 User Action: Remove the DESC clause from the index specification. 3 NO_DMLPLAN7 You can only use DECLARE statements in a context file.; Explanation: You can only include DECLARE statements in a= context file. These statements include DECLARE TRANSACTION," DECLARE ALIAS, and DECLARE TABLE.@ User Action: Remove everything but DECLARE statements from the context file. I3 NO_DTYPE- Definition requires an unsupported data type@ Explanation: Submessage for UNSUPVER. The definition requires= the use of a data type not supported by the database system.> This is most likely to be from a CREATE statement on a remote1 node running a version of Rdb earlier than V4.2.A User Action: Upgrade the remote node or use only supported data types. 3 NO_ENDCOM No comment terminator found9 Explanation: A PL/I begin comment was found (/*) and no? correspondiJng end comment (*/) was found before the end of the program.- User Action: Insert the comment terminator. 3 NO_ENDEXEC> An EXEC SQL flag was found before the previous END-EXEC flag.9 Explanation: The previous SQL statement was missing its> END-EXEC flag. Every COBOL SQL statement must be preceded byA EXEC SQL and be terminated by END-EXEC. A period may optionally follow the 'END-EXEC' flag.7 User Action: Add an END-EXEC flag to the previous SQL= statement. Make sure that Kthe END-EXEC flag has no embedded@ spaces, and that there is no COBOL terminator period before the END-EXEC flag. 3 NO_FILFND4 File not found for input to the SQL processor4 Explanation: Attempted to open a nonexistent file.> User Action: Check the file specified. Supply complete file specification. 3 NO_HDRPLAN* Module header is not legal in a plan file= Explanation: You have put the module header in a plan file.> User Action: Use DECLARE MODULE in the plan file aLnd put the module header in the module. 3 NO_INCFND5 Could not find file named in INCLUDE statement; Explanation: You attempted to include a nonexistent file.: User Action: Check the file specification in the INCLUDEA statement. Supply a complete file specification. Note that the default file extension is .SQL. 3 NO_NUMBER. is being converted from NUMBER to = Explanation: The NUMBER format is supported by Rdb by being= converted to another underlying datMa type. Support includes: limiting the precision limits (values 1 through 18 only).> NUMBER without precision and scale, or with precision greatre) than 18 will default to DOUBLE PRECISON.< User Action: None. This is an informational message only. 3 NO_NUMERIC0 is being converted from NUMERIC to .= Explanation: NUMERIC is not a supported data type. The SQL? interface to Oracle Rdb converts NUMERIC columns or types to a supported data type.< User Action: None. ThNis is an informational message only. 3 NO_PLNFND> Context file was not found for input to the precompiler< Explanation: Attempted to open a nonexistent context file.@ User Action: Check the file specified. Supply a complete file specification. 3 NO_SQLDA* The SQLDA cannot be used in this language= Explanation: You cannot use the PREPARE...INTO and DESCRIBE statements in this language.> User Action: Remove references to the SQLDA from this module program.3 NO_STMOTB4HDR, Statements not allowed before MODULE header; Explanation: You entered some declare statements before a, MODULE header in a Module Language Program.A User Action: Put the statements in a plan file or following the MODULE header.3 NO_SUCH_FIELD7 Domain does not exist in this database or schema@ Explanation: You specified a domain that does not exist in the database or schema.> User Action: Check database or schema entity definitions for the valid type names.P3 NO_SUCH_TYPE7 Type "" does not exist in this database or schema> Explanation: You specified a type that does not exist in the database or schema.> User Action: Check database or schema entity definitions for the valid type names.3 NO_SYS_CONFIG. SQL cannot load the system configuration file; Explanation: The UNIX system configuration file cannot be1 loaded. It is possible that it might not exist.> User Action: Check the installation and make sure the system! con Qfiguration file is installed.3 NO_TRIGGER_VALS9 The values in the row are not available for this trigger? Explanation: You tried to refer to the values in the row that? was changed in a trigger action. The values are not available; in an action if action does not specify FOR EACH ROW or is3 triggered at a time when values are not supported.@ User Action: Rewrite your trigger so that values are available* or there are no references to the values. 3 NO_TXNOUT No transaction ou Rtstanding> Explanation: You attempted to terminate a transaction with a? COMMIT or a ROLLBACK when no transaction was outstanding. SQL6 does not start a transaction when you issue a DECLARE? TRANSACTION, but waits until it encounters the first statement that requires a transaction.> User Action: Execute a statement that requires a transaction: before issuing COMMIT or ROLLBACK. All statements except@ DECLARE TRANSACTION, DECLARE ALIAS, CREATE DATABASE, ATTACH and$ DROP DATABASE rSequire transactions.3 NO_UNSNUMERIC9 is being converted from UNSIGNED NUMERIC to .= Explanation: UNSIGNED NUMERIC is not a supported data type.< The SQL interface to Oracle Rdb converts NUMERIC columns or types to a supported data type.< User Action: None. This is an informational message only.3 NO_USER_CONFIG2 SQL cannot load the user configuration file A Explanation: The UNIX user configuration file cannot be loaded.( It is possible that it might not exist.T@ User Action: Check that the user configuration file exists and can be accessed. 3 NSEGBLR unable to recover BLR string> Explanation: Attempt to import a BLR list with more than one segment.: User Action: Contact your Oracle support representative.A Retain a copy of the Oracle Rdb interchange file that caused the error. 3 NULLNOIND9 Tried to store null into host variable with no indicator variable? Explanation: Null values can only be stored in host variables U which have indicator variables.= User Action: Add an indicator variable to the host variable> reference or make sure that no null values can be returned to it. 3 NULLUSRPWD= A username and/or password was expected on the command line. Null is being used? Explanation: In a DECLARE ALIAS statement the DEFAULT keyword; was used in place of the actual username or password. The: necessary qualifiers were not provided in the compilation' command line, so a null is being used.A U Vser Action: Compile the module again and provide the necessary6 username and/or password qualifiers. For SQL$MOD use8 /USERNAME=username /PASSWORD=password. For SQL$PRE use3 /SQLOPTIONS=(USERNAME=username,PASSWORD=password).3 NULL_COMP_COL? Computed Column in table is invalid - drop cascade? Explanation: When you DROP an object and specify CASCADE, SQL@ drops or marks as invalid objects referencing it. Any computed> column in another table that references the dropped t Wable, is> now invalid. This informational message indicates the column that was affected.: User Action: Rollback the DROP ... CASCADE operation or redefined the missing object. 3 NUMCMPTXT< Numeric column will be compared with string literal as textA Explanation: You tried to compare a text literal with a numeric9 column. The numeric column is converted to text and the? comparison is made from left-to-right, character by character.7 This can lead to unexpected results. For eXxample, the= comparison N between "0001" and "0999", no matter what N is,= will never be true, because N is converted to text without a= leading zero and compared alphabetically with the two string literals.? User Action: None, as long as you understand the semantics of= the operation. You should be aware that the comparison will take place between text values. 3 NUMHVSNOTA Number of host variables passed () does not match number of parameters ()? Explanation: T Yhe number of host variables you passed in to an? EXECUTE, OPEN, or FETCH statement does not match the number of> parameter markers (question marks) in the PREPARE statement's command string.A User Action: Make sure the number of host variables matches theA number of parameter markers in the PREPARE statement. There are? two ways to pass in host variables. One, explicitly pass in a< list of host variables in a USING list. Or two, pass in an@ SQLDA in a USING DESCRIPTOR clause. If y Zou are using an SQLDA,> you must specify in the SQLDA SQLN field the number of SQLVAR< structures you have initialized to point to your variables. 3 NUMITESEL? Number of items selected does not match number of items in the INTO clauseA Explanation: A SELECT statement must have as many values in the- select list as there are in the INTO clause.= User Action: Enter the same number of columns in the select> list and the INTO clause. If you are using 'SELECT *', check4 the columns t[hat are defined in the selected table. 3 NUMXPREXP" A numeric expression was expected> Explanation: A numeric literal, a numeric host variable, was' expected but something else was found.( User Action: Correct the syntax error. 3 NUM_TO_DATE? Numeric data in cannot be converted to a date data typeA Explanation: Oracle Rdb will not allow numeric data types to be converted to date.# User Action: Do not try it again.3 OBJECT_EXISTS Object already ex\ists; Explanation: The object exists in the specified database.> User Action: Please check that name exists in this database. 3 OBJNOTEXI; The object does not exist in this schema or database9 Explanation: The specified object does not exist in the? database. The objects checked were tables, views, procedures,= functions, domains, modules, types, sequences, and synonyms.A User Action: Create the object first then recreate the synonym. 3 ONEDBINMOD' Only one alias is] legal in this module? Explanation: This statement declares more than one alias in a: module. This is illegal because it requires the use of a/ database facility that cannot cross databases.A User Action: Remove the offending statement or additional alias declarations. 3 ONEEPERM4 only one E character is permitted in an edit stringA Explanation: An edit string contains more than one E character. Only one is allowed.7 User Action: Redefine the edit string with only one E^ character. 3 ONEJOIN6 a predicate may reference only one outer-joined table> Explanation: A predicate may reference only one outer-joined@ table The (+) notation, may only be specified on the columns of? one table in a predicate for a given join. Multiple joins may exist in a predicate.% User Action: Rewrite the predicate.3 ONETABLEJOIN7 a table may be outer joined to at most one other table? Explanation: A table may be outer joined to at most one other9 table. When mu _ltiple joins are being expressed, the (+); notation may only be specified on columns of a table being4 compared to the columns of exactly one other table.% User Action: Rewrite the predicate. 3 ONETXNMOD= Only one DECLARE TRANSACTION statement is allowed per moduleA Explanation: You can use only one DECLARE TRANSACTION statement: in a preprocessed module. It must occur before the first= executable statement (SELECT, INSERT, UPDATE, CREATE, etc.).> User Action: Only use one DE `CLARE TRANSACTION statement in a module. 3 ONLFIRPRE4 Only the first file in the list will be precompiled= Explanation: You specified a list of files to be processed.> This list will be passed along to the compiler with the firstA file replaced by the generated language file. However, only the, first file in the list will be precompiled.@ User Action: If more than one of the files has SQL statements,A they must be precompiled in separate command lines. If you want8 only the firsat file precompiled, then no user action is neccessary. 3 ONLFIRVAR5 Only first variable in qualified variable expression8 Explanation: COBOL allows only the first variable in a8 qualification to be an array. The preprocessors do not? recognize the arrays of arrays constructs in FORTRAN, COBOL or BASIC.: User Action: Rewrite the query and check the appropriate language reference manual. 3 ONLONEDB7 Only one database can be referred to in this statementA Explanation: You c bannot use objects from more than one database; in a SELECT, UPDATE, DELETE or CREATE statement. You can,8 however, refer to tables from one database in an INSERT@ statement and refer to tables in another database in the SELECT; which provides the values for that INSERT statement if the6 insert statement is not part of a trigger definition.< User Action: Use separate statements for multiple database access. 3 ONLONETRN' Only one transaction allowed at a time? Explanation: Only once transaction is allowed at a time. Note; that SQL starts a transaction, even if none was previously4 declared, on the first data manipulation statement.@ User Action: Issue a COMMIT or ROLLBACK statement to terminate' the transaction, then declare another. 3 ONLVALLST> Only a value list is valid in an INSERT LIST CURSOR statement9 Explanation: The only valid expression is a value list., User Action: Use only a VALUES expression. 3 ONLY1LIST& Only one list column may be specidfied= Explanation: The list specification specifies more than one8 column in the SELECT list. List cursors are limited to processing only a single list.< User Action: DECLARE a separate list cursor for each list. 3 ONLY1TBL< Only one table may be specified in an INSERT or LIST CURSORA Explanation: It is illegal to specify more than one table in an INSERT or LIST CURSOR.= User Action: Limit usage to specifying only a single table.3 ONLYONEPSECT1 Only one PSECT statement eper module is supported< Explanation: The PSECT directive may only be used once per module.A User Action: Decide which PSECT statement is really desired and delete all others. 3 OPENERR- unable to open as the interchange file@ Explanation: Could not access the Oracle Rdb interchange file.: User Action: Correct the problem indicated by subsequent& messages and try the operation again. 3 OPERCLOSE. database operator requested database shutdown; Explanation: Your fprogram has been terminated because the9 database operator shut down the database you were using.= User Action: Try again later after the database shutdown is complete. 3 OPERNOTIFY% system operator notification: ; Explanation: The indicated message was sent to one of the configured system operators.< User Action: Examine the indicated message and perform the appropriate operation. 3 OPERSHUTDN5 database operator requested monitor process shutdown; Explanation: g Your program has been terminated because the: database operator shut down the database monitor process.= User Action: Try again later after the database shutdown is complete.3 OPRSTK_OVRFLO Operator stack overflow? Explanation: The internal limit of the parsing operator stack was exceeded.: User Action: Contact your Oracle support representative., Retain the the query that caused the error. 3 OPTDDLREC8 TSN : contains DDL information that cannot be optimizedh@ Explanation: The identified transaction contains an AIJ record? with DDL information. DDL information cannot be optimized andA forces a flush of the accumulated SORT information. Too many of: these operations limit the effectiveness of the resulting7 optimized after-image journal and decrease the overall optimization performance.* User Action: No user action is required. 3 OPTEXCMAX? TSN : record size exceeds maximum record size@ Explanation: The ide intified transaction contains an AIJ record; whose size exceeds the maximum specified sort record size.A During AIJ optimization, fixed-length data records are passed to? the sort utility. By default, the size of the sort records is? 1548 bytes in length, which is also the maximum value allowed.A The sort record length affects the amount of disk space required= to complete the AIJ optimization operation. The size of the< record passed to the sort utility can be adjusted using the( j$BIND_OPTIMIZE_AIJ_RECLEN logical.@ User Action: If possible, increase the size of the sort record2 using the $BIND_OPTIMIZE_AIJ_RECLEN logical. 3 OPTEXCSRT9 AIJ record count exceeded specified sort threshold? Explanation: The number of AIJ records processed exceeded the( maximum sort threshold specified by theA $BIND_OPT_SORT_THRESHOLD logical name. This is not a fatal error.> User Action: None. Use of the $BIND_OPT_SORT_THRESHOLD> may reduce the sort w kork file disk space required for the AIJ> optimization operation. However, this may result in a larger output file. 3 OPTEXCTXN= TSN : error count exceeded failure threshold= Explanation: The number of AIJ optimize errors exceeded the- transaction error threshold specified by the@ $BIND_OPT_TXN_THRESHOLD logical name. This is not a fatal error.? User Action: None. The remainder of the transaction contents< are written directly to the optimized AIJ file. l Use of the@ $BIND_OPT_TXN_THRESHOLD logical name may actually increaseA the AIJ optimize operation performance as the number of required; sort operations is reduced. However, this may result in a larger output file. 3 OPTIMATTOP: The OPTIMIZE clause must appear in the outermost compound> Explanation: You have used the OPTIMIZE clause in a compound; statement that is nested within one or more other compound statements.A User Action: Move the OPTIMIZE clause to the outermost m compound statement in the procedure. 3 OPTINCONSIS5 optimized AIJ file is inconsistent with the databaseA Explanation: The database and/or some areas within the database: are not consistent with the optimized AIJ file. The last> transaction committed to the database and/or to some database? areas is not the same as the last transaction committed to the@ database at the time the optimized AIJ file's original AIJ fileA was created. To use an optimized AIJ file for recovery, it mustn/ be consistent with the database and all areas.A User Action: Use the original, non-optimized AIJ file to do the recovery.3 OPTNOAREAREC6 cannot do by-area recovery with an optimized AIJ file@ Explanation: A recover-by-area operation was attempted with anA optimized AIJ file. Optimized AIJ files do not support recovery0 by area, so the recovery operation was aborted.A User Action: Use the original, non-optimized AIJ file to do the by area recovery.3 OPTNOUNTILREC6 canno ot do a /RECOVER/UNTIL with an optimized AIJ file@ Explanation: A recover operation specifying an "until" time is8 not allowed with an optimized AIJ file. No recovery is* performed if this condition is specified.A User Action: Use the original, non-optimized AIJ file to do the /RECOVER/UNTIL operation. 3 OPTRECLEN> AIJ optimization record length was characters in lengthA Explanation: During AIJ optimization, fixed-length data records= are passed to the sort utility. By def pault, the size of the@ sort records is 1548 bytes in length, which is also the maximum= value allowed. The sort record length affects the amount of@ disk space required to complete the AIJ optimization operation.9 The size of the record passed to the sort utility can beA adjusted using the $BIND_OPTIMIZE_AIJ_RECLEN logical. This? message indicates the size of the largest AIJ record passed toA the sort utility that was less than or equal to the maximum sort record length.* Useqr Action: No user action is required. 3 OPTSRTSTAT : = Explanation: During optimization operations, statistics are9 often collected to aid the user in tuning. This message displays a single statistic. 3 ORAROWNUM/ ROWNUM only available in ORACLE LEVEL1 dialect@ Explanation: You have used ROWNUM outside of the ORACLE LEVEL1 dialect.A User Action: Set your dialect to ORACLE LEVEL1 and re-issue the query. 3 OTHPARTEX, duplicate otherwise partition defrined: Explanation: This partitioned view already has a default partition.> User Action: Remove one of the partitions or redefine one of their conditions. 3 OUTLNOTDEF# query outline is not defined@ Explanation: The specified query outline does not exist in the specified database.? User Action: Check the spelling of the query outline name and? ensure that it is the name of a query outline in the specified database. 3 OUTL_EXISTS# query outline already existss: Explanation: A query outline with the name given already exists.< User Action: Pass the name of a query outline that doesn't exist. 3 OVERFLOW data conversion overflow= Explanation: A loss of information would have occurred on a< data item transformation. The operation was not performed.= User Action: Correct the error and try the operation again. 3 PAGINCONSIS page is inconsistentA Explanation: An attempt was made to fetch an inconsistent page.5 This page c tannot be accessed until it is consistent.6 User Action: Take the proper action to make the page> consistent. For example, perform a RESTORE/RECOVER operation@ for a data or AIP page, or a REPAIR operation for a SPAM or ABM page.3 PARAMNAMEREQ, Parameter name required for stored routines; Explanation: A parameter name is required when defining a< parameter within a stored routine. A parameter name is not> required when defining a parameter within an external routine; and/or an ext uernal routine defined within a stored module.7 User Action: Redefine the routine and when defining a' parameter, specify the parameter name. 3 PARAMNOTSTRA Parameter in procedure must be a character parameter@ Explanation: You used the parameter as a runtime parameter for< a filename or pathname in a DECLARE SCHEMA statement. Such> parameters must be declared in every procedure in the module,9 and must be character data types. The parameter in this' procedure is not va character data type? User Action: Declare the parameter as a character variable in< the procedure. The use of DECLARE SCHEMA is deprecated and4 should be changed to use DECLARE ALIAS and connect. 3 PARAMQUAL! Parameters must not be qualified> Explanation: A reference to a parameter included qualifiers. You cannot qualify parameters.> User Action: Define the parameter in the procedure, or use a2 parameter name which is defined in the procedure. 3 PARBADCLA; Parameter w passed by invalid descriptor class ()< Explanation: The parameter was passed to a module language@ procedure by descriptor when parameter checking was enabled and; the class of the descriptor was not a supported descriptor class.@ User Action: Correct the argument in the host language program 3 PARBADDAT> Parameter has invalid data type: declared,  passed.< Explanation: The parameter was passed to a module languageA procedure with a different data type xthan it was declared in the; procedure. The codes for the data type as declared and as= passed are specified in the message. The codes are from the? DSC$B_DTYPE from the descriptor. See the "Introduction to VMS) System Routines" manual for these codes.= User Action: Make the parameter agree in the module and the host language. 3 PARBADLEN; Parameter has invalid length: declared,  passed.< Explanation: The parameter was passed to a module language> proce ydure with a different length than it was declared in the: procedure. The error message indicates the length of the; parameter as declared in the module, and the length of the parameter passed at run-time.= User Action: Make the parameter agree in the module and the host language. 3 PARBADSCA: Parameter has invalid scale: declared,  passed.< Explanation: The parameter was passed to a module language= procedure with a different scale than it was declared in thez9 procedure. The error message indicates the scale of the: parameter as declared in the module, and the scale of the parameter passed at run-time.= User Action: Make the parameter agree in the module and the host language. 3 PARBINSCA* Parameter has a binary scale factor< Explanation: The parameter was passed to a module languageA procedure with a binary scale factor. SQL supports only decimal scale factors.> User Action: Either do not use a scale factor, or use a {data? type with which your language uses decimal scale factors. For? example, PL/I uses binary scale factors with fixed binary data@ and decimal scale factors with fixed decimal data. If you want@ to use scale factors, use fixed decimal. Be sure to change the( module to agree with the new data type. 3 PARMLISTREQ/ FETCH LIST statements require a parameter list> Explanation: The FETCH LIST statement requires that the user% explicitly specify a parameter list.* User Action: Speci|fy the parameter list. 3 PARSE_INIT8 SQL cannot parse either the command line or the DBSINIT environment variable; Explanation: The format of either the command line or the) DBSINIT environment variable is invalid.A User Action: Check the formats of both the command line and the DBSINIT environment variable.3 PARSE_STACK_OVERFLOW Parse stack overflow; Explanation: The internal limit of the parsing stack were exceeded.: User Action: Contact your Oracle support represe}ntative., Retain the the query that caused the error. 3 PARTDTXNERR> error when trying to participate in a distributed transaction; Explanation: The process was unable to participate in theA DECdtm distributed transaction, because of a DECdtm error. This2 error is returned in the secondary error message.< User Action: Look at the secondary error message, make the3 necessary correction, and try the operation again.3 PASPRGNOTFND No Pascal program was found7 Explanation: No Pa~scal program was found in the input< preprocessor file. The embedded SQL statements can only be" processed within a program block.= User Action: Add a program block around the SQL statements. 3 PASRECUNS6 Host variable is based on a record type that is unsupported> Explanation: The host variable you referred to is based on a" record type which is unsupported.. User Action: Use a different type defintion. 3 PASVARUNSA Host variable is based on a record type that uses variants> Explanation: The host variable you referred to is based on a> record type which uses Pascal variants. SQL does not support types which include variants./ User Action: Use a different type definition.3 PATH_NAM_REQ: PATHNAME clause necessary when the repository is requiredA Explanation: When you create a database using the DICTIONARY ISA REQUIRED clause, then you must also specify the PATHNAME clause.A User Action: Change the CREATE DATABASE statement to either add@ the the PATHNAME clause or to remove the DICTIONARY IS REQUIRED clause. 3 PHYBACDAT$ it was physically exported on A Explanation: Information about the Oracle Rdb interchange file. User Action: None. 3 PKCONSNOTCB) Computed column may not be a primary key; Explanation: You specified a primary key constraint for a9 computed column, which does not support this constraint.: User Action: Remove the primary key constraint from this definition. 3 PKGNAMCHG: The  SQL package name has been changed from to 9 Explanation: The name of the Ada source file is used to= generate the name of a SQL package. Because the SQL package? name is not a legal Ada name, the package name is changed to a legal Ada name.@ User Action: If the SQL package name and declaration file mustA be the same name as the Ada source file, then change the name of: the Ada source file. If not, no user action is required. 3 PKNOTNULLA Column is used in a pri mary or unique key but permits NULL values@ Explanation: You specified a column in a primary or unique key@ definition which permits NULL values. The current ANSI and ISO= SQL standards require that only fields for which NOT NULL is6 specified may be included in a primary or unique key.A User Action: If it is important to have only standard syntax in; your program, you should either remove the column from the< primary or unique key, or add the NOT NULL attribute to the column.3 PREC_SPEC_TWICE) Precision specified twice in declaration= Explanation: Parsing the data declaration for this variable2 indicated that the precision was specified twice.; User Action: Check the declaration of this variable. Pay; particular attention to the area surrounding the precision declaration. 3 PREFORSTR? The host variable in the PREPARE FROM clause must be a string.> Explanation: A host variable in the FROM clause of a PREPARE( statement must have a string data type.@ User Action: In COBOL declare the variable to be PIC X(n). In> PL/I declare the variable to be CHAR(n). In FORTRAN, declare$ the variable to be CHARACTER XYZ*n.3 PREMATURE_EOF& Statement is syntactically incomplete@ Explanation: You entered a syntactically incomplete statement.= User Action: Complete the statement before typing "RETURN". 3 PREMEOF+ premature end of file encountered in < Explanation: A premature end-of-file was encountered while reading the spe cified file.3 PREPNOCTXSTR< This statement may not be prepared with a context structure> Explanation: A PREPARE or EXECUTE IMMEDIATE with an embedded> USING CONTEXT clause or in a module language procedure with a: context parameter was passed a statement which may not be# prepared with a context structure.A User Action: If you are using a precompiled program, remove the< USING CONTEXT clause. If you are calling a module language5 procedure, either remove the procedure name from the@ /CONTEXT=(...) list or, if /CONTEXT=ALL is used, pass a zero asA the address of the context structure or fill the distributed TID. portion of the context structure with zeroes. 3 PRESS_RET Press RETURN for more:1 Explanation: Used in online HELP display paging User Action: 3 PRESTAOPE@ Cannot prepare or release statement name used by an open cursor8 Explanation: You declared a cursor based on a prepared= statement name and opened the cursor. While that cursor was? still open, you tried to prepare or release the same statement name.= User Action: Close the cursor or end the transaction before= using a PREPARE or RELEASE statement with the same statement name. 3 PRIKEYEXI& Table already has a primary keyA Explanation: You specified a primary key definition for a table? which already had one. A table can have only one primary key.9 User Action: Remove the primary key definition from the? statement, or delete the existing primary key before executing the statement.3 PRMLENMISMAT@ Value assigned to in the routine "" truncated during call@ Explanation: When calling a function or procedure you passed a> character string value which was longer than could be held by= the parameter. SQL will therefore truncate the value during assignment to the parameter.; User Action: This is just a warning. However, you should= probably correct the strings length (possibly using the CAST= function), or adjust th e routine definition to avoid loss of data. 3 PROCALREXI: procedure already exists in this schema or databaseA Explanation: The specified function or procedure already exists< in the specified database. This could be caused by another@ procedure or an external function with the same name. Remember> that procedure names are scoped to the schema not the module.> User Action: Check the spelling of the function or procedureA name and ensure that it is a unique function or procedure in the specified database. 3 PROCNOCA; Procedure has neither an SQLCA nor SQLCODE parameter> Explanation: A module language procedure must have either an< SQLCA or an SQLCODE parameter declared. This procedure had neither.8 User Action: Add either an SQLCODE or SQLCA parameter. 3 PROCNOTDEF procedure is not definedA Explanation: The specified function or procedure does not exist in the specified database.> User Action: Check the spelling of the function or procedure? name and ensure that it is the name of a function or procedure in the specified database. 3 PROCNOTEXT: SHOW PROTECTION and SHOW PRIVILEGES are invalid on stored procedures; Explanation: The specified routine is a stored procedure.@ Because the GRANT and REVOKE statements are only allowed on theA module level, you cannot SHOW PROTECTION or SHOW PRIVILEGES on a stored procedure.< User Action: Specify the SHOW PROTECTION or SHOW PRIVLEGES! statements on the stored module. 3 PROCSTATWO= Procedure has more than one SQLCA or SQLCODE parameter> Explanation: A module language procedure must have either anA SQLCA or an SQLCODE parameter declared. This procedure had more than one.4 User Action: Remove an SQLCODE or SQLCA parameter. 3 PRPSELINTO; Preprocessed SELECT statements must include an INTO clause? Explanation: A preprocessed SELECT statement needs a place to: put the data it retrieves. An INTO clause is required to specify where to put the data.: User Action: Add an INTO clause to the SELECT statement.3 PRVERRSDTPUNK) Data type unknown due to previous errors@ Explanation: Due to previous errors, the precompiler or module8 language compiler does not understand either side of an assignment.A User Action: Correct errors previously reported, and recompile. 3 PTR_VAR> Host variable is a pointer variable which is illegal in SQL statements.; Explanation: The named variable is defined as a C pointer@ variable. These variables are currently not supported by the C precompiler.( User Action: Use a different variable. 3 PUTOPESEG! Attempt to put to an opened list> Explanation: You attempted to do a SEGSTR.PUT using a handle6 returned by a SEGSTR.OPEN statement. You can only do/ SEGSTR.GETs using the handle returned by open.) User Action: Specify the correct handle 3 QIOXFRLEN: data transfer length error - expected , actual A Explanation: The expected data-transfer length was not equal to! the actual data-transfer length.< User Action: This is usually caused by a hardware problem. 3 QUAINVVAL/ An invalid value was specified for @ Explanation: You specified an invalid value for a command line qualifier5 User Action: Correct the command line syntax error.3 QUALNOTALLOW0 A qualified name is not allowed in this context? Explanation: A qualified name was entered by the user where a! non-qualified name was required.> User Action: Reenter the statement omitting the illegal name qualifier. 3 QUALVALPOS; The value of the qualifier must be a positive number= Explanation: The value of the specified qualifier must be a3 positive number. A negative number was specified.@ User Action: Change the qualifier to specify a positive value. 3 QUANOVAL* The qualifier does not take a valueA Explanation: You specified a value for a command line qualifier which cannot have a value.5 User Action: Correct the command line syntax error. 3 QUERYCAN" Query cancelled at user's request= Explanation: The query was cancelled at the user's request.> User Action: No action required. If the query was cancelled, due to its complexity, try a simpler query. 3 QUERYLIMPOS& Query limit must be a positive number? Explanation: The limit of the number of rows or the number of seconds must be positive.A User Action: Change the SET statement of compiler qualifiers to  specify a positive value. 3 QUETOOBIG4 Query or routine contains too many table referencesA Explanation: A query expression, trigger actions, procedures or= function definition involves too many tables, views or table! expressions in joins and unions.? User Action: Rewrite the query to use fewer tables. Creating< views to define intermediate unions and joins may solve the; problem. For stored routines break the routine into small< routines and use the CALL statement to execute parts of the program. 3 QUIETPT+ waiting for database quiet point at