Information Technology - Database Language SQL (Proposed revised text of DIS 9075) July 1992 (Second Informal Review Draft) ISO/IEC 9075:1992, Database Language SQL- July 30, 1992 Digital Equipment Corporation Maynard, Massachusetts Contents Page Foreword.........................................................xi Introduction.....................................................xiii 1 Scope ........................................................ 1 2 Normative references ......................................... 3 3 Definitions, notations, and conventions ...................... 5 3.1 Definitions ................................................ 5 3.1.1Definitions taken from ISO/IEC 10646 ....................... 5 3.1.2Definitions taken from ISO 8601 ............................ 5 3.1.3Definitions provided in this International Standard ........ 5 3.2 Notation ................................................... 7 3.3 Conventions ................................................ 9 3.3.1Informative elements ....................................... 9 3.3.2Specification of syntactic elements ........................ 9 3.3.3Specification of the Information Schema ....................10 3.3.4Use of terms ...............................................10 3.3.4Exceptions .................................................10 3.3.4Syntactic containment ......................................11 3.3.4Terms denoting rule requirements ...........................12 3.3.4Rule evaluation order ......................................12 3.3.4Conditional rules ..........................................13 3.3.4Syntactic substitution .....................................13 3.3.4Other terms ................................................14 3.3.5Descriptors ................................................14 3.3.6Index typography ...........................................15 3.4 Object identifier for Database Language SQL ................16 4 Concepts .....................................................19 4.1 Data types .................................................19 4.2 Character strings ..........................................20 4.2.1Character strings and collating sequences ..................20 4.2.2Operations involving character strings .....................22 4.2.2Operators that operate on character strings and return char- acter strings...............................................22 4.2.2Other operators involving character strings ................23 4.2.3Rules determining collating sequence usage .................23 4.3 Bit strings ................................................26 4.3.1Bit string comparison and assignment .......................27 4.3.2Operations involving bit strings ...........................27 4.3.2Operators that operate on bit strings and return bit strings ............................................................27 4.3.2Other operators involving bit strings ......................27 ii Database Language SQL 4.4 Numbers ....................................................27 4.4.1Characteristics of numbers .................................28 4.4.2Operations involving numbers ...............................29 4.5 Datetimes and intervals ....................................29 4.5.1Datetimes ..................................................30 4.5.2Intervals ..................................................32 4.5.3Operations involving datetimes and intervals ...............34 4.6 Type conversions and mixing of data types ..................34 4.7 Domains ....................................................35 4.8 Columns ....................................................36 4.9 Tables .....................................................37 4.10 Integrity constraints ......................................40 4.10.Checking of constraints ....................................41 4.10.Table constraints ..........................................41 4.10.Domain constraints .........................................43 4.10.Assertions .................................................43 4.11 SQL-schemas ................................................44 4.12 Catalogs ...................................................45 4.13 Clusters of catalogs .......................................45 4.14 SQL-data ...................................................45 4.15 SQL-environment ............................................46 4.16 Modules ....................................................46 4.17 Procedures .................................................47 4.18 Parameters .................................................47 4.18.Status parameters ..........................................47 4.18.Data parameters ............................................48 4.18.Indicator parameters .......................................48 4.19 Diagnostics area ...........................................48 4.20 Standard programming languages .............................49 4.21 Cursors ....................................................49 4.22 SQL-statements .............................................51 4.22.Classes of SQL-statements ..................................51 4.22.SQL-statements classified by function ......................52 4.22.Embeddable SQL-statements ..................................55 4.22.Preparable and immediately executable SQL-statements .......56 4.22.Directly executable SQL-statements .........................58 4.22.SQL-statements and transaction states ......................59 4.23 Embedded syntax ............................................61 4.24 SQL dynamic statements .....................................61 4.25 Direct invocation of SQL ...................................64 4.26 Privileges .................................................64 4.27 SQL-agents .................................................66 4.28 SQL-transactions ...........................................67 4.29 SQL-connections ............................................70 4.30 SQL-sessions ...............................................72 Table of Contents iii 4.31 Client-server operation ....................................74 4.32 Information Schema .........................................75 4.33 Leveling ...................................................75 4.34 SQL Flagger ................................................76 5 Lexical elements .............................................79 5.1 ...................................79 5.2 and ....................................82 5.3 ..................................................89 5.4 Names and identifiers ......................................98 6 Scalar expressions ...........................................107 6.1 ................................................107 6.2 and ...........114 6.3 ..........................................118 6.4 .........................................121 6.5 ...............................124 6.6 ...................................128 6.7 ....................................132 6.8 ..................................139 6.9 ..........................................141 6.10 .......................................144 6.11 .........................................155 6.12 .................................157 6.13 ..................................160 6.14 ................................165 6.15 ................................168 7 Query expressions ............................................173 7.1 ....................................173 7.2
..................................176 7.3
.........................................177 7.4 ..............................................178 7.5 .............................................180 7.6 .............................................185 7.7 ..........................................187 7.8 ............................................189 7.9 ......................................191 7.10 .........................................196 7.11 , , and
....203 8 Predicates ...................................................205 8.1 ................................................205 8.2 .....................................207 8.3 ........................................211 8.4 .............................................212 iv Database Language SQL 8.5 ...........................................214 8.6 ...........................................218 8.7 ..........................220 8.8 .........................................222 8.9 .........................................223 8.10 ..........................................224 8.11 .......................................227 8.12 .........................................229 9 Data assignment rules ........................................231 9.1 Retrieval assignment .......................................231 9.2 Store assignment ...........................................234 9.3 Set operation result data types ............................237 10 Additional common elements ...................................239 10.1 .......................................239 10.2 ..........................................243 10.3 ...............................................245 10.4 ..............................248 10.5 ...........................................251 10.6 and ...252 11 Schema definition and manipulation ...........................255 11.1 ........................................255 11.2 ....................................258 11.3
.........................................260 11.4 ........................................262 11.5 ...........................................266 11.6
..............................270 11.7 .............................272 11.8 ........................274 11.9 ..............................281 11.10 ....................................283 11.11 ....................................284 11.12 ..................................286 11.13 ................................287 11.14 ...............................288 11.15 ...................................289 11.16 ..........................291 11.17 .........................292 11.18 .....................................294 11.19 ..........................................296 11.20 ......................................300 11.21 ........................................301 11.22 ...................................304 11.23 ................................305 Table of Contents v 11.24 ...............................306 11.25 .........................307 11.26 ........................308 11.27 ....................................309 11.28 .................................311 11.29 .............................313 11.30 .....................................314 11.31 .................................318 11.32 ...................................320 11.33 ...............................323 11.34 .....................................325 11.35 .................................328 11.36 ..........................................329 11.37 .........................................333 12 Module .......................................................341 12.1 ...................................................341 12.2 .......................................344 12.3 ................................................346 12.4 Calls to a .....................................352 12.5 ..................................368 13 Data manipulation ............................................371 13.1 ...........................................371 13.2 ...........................................375 13.3 ..........................................377 13.4 ..........................................381 13.5
that identifies a view that is defined by a V, then is said to generally contain the contained in V. If contains , then generally contains . If generally contains and generally contains , then generally contains . An instance A1 of directly contains an instance B1 of if A1 contains B1 without an intervening or . Definitions, notations, and conventions 11 X3H2-92-154/DBL CBR-002 3.3 Conventions 3.3.4.3 Terms denoting rule requirements In the Syntax Rules, the term shall defines conditions that are required to be true of syntactically conforming SQL language. When such conditions depend on the contents of the schema, then they are required to be true just before the actions specified by the General Rules are performed. The treatment of language that does not conform to the SQL Formats and Syntax Rules is implementation- dependent. If any condition required by Syntax Rules is not sat- isfied when the evaluation of Access or General Rules is attempted and the implementation is neither processing non-conforming SQL language nor processing conforming SQL language in a non-conforming manner, then an exception condition is raised: syntax error or access rule violation (if this situation occurs during dynamic ex- ecution of an SQL-statement, then the exception that is raised is syntax error or access rule violation in dynamic SQL statement; if the situation occurs during direct invocation of an SQL-statement, then the exception that is raised is syntax error or access rule violation in direct SQL statement). In the Access Rules, the term shall defines conditions that are required to be satisfied for the successful application of the General Rules. If any such condition is not satisfied when the General Rules are applied, then an exception condition is raised: syntax error or access rule violation (if this situation occurs during dynamic execution of an SQL-statement, then the exception that is raised is syntax error or access rule violation in dynamic SQL statement; if the situation occurs during direct invocation of an SQL-statement, then the exception that is raised is syntax error or access rule violation in direct SQL statement). In the Leveling Rules, the term shall defines conditions that are required to be true of SQL language for it to syntactically conform to the specified level of conformance. 3.3.4.4 Rule evaluation order A conforming implementation is not required to perform the exact sequence of actions defined in the General Rules, but shall achieve the same effect on SQL-data and schemas as that sequence. The term effectively is used to emphasize actions whose effect might be achieved in other ways by an implementation. The Syntax Rules and Access Rules for contained syntactic elements are effectively applied at the same time as the Syntax Rules and Access Rules for the containing syntactic elements. The General Rules for contained syntactic elements are effectively applied be- fore the General Rules for the containing syntactic elements. Where the precedence of operators is determined by the Formats of this International Standard or by parentheses, those operators are ef- fectively applied in the order specified by that precedence. Where the precedence is not determined by the Formats or by parentheses, effective evaluation of expressions is generally performed from 12 Database Language SQL X3H2-92-154/DBL CBR-002 3.3 Conventions left to right. However, it is implementation-dependent whether ex- pressions are actually evaluated left to right, particularly when operands or operators might cause conditions to be raised or if the results of the expressions can be determined without completely evaluating all parts of the expression. In general, if some syn- tactic element contains more than one other syntactic element, then the General Rules for contained elements that appear earlier in the production for the containing syntactic element are applied before the General Rules for contained elements that appear later. For example, in the production: ::= the Syntax Rules and Access Rules for , , and are ef- fectively applied simultaneously. The General Rules for are applied before the General Rules for , and the General Rules for are applied after the General Rules for both and . If the result of an expression or search condition can be deter- mined without completely evaluating all parts of the expression or search condition, then the parts of the expression or search condi- tion whose evaluation is not necessary are called the inessential parts. If the Access Rules pertaining to inessential parts are not satisfied, then the syntax error or access rule violation exception condition is raised regardless of whether or not the inessential parts are actually evaluated. If evaluation of the inessential parts would cause an exception condition to be raised, then it is implementation-dependent whether or not that exception condition is raised. 3.3.4.5 Conditional rules Conditional rules are specified with "If" or "Case" conventions. Rules specified with "Case" conventions include a list of con- ditional sub-rules using "If" conventions. The first such "If" sub-rule whose condition is true is the effective sub-rule of the "Case" rule. The last sub-rule of a "Case" rule may specify "Otherwise". Such a sub-rule is the effective sub-rule of the "Case" rule if no preceding "If" sub-rule in the "Case" rule has a true condition. 3.3.4.6 Syntactic substitution In the Syntax and General Rules, the phrase "X is implicit" indi- cates that the Syntax and General Rules are to be interpreted as if the element X had actually been specified. In the Syntax and General Rules, the phrase "the following is implicit: Y" indicates that the Syntax and General Rules are to be interpreted as if a syntactic element containing Y had actually been specified. Definitions, notations, and conventions 13 X3H2-92-154/DBL CBR-002 3.3 Conventions In the Syntax Rules and General Rules, the phrase "former is equiv- alent to latter" indicates that the Syntax Rules and General Rules are to be interpreted as if all instances of former in the element had been instances of latter. If a BNF nonterminal is referenced in a Subclause without speci- fying how it is contained in a BNF production that the Subclause defines, then Case: - If the BNF nonterminal is itself defined in the Subclause, then the reference shall be assumed to be the occurrence of that BNF nonterminal on the left side of the defining production. - Otherwise, the reference shall be assumed to be to a BNF pro- duction in which the particular BNF nonterminal is immediately contained. 3.3.4.7 Other terms Some Syntax Rules define terms, such as T1, to denote named or unnamed tables. Such terms are used as table names or correlation names. Where such a term is used as a correlation name, it does not imply that any new correlation name is actually defined for the denoted table, nor does it affect the scopes of any actual correlation names. An SQL-statement S1 is said to be executed as a direct result of executing an SQL-statement if S1 is the SQL-statement contained in a that has been executed, or if S1 is the value of an referenced by an contained in a that has been executed, or if S1 was the value of the that was associ- ated with an by a and that same is referenced by an contained in a that has been executed. 3.3.5 Descriptors A descriptor is a conceptual structured collection of data that defines the attributes of an instance of an object of a specified type. The concept of descriptor is used in specifying the seman- tics of SQL. It is not necessary that any descriptor exist in any particular form in any database or environment. Some SQL objects cannot exist except in the context of other SQL objects. For example, columns cannot exist except in tables. Those objects are independently described by descriptors, and the de- scriptors of enabling objects (e.g., tables) are said to include the descriptors of enabled objects (e.g., columns or table con- straints). Conversely, the descriptor of an enabled object is said to be included in the descriptor of an enabling object. 14 Database Language SQL X3H2-92-154/DBL CBR-002 3.3 Conventions In other cases, certain SQL objects cannot exist unless some other SQL object exists, even though there is not an inclusion relation- ship. For example, SQL does not permit an assertion to exist if the tables referenced by the assertion do not exist. Therefore, an as- sertion descriptor is dependent on or depends on zero or more table descriptors (equivalently, an assertion is dependent on or depends on zero or more tables). In general, a descriptor D1 can be said to depend on, or be dependent on, some descriptor D2. There are two ways of indicating dependency of one construct on another. In many cases, the descriptor of the dependent construct is said to "include the name of" the construct on which it is de- pendent. In this case "the name of" is to be understood as meaning "sufficient information to identify the descriptor of"; thus an implementor might choose to use a pointer or a concatenation of , , etc. Alternatively, the descrip- tor may be said to include text (e.g., , ). In such cases, whether the implementation includes ac- tual text (with defaults and implications made explicit) or its own style of parse tree is irrelevant; the validity of the descriptor is clearly "dependent on" the existence of descriptors for objects that are referred to in it. The statement that a column "is based on" a domain, is equivalent to a statement that a column "is dependent on" that domain. An attempt to destroy a descriptor may fail if other descriptors are dependent on it, depending on how the destruction is specified. Such an attempt may also fail if the descriptor to be destroyed is included in some other descriptor. Destruction of a descriptor results in the destruction of all descriptors included in it, but has no effect on descriptors on which it is dependent. 3.3.6 Index typography In the Index to this International Standard, the following conven- tions are used: - Index entries appearing in boldface indicate the page where the word, phrase, or BNF nonterminal was defined; - Index entries appearing in italics indicate a page where the BNF nonterminal was used in a Format; and - Index entries appearing in roman type indicate a page where the word, phrase, or BNF nonterminal was used in a heading, Function, Syntax Rule, Access Rule, General Rule, Leveling Rule, Table, or other descriptive text. Definitions, notations, and conventions 15 X3H2-92-154/DBL CBR-002 3.4 Object identifier for Database Language SQL 3.4 Object identifier for Database Language SQL Function The object identifier for Database Language SQL identifies the characteristics of an SQL-implementation to other entities in an open systems environment. Format ::= ::= ::= iso | 1 | iso 1 ::= standard | 0 | standard 0 ::= 9075 ::= ::= <1987> | <1989> | <1992> <1987> ::= 0 | edition1987 0 <1989> ::= <1989 base> <1989 package> <1989 base> ::= 1 | edition1989 1 <1989 package> ::= | ::= 0 | IntegrityNo 0 ::= 1 | IntegrityYes 1 <1992> ::= 2 | edition1992 2 ::= | | ::= 0 | Low 0 ::= 1 | Intermediate 1 ::= 2 | High 2 16 Database Language SQL X3H2-92-154/DBL CBR-002 3.4 Object identifier for Database Language SQL Syntax Rules 1) An of shall not be specified unless the is specified as <1992>. 2) The value of identifies the level at which conformance is claimed as follows: a) If specifies <1992>, then Case: i) , then Entry SQL level. ii) , then Intermediate SQL level. iii) , then Full SQL level. b) Otherwise: i) , then level 1. ii) , then level 2. 3) A specification of <1989 package> as implies that the integrity enhancement feature is not implemented. A specification of <1989 package> as implies that the integrity enhancement feature is implemented. Definitions, notations, and conventions 17 X3H2-92-154/DBL CBR-002 18 Database Language SQL X3H2-92-154/DBL CBR-002 4 Concepts 4.1 Data types A data type is a set of representable values. The logical represen- tation of a value is a . The physical representation of a value is implementation-dependent. A value is primitive in that it has no logical subdivision within this International Standard. A value is a null value or a non-null value. A null value is an implementation-dependent special value that is distinct from all non-null values of the associated data type. There is effectively only one null value and that value is a member of every SQL data type. There is no for a null value, although the keyword NULL is used in some places to indicate that a null value is desired. SQL defines distinct data types named by the following s: CHARACTER, CHARACTER VARYING, BIT, BIT VARYING, NUMERIC, DECIMAL, INTEGER, SMALLINT, FLOAT, REAL, DOUBLE PRECISION, DATE, TIME, TIMESTAMP, and INTERVAL. Subclause 6.1, "", describes the semantic properties of each data type. For reference purposes, the data types CHARACTER and CHARACTER VARYING are collectively referred to as character string types. The data types BIT and BIT VARYING are collectively referred to as bit string types. Character string types and bit string types are collectively referred to as string types and values of string types are referred to as strings. The data types NUMERIC, DECIMAL, INTEGER, and SMALLINT are collectively referred to as exact numeric types. The data types FLOAT, REAL, and DOUBLE PRECISION are col- lectively referred to as approximate numeric types. Exact numeric types and approximate numeric types are collectively referred to as numeric types. Values of numeric type are referred to as numbers. The data types DATE, TIME, and TIMESTAMP are collectively referred to as datetime types. Values of datetime types are referred to as datetimes. The data type INTERVAL is referred to as an interval type. Values of interval types are called intervals. Each data type has an associated data type descriptor. The contents of a data type descriptor are determined by the specific data type that it describes. A data type descriptor includes an identifica- tion of the data type and all information needed to characterize an instance of that data type. Concepts 19 X3H2-92-154/DBL CBR-002 4.1 Data types Each host language has its own data types, which are separate and distinct from SQL data types, even though similar names may be used to describe the data types. Mappings of SQL data types to data types in host languages are described in Subclause 12.3, "", and Subclause 19.1, "". Not every SQL data type has a corresponding data type in every host language. 4.2 Character strings A character string data type is described by a character string data type descriptor. A character string data type descriptor con- tains: - the name of the specific character string data type (CHARACTER or CHARACTER VARYING; NATIONAL CHARACTER and NATIONAL CHARACTER VARYING are represented as CHARACTER and CHARACTER VARYING, respectively); - the length or maximum length in characters of the character string data type; - the catalog name, schema name, and character set name of the character set of the character string data type; and - the catalog name, schema name, and collation name of the colla- tion of the character string data type. Character sets fall into three categories: those defined by na- tional or international standards, those provided by implemen- tations, and those defined by applications. All character sets, however defined, always contain the character. Character sets defined by applications can be defined to "reside" in any schema chosen by the application. Character sets defined by stan- dards or by implementations reside in the Information Schema (named INFORMATION_SCHEMA) in each catalog, as do collations defined by standards and collations and form-of-use conversions defined by implementations. The SQL_TEXT specifies the name of a character repertoire and implied form-of- use that can represent every character that is in and all other characters that are in character sets supported by the implementation. 4.2.1 Character strings and collating sequences A character string is a sequence of characters chosen from the same character repertoire. The character repertoire from which the characters of a particular string are chosen may be specified explicitly or implicitly. A character string has a length, which is the number of characters in the sequence. The length is 0 or a positive integer. 20 Database Language SQL X3H2-92-154/DBL CBR-002 4.2 Character strings All character strings of a given character repertoire are mutu- ally comparable, subject to the restrictions specified in Table 3, "Collating sequence usage for comparisons". A collating sequence, also known as a collation, is a set of rules determining comparison of character strings in a particular char- acter repertoire. There is a default collating sequence for each character repertoire, but additional collating sequences can be defined for any character repertoire. Note: A column may be defined as having a default collating se- quence. This default collating sequence for the column may be different from the default collating sequence for its character repertoire, e.g., if the is specified in the . It will be clear from context when the term "default collating sequence" is used whether it is meant for a column or for a character repertoire. Given a collating sequence, two character strings are identical if and only if they are equal in accordance with the comparison rules specified in Subclause 8.2, "". The collat- ing sequence used for a particular comparison is determined as in Subclause 4.2.3, "Rules determining collating sequence usage". The s NATIONAL CHARACTER are used to specify a character string data type with a particular implementation-defined character repertoire. Special syntax (N'string') is provided for representing literals in that character repertoire. A character set is described by a character set descriptor. A char- acter set descriptor includes: - the name of the character set or character repertoire, - if the character set is a character repertoire, then the name of the form-of-use, - an indication of what characters are in the character set, and - the name of the default collation of the character set. For every character set, there is at least one collation. A colla- tion is described by a collation descriptor. A collation descriptor includes: - the name of the collation, - the name of the character set on which the collation operates, - whether the collation has the NO PAD or the PAD SPACE attribute, and - an indication of how the collation is performed. Concepts 21 X3H2-92-154/DBL CBR-002 4.2 Character strings 4.2.2 Operations involving character strings 4.2.2.1 Operators that operate on character strings and return character strings is an operator, |, that returns the char- acter string made by joining its character string operands in the order given. is a triadic function, SUBSTRING, that returns a string extracted from a given string according to a given numeric starting position and a given numeric length. Truncation occurs when the implied starting and ending positions are not both within the given string. is a pair of functions for converting all the lower case characters in a given string to upper case (UPPER) or all the upper case ones to lower case (LOWER), useful only in connection with strings that may contain s. is a function that invokes an installation- supplied form-of-use conversion to return a character string S2 derived from a given character string S1. It is intended, though not enforced by this International Standard, that S2 be exactly the same sequence of characters as S1, but encoded according some dif- ferent form-of-use. A typical use might be to convert a character string from two-octet UCS to one-octet Latin1 or vice versa. is a function that returns its first string ar- gument with leading and/or trailing pad characters removed. The second argument indicates whether leading, or trailing, or both leading and trailing pad characters should be removed. The third argument specifies the pad character that is to be removed. is a function for changing each charac- ter of a given string according to some many-to-one or one-to-one mapping between two not necessarily distinct character sets. The mapping, rather than being specified as part of the function, is some external function identified by a . For any pair of character sets, there are zero or more translations that may be invoked by a . A translation is described by a translation descriptor. A translation descriptor includes: - the name of the translation, - the name of the character set from which it translates, - the name of the character set to which it translates, and - an indication of how the translation is performed. 22 Database Language SQL X3H2-92-154/DBL CBR-002 4.2 Character strings 4.2.2.2 Other operators involving character strings returns the length of a given character string, as an integer, in characters, octets, or bits according to the choice of function. determines the first position, if any, at which one string, S1, occurs within another, S2. If S1 is of length zero, then it occurs at position 1 for any value of S2. If S1 does not occur in S2, then zero is returned. uses the triadic operator LIKE (or the inverse, NOT LIKE), operating on three character strings and returning a Boolean. LIKE determines whether or not a character string "matches" a given "pattern" (also a character string). The char- acters '%' (percent) and '_' (underscore) have special meaning when they occur in the pattern. The optional third argument is a charac- ter string containing exactly one character, known as the "escape character", for use when a percent or underscore is required in the pattern without its special meaning. 4.2.3 Rules determining collating sequence usage The rules determining collating sequence usage for character strings are based on the following: - Expressions where no columns are involved (e.g., literals, host variables) are by default compared using the default collating sequence for their character repertoire. Note: The default collating sequence for a character repertoire is defined in Subclause 10.4, "", and Subclause 11.28, "". - When columns are involved (e.g., comparing two columns, or com- paring a column to a literal), by default the default collating sequence of the columns involved is used so long as the columns have the same default collating sequence. - When columns are involved having different default collating sequences, explicit specification of the collating sequence in the expression is required via the when the expression participates in a comparison. - Any explicit specification of collating sequence in an expres- sion overrides any default collating sequence. To formalize this, s effectively have a coercibility attribute. This attribute has the values Coercible, Implicit, No collating sequence, and Explicit. s with the Coercible, Implicit, or Explicit attributes have a collating sequence. Concepts 23 X3H2-92-154/DBL CBR-002 4.2 Character strings A consisting of a column reference has the Implicit attribute, with collating sequence as defined when the column was created. A consisting of a value other than a column (e.g., a host variable or a literal) has the Coercible attribute, with the default collation for its char- acter repertoire. A simply containing a has the Explicit attribute, with the collating sequence specified in the . Note: When the coercibility attribute is Coercible, the collating sequence is uniquely determined as specified in Subclause 8.2, "". The tables below define how the collating sequence and the co- ercibility attribute is determined for the result of any monadic or dyadic operation. Table 1, "Collating coercibility rules for monadic operators", shows the collating sequence and coercibility rules for monadic operators, and Table 2, "Collating coercibil- ity rules for dyadic operators", shows the collating sequence and coercibility rules for dyadic operators. Table 3, "Collating se- quence usage for comparisons", shows how the collating sequence is determined for a particular comparison. _____Table_1-Collating_coercibility_rules_for_monadic_operators____ Operand Coercibility Result Coercibility _____and_Collating_Sequence_____ _____and_Collating_Sequence___ | Collating | Collating | |_Coercibility______Sequence______|_Coercibility______Sequence_____| | | | | Coercible | default | Coercible | default | | | | | | | Implicit | X | Implicit | X | | | | | | | Explicit | X | Explicit | X | | | | | | |_______No_collati|g_sequence_____|______No_collatin|_sequence_____| | | | | | _____Table_2-Collating_coercibility_rules_for_dyadic_operators_____ Result Coercibility Operand 1 Coercibility Operand 2 Coercibility and Collating _and_Collating_Sequence _and_Collating_Sequence ___Sequence___ | Collating | Collating | Col|ating |_Coercibility_Sequence__|_Coercibility_Sequence__|__CoercibilitySe|uence | | | | | Coercible | default | Coercible | default | Coercible| def|ult | | | | | | | | Coercible | default | Implicit | Y | Implicit | Y | | | | | | | | | Coercible | default | No collati|g sequence | No colla|ing | sequence 24 Database Language SQL X3H2-92-154/DBL CBR-002 4.2 Character strings _Table_2-Collating_coercibility_rules_for_dyadic_operators_(Cont.)_ Result Coercibility Operand 1 Coercibility Operand 2 Coercibility and Collating _and_Collating_Sequence _and_Collating_Sequence ___Sequence___ | Collating | Collating | Col|ating |_Coercibility_Sequence__|_Coercibility_Sequence__|__CoercibilitySe|uence | | | | | Coercible | default | Explicit | Y | Explicit | Y | | | | | | | | | Implicit | X | Coercible | default | Implicit | X | | | | | | | | | Implicit | X | Implicit | X | Implicit | X | | | | | | | | | Implicit | X | Implicit | Y /= X | No colla|ing | sequence | Implicit | X | No collati|g sequence | No collating | | | | | | sequence | | | | | | | | Implicit | X | Explicit Y | Explicit Y | | | | | | | No collati|g sequence | Any, | Any | No colla|ing | except sequence Explicit | No collating sequence | Explicit | X | Explicit X | | | | | | | Explicit X | Coercible | default | Explicit | X | | | | | | | | Explicit | X | Implicit | Y | Explicit | X | | | | | | | | | Explicit | X | No collati|g sequence | Explicit | X | | | | | | | | | Explicit | X | Explicit X | Explicit | X | | | | | | | | Explicit | X | Explicit | Y /= X | Not permi|ted:| ____________________________________________________invalid_syntax_ |__________Ta|le_3-Collat|ng_sequence_|sage_for_co|parisons________| Comparand 1 Comparand 2 Coercibility and Coercibility and _Collating_Sequence _Collating_Sequence | | | Collating Sequence | | Collatin| Collatin| Used For The | |_CoercibilitSequence|_CoercibilitSequence|__Comparison____________| | | | | | Coercible| default | Coercible| default | default | | | | | | | | Coercible| default | Implicit | Y | Y | | | | | | | | Coercible| default | No co|lating | Not permitted: invalid| sequence syntax | Coercible| default | Explicit Y | Y | | | | | | Concepts 25 X3H2-92-154/DBL CBR-002 4.2 Character strings ______Table_3-Collating_sequence_usage_for_comparisons_(Cont.)_____ Comparand 1 Comparand 2 Coercibility and Coercibility and _Collating_Sequence _Collating_Sequence | | | Collating Sequence | | Collatin| Collatin| Used For The | |_CoercibilitSequence|_CoercibilitSequence|__Comparison____________| | | | | | Implicit | X | Coercible| default | X | | | | | | | | Implicit | X | Implicit | X | X | | | | | | | | Implicit | X | Implicit | Y /= X | Not permitted: invalid| syntax | Implicit | X | No co|lating | Not permitted: invalid| | | | seq|ence | syntax | | | | | | | | Implicit | X | Explicit Y | Y | | | | | | | No co|lating | Any | Any | Not permitted: invalid| sequence except syntax Explicit | No collating | Explicit | X | X | | sequence | | | | | | | | | | Explicit X | Coercible| default | X | | | | | | | Explicit | X | Implicit | Y | X | | | | | | | | Explicit | X | No co|lating | X | sequence | Explicit | X | Explicit X | X | | | | | | | Explicit | X | Explicit | Y /= X | Not permitted: invalid| ____________________________________________syntax_________________ |For n-adic|operation| (e.g., ) with operands X1, | X2, . . . , n , the collating sequence is effectively determined by considering X1 and X2, then combining this result with X3, and so on. 4.3 Bit strings A bit string is a sequence of bits, each having the value of 0 or 1. A bit string has a length, which is the number of bits in the string. The length is 0 or a positive integer. A bit string data type is described by a bit string data type de- scriptor. A bit string data type descriptor contains: - the name of the specific bit string data type (BIT or BIT VARYING); and 26 Database Language SQL X3H2-92-154/DBL CBR-002 4.3 Bit strings - the length of the bit string data type (in bits). 4.3.1 Bit string comparison and assignment All bit strings are mutually comparable. A bit string is identical to another bit string if and only if it is equal to that bit string in accordance with the comparison rules specified in Subclause 8.2, "". Assignment of a bit string to a bit string variable is performed from the most significant bit to the least significant bit in the source string to the most significant bit in the target string, one bit at a time. 4.3.2 Operations involving bit strings 4.3.2.1 Operators that operate on bit strings and return bit strings is an operator, |, that returns the bit string made by concatenating the two bit string operands in the order given. is a triadic function identical in syntax and semantics to except that the first argument and the returned value are both bit strings. 4.3.2.2 Other operators involving bit strings returns the length (as an integer number of octets or bits according to the choice of function) of a given bit string. determines the first position, if any, at which one string, S1, occurs within another, S2. If S1 is of length zero, then it occurs at position 1 for any value of S2. If S1 does not occur in S2, then zero is returned. 4.4 Numbers A number is either an exact numeric value or an approximate numeric value. Any two numbers are mutually comparable to each other. A numeric data type is described by a numeric data type descriptor. A numeric data type descriptor contains: - the name of the specific numeric data type (NUMERIC, DECIMAL, INTEGER, SMALLINT, FLOAT, REAL, or DOUBLE PRECISION); - the precision of the numeric data type; Concepts 27 X3H2-92-154/DBL CBR-002 4.4 Numbers - the scale of the numeric data type, if it is an exact numeric data type; and - an indication of whether the precision (and scale) are expressed in decimal or binary terms. 4.4.1 Characteristics of numbers An exact numeric value has a precision and a scale. The precision is a positive integer that determines the number of significant digits in a particular radix (binary or decimal). The scale is a non-negative integer. A scale of 0 indicates that the number is an integer. For a scale of S, the exact numeric value is the integer value of the significant digits multiplied by 10-S. An approximate numeric value consists of a mantissa and an expo- nent. The mantissa is a signed numeric value, and the exponent is a signed integer that specifies the magnitude of the mantissa. An approximate numeric value has a precision. The precision is a posi- tive integer that specifies the number of significant binary digits in the mantissa. The value of an approximate numeric value is the mantissa multiplied by 10exponent. Whenever an exact or approximate numeric value is assigned to a data item or parameter representing an exact numeric value, an approximation of its value that preserves leading significant dig- its after rounding or truncating is represented in the data type of the target. The value is converted to have the precision and scale of the target. The choice of whether to truncate or round is implementation-defined. An approximation obtained by truncation of a numerical value N for an T is a value V representable in T such that N is not closer to zero than the numerical value of V and such that the absolute value of the difference between N and the numer- ical value of V is less than the absolute value of the difference between two successive numerical values representable in T. An approximation obtained by rounding of a numerical value N for an T is a value V representable in T such that the absolute value of the difference between N and the nu- merical value of V is not greater than half the absolute value of the difference between two successive numerical values repre- sentable in T. If there are more than one such values V, then it is implementation-defined which one is taken. All numerical values between the smallest and the largest value, inclusive, representable in a given exact numeric type have an approximation obtained by rounding or truncation for that type; it is implementation-defined which other numerical values have such approximations. 28 Database Language SQL X3H2-92-154/DBL CBR-002 4.4 Numbers An approximation obtained by truncation or rounding of a numerical value N for an T is a value V repre- sentable in T such that there is no numerical value representable in T and distinct from that of V that lies between the numerical value of V and N, inclusive. If there are more than one such values V then it is implementation- defined which one is taken. It is implementation-defined which numerical values have approximations obtained by rounding or trun- cation for a given approximate numeric type. Whenever an exact or approximate numeric value is assigned to a data item or parameter representing an approximate numeric value, an approximation of its value is represented in the data type of the target. The value is converted to have the precision of the target. Operations on numbers are performed according to the normal rules of arithmetic, within implementation-defined limits, except as provided for in Subclause 6.12, "". 4.4.2 Operations involving numbers As well as the usual arithmetic operators, plus, minus, times, divide, unary plus, and unary minus, there are the following func- tions that return numbers: - (see Subclause 4.2.2, "Operations involv- ing character strings", and Subclause 4.3.2, "Operations involv- ing bit strings") takes two strings as arguments and returns an integer; - (see Subclause 4.2.2, "Operations involving character strings", and Subclause 4.3.2, "Operations involv- ing bit strings") operates on a string argument and returns an integer; - (see Subclause 4.5.3, "Operations involving datetimes and intervals") operates on a datetime or interval argument and returns an integer. 4.5 Datetimes and intervals A datetime data type is described by a datetime data type descrip- tor. An interval data type is described by an interval data type descriptor. A datetime data type descriptor contains: - the name of the specific datetime data type (DATE, TIME, TIMESTAMP, TIME WITH TIME ZONE, or TIMESTAMP WITH TIME ZONE); and Concepts 29 X3H2-92-154/DBL CBR-002 4.5 Datetimes and intervals - the value of the
that does not specify TEMPORARY. A derived table is a table derived directly or indirectly from one or more other tables by the evaluation of a . The values of a derived table are derived from the values of the underlying tables when the is evaluated. A viewed table is a named derived table defined by a . A viewed table is sometimes called a view. Concepts 37 X3H2-92-154/DBL CBR-002 4.9 Tables The terms simply underlying table, underlying table, leaf underly- ing table, generally underlying table, and leaf generally underly- ing table define a relationship between a derived table or cursor and other tables. The simply underlying tables of derived tables and cursors are defined in Subclause 7.9, "", Subclause 7.10, "", and Subclause 13.1, "". A viewed table has no simply underlying tables. The underlying tables of a derived table or cursor are the simply underlying tables of the derived table or cursor and the underlying tables of the simply underlying tables of the derived table or cursor. The leaf underlying tables of a derived table or cursor are the underlying tables of the derived table or cursor that do not them- selves have any underlying tables. The generally underlying tables of a derived table or cursor are the underlying tables of the derived table or cursor and, for those underlying tables of the derived table or cursor that are viewed tables, the of each viewed table and the gen- erally underlying tables of the of each viewed table. The leaf generally underlying tables of a derived table or cursor are the generally underlying tables of the derived table or cursor that do not themselves have any generally underlying tables. All base tables are updatable. Derived tables are either updatable or read-only. The operations of insert, update, and delete are permitted for updatable tables, subject to constraining Access Rules. The operations of insert, update, and delete are not allowed for read-only tables. A grouped table is a set of groups derived during the evaluation of a or a . A group is a multiset of rows in which all values of the grouping column or columns are equal if a is specified, or the group is the entire table if no is specified. A grouped table may be considered as a collection of tables. Set functions may operate on the individual tables within the grouped table. A global temporary table is a named table defined by a
that specifies GLOBAL TEMPORARY. A created local temporary table is a named table defined by a
that speci- fies LOCAL TEMPORARY. Global and created local temporary tables are effectively materialized only when referenced in an SQL-session. Every in every SQL-session that references a created local temporary table causes a distinct instance of that created local temporary table to be materialized. That is, the contents of a global temporary table or a created local temporary table cannot be shared between SQL-sessions. In addition, the contents of a cre- ated local temporary table cannot be shared between s of a single SQL-session. The definition of a global temporary table or a created local temporary table appears in a schema. In SQL language, 38 Database Language SQL X3H2-92-154/DBL CBR-002 4.9 Tables the name and the scope of the name of a global temporary table or a created local temporary table are indistinguishable from those of a persistent base table. However, because global temporary ta- ble contents are distinct within SQL-sessions, and created local temporary tables are distinct within s within SQL-sessions, the effective of the schema in which the global tem- porary table or the created local temporary table is instantiated is an implementation-dependent that may be thought of as having been effectively derived from the of the schema in which the global temporary table or created local temporary table is defined and the implementation-dependent SQL- session identifier associated with the SQL-session. In addition, the effective of the schema in which the created local temporary table is instantiated may be thought of as being further qualified by a unique implementation-dependent name associ- ated with the in which the created local temporary table is referenced. A declared local temporary table is a named table defined by a that is effectively materialized the first time any in the that contains the is executed. A declared local tem- porary table is accessible only by s in the that contains the . The effective of the of the declared local tem- porary table may be thought of as the implementation-dependent SQL-session identifier associated with the SQL-session and a unique implementation-dependent name associated with the that contains the . All references to a declared local temporary table are prefixed by "MODULE.". The materialization of a temporary table does not persist beyond the end of the SQL-session in which the table was materialized. Temporary tables are effectively empty at the start of an SQL- session. A table is described by a table descriptor. A table descriptor is either a base table descriptor, a view descriptor, or a derived table descriptor (for a derived table that is not a view). Every table descriptor includes: - the degree of the table (the number of column descriptors); and - the column descriptor of each column in the table. A base table descriptor describes a base table. In addition to the components of every table descriptor, a base table descriptor includes: - the name of the base table; - an indication of whether the table is a persistent base table, a global temporary table, a created local temporary table, or a declared local temporary table; and Concepts 39 X3H2-92-154/DBL CBR-002 4.9 Tables - the descriptor of each table constraint specified for the table. A derived table descriptor describes a derived table. In addi- tion to the components of every table descriptor, a derived table descriptor includes: - if the table is named, then the name of the table; - the that defines how the table is to be de- rived; and - an indication of whether the derived table is updatable or read- only (this is derived from the ); A view descriptor describes a view. In addition to the components of a derived table descriptor, a view descriptor includes: - an indication of whether the view has the CHECK OPTION; if so, whether it is to be applied as CASCADED or LOCAL. 4.10 Integrity constraints Integrity constraints, generally referred to simply as constraints, define the valid states of SQL-data by constraining the values in the base tables. A constraint is either a table constraint, a domain constraint or an assertion. A constraint is described by a constraint descriptor. A constraint descriptor is either a table constraint descriptor, a domain constraint descriptor or an assertion descriptor. Every constraint descriptor includes: - the name of the constraint; - an indication of whether or not the constraint is deferrable; - an indication of whether the initial constraint mode is deferred or immediate; A or is possibly non- deterministic if an implementation might, at two different times where the state of the SQL-data is the same, produce results that differ by more than the order of the rows due to General Rules that specify implementation-dependent behavior. No integrity constraint shall be defined using a or a that is possibly non-deterministic. 40 Database Language SQL X3H2-92-154/DBL CBR-002 4.10 Integrity constraints 4.10.1 Checking of constraints Every constraint is either deferrable or non-deferrable. Within a transaction, every constraint has a constraint mode; if a con- straint is non-deferrable, then its constraint mode is always im- mediate, otherwise it is either or immediate or deferred. Every constraint has an initial constraint mode that specifies the constraint mode for that constraint at the start of each SQL- transaction and immediately after definition of that constraint. If a constraint is deferrable, then its constraint mode may be changed (from immediate to deferred, or from deferred to immediate) by execution of a . The checking of a constraint depends on its constraint mode within the current SQL-transaction. If the constraint mode is immedi- ate, then the constraint is effectively checked at the end of each SQL-statement. If the constraint mode is deferred, then the constraint is effectively checked when the constraint mode is changed to immediate either explicitly by execution of a , or implicitly at the end of the current SQL-transaction. When a constraint is checked other than at the end of an SQL- transaction, if it is not satisfied, then an exception condition is raised and the SQL-statement that caused the constraint to be checked has no effect other than entering the exception information into the diagnostics area. When a is executed, all constraints are effectively checked and, if any constraint is not satisfied, then an exception condition is raised and the transaction is terminated by an implicit . 4.10.2 Table constraints A table constraint is either a unique constraint, a referential constraint or a table check constraint. A table constraint is de- scribed by a table constraint descriptor which is either a unique constraint descriptor, a referential constraint descriptor or a table check constraint descriptor. A unique constraint is described by a unique constraint descriptor. In addition to the components of every table constraint descriptor, a unique constraint descriptor includes: - an indication of whether it was defined with PRIMARY KEY or UNIQUE, and - the names and positions of the unique columns specified in the ; A referential constraint is described by a referential constraint descriptor. In addition to the components of every table constraint descriptor, a referential constraint descriptor includes: Concepts 41 X3H2-92-154/DBL CBR-002 4.10 Integrity constraints - the names of the referencing columns specified in the , - the names of the referenced columns and referenced table speci- fied in the , and - the value of the , if specified, and the , if specified. Note: If MATCH FULL or MATCH PARTIAL is specified for a referential constraint and if the referencing table has only one column spec- ified in for that referential constraint, or if the referencing table has more than one specified column for that , but none of those columns is nullable, then the effect is the same as if no were specified. A table check constraint is described by a table check constraint descriptor. In addition to the components of every table constraint descriptor, a table check constraint descriptor includes: - the . A unique constraint is satisfied if and only if no two rows in a table have the same non-null values in the unique columns. In addition, if the unique constraint was defined with PRIMARY KEY, then it requires that none of the values in the specified column or columns be the null value. In the case that a table constraint is a referential constraint, the table is referred to as the referencing table. The referenced columns of a referential constraint shall be the unique columns of some unique constraint of the referenced table. A referential constraint is satisfied if one of the following con- ditions is true, depending on the specified in the : - If no was specified then, for each row R1 of the referencing table, either at least one of the values of the referencing columns in R1 shall be a null value, or the value of each referencing column in R1 shall be equal to the value of the corresponding referenced column in some row of the referenced table. - If MATCH FULL was specified then, for each row R1 of the refer- encing table, either the value of every referencing column in R1 shall be a null value, or the value of every referencing column in R1 shall not be null and there shall be some row R2 of the referenced table such that the value of each referencing col- umn in R1 is equal to the value of the corresponding referenced column in R2. 42 Database Language SQL X3H2-92-154/DBL CBR-002 4.10 Integrity constraints - If MATCH PARTIAL was specified then, for each row R1 of the referencing table, there shall be some row R2 of the refer- enced table such that the value of each referencing column in R1 is either null or is equal to the value of the corresponding referenced column in R2. The referencing table may be the same table as the referenced ta- ble. A table check constraint is satisfied if and only if the specified is not false for any row of a table. 4.10.3 Domain constraints A domain constraint is a constraint that is specified for a domain. It is applied to all columns that are based on that domain, and to all values cast to that domain. A domain constraint is described by a domain constraint descriptor. In addition to the components of every constraint descriptor a domain constraint descriptor includes: - the . A domain constraint is satisfied by SQL-data if and only if, for any table T that has a column named C based on that domain, the specified , with each occurrence of VALUE re- placed by C, is not false for any row of T. A domain constraint is satisfied by the result of a if and only if the specified , with each occurrence of VALUE replaced by that result, is not false. 4.10.4 Assertions An assertion is a named constraint that may relate to the content of individual rows of a table, to the entire contents of a table, or to a state required to exist among a number of tables. An assertion is described by an assertion descriptor. In addi- tion to the components of every constraint descriptor an assertion descriptor includes: - the . An assertion is satisfied if and only if the specified is not false. Concepts 43 X3H2-92-154/DBL CBR-002 4.11 SQL-schemas 4.11 SQL-schemas An SQL-schema is a persistent descriptor that includes: - the of the SQL-schema; - the of the owner of the SQL-schema; - The of the default character set for the SQL-schema; and - the descriptor of every component of the SQL-schema. In this International Standard, the term "schema" is used only in the sense of SQL-schema. Each component descriptor is either a domain descriptor, a base table descriptor, a view descriptor, an assertion descriptor, a privilege descriptor, a character set descriptor, a collation descriptor, or a translation descriptor. The persistent objects described by the descriptors are said to be owned by or to have been created by the of the schema. A schema is created initially using a and may be subsequently modified incrementally over time by the execution of s. s are unique within a catalog. A is explicitly or implicitly qualified by a that identifies a catalog. Base tables and views are identified by
s. A
consists of a and an . For a per- sistent table, the identifies the schema in which the base table or view identified by the
was de- fined. Base tables and views defined in different schemas can have s that are equal according to the General Rules of Subclause 8.2, "". If a reference to a
does not explicitly contain a , then a specific is implied. The par- ticular associated with such a
depends on the context in which the
appears and is governed by the rules for . The default schema for s that are dynamically prepared in the current SQL- session through the execution of s and s is initially implementation-defined but may be changed by the use of s. 44 Database Language SQL X3H2-92-154/DBL CBR-002 4.12 Catalogs 4.12 Catalogs Catalogs are named collections of schemas in an SQL-environment. An SQL-environment contains zero or more catalogs. A catalog con- tains one or more schemas, but always contains a schema named INFORMATION_SCHEMA that contains the views and domains of the Information Schema. The method of creation and destruction of catalogs is implementation-defined. The set of catalogs that can be referenced in any SQL-statement, during any particular SQL-transaction, or during the course of an SQL-session is also implementation-defined. The default catalog for a whose does not specify an explicit to qualify the is implementation-defined. The default catalog for s that are dynami- cally prepared in the current SQL-session through the execution of s and s is ini- tially implementation-defined but may be changed by the use of s. 4.13 Clusters of catalogs A cluster is an implementation-defined collection of catalogs. Exactly one cluster is associated with an SQL-session and it defines the totality of the SQL-data that is available to that SQL-session. An instance of a cluster is described by an instance of a defi- nition schema. Given some SQL-data object, such as a view, a con- straint, a domain, or a base table, the definition of that object, and of all the objects that it directly or indirectly references, are in the same cluster of catalogs. For example, no and no can "cross" a cluster boundary. Whether or not any catalog can occur simultaneously in more than one cluster is implementation-defined. Within a cluster, no two catalogs have the same name. 4.14 SQL-data SQL-data is any data described by schemas that is under the control of an SQL-implementation in an SQL-environment. Concepts 45 X3H2-92-154/DBL CBR-002 4.15 SQL-environment 4.15 SQL-environment An SQL-environment comprises the following: - an SQL-implementation capable of processing some Level (Entry SQL, Intermediate SQL, or Full SQL) of this International Standard and at least one binding style; see Clause 23, "Conformance" for further information about binding styles; - zero or more catalogs; - zero or more s; - zero or more s; and - the SQL-data described by the schemas in the catalogs. An SQL-environment may have other implementation-defined contents. The rules determining which s are considered to be within an SQL-environment are implementation-defined. 4.16 Modules A is an object specified in the module language. A is either a persistent or an SQL-session . The mechanisms by which s are created or destroyed are implementation-defined. A consists of an optional , a , a with either or both of a and a , an optional that iden- tifies the character repertoire used for expressing the names of schema objects used in the , zero or more s, zero or more cursors specified by s, and one or more s. All s contained in the are expressed in either or the character repertoire indicated by unless they are specified with "". A compilation unit is a segment of executable code, possibly con- sisting of one or more subprograms. A is associated with a compilation unit during its execution. A single may be associated with multiple compilation units and multiple s may be associated with a single compilation unit. The manner in which this association is specified, including the possible re- quirement for execution of some implementation-defined statement, is implementation-defined. Whether a compilation unit may invoke or transfer control to other compilation units, written in the same or a different programming language, is implementation-defined. 46 Database Language SQL X3H2-92-154/DBL CBR-002 4.17 Procedures 4.17 Procedures A consists of a , a sequence of s, and a single . A in a is invoked by a compilation unit as- sociated with the by means of a host language "call" statement that specifies the of the and supplies a sequence of parameter values corresponding in number and in to the s of the . A call of a causes the that it contains to be executed. 4.18 Parameters A parameter is declared in a by a . The specifies the of its value. A parameter either assumes or supplies the value of the corresponding argument in the call of that . These s map to host language types and are not nullable except through the use of additional indicator variables. 4.18.1 Status parameters The SQLSTATE and SQLCODE parameters are status parameters. They are set to status codes that indicate either that a call of the completed successfully or that an exception condition was raised during execution of the . Note: The SQLSTATE parameter is the preferred status parameter. The SQLCODE parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". A shall specify either the SQLSTATE parameter or the SQLCODE parameter or both. The SQLSTATE parameter is a charac- ter string parameter for which exception values are defined in Clause 22, "Status codes". The SQLCODE parameter is an integer pa- rameter for which the negative exception values are implementation- defined. If a condition is raised that causes a statement to have no effect other than that associated with raising the condition (that is, not a completion condition), then the condition is said to be an exception condition or exception. If a condition is raised that permits a statement to have an effect other than that associated with raising the condition (corresponding to an SQLSTATE class value of successful completion, warning, or no data), then the condition is said to be a completion condition. Concepts 47 X3H2-92-154/DBL CBR-002 4.18 Parameters 4.18.2 Data parameters A data parameter is a parameter that is used to either assume or supply the value of data exchanged between a host program and an SQL-implementation. 4.18.3 Indicator parameters An indicator parameter is an integer parameter that is specified immediately following another parameter. Its primary use is to indicate whether the value that the other parameter assumes or supplies is a null value. An indicator parameter cannot immediately follow another indicator parameter. The other use for indicator parameters is to indicate whether string data truncation occurred during a transfer between a host program and an SQL-implementation in parameters or host variables. If a non-null string value is transferred and the length of the target data item is sufficient to accept the entire source data item, then the indicator parameter or variable is set to 0 to in- dicate that truncation did not occur. However, if the length of the target data item is insufficient, then the indicator parame- ter or variable is set to the length of the source data item (in characters or bits, as appropriate) to indicate that truncation occurred and to indicate the original length in characters or bits, as appropriate, of the source. 4.19 Diagnostics area The diagnostics area is a place where completion and exception con- dition information is stored when an SQL-statement is executed. There is one diagnostics area associated with an SQL-agent, regard- less of the number of s that the SQL-agent includes or the number of connections in use. At the beginning of the execution of any statement that is not an , the diagnostics area is emptied. An implementation shall place information about a completion condition or an exception condition reported by SQLCODE or SQLSTATE into this area. If other conditions are raised, an implementation may place information about them into this area. s containing s return a code indicating completion or exception conditions for that statement via SQLCODE or SQLSTATE, but do not modify the diagnostics area. An SQL-agent may choose the size of the diagnostics area with the ; if an SQL-agent does not specify the size of the diagnostics area, then the size of the diagnostics area is implementation-dependent, but shall always be able to hold information about at least one condition. An implementation may place information into this area about fewer conditions than are specified. The ordering of the information about conditions placed 48 Database Language SQL X3H2-92-154/DBL CBR-002 4.19 Diagnostics area into the diagnostics area is implementation-dependent, except that the first condition in the diagnostics area always corresponds to the condition specified by the SQLSTATE or SQLCODE value. 4.20 Standard programming languages This International Standard specifies the actions of s in s when those s are called by programs that conform to certain specified programming language standards. The term "standard PLN program", where PLN is the name of a program- ming language, refers to a program that conforms to the standard for that programming language as specified in Clause 2, "Normative references". This International Standard also specifies a mechanism whereby SQL language may be embedded in programs that otherwise conform to any of the same specified programming language stan- dards. Note: In this International Standard, for the purposes of inter- facing with programming languages, the data types DATE, TIME, TIMESTAMP, and INTERVAL shall be converted to or from character strings in those programming languages by means of a . It is anticipated that future evolution of programming language standards will support data types corresponding to these four SQL data types; this standard will then be amended to reflect the availability of those corresponding data types. The data type CHARACTER is also mapped to character strings in the programming languages. However, because the facilities available in the pro- gramming languages do not provide the same capabilities as those available in SQL, there shall be agreement between the host pro- gram and SQL regarding the specific format of the character data being exchanged. Specific syntax for this agreement is provided in this International standard. For standard programming lan- guages, C, COBOL, Fortran, and Pascal, bit strings are mapped to character variables in the host language in a manner described in Subclause 19.1, "". For standard pro- gramming languages Ada and PL/I, bit string variables are directly supported. 4.21 Cursors A cursor is specified by a , , or . For every or in a , a cursor is effectively created when an SQL-transaction (see Subclause 4.28, "SQL-transactions") referencing the is initiated, and destroyed when that SQL-transaction is terminated. A cursor is also effectively created when an is executed within a SQL-transaction and destroyed when that SQL-transaction is terminated. In addition, an extended dynamic Concepts 49 X3H2-92-154/DBL CBR-002 4.21 Cursors cursor is destroyed when a is exe- cuted that deallocates the prepared statement on which the extended dynamic cursor is based. A cursor is in either the open state or the closed state. The ini- tial state of a cursor is the closed state. A cursor is placed in the open state by an or and returned to the closed state by a or , a , or a . A cursor in the open state identifies a table, an ordering of the rows of that table, and a position relative to that ordering. If the does not include an , or includes an that does not specify the order of the rows completely, then the rows of the table have an order that is defined only to the extent that the specifies an order and is otherwise implementation-dependent. When the ordering of a cursor is not defined by an , the relative positions of two rows is implementation- dependent. When the ordering of a cursor is partially determined by an , then the relative positions of two rows are determined only by the ; if the two rows have equal values for the purpose of evaluating the , then their relative positions are implementation-dependent. A cursor is either read-only or updatable. If the table identified by a cursor is not updatable or if INSENSITIVE is specified for the cursor, then the cursor is read-only; otherwise, the cursor is updatable. The operations of update and delete are not allowed for read-only cursors. The position of a cursor in the open state is either before a cer- tain row, on a certain row, or after the last row. If a cursor is on a row, then that row is the current row of the cursor. A cursor may be before the first row or after the last row of a table even though the table is empty. When a cursor is initially opened, the position of the cursor is before the first row. A or positions an open cursor on a specified row of the cursor's ordering and retrieves the values of the columns of that row. An or updates the current row of the cursor. A or deletes the current row of the cursor. If an error occurs during the execution of an SQL-statement that identifies an open cursor, then, except where otherwise explic- itly defined, the effect, if any, on the position or state of that cursor is implementation-dependent. If a cursor is open, and the current SQL-transaction makes a change to SQL-data other than through that cursor, and the for that cursor specified INSENSITIVE, then the effect of that change will not be visible through that cursor before it is closed. Otherwise, whether the effect of such a change will be 50 Database Language SQL X3H2-92-154/DBL CBR-002 4.21 Cursors visible through that cursor before it is closed is implementation- dependent. 4.22 SQL-statements 4.22.1 Classes of SQL-statements An SQL-statement is a string of characters that conforms to the format and syntax rules specified in this international standard. Most SQL-statements can be prepared for execution and executed in one of a number of ways. These are: - in a , in which case it is prepared when the is created (see Subclause 4.16, "Modules") and executed when the containing procedure is called. - in an embedded SQL host program, in which case it is pre- pared when the embedded SQL host program is preprocessed (see Subclause 4.23, "Embedded syntax"). - being prepared and executed by the use of SQL-dynamic statements (which are themselves executed in one of the foregoing two ways- see Subclause 4.24, "SQL dynamic statements"). - direct invocation, in which case it is effectively prepared immediately prior to execution (see Subclause 4.25, "Direct invocation of SQL"). There are at least five ways of classifying SQL-statements: - According to their effect on SQL objects, whether persistent objects, i.e., SQL-data and schemas, or transient objects, such as SQL-sessions and other SQL-statements. - According to whether or not they start a transaction, or can, or must, be executed when no transaction is active. - According to whether or not they may be embedded. - According to whether they may be dynamically prepared and exe- cuted. - According to whether or not they may be directly executed. This International Standard permits implementations to provide ad- ditional, implementation-defined, statements that may fall into any of these categories. This Subclause will not mention those state- ments again, as their classification is entirely implementation- defined. Concepts 51 X3H2-92-154/DBL CBR-002 4.22 SQL-statements 4.22.2 SQL-statements classified by function The following are the main classes of SQL-statements: - SQL-schema statements; these may have a persistent effect on schemas - SQL-data statements; some of these, the SQL-data change state- ments, may have a persistent effect on SQL-data - SQL-transaction statements; except for the , these, and the following classes, have no effects that persist when a session is terminated - SQL-connection statements - SQL-session statements - SQL-dynamic statements - SQL-diagnostics statements - SQL embedded exception declaration The following are the SQL-schema statements: - - - - -
- - - - - - - - - - - 52 Database Language SQL X3H2-92-154/DBL CBR-002 4.22 SQL-statements - - - - The following are the SQL-data statements: - - - - - - - - - - - - o o o o o o o Concepts 55 X3H2-92-154/DBL CBR-002 4.22 SQL-statements The following SQL-statements are embeddable in an embedded SQL host program, and may occur in a , though not in a : - - - The following SQL-statements are embeddable in an embedded SQL host program, but may not occur in a : - SQL embedded exception declarations Consequently, the following SQL-data statements are not embeddable in an embedded SQL host program, nor may they occur in a , nor be the in a in a : - - - - - 4.22.4 Preparable and immediately executable SQL-statements The following SQL-statements are preparable: - All SQL-schema statements - All SQL-transaction statements - All SQL-session statements - The following SQL-data statements: o o o o o o o o 56 Database Language SQL X3H2-92-154/DBL CBR-002 4.22 SQL-statements Consequently, the following SQL-statements are not preparable: - All SQL-connection statements - All SQL-dynamic statements - All SQL-diagnostics statements - SQL embedded exception declarations - The following SQL-data statements: o o o o o o o o o o 58 Database Language SQL X3H2-92-154/DBL CBR-002 4.22 SQL-statements o o o o o o 4.22.6 SQL-statements and transaction states Whether an starts a transaction de- pends on what SQL-statement is the value of . Whether an starts a transaction depends on what SQL-statement was the value of when the prepared statement identified by was prepared. The following SQL-statements are transaction initiating SQL- statements, i.e., if there is no current transaction, and a state- ment of this class is executed, a transaction is initiated: - All SQL-schema statements - The following SQL-data statements: o o o o o o o o o
::= | ::= MODULE ::= ::= ::= [ ] ::= ::= ::= [ ] ::= ::= 98 Database Language SQL X3H2-92-154/DBL CBR-002 5.4 Names and identifiers ::= ::= ::= ::= ::= | ::= ::= [ ] ::= | ::= [ ] ::= [ ] ::= GLOBAL | LOCAL ::= ::= ::= ::= [ ] ::= ::= ::= ::= ::= Lexical elements 99 X3H2-92-154/DBL CBR-002 5.4 Names and identifiers Syntax Rules 1) If a is not specified in an , then the set of characters contained in the shall be wholly contained in either or the character repertoire identified by: Case: a) If the is contained in a , then the , b) If the is contained in a that is not contained in a , then the , c) If the is contained in a that is prepared in the current SQL-session by an or a or in a that is invoked directly, then the default character set name for the SQL-session. 2) If a is specified in an , then: a) There shall be no between the and the . b) The set of characters contained in the or shall be wholly contained in the character repertoire indicated by the . 3) The sum of the number of s and the number of s in an shall not be greater than 128. 4) An is equivalent to an in which every letter that is a lower-case letter is replaced by the equivalent upper-case letter or letters. This treatment includes determination of equivalence, representation in the Information and Definition Schemas, representation in the diagnostics area, and similar uses. 5) An (with every letter that is a lower- case letter replaced by the equivalent upper-case letter), treated as the repetition of a that specifies a of SQL_TEXT, shall not be equal, according to the comparison rules in Subclause 8.2, "", to any (with every letter that is a lower-case letter replaced by the equivalent upper-case letter), treated as the repetition of a that specifies a of SQL_TEXT. 100 Database Language SQL X3H2-92-154/DBL CBR-002 5.4 Names and identifiers Note: It is the intention that no specified in this International standard or revisions thereto shall end with an . 6) If
is not a , then the table identified by
shall not be a declared local temporary table. 7) No shall specify DEFINITION_SCHEMA. 8) If a does not contain a , then Case: a) If the is contained in a , then the that is specified or implicit in the is implicit. b) If the is contained in a that is prepared in the current SQL-session by an or a or in a that is invoked directly, then the default for the SQL-session is implicit. c) Otherwise, the that is specified or implicit for the is implicit. 9) If a does not contain a , then Case: a) If the is contained in a , then an implementation-defined is implicit. b) If the is contained in a other than in a , then the that is specified or implicit in the is implicit. c) If the is contained in a that is prepared in the current SQL-session by an or a or in a that is invoked directly, then the default catalog name for the SQL-session is implicit. d) If the is contained in a , then Case: i) If the is contained in a , then the explicit or implicit contained in the is implicit. Lexical elements 101 X3H2-92-154/DBL CBR-002 5.4 Names and identifiers ii) Otherwise, an implementation-defined is implicit. e) Otherwise, the explicit or implicit contained in the is implicit. 10)Two s are equal if and only if they have the same and the same , regard- less of whether the s are implicit or explicit. 11)Two s are equal if and only if they have the same and the same , regard- less of whether the s are implicit or explicit. 12)An that is a is associated with a table within a particular scope. The scope of a is either a
"). Scopes may be nested. In different scopes, the same may be associated with different tables or with the same table. 13)The of or shall not be a . 14)The data type of the of shall be character string with an implementation-defined character set and shall have an octet length of 128 octets or less. 15)The data type of the of shall be character string with an implementation- defined character set and shall have an octet length of 128 octets or less. 16)The data type of the of shall be character string with an implementation-defined character set and shall have an octet length of 128 octets or less. 17)In a , , or , if a is not specified, then a of LOCAL is implicit. 18)No shall specify "PUBLIC". 19)Those s that are valid s are implementation-defined. 20)Those s that are valid s are implementation- defined. 102 Database Language SQL X3H2-92-154/DBL CBR-002 5.4 Names and identifiers 21)If a does not specify a , then INFORMATION_SCHEMA is implicit. 22)If a does not specify a , then INFORMATION_SCHEMA is implicit. 23)If a does not specify a , then INFORMATION_SCHEMA is implicit. 24)The of , , and shall be character string with an implementation- defined character set and shall have an octet length of 128 octets or less. 25)If a does not specify a , then INFORMATION_SCHEMA is implicit; otherwise, INFORMATION_ SCHEMA shall be specified. Access Rules None. General Rules 1) A
identifies a table. 2) Within its scope, a identifies a table. 3) A identifies a declared local temporary ta- ble. 4) A identifies a column. 5) A identifies a domain. 6) An represents an authorization iden- tifier and identifies a set of privileges. 7) A identifies a . 8) A identifies a cursor. 9) A identifies a . 10)A identifies a parameter. 11)A identifies a table constraint, a domain constraint, or an assertion. 12)A identifies a statement prepared by the execu- tion of a . The scope of a is the in which it appears and the current SQL-session. Lexical elements 103 X3H2-92-154/DBL CBR-002 5.4 Names and identifiers 13)The value of an identifies a statement prepared by the execution of a . If a of GLOBAL is specified, then the scope of the is the current SQL-session. If a of LOCAL is specified or implicit, then the scope of the state- ment name is further restricted to the in which the appears. 14)A identifies a cursor in an . 15)The value of an identifies a cursor cre- ated by the execution of an . If a of GLOBAL is specified, then the scope of the is the current SQL-session. If a of LOCAL is specified of implicit, then the scope of the cursor name is further restricted to the in which the appears. 16)A identifies an SQL descriptor area created by the execution of an . If a of GLOBAL is specified, then the scope of the is the current SQL-session. If a of LOCAL is specified or implicit, then the scope of the is further restricted to the in which the appears. 17)A identifies a catalog. 18)A identifies a schema. 19)A identifies a collating sequence. 20)A identifies a character set. 21)A identifies a character translation. 22)A identifies a form-of-use con- version. All s are implementation- defined. 23)A identifies an SQL-connection. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any or . b) Conforming Intermediate SQL language shall not contain any explicit , , , , , or . 104 Database Language SQL X3H2-92-154/DBL CBR-002 5.4 Names and identifiers 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any , , , , , or . b) An shall not specify a . Lexical elements 105 X3H2-92-154/DBL CBR-002 106 Database Language SQL X3H2-92-154/DBL CBR-002 6 Scalar expressions 6.1 Function Specify a data type. Format ::= [ CHARACTER SET ] | | | | | ::= CHARACTER [ ] | CHAR [ ] | CHARACTER VARYING | CHAR VARYING | VARCHAR ::= NATIONAL CHARACTER [ ] | NATIONAL CHAR [ ] | NCHAR [ ] | NATIONAL CHARACTER VARYING | NATIONAL CHAR VARYING | NCHAR VARYING ::= BIT [ ] | BIT VARYING ::= | ::= NUMERIC [ [ ] ] | DECIMAL [ [ ] ] Scalar expressions 107 X3H2-92-154/DBL CBR-002 6.1 | DEC [ [ ] ] | INTEGER | INT | SMALLINT ::= FLOAT [ ] | REAL | DOUBLE PRECISION ::= ::= ::= ::= DATE | TIME [
6.3
Function Reference a table. Format
::=
[ [ AS ] [ ] ] | [ AS ] [ ] | ::=
::= ::= [ { }... ] Syntax Rules 1) A immediately contained in a
TR is exposed by TR. A
immediately contained in a
TR is exposed by TR if and only if TR does not specify a . 2) Case: a) If a
TR is contained in a FC with no intervening , then the scope clause SC of TR is the
of TR is the
of TR is the of SC and of all s contained in SC that contain TR. 3) A
that is exposed by a
TR shall not be the same as any other
that is exposed by a
with the same scope clause as TR. 118 Database Language SQL X3H2-92-154/DBL CBR-002 6.3
4) A that is exposed by a
TR shall not be the same as any other that is exposed by a
with the same scope clause as TR and shall not be the same as the of any
that is exposed by a
with the same scope clause as TR. 5) A
immediately contained in a
TR has a scope clause and scope defined by that
if and only if the
is exposed by TR. 6) The same shall not be specified more than once in a . 7) If a is specified in a
, then the number of s in the shall be the same as the degree of the table specified by the or the
of that
, and the name of the i-th column of that or the effective name of the i-th column of that
is the i-th in that . 8) A is an updatable derived table if and only if the simply contained in the of the
of the is updatable. Access Rules 1) Let T be the table identified by the
immediately contained in
. If the
is contained in any of: a) a simply contained in a , a , a , or an ; or b) a
or ; or c) a immediately contained in a or an ; or d) a immediately contained in an , then the applicable privileges shall include SELECT for T. General Rules 1) The or exposed
contained in a
defines that or
to be an identifier of the table identified by the
or of that
. Scalar expressions 119 X3H2-92-154/DBL CBR-002 6.3
Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A
shall not be a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A
shall not be a . b) The optional AS shall not be specified. c) shall not be specified. 120 Database Language SQL X3H2-92-154/DBL CBR-002 6.4 6.4 Function Reference a column. Format ::= [ ] ::=
| Syntax Rules 1) Let CR be the , let CN be the contained in CR, and let C be the column identified by CN. 2) If CR contains a Q, then CR shall appear within the scope of one or more
s or s that are equal to Q. If there is more than one such
or , then the one with the most local scope is specified. Let T be the table associated with Q. a) T shall include a column whose is CN. b) If T is a
in a J, then CN shall not be a common column name in J. Note: Common column name is defined in Subclause 7.5, "". 3) If CR does not contain a , then CR shall be contained within the scope of one or more
s or s whose associated tables include a column whose is CN. Let the phrase possible qualifiers denote those
s and s. a) Case: i) If the most local scope contains exactly one possible qualifier, then the qualifier Q equivalent to that unique
or is implicit. ii) If there is more than one possible qualifier with most local scope, then: 1) Each possible qualifier shall be a
or a of a
that is di- rectly contained in a J. Scalar expressions 121 X3H2-92-154/DBL CBR-002 6.4 2) CN shall be a common column name in J. Note: Common column name is defined in Subclause 7.5, "". 3) The implicit qualifier Q is implementation-dependent. The scope of Q is that which Q would have had if J had been replaced by the
: ( J ) AS Q b) Let T be the table associated with Q. 4) The data type of CR is the data type of column C of T. CN shall uniquely identify a column of T. 5) If the data type of CR is character string, then CR has the Implicit coercibility attribute and its collating sequence is the default collating sequence for column C of T. 6) If the data type of CR is TIME or TIMESTAMP, then the implicit time zone of the data is the current default time zone for the SQL-session. 7) If the data type of CR is TIME WITH TIME ZONE or TIMESTAMP WITH TIME ZONE, then the time zone of the data is the time zone rep- resented in the value of CR. 8) If CR is contained in a
TE and the scope clause of the
immediately containing the or Q also contains TE, then CR is an outer reference to the table associated with Q. 9) Let CR be the and let C be the column identi- fied by CR. C is an underlying column of CR. If C is a , then every underlying column of C is an underlying column of CR. Note: The underlying columns of a are defined in Subclause 7.9, "". Access Rules 1) The applicable privileges shall include SELECT for T if CR is contained in any of: a) a immediately contained in a or an ; or b) a immediately contained in an . 122 Database Language SQL X3H2-92-154/DBL CBR-002 6.4 General Rules 1) The Q.CN references column C in a given row of T. 2) If the data type of CR is TIME, TIMESTAMP, TIME WITH TIME ZONE or TIMESTAMP WITH TIME ZONE, then let TZ be an INTERVAL HOUR TO MINUTE containing the value of the time zone displacement associated with CR. The value of CR, normalized to UTC, is ef- fectively computed as CR + TZ. Leveling Rules 1) The following restrictions apply for Intermediate SQL; None. 2) The following restrictions apply for Entry SQL; None. Scalar expressions 123 X3H2-92-154/DBL CBR-002 6.5 6.5 Function Specify a value derived by the application of a function to an argument. Format ::= COUNT | ::= [ ] ::= AVG | MAX | MIN | SUM | COUNT ::= DISTINCT | ALL Syntax Rules 1) If is not specified, then ALL is implicit. 2) The argument of COUNT(*) and the argument source of a is a table or a group of a grouped table as spec- ified in Subclause 7.8, "", and Subclause 7.9, "". Note: argument source is defined in Subclause 7.8, "". 3) Let T be the argument or argument source of a . 4) The simply contained in shall not contain a or a . If the contains a that is an outer reference, then that outer reference shall be the only contained in the . Note: Outer reference is defined in Subclause 6.4, "". 5) If a contains a that is an outer reference, then the shall be contained in either: a) a
that is directly contained in the
that directly contains the . Note: Outer reference is defined in Subclause 6.4, "". 6) Let DT be the data type of the . 7) If COUNT is specified, then the data type of the result is exact numeric with implementation-defined precision and scale of 0. 8) If MAX or MIN is specified, then the data type of the result is DT. 9) If SUM or AVG is specified, then: a) DT shall not be character string, bit string, or datetime. b) If SUM is specified and DT is exact numeric with scale S, then the data type of the result is exact numeric with implementation-defined precision and scale S. c) If AVG is specified and DT is exact numeric, then the data type of the result is exact numeric with implementation- defined precision not less than the precision of DT and implementation-defined scale not less than the scale of DT. d) If DT is approximate numeric, then the data type of the result is approximate numeric with implementation-defined precision not less than the precision of DT. e) If DT is interval, then the data type of the result is inter- val with the same precision as DT. 10)If the data type of the result is character string, then the collating sequence and the coercibility attribute are determined as in Subclause 4.2.3, "Rules determining collating sequence usage". Access Rules None. General Rules 1) Case: a) If COUNT(*) is specified, then the result is the cardinality of T. Scalar expressions 125 X3H2-92-154/DBL CBR-002 6.5 b) Otherwise, let TX be the single-column table that is the result of applying the to each row of T and eliminating null values. If one or more null values are eliminated, then a completion condition is raised: warning- null value eliminated in set function. 2) If DISTINCT is specified, then let TXA be the result of elimi- nating redundant duplicate values from TX. Otherwise, let TXA be TX. Case: a) If the COUNT is specified, then the result is the cardinality of TXA. b) If AVG, MAX, MIN, or SUM is specified, then Case: i) If TXA is empty, then the result is the null value. ii) If AVG is specified, then the result is the average of the values in TXA. iii) If MAX or MIN is specified, then the result is respec- tively the maximum or minimum value in TXA. These results are determined using the comparison rules specified in Subclause 8.2, "". iv) If SUM is specified, then the result is the sum of the values in TXA. If the sum is not within the range of the data type of the result, then an exception condition is raised: data exception-numeric value out of range. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) If a specifies DISTINCT, then the shall be a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If a specifies or implies ALL, then COUNT shall not be specified. b) If a specifies or implies ALL, then the shall include a that references a column of T. c) If the contains a that is an outer reference, then the shall be a . 126 Database Language SQL X3H2-92-154/DBL CBR-002 6.5 d) No contained in a shall reference a column derived from a that generally contains a . Scalar expressions 127 X3H2-92-154/DBL CBR-002 6.6 6.6 Function Specify a function yielding a value of type numeric. Format ::= | | ::= POSITION IN ::= | | ::= { CHAR_LENGTH | CHARACTER_LENGTH } ::= OCTET_LENGTH ::= BIT_LENGTH ::= EXTRACT FROM ::= |
shall not contain more than one . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not specify DEFAULT. Query expressions 175 X3H2-92-154/DBL CBR-002 7.2
7.2
Function Specify a set of s to be constructed into a table. Format
::= VALUES
::= [ { }... ] Syntax Rules 1) All s shall be of the same degree. Access Rules None. General Rules 1) Let Ti be a table whose j-th column has the same data type as the j-th in the i-th and let Ti contain one row whose j-th column has the same value as the j-th in the i-th . 2) The result of the
is the same as the result of T1 [ UNION ALL T2 [ . . . UNION ALL n ] . . . ] Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A
shall contain exactly one that shall be of the form "()". b) A
shall be the of an . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 176 Database Language SQL X3H2-92-154/DBL CBR-002 7.3
7.3
Function Specify a table or a grouped table. Format
::= [ ] [ ] [ ] Syntax Rules 1) The result of a
is a derived table in which the descriptor of the i-th column is the same as the descriptor of the i-th column of the table specified by the . 2) Let C be some column. Let TE be the
. C is an underlying column of TE if and only if C is an underlying column of some contained in TE. Access Rules None. General Rules 1) If all optional clauses are omitted, then the result of the is the same as the result of the . Otherwise, each specified clause is applied to the result of the previously specified clause and the result of the
is the result of the application of the last specified clause. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If the table identified in the is a grouped view, then the
shall not contain a , , or . Query expressions 177 X3H2-92-154/DBL CBR-002 7.4 7.4 Function Specify a table derived from one or more named tables. Format ::= FROM
[ {
}... ] Syntax Rules 1) Case: a) If the contains a single
with no intervening or , then the descriptor of the result of the is the same as the descriptor of the table identified by that
. b) If the contains more than one
with no intervening or , then the descriptors of the columns of the result of the are the descriptors of the columns of the tables identified by the
s, in the order in which the
s appear in the and in the order in which the columns are defined within each table. Access Rules None. General Rules 1) Case: a) If the contains a single
with no intervening or , then the result of the is the table identified by that
. b) If the contains more than one
with no intervening or , then the result of the is the extended Cartesian product of the tables identified by those
s. The extended Cartesian product, CP, is the multiset of all rows R such that R is the concatenation of a row from each of the identified tables in the order in which they are iden- tified. The cardinality of CP is the product of the cardi- nalities of the identified tables. The ordinal position of a 178 Database Language SQL X3H2-92-154/DBL CBR-002 7.4 column in CP is N+S, where N is the ordinal position of that column in the identified table T from which it is derived and S is the sum of the degrees of the tables identified before T in the . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If the table identified by
is a grouped view, then the shall contain exactly one
. Query expressions 179 X3H2-92-154/DBL CBR-002 7.5 7.5 Function Specify a table derived from a Cartesian product, inner or outer join, or union join. Format ::= | | ::=
CROSS JOIN
::=
[ NATURAL ] [ ] JOIN
[ ] ::= | ::= ON ::= USING ::= INNER | [ OUTER ] | UNION ::= LEFT | RIGHT | FULL ::= Syntax Rules 1) Let TR1 and TR2 be the first and second
s of the , respectively. Let T1 and T2 be the tables identified by TR1 and TR2, respectively. Let TA and TB be the correlation names of TR1 and TR2, respectively. Let CP be: SELECT * FROM TR1, TR2 2) If a is specified, then 180 Database Language SQL X3H2-92-154/DBL CBR-002 7.5 Case: a) If NATURAL is specified, then a shall not be specified. b) If UNION is specified, then neither NATURAL nor a shall be specified. c) Otherwise, a shall be specified. 3) If a is specified and a is not specified, then INNER is implicit. 4) If a containing a is speci- fied, then; a) Each directly contained in the shall unambiguously reference a column of T1 or T2 or be an outer reference. b) If a directly contained in the is a , then the shall be contained in a or of s of the form COALESCE ( TA.C, TB.C ) AS C for every column C that is a corresponding join column, taken in order of their ordinal positions in T1. e) Let SL1 be a of those s of T2 that are not correspond- ing join columns, taken in order of their ordinal positions in T2. f) The descriptors of the columns of the result of the are the same as the descriptors of the columns of the result of SELECT SLCC, SLT1, SLT2 FROM TR1, TR2 7) For every column CR of the result of the that is not a corresponding join column and that corresponds to a column C1 of T1, CR is possibly nullable if any of the following conditions are true: a) RIGHT, FULL, or UNION is specified, or b) INNER, LEFT, or CROSS JOIN is specified or implicit and 1 is possibly nullable. 8) For every column CR of the result of the that is not a corresponding join column and that corresponds to a column C2 of T2, CR is possibly nullable if any of the following conditions are true: a) LEFT, FULL, or UNION is specified, or b) INNER, RIGHT, or CROSS JOIN is specified or implicit and C is possibly nullable. 9) For every column CR of the result of the that is a corresponding join column and that corresponds to a column C1 of T1 and C2 of T2, CR is possibly nullable if any of the following conditions are true: a) RIGHT, FULL, or UNION is specified and 1 is possibly nul- lable, or b) LEFT, FULL, or UNION is specified and 2 is possibly nul- lable. 10)The is a read-only table. 182 Database Language SQL X3H2-92-154/DBL CBR-002 7.5 Access Rules None. General Rules 1) Case: a) If is UNION, then let T be the empty set. b) If a is specified, then let T be the multiset of rows of CP. c) If a is specified, then let T be the multi- set of rows of CP for which the specified is true. d) If NATURAL is specified or is specified, then Case: i) If there are corresponding join columns, then let T be the multiset of rows of CP for which the corresponding join columns have equal values. ii) Otherwise, let T be the multiset of rows of CP. 2) Let P1 be the multiset of rows of T1 for which there exists in T some row that is the concatenation of some row R1 of T1 and some row R2 of T2. Let P2 be the multiset of rows of T2 for which there exists in T some row that is the concatenation of some row R1 of T1 and some row R2 of T2. 3) Let U1 be those rows of T1 that are not in P1 and let U2 be those rows of T2 that are not in P2. 4) Let D1 and D2 be the degree of T1 and T2, respectively. Let X1 be U1 extended on the right with D2 columns containing the null value. Let X2 be U2 extended on the left with D1 columns containing the null value. 5) Let XN1 and XN2 be effective distinct names for X1 and X2, re- spectively. Let TN be an effective name for T. Case: a) If INNER or is specified, then let S be the multiset of rows of T. b) If LEFT is specified, then let S be the multiset of rows resulting from: SELECT * FROM TN UNION ALL SELECT * FROM XN1 Query expressions 183 X3H2-92-154/DBL CBR-002 7.5 c) If RIGHT is specified, then let S be the multiset of rows resulting from: SELECT * FROM TN UNION ALL SELECT * FROM XN2 d) If FULL is specified, then let S be the multiset of rows resulting from: SELECT * FROM TN UNION ALL SELECT * FROM XN1 UNION ALL SELECT * FROM XN2 e) If UNION is specified, then let S be the multiset of rows resulting from: SELECT * FROM XN1 UNION ALL SELECT * FROM XN2 6) Let SN be an effective name of S. Case: a) If NATURAL is specified or a is speci- fied, then the result of the is the multiset of rows resulting from: SELECT SLCC, SLT1, SLT2 FROM SN b) Otherwise, the result of the is S. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . b) Conforming Intermediate SQL language shall not specify UNION JOIN. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . 184 Database Language SQL X3H2-92-154/DBL CBR-002 7.6 7.6 Function Specify a table derived by the application of a to the result of the preceding . Format ::= WHERE Syntax Rules 1) Let T be the result of the preceding . Each directly contained in the shall unambiguously reference a column of T or be an outer reference. Note: Outer reference is defined in Subclause 6.4, "". 2) If a directly contained in the is a , then the shall be contained in a or
. Format ::= SELECT [ ]
[ { ::= | ::= [ ] ::= [ AS ] Syntax Rules 1) Let T be the result of the
. 2) The degree of the table specified by a is equal to the cardinality of the "*" is simply contained in a that is immediately contained in an , then the "*" is equivalent to a sequence in which each is a that references a column of T and each column of T is referenced exactly once. The columns are ref- erenced in the ascending sequence of their ordinal position within T. 4) The of QS. For all i, C is an underlying column of DCi, and of any that identifies DCi, if and only if C is an underlying column of the of DCi, or C is an underlying column of the
immediately contained in QS. 6) Each directly contained in each and each contained in a directly contained in each shall unambiguously reference a column of T. 7) If T is a grouped table, then each in each that references a column of T shall refer- ence a grouping column or be specified within a . If T is not a grouped table and any contains a that contains a reference to a column of T or any directly contains a that does not contain an outer reference, then every in every that references a column of T shall be specified within a . 8) Each column of the table that is the result of a has a column descriptor that includes a data type descriptor that is the same as the data type descriptor of the from which the column was derived. 9) Case: a) If the i-th in the does not specify an and the of that is a single , then the of the i-th column of the result is C. c) Otherwise, the of the i-th column of the is implementation-dependent and different from the of any column, other than itself, of a table referenced by any
contained in the SQL-statement. 10)A column of the table that is the result of a is possibly nullable if and only if it contains a for a column C that is possibly nullable, an , an , a , CAST NULL AS X (X represents a or a ), SYSTEM_ USER, or a that does not contain COUNT. 192 Database Language SQL X3H2-92-154/DBL CBR-002 7.9 11)Let TREF be the
s that are simply contained in the of the
. The simply un- derlying tables of the are the tables identified by the
s and s contained in TREF without an intervening . 12)A QS is updatable if and only if the fol- lowing conditions hold: a) QS does not specify DISTINCT. b) Every contained in the
immediately contained in QS specifies exactly one
and that
refers either to a base table or to an updatable derived table. Note: updatable derived table is defined in Subclause 6.3, "
". d) If the
immediately contained in QS imme- diately contains a WC, then no leaf generally underlying table of QS shall be a generally underlying table of any contained in WC. e) The
immediately contained in QS does not include a or a . 13)A is possibly non-deterministic if any of the following conditions are true: a) The DISTINCT is specified and one of the columns of T has a data type of character string; or b) The directly contains a that is possibly non-deterministic; or c) The contains a that contains a reference to a column of T or di- rectly contains a that does not contain an outer reference, then T is the argument or argument source of each such and the result of the is a table con- sisting of 1 row. The i-th value of the row is the value specified by the i-th . ii) If the
contains a . b) A
of the is a grouped view, then the
| ::= TABLE
::= CORRESPONDING [ BY ] ::= 196 Database Language SQL X3H2-92-154/DBL CBR-002 7.10 Syntax Rules 1) Let T be the table specified by the . 2) The TABLE
is equivalent to the ( SELECT * FROM
) 3) Let set operator be UNION [ALL], EXCEPT [ALL], or INTERSECT [ALL]. 4) T is an updatable table and the is updatable if and only if it simply contains a QE or a QS and: a) the contains QE or QS without an inter- vening that specified UNION or EXCEPT; b) the contains QE or QS without an interven- ing that specifies INTERSECT; and c) QE or QS is updatable. 5) Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . b) If a is an , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the table identified by the
contained in the . c) Otherwise, the column descriptor of the i-th column of the is same as the column descriptor of the i- th column of the
, except that the is implementation-dependent and different from the of any column, other than itself, of a table referenced by any
contained in the SQL-statement. 6) Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . Query expressions 197 X3H2-92-154/DBL CBR-002 7.10 b) Otherwise, the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . 7) Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . b) Otherwise, the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . 8) If a set operator is specified in a or a , then let T1, T2, and TR be respec- tively the first operand, the second operand, and the result of the or . Let TN1 and TN2 be the effective names for T1 and T2, respectively. 9) If a set operator is specified in a or a , then let OP be the set operator. Case: a) If CORRESPONDING is specified, then: i) Within the columns of T1, the same shall not be specified more than once and within the columns of T2, the same shall not be specified more than once. ii) At least one column of T1 shall have a that is the of some column of T2. iii) Case: 1) If is not specified, then let SL be a of those s explic- itly appearing in the in the order that these s appear in the . Every in the shall be a of both T1 and T2. iv) The or is equivalent to: ( SELECT SL FROM TN1 ) OP ( SELECT SL FROM TN2 ) 198 Database Language SQL X3H2-92-154/DBL CBR-002 7.10 b) If CORRESPONDING is not specified, then T1 and T2 shall be of the same degree. 10)Case: a) If the is a , then the column descriptor of the i-th column of the is same as the column descriptor of the i-th column of the . b) Otherwise, i) Case: 1) Let C be the of the i-th column of T1. If the of the i-th column of T2 is C, then the of the i-th column of TR is C. 2) Otherwise, the of the i-th column of TR is implementation-dependent and different from the of any column, other than itself, of any table referenced by any
contained in the SQL-statement. ii) The data type of the i-th column of TR is determined by applying Subclause 9.3, "Set operation result data types", to the data types of the i-th column of T1 and the i-th column of T2. If the i-th column of both T1 and T2 are known not nullable, then the i-th column of TR is known not nullable; otherwise, the i-th column of T is possibly nullable. 11)Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . b) Otherwise, the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . 12)Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . Query expressions 199 X3H2-92-154/DBL CBR-002 7.10 b) Otherwise, i) Case: 1) Let C be the of the i-th column of T1. If the of the i-th column of T2 is C, then the of the i-th column of TR is C. 2) Otherwise, the of the i-th column of TR is implementation-dependent and different from the of any column, other than itself, of any table referenced by any
contained in the SQL-statement. ii) The data type of the i-th column of TR is determined by applying Subclause 9.3, "Set operation result data types", to the data types of the i-th column of T1 and the i-th column of T2. If the i-th column of both T1 and T2 are known not nullable, then the i-th column of TR is known not nullable; otherwise, the i-th column of T is possibly nullable. 13)Case: a) If a is a , then the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . b) Otherwise, the column descriptor of the i-th column of the is the same as the column descriptor of the i-th column of the . 14)The simply underlying tables of a are the tables identified by those
s, s, and s contained in the without an intervening , an intervening , or an intervening . 15)A is possibly non-deterministic if a) it contains a set operator UNION and ALL is not specified, or if it contains EXCEPT or INTERSECT; and b) the first or second operand contains a column that has a data type of character string. 16)The underlying columns of each column of QE and of QE itself are defined as follows: a) A column of a
has no underlying columns. b) The underlying columns of every i-th column of a ST are the underlying columns of the i-th column of the table immediately contained in ST. 200 Database Language SQL X3H2-92-154/DBL CBR-002 7.10 c) If no set operator is specified, then the underlying columns of every i-th column of QE are the underlying columns of the i-th column of the simply contained in QE. d) If a set operator is specified, then the underlying columns of every i-th column of QE are the underlying columns of the i-th column of T1 and those of the i-th column of T2. e) Let C be some column. C is an underlying column of QE if and only if C is an underlying column of some column of QE. Access Rules None. General Rules 1) Case: a) If no set operator is specified, then T is the result of the specified or . b) If a set operator is specified, then the result of applying the set operator is a table containing the following rows: i) Let R be a row that is a duplicate of some row in T1 or of some row in T2 or both. Let m be the number of duplicates of R in T1 and let n be the number of duplicates of R in T2, where m 0 and n 0. ii) If ALL is not specified, then Case: 1) If UNION is specified, then Case: A) If m > 0 or n > 0, then T contains exactly one dupli- cate of R. B) Otherwise, T contains no duplicate of R. 2) If EXCEPT is specified, then Case: A) If m > 0 and n = 0, then T contains exactly one dupli- cate of R. B) Otherwise, T contains no duplicate of R. 3) If INTERSECT is specified, then Case: A) If m > 0 and n > 0, then T contains exactly one dupli- cate of R. Query expressions 201 X3H2-92-154/DBL CBR-002 7.10 B) Otherwise, T contains no duplicates of R. iii) If ALL is specified, then Case: 1) If UNION is specified, then the number of duplicates of R that T contains is (m + n). 2) If EXCEPT is specified, then the number of duplicates of R that T contains is the maximum of (m - n) and 0. 3) If INTERSECT is specified, then the number of duplicates of R that T contains is the minimum of m and n. Note: See the General Rules of Subclause 8.2, "". 2) If a set operator is specified, then for each column whose data type is interval, let UDT be in turn the data type of the cor- responding column of T and let SV be the value of the column in each row of the first and second operands. The value of the corresponding column of T in the corresponding row of T is CAST (SV AS UDT) Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not be a
except in an . b) Conforming Intermediate SQL shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not specify EXCEPT. b) A shall not specify INTERSECT. c) A shall not contain a . d) A shall not specify CORRESPONDING. e) If UNION is specified, then except for column names, the descriptors of the first and second operands shall be iden- tical and the descriptor of the result is identical to the descriptor of the operands. 202 Database Language SQL X3H2-92-154/DBL CBR-002 7.11 , , and
7.11 , , and
Function Specify a scalar value, a row, or a table derived from a . Format ::= ::=
::= ::= Syntax Rules 1) The degree of a shall be 1. 2) The degree of a shall be greater than 1. 3) The data type of a is the data type of the column of the immediately contained in the . 4) The data types of the columns of a or
are the data types of the respective columns of the immediately contained in the or
. Access Rules None. General Rules 1) If the cardinality of a or a is greater than 1, then an exception condition is raised: cardinal- ity violation. Leveling Rules 1) The following restrictions apply for Intermediate SQL: 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If a is contained in a , then the
in the shall not contain a or a and shall not identify a grouped view. Query expressions 203 X3H2-92-154/DBL CBR-002 7.11 , , and
b) The contained in a shall be a . 204 Database Language SQL X3H2-92-154/DBL CBR-002 8 Predicates 8.1 Function Specify a condition that can be evaluated to give a truth value of true, false, or unknown. Format ::= | | | | | | | | | Syntax Rules None. Access Rules None. General Rules 1) The result of a is a truth value derived according to the General Rules of Subclause 8.2, "", Subclause 8.3, "", Subclause 8.4, "", Subclause 8.5, "", Subclause 8.6, "", Subclause 8.7, "", Subclause 8.8, "", Subclause 8.9, "", Subclause 8.10, "", or Subclause 8.11, "", as appropriate. Predicates 205 X3H2-92-154/DBL CBR-002 8.1 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not be a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . b) Conforming Entry SQL language shall not contain any . 206 Database Language SQL X3H2-92-154/DBL CBR-002 8.2 8.2 Function Specify a comparison of two row values. Format ::= ::= | | | | | Syntax Rules 1) The two s shall be of the same degree. 2) Let corresponding values be values with the same ordinal posi- tion in the two s. 3) The data types of the corresponding values of the two s shall be comparable. 4) Let X be a value in the first and Y be the corresponding value in the second . If X and Y have data type character string, then the pair-wise comparison collating sequence used to compare X and Y is de- termined by the table for collating sequences for comparisons (Subclause 4.2.3, "Rules determining collating sequence usage"). For any pair of corresponding character strings, let CS be the identified collating sequence. Access Rules None. General Rules 1) Let X and Y be any two corresponding s. Let XV and YV be the values represented by X and Y, respectively. Case: a) If XV or YV is the null value, then "X Y" is un- known. Predicates 207 X3H2-92-154/DBL CBR-002 8.2 b) If XV and YV are non-null values, then "X Y" is true or false as follows: i) "X = Y" is true if and only if XV and YV are equal. ii) "X <> Y" is true if and only if XV and YV are not equal. iii) "X < Y" is true if and only if XV is less than YV. iv) "X > Y" is true if and only if XV is greater than YV. v) "X <= Y" is true if and only if XV is not greater than YV. vi) "X >= Y" is true if and only if XV is not less than YV. vii) "X Y" is false if and only if "X Y" is not true. 2) Numbers are compared with respect to their algebraic value. 3) The comparison of two character strings is determined as fol- lows: a) If the length in characters of X is not equal to the length in characters of Y, then the shorter string is effectively replaced, for the purposes of comparison, with a copy of itself that has been extended to the length of the longer string by concatenation on the right of one or more pad char- acters, where the pad character is chosen based on CS. If CS has the NO PAD attribute, then the pad character is an implementation-dependent character different from any char- acter in the character set of X and Y that collates less than any string under CS. Otherwise, the pad character is a . b) The result of the comparison of X and Y is given by the col- lating sequence CS. c) Depending on the collating sequence, two strings may com- pare as equal even if they are of different lengths or con- tain different sequences of characters. When the operations MAX, MIN, DISTINCT, references to a grouping column, and the UNION, EXCEPT, and INTERSECT operators refer to character strings, the specific value selected by these operations from a set of such equal values is implementation-dependent. Note: If the coercibility attribute of the comparison is Coercible, then the collating sequence used is the default de- fined for the character repertoire. See also other Syntax Rules in this Subclause, Subclause 10.4, "", and Subclause 11.28, "". 208 Database Language SQL X3H2-92-154/DBL CBR-002 8.2 4) The comparison of two bit string values, X and Y, is determined by comparison of their bits with the same ordinal position. If Xi and Yi are the values of the i-th bits of X and Y, re- spectively, and if LX is the length in bits of X and LY is the length in bits of Y, then: a) X is equal to Y if and only if X = LY and Xi = Yi for all i. b) X is less than Y if and only if: i) LX < LY and Xi = Yi for all i less than or equal to LX; or ii) Xi = Yi for all i < n and Xn = 0 and Yn = 1 for some n less than or equal to the minimum of LX and LY. 5) The comparison of two datetimes is determined according to the interval resulting from their subtraction. Let X and Y be the two values to be compared and let H be the least significant of X and Y. The result of X Y is defined as: ( X - Y ) H INTERVAL (0) H Note: Two datetimes are comparable only if they have the same s; see Subclause 4.5.1, "Datetimes". 6) The comparison of two intervals is determined by the compari- son of their corresponding values after conversion to integers in some common base unit. Let X and Y be the two intervals to be compared. Let A TO B be the specified or implied datetime qualifier of X and C TO D be the specified or implied datetime qualifier of Y. Let T be the least significant of B and D and let U be a datetime qualifier of the form T(N), where N is an large enough so that significance is not lost in the CAST operation. X is effectively replaced by CAST (X AS INTERVAL U). Y is effectively replaced by CAST (Y AS INTERVAL U). The result of the comparison is effectively computed as: CAST ( X AS INTEGER ) CAST ( Y AS INTEGER ) 7) Let Rx and Ry be the two s of the and let RXi and RYi be the i-th s of Rx and Ry, respectively. "Rx Ry" is true, false, or unknown as follows: a) "x = Ry" is true if and only if RXi = RYi for all i. b) "x <> Ry" is true if and only if RXi <> RYi for some i. c) "x < Ry" is true if and only if RXi = RYi for all i < n and RXn < RYn for some n. d) "x > Ry" is true if and only if RXi = RYi for all i < n and RXn > RYn for some n. Predicates 209 X3H2-92-154/DBL CBR-002 8.2 e) "x <= Ry" is true if and only if Rx = Ry or Rx < Ry. f) "x >= Ry" is true if and only if Rx = Ry or Rx > Ry. g) "x = Ry" is false if and only if "Rx <> Ry" is true. h) "x <> Ry" is false if and only if "Rx = Ry" is true. i) "x < Ry" is false if and only if "Rx >= Ry" is true. j) "x > Ry" is false if and only if "Rx <= Ry" is true. k) "x <= Ry" is false if and only if "Rx > Ry" is true. l) "x >= Ry" is false if and only if "Rx < Ry" is true. m) "x Ry" is unknown if and only if "Rx Ry" is neither true nor false. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 210 Database Language SQL X3H2-92-154/DBL CBR-002 8.3 8.3 Function Specify a range comparison. Format ::= [ NOT ] BETWEEN AND Syntax Rules 1) The three s shall be of the same degree. 2) Let respective values be values with the same ordinal position in the two s. 3) The data types of the respective values of the three s shall be comparable. 4) Let X, Y, and Z be the first, second, and third s, respectively. 5) "X NOT BETWEEN Y AND Z" is equivalent to "NOT ( X BETWEEN Y AND Z )". 6) "X BETWEEN Y AND Z" is equivalent to "X>=Y AND X<=Z". Access Rules None. General Rules None. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Predicates 211 X3H2-92-154/DBL CBR-002 8.4 8.4 Function Specify a quantified comparison. Format ::= [ NOT ] IN ::=
| ::= { }... Syntax Rules 1) Let IVL be an . ( IVL ) is equivalent to the
: ( VALUES IVL ) 2) Let RVC be the and let IPV be the . 3) The expression RVC NOT IN IPV is equivalent to NOT ( RVC IN IPV ) 4) The expression RVC IN IPV is equivalent to RVC = ANY IPV Access Rules None. General Rules None. 212 Database Language SQL X3H2-92-154/DBL CBR-002 8.4 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain a in an that is not a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Predicates 213 X3H2-92-154/DBL CBR-002 8.5 8.5 Function Specify a pattern-match comparison. Format ::= [ NOT ] LIKE [ ESCAPE ] ::= ::= ::= Syntax Rules 1) The data types of , , and shall be character string. , , and shall be comparable. 2) Let M be the result of the of the , let P be the result of the of the , and let E be the result of the of the if one is specified. 3) "M NOT LIKE P" is equivalent to "NOT (M LIKE P)". 4) Case: a) If is not specified, then the collat- ing sequence used for the is determined by Table 3, "Collating sequence usage for comparisons", taking as comparand 1 and as comparand 2. b) Otherwise, let C1 be the coercibility attribute and collat- ing sequence of the , and C2 be the coercibility attribute and collating sequence of the . Let C3 be the resulting coercibility attribute and collating sequence as determined by Table 2, "Collating coercibility rules for dyadic operators", taking C1 as the operand 1 coercibility and C2 as the operand 2 coercibility. The collating sequence used for the is determined by Table 3, "Collating sequence usage for comparisons", taking C3 as the coercibility attribute and collating sequence of comparand 1 and as comparand 2. 214 Database Language SQL X3H2-92-154/DBL CBR-002 8.5 Access Rules None. General Rules 1) If an is specified and M, P, or E is the null value, then M LIKE P ESCAPE E is unknown. 2) If an is not specified and M or P is the null value, then M LIKE P is unknown. 3) Case: a) If an is specified, then: i) If the length in characters of E is not equal to 1, then an exception condition is raised: data exception-invalid escape character. ii) If there is not a partitioning of the string P into sub- strings such that each substring has length 1 or 2, no substring of length 1 is the escape character E, and each substring of length 2 is the escape character E followed by either the escape character E, an character, or the character, then an exception condition is raised: data exception-invalid escape sequence. If there is such a partitioning of P, then in that parti- tioning, each substring with length 2 represents a single occurrence of the second character of that substring. Each substring with length 1 that is the character represents an arbitrary character specifier. Each substring with length 1 that is the character represents an arbitrary string specifier. Each substring with length 1 that is neither the character nor the character represents the character that it contains. b) If an is not specified, then each character in P represents an arbitrary character spec- ifier, each character in P represents an arbitrary string specifier, and each character in P that is neither the character nor the character represents itself. Predicates 215 X3H2-92-154/DBL CBR-002 8.5 4) The string P is a sequence of the minimum number of substring specifiers such that each of P is part of exactly one substring specifier. A substring specifier is an arbitrary character specifier, an arbitrary string spec- ifier, or any sequence of s other than an arbitrary character specifier or an arbitrary string specifier. 5) Case: a) If M and P are character strings whose lengths are variable and if the lengths of both M and P are 0, then M LIKE P is true. b) The M LIKE P is true if there exists a partitioning of M into substrings such that: i) A substring of M is a sequence of 0 or more contiguous s of M and each of M is part of exactly one substring. ii) If the i-th substring specifier of P is an arbitrary char- acter specifier, the i-th substring of M is any single . iii) If the i-th substring specifier of P is an arbitrary string specifier, then the i-th substring of M is any sequence of 0 or more s. iv) If the i-th substring specifier of P is neither an arbi- trary character specifier nor an arbitrary string speci- fier, then the i-th substring of M is equal to that sub- string specifier according to the collating sequence of the , without the appending of characters to M, and has the same length as that substring specifier. v) The number of substrings of M is equal to the number of substring specifiers of P. c) Otherwise, M LIKE P is false. 216 Database Language SQL X3H2-92-154/DBL CBR-002 8.5 Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) The shall be a . b) A shall be a . c) An shall be a . Predicates 217 X3H2-92-154/DBL CBR-002 8.6 8.6 Function Specify a test for a null value. Format ::= IS [ NOT ] NULL Syntax Rules None. Access Rules None. General Rules 1) Let R be the value of the . 2) If all the values in R are the null value, then "R IS NULL" is true; otherwise, it is false. 3) If none of the values in R are the null value, then "R IS NOT NULL" is true; otherwise, it is false. Note: For all R, "R IS NOT NULL" has the same result as "NOT R IS NULL" if and only if R is of degree 1. Table 12, " semantics", specifies this behavior. ________________Table_12-_semantics________________ R IS R IS NOT NOT R IS NOT R IS NOT _Expression_______NULL____NULL__________NULL__________NULL_________ | degree 1: null | true | false | false | true | | | | | | | | degree 1: not | false | true | true | false | null | degree > 1: | true | false | false | true | | all null | | | | | | | | | | | | degree > 1: | false | false | true | true | | some null | | | | | | | | | | | | degree > 1: | false | true | true | false | |_none_null______|_______|_____________|____________|______________| | | | | | | |Leveling Rules | | | | | | | | | | | 218 Database Language SQL X3H2-92-154/DBL CBR-002 8.6 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall be a . Predicates 219 X3H2-92-154/DBL CBR-002 8.7 8.7 Function Specify a quantified comparison. Format ::=
::= | ::= ALL ::= SOME | ANY Syntax Rules 1) The shall be of the same degree as the result of the
. 2) The data types of the values of the shall be respectively comparable to those of the columns of the
. 3) The collating sequence for each pair of respective values in the is determined in the same manner as described in Subclause 8.2, "". Access Rules None. General Rules 1) Let R be the result of the and let T be the result of the
. 2) The result of "R T" is derived by the application of the implied "R RT" to every row RT in T: Case: a) If T is empty or if the implied is true for every row RT in T, then "R T" is true. b) If the implied is false for at least one row RT in T, then "R T" is false. 220 Database Language SQL X3H2-92-154/DBL CBR-002 8.7 c) If the implied is true for at least one row RT in T, then "R T" is true. d) If T is empty or if the implied is false for every row RT in T, then "R T" is false. e) If "R T" is neither true nor false, then it is unknown. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Predicates 221 X3H2-92-154/DBL CBR-002 8.8 8.8 Function Specify a test for a non-empty set. Format ::= EXISTS
Syntax Rules None. Access Rules None. General Rules 1) Let T be the result of the
. 2) If the cardinality of T is greater than 0, then the result of the is true; otherwise, the result of the is false. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 222 Database Language SQL X3H2-92-154/DBL CBR-002 8.9 8.9 Function Specify a test for the absence of duplicate rows. Format ::= UNIQUE
Syntax Rules None. Access Rules None. General Rules 1) Let T be the result of the
. 2) If there are no two rows in T such that the value of each column in one row is non-null and is equal to the value of the cor- responding column in the other row according to Subclause 8.2, "", then the result of the is true; otherwise, the result of the is false. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . Predicates 223 X3H2-92-154/DBL CBR-002 8.10 8.10 Function Specify a test for matching rows. Format ::= MATCH [ UNIQUE ] [ PARTIAL | FULL ]
Syntax Rules 1) The shall be of the same degree as the
. 2) The data types of the values of the shall be respectively comparable to those of the corresponding columns of the
. 3) The collating sequence for each pair of respective values in the is determined in the same manner as described in Subclause 8.2, "". Access Rules None. General Rules 1) Let R be the . 2) If neither PARTIAL nor FULL is specified, then Case: a) If some value in R is the null value, then the is true. b) If no value in R is the null value, then Case: i) If UNIQUE is not specified and there exists a (possibly non-unique) row RTi of the
such that R = RTi then the is true. ii) If UNIQUE is specified and there is a unique row RTi of the
such that R = RTi 224 Database Language SQL X3H2-92-154/DBL CBR-002 8.10 then the is true. iii) Otherwise, the is false. 3) If PARTIAL is specified, then Case: a) If all values in R are the null value, then the is true. b) Otherwise, Case: i) If UNIQUE is not specified and there exists a (possibly non-unique) row RTi of the
such that each non-null value of R equals its corresponding value in RTi, then the is true. ii) If UNIQUE is specified and there is a unique row RTi of the
such that each non-null value of R equals its corresponding value in RTi, then the is true. iii) Otherwise, the is false. 4) If FULL is specified, then Case: a) If all values in R are the null value, then the is true. b) If no values in R are the null value, then Case: i) If UNIQUE is not specified and there exists a (possibly non-unique) row RTi of the
such that R = RTi then the is true. ii) If UNIQUE is specified and there exists a unique row RTi of the
such that R = RTi then the is true. iii) Otherwise, the is false. c) Otherwise, the is false. Predicates 225 X3H2-92-154/DBL CBR-002 8.10 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 226 Database Language SQL X3H2-92-154/DBL CBR-002 8.11 8.11 Function Specify a test for an overlap between two events. Format ::= OVERLAPS ::= ::= Syntax Rules 1) The degree of and shall both be 2. 2) The data type of the first column of each shall be a datetime data type and the first column of each shall be comparable. Note: Two datetimes are comparable only if they have the same s; see Subclause 4.5.1, "Datetimes". 3) The data type of the second column of each shall be a datetime data type or INTERVAL. Case: a) If the data type is INTERVAL, then the precision of the data type shall be such that the interval can be added to the datetime data type contained in the first column of the . b) If the data type is a datetime data type, then it shall be comparable with the datetime data type contained in the first column of the . Access Rules None. General Rules 1) Let D1 be the value of the first column of and D2 be the value of the first column of . Predicates 227 X3H2-92-154/DBL CBR-002 8.11 2) Case: a) If the data type of the second column of is a datetime data type, then let E1 be the value of the second column of . b) If the data type of the second column of is INTERVAL, then let I1 be the value of the second column of . Let E1 = D1 + I1. 3) If D1 is the null value or if E1 < D1, then let S1 = E1 and let T1 = D1. Otherwise, let S1 = D1 and let T1 = E1. 4) Case: a) If the data type of the second column of is a datetime data type, then let E2 be the value of the second column of . b) If the data type of the second column of is INTERVAL, then let I2 be the value of the second column of . Let E2 = D2 + I2. 5) If D2 is the null value or if E2 < D2, then let S2 = E2 and let T2 = D2. Otherwise, let S2 = D2 and let T2 = E2. 6) The result of the is the result of the following expression: ( S1 > S2 AND NOT ( S1 >= T2 AND T1 >= T2 ) ) OR ( S2 > S1 AND NOT ( S2 >= T1 AND T2 >= T1 ) ) OR ( S1 = S2 AND ( T1 <> T2 OR T1 = T2 ) ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . 228 Database Language SQL X3H2-92-154/DBL CBR-002 8.12 8.12 Function Specify a condition that has the truth value true, false, or unknown, depending on the result of applying boolean operators to specified conditions. Format ::= | OR ::= | AND ::= [ NOT ] ::= [ IS [ NOT ] ] ::= TRUE | FALSE | UNKNOWN ::= | Syntax Rules 1) If NOT is specified in a , then let BP be the contained and let TV be the contained . The is equivalent to: ( NOT ( BP IS TV ) ) Access Rules None. General Rules 1) The result is derived by the application of the specified boolean operators ("AND", "OR", "IS", and "NOT") to the results derived from each evaluation. If boolean operators are not specified, then the result of the is the result of the specified . Predicates 229 X3H2-92-154/DBL CBR-002 8.12 2) NOT(true) is false, NOT(false) is true, and NOT(unknown) is unknown. Table 13, "Truth table for the AND boolean", Table 14, "Truth table for the OR boolean", and Table 15, "Truth table for the IS boolean" specify the semantics of AND, OR, and IS, respectively. ______________Table_13-Truth_table_for_the_AND_boolean_____________ ___________________________________________________________________ | true | true | false | unknown | | | | | | | false | false | false | false | | | | | | |__________|_________|__________|__________________________________| | | | | | ______________Table_14-Truth_table_for_the_OR_boolean______________ ___________________________________________________________________ | true | true | true | true | | | | | | | false | true | false | unknown | | | | | | |__________|_________|__________|__________________________________| | | | | | ______________Table_15-Truth_table_for_the_IS_boolean______________ _IS_________TRUE______FALSE______UNKNOWN___________________________ | true | true | false | false | | | | | | | false | false | true | false | | | | | | |__________|_________|__________|__________________________________| | | | | | 3) When a S is evaluated against a row of a table, each reference to a column of that table by a directly contained in S is a reference to the value of that column in that row. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not specify a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 230 Database Language SQL X3H2-92-154/DBL CBR-002 9 Data assignment rules 9.1 Retrieval assignment Function Specify rules for value assignments that retrieve SQL-data. Syntax Rules 1) Let T and V be a TARGET and VALUE specified in an application of this Subclause. 2) If the data type of T is character string, bit string, numeric, datetime, or interval, then the data type of V shall be a mu- tually assignable character string type, a bit string type, a numeric type, the same datetime type, or a comparable interval type, respectively. General Rules 1) If V is the null value, then Case: a) If an indicator is specified for T, then that indicator is set to -1. b) If no indicator is specified for T, then an exception con- dition is raised: data exception-null value, no indicator parameter. 2) If V is not the null value and T has an indicator, then Case: a) If the data type of T is character string or bit string and the length in characters or bits, respectively, M of V is greater than the length in characters or bits, respectively, of T, then the indicator is set to M. If M exceeds the maxi- mum value that the indicator can contain, then an exception condition is raised: data exception-indicator overflow. b) Otherwise, the indicator is set to 0. 3) If V is not the null value, then Case: a) If the data type of T is fixed-length character string with length in characters L and the length in characters of V is equal to L, then the value of T is set to V. Data assignment rules 231 X3H2-92-154/DBL CBR-002 9.1 Retrieval assignment b) If the data type of T is fixed-length character string with length in characters L, and the length in characters of V is greater than L, then the value of T is set to the first L characters of V and a completion condition is raised: warning-string data, right truncation. c) If the data type of T is fixed-length character string with length in characters L, and the length in characters M of V is smaller than L, then the first M characters of T are set to V, and the last L-M characters of T are set to s. d) If the data type of T is variable-length character string and the length in characters M of V is not greater than the maximum length in characters of T, then the value of T is set to V and the length in characters of T is set to M. e) If the data type of T is variable-length character string and the length in characters of V is greater than the maximum length in characters L of T, then the value of T is set to the first L characters of V, the length in characters of T becomes L, and a completion condition is raised: warning- string data, right truncation. f) If the data type of T is fixed-length bit string with length in bits L and the length in bits of V is equal to L, then the value of T is set to V. g) If the data type of T is fixed-length bit string with length in bits L and the length in bits of V is greater than L, then the value of T is set to the first L bits of V and a completion condition is raised: warning-string data, right truncation. h) If the data type of T is fixed-length bit string with length in bits L and the length in bits M of V is smaller than L, then the first M bits of T are set to V, the remaining bits of T are set to bits each with the value of 0, and a comple- tion condition is raised: warning-implicit zero-bit padding. i) If the data type of T is variable-length bit string and the length in bits M of V is not greater than the maximum length in bits of T, then the value of T is set to V and the length in bits of T is set to M. j) If the data type of T is variable-length bit string, and the length in bits of V is greater than the maximum length in bits L of T, then the value of T is set to the first L bits of V, the length in bits of T is set to L, and a completion condition is raised: warning-string data, right truncation. 232 Database Language SQL X3H2-92-154/DBL CBR-002 9.1 Retrieval assignment k) If the data type of T is numeric and there is an approxi- mation obtained by rounding or truncation of the numerical value of V for the data type of T, then the value of T is set to such an approximation. If there is no such approximation, then an exception condi- tion is raised: data exception-numeric value out of range. If the data type of T is exact numeric, then it is implementation- defined whether the approximation is obtained by rounding or by truncation. l) If the data type of T is datetime and there is a representa- tion of the value of V in the data type of T, then the value of T is set to that representation. m) If the data type of T is interval and there is a representa- tion of the value of V in the data type of T, then the value of T is set to that representation. Otherwise, an exception condition is raised: data exception-interval field overflow. Data assignment rules 233 X3H2-92-154/DBL CBR-002 9.2 Store assignment 9.2 Store assignment Function Specify rules for value assignments that store SQL-data. Syntax Rules 1) Let T and V be a TARGET and VALUE specified in an application of this Subclause. 2) If the data type of T is character string, bit string, numeric, datetime, or interval, then the data type of V shall be char- acter string, bit string, numeric, the same datetime type, or a comparable interval type, respectively. General Rules 1) Let T be an object column. 2) If the value of V is the null value, then the value of T is set to the null value. 3) Otherwise, let V denote a non-null value of T. Case: a) If the data type of T is fixed-length character string with length in characters L and the length in characters of V is equal to L, then the value of T is set to V. b) If the data type of T is fixed-length character string with length in characters L and the length in characters M of V is larger than L, then Case: i) If the rightmost M-L characters of V are all s, then the value of T is set to the first L characters of V. ii) If one or more of the rightmost M-L characters of V are not s, then an exception condition is raised: data exception-string data, right truncation. c) If the data type of T is fixed-length character string with length in characters L and the length in characters M of V is less than L, then the first M characters of T are set to V and the last L-M characters of T are set to s. d) If the data type of T is variable-length character string and the length in characters M of V is not greater than the maximum length in characters of T, then the value of T is set to V and the length in characters of T is set to M. e) If the data type of T is variable-length character string and the length in characters M of V is greater than the maximum length in characters L of T, then, 234 Database Language SQL X3H2-92-154/DBL CBR-002 9.2 Store assignment Case: i) If the rightmost M-L characters of V are all s, then the value of T is set to the first L characters of V and the length in characters of T is set to L. ii) If one or more of the rightmost M-L characters of V are not s, then an exception condition is raised: data exception-string data, right truncation. f) If the data type of T is fixed-length bit string with length in bits L and the length in bits of V is equal to L, then the value of T is set to V. g) If the data type of T is fixed-length bit string with length in bits L and the length in bits M of V is greater than L, then an exception condition is raised: data exception-string data, right truncation. h) If the data type of T is fixed-length bit string with length in bits L and the length in bits M of V is less than L, then an exception condition is raised: data exception-string data, length mismatch. i) If the data type of T is variable-length bit string and the length in bits M of V is not greater than the maximum length in bits of T, then the value of T is set to V and the length in bits of T is set to M. j) If the data type of T is variable-length bit string, and the length in bits M of V is greater than the maximum length in bits L of T, then an exception condition is raised: data exception-string data, right truncation. k) If the data type of T is numeric and there is an approxi- mation obtained by rounding or truncation of the numerical value of V for the data type of T, then the value of T is set to such an approximation. If there is no such approximation, then an exception condi- tion is raised: data exception-numeric value out of range. If the data type of T is exact numeric, then it is implementation- defined whether the approximation is obtained by rounding or by truncation. l) If the data type of T is datetime and there is a representa- tion of the value of V in the data type of T, then the value of T is set to that representation. m) If the data type of T is interval and there is a representa- tion of the value of V in the data type of T, then the value of T is set to that representation. Otherwise, an exception condition is raised: data exception-interval field overflow. Data assignment rules 235 X3H2-92-154/DBL CBR-002 9.2 Store assignment 4) If the column definition of T includes the name of a domain whose domain descriptor includes a domain constraint D, then D is effectively checked. If D is not satisfied, then an exception condition is raised: integrity constraint violation. 236 Database Language SQL X3H2-92-154/DBL CBR-002 9.3 Set operation result data types 9.3 Set operation result data types Function Specify the Syntax Rules and result data types for s and s having set operators. Syntax Rules 1) Let DTS be a set of data types specified in an application of this Subclause. 2) All of the data types in DTS shall be comparable. 3) Case: a) If any of the data types in DTS is character string, then all data types in DTS shall be character string, and all of them shall have the same character repertoire. That charac- ter repertoire is the character repertoire of the result. The character set of the result is the character set of one of the data types in DTS. The specific character set chosen is implementation-dependent. The collating sequence and the co- ercibility attribute are determined as specified in Table 2, "Collating coercibility rules for dyadic operators". Case: i) If any of the data types in DTS is variable-length char- acter string, then the result data type is variable-length character string with maximum length in characters equal to the maximum of the lengths in characters and maximum lengths in characters of the data types in DTS. ii) Otherwise, the result data type is fixed-length character string with length in characters equal to the maximum of the lengths in characters of the data types in DTS. b) If any of the data types in DTS is bit string, then all data types in DTS shall be bit string. Case: i) If any of the data types in DTS is variable-length bit string, then the result data type is variable-length bit string with maximum length in bits equal to the maximum of the lengths in bits and maximum lengths in bits of the data types in DTS. ii) Otherwise, the result data type is fixed-length bit string with length in bits equal to the maximum of the lengths in bits of the data types in DTS. Data assignment rules 237 X3H2-92-154/DBL CBR-002 9.3 Set operation result data types c) If all of the data types in DTS are exact numeric, then the result data type is exact numeric with implementation-defined precision and with scale equal to the maximum of the scales of the data types in DTS. d) If any data type in DTS is approximate numeric, then each data type in DTS shall be numeric and the result data type is approximate numeric with implementation-defined precision. e) If any data type in DTS is a datetime data type, then each data type in DTS shall be the same datetime data type. The result data type is the same datetime data type. f) If any data type in DTS is interval, then each data type in DTS shall be interval. If the precision of any data type in DTS specifies YEAR or MONTH, then the precision of each data type shall specify only YEAR or MONTH. If the preci- sion of any data type in DTS specifies DAY, HOUR, MINUTE, or SECOND(N), then the precision of no data type of DTS shall specify the s YEAR and MONTH. The result data type is interval with precision "S TO E", where S and E are the most significant of the s and the least significant of the s of the data types in DTS, respectively. General Rules None. 238 Database Language SQL X3H2-92-154/DBL CBR-002 10 Additional common elements 10.1 Function Specify the precision of an interval data type. Format ::= TO | ::= [ ] ::= | SECOND [ ] ::= [ ] | SECOND [ [ ] ] ::= | SECOND ::= YEAR | MONTH | DAY | HOUR | MINUTE ::= ::= Additional common elements 239 X3H2-92-154/DBL CBR-002 10.1 Syntax rules 1) There is a significance of ordering of s. In order from most significant to least significant, the ordering is: YEAR, MONTH, DAY, HOUR, MINUTE, and SECOND. A or with an i is more significant than a or with an j if i>j. An or with an i is more significant than an or with an j if i>j. 2) If TO is specified, then: a) shall be more significant than , b) shall not specify MONTH, and c) if specified YEAR, then shall spec- ify MONTH. 3) The maximum value of is implementation-defined, but shall not be less than 2. 4) The maximum value of is implementation-defined, but shall not be less than 6. 5) An , if specified, shall be greater than 0 and shall not be greater than the implementation- defined maximum. If is not specified, then an of 2 is implicit. 6) An , if specified, shall be greater than or equal to 0 and shall not be greater than the implementation-defined maximum. If SECOND is specified and is not specified, then an of 6 is implicit. Access Rules None. General Rules 1) An item qualified by an contains the date- time fields identified by the . Case: a) If the specifies a , then the identifies a single . Any reference to the most significant or 240 Database Language SQL X3H2-92-154/DBL CBR-002 10.1 least significant of the item refers to that . b) Otherwise, the identifies those datetime fields from to , inclusive. 2) An specifies Case: a) If the is SECOND, then the number of decimal digits of precision before the specified or implied decimal point of the seconds . b) Otherwise, the number of decimal digits of precision of the first . 3) An specifies the num- ber of decimal digits of precision following the specified or implied decimal point in the SECOND. 4) If is not specified and and are the same , then the is equivalent to a that is that . 5) The length in positions of an item of type interval is computed as follows. Case: a) If the item is a year-month interval, then Case: i) If the is a , then the length in positions of the item is the implicit or explicit of the . ii) Otherwise, the length in positions of the item is the im- plicit or explicit of the plus 2 (the length of the that is the ) plus 1 (the length of the between the and the in a ). b) Otherwise, Case: i) If the is a that does not specify SECOND, then the length in positions of the item is the implicit or explicit of the . Additional common elements 241 X3H2-92-154/DBL CBR-002 10.1 ii) If the is a that specifies SECOND, then the length in positions of the item is the implicit or explicit of the plus the implicit or explicit . If is greater than zero, then the length in positions of the item is increased by 1 (the length in positions of the between the and the ). iii) Otherwise, let participating datetime fields mean the date- time fields that are less significant than the and more significant than the of the . The length in positions of each par- ticipating datetime field is 2. Case: 1) If is SECOND, then the length in positions of the item is the implicit or explicit , plus 3 times the number of par- ticipating datetime fields (each participating datetime field has length 2 positions , plus the s or s that precede them have length 1 position), plus the implicit or explicit , plus 1 (the length in positions of the preceding the ). If is greater than zero, then the length in positions of the item is increased by 1 (the length in positions of the within the field identified by the ). 2) Otherwise, the length in positions of the item is the implicit or explicit , plus 3 times the number of participating datetime fields (each participating datetime field has length 2 positions, plus the s or s that pre- cede them have length 1 position), plus 2 (the length in positions of the ), plus 1 (the length in positions of the preceding the ). Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . 242 Database Language SQL X3H2-92-154/DBL CBR-002 10.2 10.2 Function Specify a standard programming language. Format ::= LANGUAGE ::= ADA | C | COBOL | FORTRAN | MUMPS | PASCAL | PLI Syntax Rules None. Access Rules None. General Rules 1) The standard programming language specified by the clause is defined in the International Standard identified by the keyword. Table 16, "Standard programming languages", specifies the relationship. ______________Table_16-Standard_programming_languages______________ Language _keyword______Relevant_standard____________________________________ | ADA | ISO/IEC 8652 | | | | | C | ISO/IEC 9899 | | | | | COBOL | ISO 1989 | | | | | FORTRAN | ISO/IEC 1539 | | | | | MUMPS | ISO/IEC 11756 | | | | | PASCAL | ISO 7185 and ISO/IEC 10206 | | | | |_PLI________|_ISO_6160____________________________________________| | | | Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. Additional common elements 243 X3H2-92-154/DBL CBR-002 10.2 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not specify MUMPS. 244 Database Language SQL X3H2-92-154/DBL CBR-002 10.3 10.3 Function Specify privileges. Format ::= ALL PRIVILEGES | ::= [ { }... ] ::= SELECT | DELETE | INSERT [ ] | UPDATE [ ] | REFERENCES [ ] | USAGE ::= ::= PUBLIC | Syntax Rules 1) If the of the or specifying specifies
, then let T be the table identified by that
. T shall not be a declared local temporary table. 2) If T is a temporary table, then shall specify ALL PRIVILEGES. 3) Each in a shall identify a column of T. 4) UPDATE () is equivalent to the spec- ification of UPDATE () for each in . INSERT () is equivalent to the specification of INSERT () for each in . REFERENCES () is equivalent to the specification of Additional common elements 245 X3H2-92-154/DBL CBR-002 10.3 REFERENCES () for each in . 5) ALL PRIVILEGES is equivalent to the specification of all of the privileges on for which the current has grantable privilege descriptors. Access Rules None. General Rules 1) A of PUBLIC denotes at all times a list of s containing all of the s in the SQL environment. 2) The set of applicable privileges for an includes those privileges defined by privilege descriptors associated with that , together with those defined by privilege descriptors associated with PUBLIC. 3) UPDATE () specifies the UPDATE privilege on the in- dicated column and implies one or more column privilege descrip- tors. If the is omitted, then UPDATE specifies the UPDATE privilege on all columns of T including any column subsequently added to T and implies a table privilege descriptor and one or more column privilege descriptors. 4) INSERT () specifies the INSERT privilege on the in- dicated column and implies one or more column privilege descrip- tors. If the is omitted, then INSERT specifies the INSERT privilege on all columns of T including any column subsequently added to T and implies a table privilege descriptor and one or more column privilege descriptors. 5) REFERENCES () specifies the REFERENCES privilege on the indicated column and implies one or more column privilege descriptors. If the is omitted, then REFERENCES specifies the REFERENCES privilege on all columns of T including any column subsequently added to T and implies a table privilege descriptor and one or more column privilege descriptors. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) An that specifies INSERT shall not contain a . 246 Database Language SQL X3H2-92-154/DBL CBR-002 10.3 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Additional common elements 247 X3H2-92-154/DBL CBR-002 10.4 10.4 Function Identify a character set. Format ::= | | | | ::= ::= ::= ::= ::= Syntax Rules 1) The s, s, s, and s that are supported are implementation-defined. 2) A character set identified by a , by an , by a , or by an has associated with it a privilege descriptor that was effec- tively defined by the GRANT USAGE ON CHARACTER SET CS TO PUBLIC WITH GRANT OPTION where CS is the contained in the . The grantor of the privilege descriptor is set to the special grantor value "_SYSTEM". 3) The s shall include SQL_TEXT. 248 Database Language SQL X3H2-92-154/DBL CBR-002 10.4 Access Rules 1) Let C be the contained in the . The applicable privileges shall include USAGE on C. General Rules 1) A identifies a character set. Let the identified character set be CS. Note: A character set comprises the characters in the character set's repertoire together with a form-of-use that specifies the convention for arranging those characters into character strings. 2) A specifies the name of a character repertoire that is defined by a national or interna- tional standard. The character repertoire and form-of-use of CS, implied by the , are defined by the standard that defined that . The default collating sequence of the character reper- toire is defined by the order of the characters in the standard and has the PAD SPACE attribute. 3) An speci- fies the name of a character repertoire that is implementation- defined. The character repertoire and form-of-use of CS, implied by the , are implementation-defined. The default collating sequence of the character repertoire and whether the collating sequence has the NO PAD attribute or the PAD SPACE attribute is implementation- defined. 4) A identifies a charac- ter set whose descriptor is in some schema whose is not INFORMATION_SCHEMA. Note: The default collating sequence and form-of-use of CS are as defined in Subclause 11.28, "". 5) A identifies form-of-use that is defined by some national or international standard. That form-of-use is the form-of-use of CS. The charac- ter repertoire of CS is as defined in that standard. The default collating sequence of the character repertoire is defined by the order of the characters in ISO/IEC 10646 and has the PAD SPACE attribute. Note: Specific forms-of-use implied by this rule include ISO 2022 code extension techniques. 6) An identifies an implementation-defined form-of-use that shall be the form-of-use of CS. The implied character repertoire and Additional common elements 249 X3H2-92-154/DBL CBR-002 10.4 default collating sequence of CS and whether the collating se- quence has the NO PAD attribute or the PAD SPACE attribute are implementation-defined. Note: Specific forms-of-use implied by this rule include implementation-defined techniques such as mixed one-octet/two- octet Latin/Kanji or Compound String. 7) There is a character set descriptor for every character set that can be specified by a . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . 250 Database Language SQL X3H2-92-154/DBL CBR-002 10.5 10.5 Function Specify a collating sequence. Format ::= COLLATE Syntax Rules None. Access Rules 1) Let C be the contained in the . The applicable privileges shall include USAGE on C. General Rules None. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Additional common elements 251 X3H2-92-154/DBL CBR-002 10.6 and 10.6 and Function Specify the name of a constraint and its attributes. Format ::= CONSTRAINT ::= [ [ NOT ] DEFERRABLE ] | [ NOT ] DEFERRABLE [ ] ::= INITIALLY DEFERRED | INITIALLY IMMEDIATE Syntax Rules 1) If a is contained in a , and if the contains a , then that shall be the same as the specified or implicit of the containing . 2) The of shall be differ- ent from the of the of any other constraint defined in the same schema. 3) If is not specified, then INITIALLY IMMEDIATE is implicit. 4) Case: a) If INITIALLY DEFERRED is specified, then: i) NOT DEFERRABLE shall not be specified. ii) If DEFERRABLE is not specified, then DEFERRABLE is im- plicit. b) If INITIALLY IMMEDIATE is specified or implicit and nei- ther DEFERRABLE nor NOT DEFERRABLE is specified, then NOT DEFERRABLE is implicit. Access Rules None. 252 Database Language SQL X3H2-92-154/DBL CBR-002 10.6 and General Rules 1) If NOT DEFERRABLE is specified, then the constraint is not de- ferrable; otherwise it is deferrable. 2) If is INITIALLY DEFERRED, then the ini- tial constraint mode for the constraint is deferred; otherwise, the initial constraint mode for the constraint is immediate. 3) If, on completion of any SQL-statement, the constraint mode of any constraint is immediate, then that constraint is effectively checked. Note: This includes the cases where is a , a , or the statement that causes a constraint with a constraint mode of initially immediate to be created. 4) When a constraint is effectively checked, if the constraint is not satisfied, then an exception condition is raised: integrity constraint violation. If this exception condition is raised as a result of executing a , then SQLSTATE is not set to integrity constraint violation, but is set to transaction rollback-integrity constraint violation (see the General Rules of Subclause 14.3, ""). Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no ex- plicit . Note: This means that INITIALLY IMMEDIATE NOT DEFERRABLE is implicit. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Intermediate SQL language shall contain no . Additional common elements 253 X3H2-92-154/DBL CBR-002 254 Database Language SQL X3H2-92-154/DBL CBR-002 11 Schema definition and manipulation 11.1 Function Define a schema. Format ::= CREATE SCHEMA [ ] [ ... ] ::= | AUTHORIZATION | AUTHORIZATION ::= ::= DEFAULT CHARACTER SET ::= |
| | | | | | Syntax Rules 1) If is not specified, then a equal to is implicit. 2) If AUTHORIZATION is not speci- fied, then Schema definition and manipulation 255 X3H2-92-154/DBL CBR-002 11.1 Case: a) If the is contained in a that has a specified, then an equal to that is implicit for the . b) Otherwise, an equal to the SQL- session is implicit. 3) The of the explicit or implicit shall be different from the of the of any other schema in the catalog identified by the of . 4) If a appears in a in a , then the effective and during processing of the is the and specified or implicit in the . Other SQL-statements executed in s in the have the and specified or implicit for the . 5) If is not specified, then a containing an implementation-defined is im- plicit. Access Rules 1) The privileges necessary to execute the are implementation-defined. General Rules 1) A schema S is created with a name equal to the explicit or im- plicit and a default character set name equal to the of the explicit or implicit . 2) The is the current for privilege determination for S. 3) Those objects defined by s (base tables, views, constraints, domains, assertions, character sets, translations, collations, privileges) and their associated descriptors are effectively created. 4) The explicit or implicit is used as the default character set used for all s and s that do not specify an explicit charac- ter set. 256 Database Language SQL X3H2-92-154/DBL CBR-002 11.1 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . b) Conforming Intermediate SQL language shall not contain any . c) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Intermediate SQL language shall not contain any . b) A shall specify AUTHORIZATION and shall not specify a . c) A shall not be speci- fied. d) Conforming Entry SQL language shall not contain any . Schema definition and manipulation 257 X3H2-92-154/DBL CBR-002 11.2 11.2 Function Destroy a schema. Format ::= DROP SCHEMA ::= CASCADE | RESTRICT Syntax Rules 1) Let S be the schema identified by . 2) S shall identify a schema in the catalog identified by the ex- plicit or implicit . 3) If RESTRICT is specified, then S shall not contain any per- sistent base tables, global temporary tables, created local temporary tables, views, domains, assertions, character sets, collations, or translations. Note: If CASCADE is specified, then such objects will be dropped by the effective execution of the SQL schema manipulation state- ments specified in the General Rules of this Subclause. Access Rules 1) The current shall be equal to the that owns the schema identified by the . General Rules 1) Let T be the
of any base table or temporary ta- ble contained in S. The following is effectively executed: DROP TABLE T CASCADE 2) Let V be the
of any view contained in S. The fol- lowing is effectively executed: DROP VIEW V CASCADE 3) Let D be the of any domain contained in S. The following is effectively executed: DROP DOMAIN D CASCADE 258 Database Language SQL X3H2-92-154/DBL CBR-002 11.2 4) Let A be the of any assertion contained in S. The following is effectively exe- cuted: DROP ASSERTION A 5) Let CD be the of any collation definition contained in S. The following is effectively executed: DROP COLLATION CD 6) Let TD be the of any translation contained in S. The following is effectively executed: DROP TRANSLATION TD 7) Let RD be the of any character set con- tained in S. The following is effectively executed: DROP CHARACTER SET RD 8) The identified schema and its description are destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . Schema definition and manipulation 259 X3H2-92-154/DBL CBR-002 11.3
11.3
Function Define a persistent base table, a created local temporary table, or a global temporary table. Format
::= CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE
[ ON COMMIT { DELETE | PRESERVE } ROWS ]
::=
[ {
}... ]
::= |
Syntax Rules 1) If a
is contained in a , and if the
contains a , then that shall be the same as the specified or implicit of the containing . 2) The schema identified by the explicit or implicit schema name of the
shall not include a table descriptor whose table name is
. 3) If ON COMMIT is specified, then TEMPORARY shall be specified. 4) If TEMPORARY is specified and ON COMMIT is not specified, then ON COMMIT DELETE ROWS is implicit. 5) A
shall contain at least one . 6) The scope of the
is the
. Access Rules 1) If a
is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the
. 260 Database Language SQL X3H2-92-154/DBL CBR-002 11.3
General Rules 1) A
defines either a persistent base table, a global temporary table or a created local temporary table. If GLOBAL is specified, then a global temporary table is defined. If LOCAL is specified, then a created local temporary table is defined. Otherwise, a persistent base table is defined. 2) The degree of the table being created is initially set to 0; the General Rules of Subclause 11.4, "" specify the degree of the table being created during the definition of columns in that table. 3) A table descriptor is created that describes the table being defined. a) The name included in the table descriptor is
. b) The table descriptor includes the degree of the table, which is the number of
s in the
that are s. 4) A set of privilege descriptors is created that define the priv- ileges INSERT, SELECT, UPDATE, DELETE, and REFERENCES on this table and INSERT, SELECT, UPDATE, and REFERENCES for every in the table definition to the of the or in which the
appears. These privileges are grantable. The grantor for each of these privilege descriptors is set to the special grantor value "_SYSTEM". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not specify TEMPORARY and shall not reference any global or local tem- porary table. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 261 X3H2-92-154/DBL CBR-002 11.4 11.4 Function Define a column of a table. Format ::= { | } [ ] [ ... ] [ ] ::= [ ] [ ] ::= NOT NULL | | | Syntax Rules 1) Case: a) If the is contained in a
, then let T be the table defined by that
. b) If the is contained in a , then let T be the table declared by that . c) If the is contained in an , then let T be the table identified in the containing . The in the shall be different from the of any column of T. 2) The i-th column of the table is described by the i-th in the
. The name and the data type or domain of the column are specified by the and or , respectively. 3) Let C be the of a . 4) If is specified, then let D be the domain identi- fied by the . 262 Database Language SQL X3H2-92-154/DBL CBR-002 11.4 5) The data type of the column is Case: a) If is specified, then that data type. b) Otherwise, the data type of D. 6) If the data type of the column is character string, then the collation of the column is Case: a) If is specified, then the collation speci- fied by that . b) If is specified, then the collation of D, if any. c) Otherwise, the default collation of the character set of the column. Note: The character set of a column is determined by its data type. 7) If a is specified, then: a) Let DT be the . b) The data type of the column is DT. c) If DT is CHARACTER or CHARACTER VARYING and does not spec- ify a , then the specified or implicit in the of the that created the schema identified by the immedi- ately contained in the
of the containing
or is implicit. d) If DT is a that identifies a char- acter set that specifies a and the does not contain a , then the of the is implicit in the . 8) If is specified, then data type shall be a character string type. 9) If a is specified, then let CND be the if one is specified and let CND be a zero-length string otherwise; let CA be the if specified and let CA be a zero-length string otherwise. The is equivalent to a
as follows: Schema definition and manipulation 263 X3H2-92-154/DBL CBR-002 11.4 Case: a) If a is specified that con- tains the NOT NULL, then it is equivalent to a
that contains the follow- ing
: CND CHECK ( C IS NOT NULL ) CA b) If a is specified that con- tains a , then it is equivalent to a
that contains the following
: CND (C) CA Note: The is defined in Subclause 11.7, "". c) If a is specified that con- tains a , then it is equivalent to a
that contains the following
: CND FOREIGN KEY (C) CA Note: The is defined in Subclause 11.8, "". d) If a is specified that con- tains a , then it is equivalent to a
that contains the follow- ing
: CND CHECK ( ) CA Each directly contained in the shall reference column C. Access Rules 1) If is specified, then the applicable privileges shall include USAGE on D.. General Rules 1) A defines a column in a table. 2) The specifies the default collating sequence for the column. If is not specified, then the default collating sequence is that used for comparisons of Coercible coercibility attribute, as defined in Subclause 8.2, "". 3) If the specifies , then a data type descriptor is created that describes the data type of the column being defined. 264 Database Language SQL X3H2-92-154/DBL CBR-002 11.4 4) The degree of the table T being defined in the containing
or or altered by the containing is increased by 1. 5) A column descriptor is created that describes the column being defined. The name included in the column descriptor is . If the specifies , then the column descriptor includes the data type descriptor of the column; otherwise, the column descriptor includes the name of the domain of the column. The ordinal position included in the column descriptor is equal to the degree of T. If the contains a , then the of the is included in the column descriptor. The column descriptor includes the nullability char- acteristic of the column, determined according to the rules in Subclause 4.8, "Columns". The column descriptor is included in the table descriptor for T. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not contain a . b) A shall not contain a . c) Conforming Intermediate SQL language shall contain no . Schema definition and manipulation 265 X3H2-92-154/DBL CBR-002 11.5 11.5 Function Specify the default for a column or domain. Format ::= DEFAULT ::= | | USER | CURRENT_USER | SESSION_USER | SYSTEM_USER | NULL Syntax Rules 1) The subject data type of a is the data type specified in the descriptor identified by the containing , , , or . 2) If USER is specified, then CURRENT_USER is implicit. 3) Case: a) If a is specified, then: Case: i) If the subject data type is character string, then the shall be a . If the length of the subject data type is fixed, then the length in characters of the shall not be greater than the length of the subject data type. If the length of the subject data type is variable, then the length in characters of the shall not be greater than the maximum length of the subject data type. The shall have the same character repertoire as the subject data type. ii) If the subject data type is bit string, then the shall be a or a . If the length of the subject data type is fixed, then the length in bits of the or shall not be greater than the length of the sub- ject data type. If the length of the subject data type is 266 Database Language SQL X3H2-92-154/DBL CBR-002 11.5 variable, then the length in bits of the or shall not be greater than the maximum length of the subject data type. iii) If the subject data type is exact numeric, then the shall be a that simply contains an . There shall be a rep- resentation of the value of the in the subject data type that does not lose any significant digits. iv) If the subject data type is approximate numeric, then the shall be a . v) If the subject data type is datetime, then the shall be a and shall contain the same s as the subject data type. vi) If the subject data type is interval, then the shall be an and shall contain the same as the subject data type. b) If CURRENT_USER, SESSION_USER, or SYSTEM_USER is specified, then the subject data type shall be character string with character set SQL_TEXT. If the length of the subject data type is fixed, then its length shall not be less than 128 characters. If the length of the subject data type is vari- able, then its maximum length shall not be less than 128 characters. c) If is specified, then the subject data type shall be datetime with the same datetime type as the datetime data type of the . Access Rules None. General Rules 1) The default value inserted in the column descriptor, if the is to apply to a column, or in the domain de- scriptor, if the is to apply to a domain, is as follows: Case: a) If the contains NULL, then the null value. b) If the contains a , then Case: i) If the subject data type is numeric, then the numeric value of the . Schema definition and manipulation 267 X3H2-92-154/DBL CBR-002 11.5 ii) If the subject data type is character string with variable length, then the value of the . iii) If the subject data type is character string with fixed length, then the value of the , extended as neces- sary on the right with s to the length in characters of the subject data type. iv) If the subject data type is bit string with variable length, then the value of the . v) If the subject data type is bit string with fixed length, then the value of the extended as necessary on the right with 0-valued bits to the length of the subject data type and a completion condition is raised: warning- implicit zero-bit padding. vi) If the subject data type is datetime or interval, then the value of the . c) If the specifies CURRENT_USER, SESSION_USER, or SYSTEM_USER, then Case: i) If the subject data type is character string with variable length, then the value specified by CURRENT_USER, SESSION_ USER, or SYSTEM_USER. ii) If the subject data type is character string with fixed length, then the value specified by CURRENT_USER, SESSION_ USER, or SYSTEM_USER, extended as necessary on the right with s to the length in characters of the subject data type. d) If the contains a , then the value of an implicit reference to the . 2) The default value of a column is Case: a) If the column descriptor of a column includes a default value derived from a , then the value of that . b) If the column descriptor includes a domain name that iden- tifies a domain descriptor that includes a default value derived from a , then the value of that . c) Otherwise, the null value. 268 Database Language SQL X3H2-92-154/DBL CBR-002 11.5 Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not specify a , SYSTEM_USER, SESSION_USER, or CURRENT_USER. Schema definition and manipulation 269 X3H2-92-154/DBL CBR-002 11.6
11.6
Function Specify an integrity constraint. Format
::= [ ]
[ ]
::= | | Syntax Rules 1) If is not specified, then INITIALLY IMMEDIATE NOT DEFERRABLE is implicit. 2) If is not specified, then a that contains an implementation- dependent is implicit. The assigned shall obey the Syntax Rules of an explicit . Access Rules None. General Rules 1) A
defines a table constraint. 2) A table constraint descriptor is created that describes the table constraint being defined. The table constraint descriptor includes the contained in the explicit or implicit . The table constraint descriptor includes an indication of whether the constraint is deferrable or not deferrable and whether the initial constraint mode of the constraint is de- ferred or immediate. Case: a) If is specified, then the table constraint descriptor is a unique constraint descriptor that includes an indication of whether it was defined with PRIMARY KEY or UNIQUE, and the names of the unique columns specified in the . 270 Database Language SQL X3H2-92-154/DBL CBR-002 11.6
b) If is specified, then the table constraint descriptor is a referential constraint de- scriptor that includes the names of the referencing columns specified in the and the names of the referenced columns and referenced table specified in the , the value of the , if specified, and the , if specified. c) If is specified, then the table constraint descriptor is a table check constraint descriptor that includes the . 3) If the
is a , then let SC be the immediately contained in the and let T be the table name included in the corresponding table constraint descriptor; the table constraint is not satisfied if and only if EXISTS ( SELECT * FROM T WHERE NOT ( SC ) ) is true. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Intermediate SQL language shall contain no . Schema definition and manipulation 271 X3H2-92-154/DBL CBR-002 11.7 11.7 Function Specify a uniqueness constraint for a table. Format ::= ::= UNIQUE | PRIMARY KEY ::= Syntax Rules 1) Let T be the table identified by the containing
or . Let TN be the
of T. 2) Let UCL be the of the . 3) Case: a) If the specifies PRIMARY KEY, then let SC be the : UNIQUE ( SELECT UCL FROM TN ) AND ( UCL ) IS NOT NULL b) Otherwise, let SC be the : UNIQUE ( SELECT UCL FROM TN ) 4) Each in the shall identify a column of T, and the same column shall not be identified more than once. 5) A
shall specify at most one implicit or ex- plicit that specifies PRIMARY KEY. 6) If a that specifies PRIMARY KEY is contained in an , then the table identified by the
immediately contained in the containing shall not have a unique constraint that was defined by a that specified PRIMARY KEY. 272 Database Language SQL X3H2-92-154/DBL CBR-002 11.7 7) The set of columns in the shall be dis- tinct from the unique columns of any other unique constraint descriptor that is included in the base table descriptor of T. Access Rules None. General Rules 1) A defines a unique constraint. Note: Subclause 10.6, " and ", specifies when a constraint is effectively checked. 2) The unique constraint is not satisfied if and only if EXISTS ( SELECT * FROM TN WHERE NOT ( SC ) ) is true. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If PRIMARY KEY or UNIQUE is specified, then the for each column whose is in the shall specify NOT NULL. Schema definition and manipulation 273 X3H2-92-154/DBL CBR-002 11.8 11.8 Function Specify a referential constraint. Format ::= FOREIGN KEY ::= REFERENCES [ MATCH ] [ ] ::= FULL | PARTIAL ::= ::=
[ ] ::= ::= [ ] | [ ] ::= ON UPDATE ::= ON DELETE ::= CASCADE | SET NULL | SET DEFAULT | NO ACTION Syntax Rules 1) Let referencing table be the table identified by the containing
or . Let referenced table be the table identified by the
in the . Let referencing columns be the column or columns identified by the in the 274 Database Language SQL X3H2-92-154/DBL CBR-002 11.8 and let referencing column be one such column. 2) Case: a) If the specifies a , then the set of column names of that shall be equal to the set of column names in the unique columns of a unique constraint of the refer- enced table. Let referenced columns be the column or columns identified by that and let refer- enced column be one such column. Each referenced column shall identify a column of the referenced table and the same column shall not be identified more than once. b) If the does not specify a , then the table descriptor of the referenced table shall include a unique constraint that spec- ifies PRIMARY KEY. Let referenced columns be the column or columns identified by the unique columns in that unique con- straint and let referenced column be one such column. The shall be considered to implic- itly specify a that is identical to that . 3) The table constraint descriptor describing the whose identifies the referenced columns shall indicate that the unique constraint is not deferrable. 4) The referenced table shall be a base table. Case: a) If the referencing table is a persistent base table, then the referenced table shall be a persistent base table. b) If the referencing table is a global temporary table, then the referenced table shall be a global temporary table. c) If the referencing table is a created local temporary table, then the referenced table shall be either a global temporary table or a created local temporary table. d) If the referencing table is a declared local temporary table, then the referenced table shall be either a global temporary table, a created local temporary table or a declared local temporary table. 5) If the referenced table is a temporary table with ON COMMIT DELETE ROWS specified, then the referencing table shall specify ON COMMIT DELETE ROWS. Schema definition and manipulation 275 X3H2-92-154/DBL CBR-002 11.8 6) Each referencing column shall identify a column of the referenc- ing table, and the same column shall not be identified more than once. 7) The shall contain the same number of s as the . The i-th col- umn identified in the corresponds to the i-th column identified in the . The data type of each referencing column shall be the same as the data type of the corresponding referenced column. 8) If a does not specify any , then an with a of NO ACTION is implicit. 9) If a does not specify any , then a with a of NO ACTION is implicit. Access Rules 1) The applicable privileges shall include REFERENCES for each referenced column. General Rules 1) A defines a referential constraint. Note: Subclause 10.6, " and ", specifies when a constraint is effectively checked. 2) Let Rf be the referencing columns and let Rt be the referenced columns in the referenced table T. The referencing table and the referenced table satisfy the referential constraint if and only if: Case: a) A is not specified and for each row of the ref- erencing table, the Rf MATCH (SELECT Rt FROM T) is true. b) PARTIAL is specified and for each row of the referencing table, the Rf MATCH PARTIAL (SELECT Rt FROM T) is true. c) FULL is specified and for each row of the referencing table, the Rf MATCH FULL (SELECT Rt FROM T) 276 Database Language SQL X3H2-92-154/DBL CBR-002 11.8 is true. 3) Case: a) If is not specified or if FULL is specified, then for a given row in the referenced table, let matching rows be all rows in the referencing table whose referenc- ing column values equal the corresponding referenced column values for the referential constraint. b) If PARTIAL is specified, then: i) For a given row in the referenced table, let matching rows be all rows in the referencing table that have at least one non-null referencing column value and whose non-null ref- erencing column values equal the corresponding referenced column values for the referential constraint. ii) For a given row in the referenced table, let unique match- ing rows be all matching rows for that given row that are matching rows only to the given row in the referenced table for the referential constraint. For a given row in the ref- erenced table, let non-unique matching rows be all matching rows for that given row that are not unique matching rows for that given row for the referential constraint. 4) For every row of the referenced table, its matching rows, unique matching rows, and non-unique matching rows are determined imme- diately before the execution of any SQL-statement. No new match- ing rows are added during the execution of that SQL-statement. The association between a referenced row and a non-unique match- ing row is dropped during the execution of that SQL-statement if the referenced row is either marked for deletion or updated to a distinct value on any referenced column that corresponds to a non-null referencing column. This occurs immediately after such a mark for deletion or update of the referenced row. Unique matching rows and non-unique matching rows for a referenced row are evaluated immediately after dropping the association between that referenced row and a non-unique matching row. 5) If a is specified and a row of the referenced table that has not previously been marked for deletion is marked for deletion, then Case: a) If is not specified or if FULL is specified, then Case: i) If the specifies CASCADE, then all matching rows are marked for deletion. Schema definition and manipulation 277 X3H2-92-154/DBL CBR-002 11.8 ii) If the specifies SET NULL, then in all match- ing rows each referencing column is set to the null value. iii) If the specifies SET DEFAULT, then in all matching rows each referencing column is set to the default value specified in the General Rules of Subclause 11.5, "". b) If PARTIAL is specified, then Case: i) If the specifies CASCADE, then all unique matching rows are marked for deletion. ii) If the specifies SET NULL, then in all unique matching rows each referencing column is set to the null value. iii) If the specifies SET DEFAULT, then in all unique matching rows each referencing column is set to the default value specified in the General Rules of Subclause 11.5, "". Note: Otherwise, the is not performed. 6) If an is specified and a non-null value of a ref- erenced column in the referenced table is updated to a value that is distinct from the current value of that column, then Case: a) If is not specified or if FULL is specified, then Case: i) If the specifies CASCADE, then in all match- ing rows the referencing column that corresponds with the referenced column is updated to the new value of the refer- enced column. ii) If the specifies SET NULL, then Case: 1) If is not specified, then in all matching rows the referencing column that corresponds with the referenced column is set to the null value. 2) If specifies FULL, then in all matching rows each referencing column is set to the null value. iii) If the specifies SET DEFAULT, then in all matching rows the referencing column that corresponds with the referenced column is set to the default value specified 278 Database Language SQL X3H2-92-154/DBL CBR-002 11.8 in the General Rules of Subclause 11.5, "". b) If PARTIAL is specified, then Case: i) If the specifies CASCADE, then for each unique matching row that contains a non-null value in the referencing column C1 that corresponds with the updated referenced column C2, C1 is updated to the new value V of C2, provided that, in all updated rows in the referenced table that formerly had, in the same SQL-statement, that unique matching row as a matching row, the values in C2 have all been updated to a value that is not distinct from V. Otherwise, an exception condition is raised: triggered data change violation. Note: Because of the Rules of Subclause 8.2, "", on which the definition of "distinct" re- lies, the values in C2 may have been updated to values that are not distinct, yet are not identical. Which of these non-distinct values is used for the cascade operation is implementation-dependent. ii) If the specifies SET NULL, then in all unique matching rows that contain a non-null value in the ref- erencing column that corresponds with the updated column, that referencing column is set to the null value. iii) If the specifies SET DEFAULT, then in all unique matching rows that contain a non-null value in the referencing column that corresponds with the updated col- umn, that referencing column is set to the default value specified in the General Rules of Subclause 11.5, "". Note: Otherwise, the is not performed. 7) If any attempt is made within an SQL-statement to update some data item to a value that is distinct from the value to which that data item was previously updated within the same SQL- statement, then an exception condition is raised: triggered data change violation. 8) If an attempts to update a row that has been deleted by any that identifies some cursor CR that is still open or updated by any that identifies some cursor CR that is still open or if a attempts to mark for deletion such a row, then a completion condition is raised: warning- cursor operation conflict. Schema definition and manipulation 279 X3H2-92-154/DBL CBR-002 11.8 9) All rows that are marked for deletion are effectively deleted at the end of the SQL-statement, prior to the checking of any integrity constraints. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not specify MATCH. b) A shall not contain an . c) The order of the column names in a shall be the same as the order of column names of the corre- sponding unique constraint of the referenced table. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not contain a . 280 Database Language SQL X3H2-92-154/DBL CBR-002 11.9 11.9 Function Specify a condition for the SQL-data. Format ::= CHECK Syntax Rules 1) The shall not contain a or a . 2) The shall not contain a that is not contained in a . 3) If is contained in a
or , then let T be the table identified by the containing
or . Case: a) If T is a persistent base table, or if the is contained in a or , then no
generally con- tained in the shall reference a temporary table. b) If T is a global temporary table, then no
generally contained in the shall reference a table other than a global temporary table. c) If T is a created local temporary table, then no
generally contained in the shall reference a table other than either a global temporary table or a created local temporary table. d) If T is a declared local temporary table, then no
generally contained in the shall reference a persistent base table. 4) If the is contained in a
that defines a temporary table and specifies ON COMMIT PRESERVE ROWS or a that specifies ON COMMIT PRESERVE ROWS, then no in the shall reference a temporary table defined by a
or a that specifies ON COMMIT DELETE ROWS. Schema definition and manipulation 281 X3H2-92-154/DBL CBR-002 11.9 5) The shall not generally contain a or a that is CURRENT_USER, SESSION_USER, or SYSTEM_USER. 6) The shall not generally contain a or a that is possibly non- deterministic. Access Rules 1) Let TN be any
referenced in the . Case: a) If a is contained in the , then the applicable privileges shall include REFERENCES for each of the table identified by TN contained in the . b) Otherwise, the applicable privileges shall include REFERENCES for at least one column of the table identified by TN. General Rules 1) A defines a check constraint. Note: Subclause 10.6, " and ", specifies when a constraint is effectively checked. The General Rules that control the evaluation of a check constraint can be found in either Subclause 11.6, "
", or Subclause 11.21, "", depending on whether it forms part of a table constraint or a domain constraint. 2) If the character representation of the cannot be represented in the Information Schema without truncation, then a completion condition is raised: warning-search condition too long for information schema. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) The contained in a shall not contain a . b) The REFERENCES privilege is not required for access. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 282 Database Language SQL X3H2-92-154/DBL CBR-002 11.10 11.10 Function Change the definition of a table. Format ::= ALTER TABLE
::= | | | | Syntax Rules 1) Let T be the table identified by the
. 2) The schema identified by the explicit or implicit schema name of the
shall include the descriptor of T. 3) The scope of the
is the entire . 4) T shall be a base table. 5) T shall not be a declared local temporary table. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the table identified by
. General Rules 1) The base table descriptor of T is modified as specified by . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain an . Schema definition and manipulation 283 X3H2-92-154/DBL CBR-002 11.11 11.11 Function Add a column to a table. Format ::= ADD [ COLUMN ] Syntax Rules None. Access Rules None. General Rules 1) The column defined by the is added to T. 2) Let C be the column added to T. Every value in C is the default value for C. Note: The default value of a column is defined in Subclause 11.5, "". Note: The addition of a column to a table has no effect on any existing included in a view descriptor or included in constraint descriptor because any implicit s in these clauses are replaced by explicit s when the clause is originally evaluated. See the Syntax Rules of Subclause 7.10, "". 3) For every table privilege descriptor that specifies T and a privilege of SELECT, UPDATE, INSERT or REFERENCES, a new col- umn privilege descriptor is created that specifies T, the same action, grantor, and grantee, and the same grantability, and specifies the of the . 4) In all other respects, the specification of a in an has the same effect as specification of the in the
for T would have had. In particular, the degree of T is increased by 1 and the ordinal position of that column is equal to the new degree of T as specified in the General Rules of Subclause 11.4, "". 284 Database Language SQL X3H2-92-154/DBL CBR-002 11.11 Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain an . Schema definition and manipulation 285 X3H2-92-154/DBL CBR-002 11.12 11.12 Function Change a column and its definition. Format ::= ALTER [ COLUMN ] ::= | Syntax Rules 1) Let T be the table identified in the containing . 2) Let C be the column identified by the . 3) C shall be a column of T. Access Rules None. General Rules 1) The column descriptor of C is modified as specified by . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain an . 286 Database Language SQL X3H2-92-154/DBL CBR-002 11.13 11.13 Function Set the default clause for a column. Format ::= SET Syntax Rules None. Access Rules None. General Rules 1) Let C be the column identified by the in the con- taining . 2) The default value specified by the is placed in the column descriptor of C. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . Schema definition and manipulation 287 X3H2-92-154/DBL CBR-002 11.14 11.14 Function Drop the default clause from a column. Format ::= DROP DEFAULT Syntax Rules 1) Let C be the column identified by the in the con- taining . 2) The descriptor of C shall include a default value. Access Rules None. General Rules 1) The default value is removed from the column descriptor of C. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . 288 Database Language SQL X3H2-92-154/DBL CBR-002 11.15 11.15 Function Destroy a column. Format ::= DROP [ COLUMN ] Syntax Rules 1) Let T be the table identified by the
in the con- taining and let TN be the name of T. 2) Let C be the column identified by the CN. 3) C shall be a column of T and C shall not be the only column of T. 4) If RESTRICT is specified, then C shall not be referenced in the of any view descriptor or in the of any constraint descriptor other than a table con- straint descriptor that contains references to no other column and that is included in the table descriptor of T. Note: A that does not specify CASCADE will fail if there are any references to that column resulting from the use of CORRESPONDING, NATURAL, SELECT * (except where contained in an exists predicate>), or REFERENCES without a in its . Note: If CASCADE is specified, then any such dependent object will be dropped by the execution of the spec- ified in the General Rules of this Subclause. Access Rules None. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE INSERT(CN), UPDATE(CN), REFERENCES(CN) ON TABLE TN FROM A CASCADE Schema definition and manipulation 289 X3H2-92-154/DBL CBR-002 11.15 2) Let VN be the name of any view that contains a reference to column C of table T. The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: DROP VIEW VN CASCADE 3) If the column is not based on a domain, then its data type de- scriptor is destroyed. 4) The data associated with C is destroyed and the descriptor of C is removed from the descriptor of T. 5) The identified column and its descriptor are destroyed. 6) The degree of T is reduced by 1. The ordinal position of all columns having an ordinal position greater than the ordinal position of C is reduced by 1. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . 290 Database Language SQL X3H2-92-154/DBL CBR-002 11.16 11.16 Function Add a constraint to a table. Format ::= ADD
Syntax Rules None. Access Rules None. General Rules 1) Let T be the table identified by the
in the con- taining . 2) The table constraint descriptor for the
is included in the table descriptor for T. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain an . Schema definition and manipulation 291 X3H2-92-154/DBL CBR-002 11.17 11.17 Function Destroy a constraint on a table. Format ::= DROP CONSTRAINT Syntax Rules 1) Let T be the table identified by the
in the con- taining . The schema identified by the explicit or implicit schema name of the
shall in- clude the descriptor of T. 2) The shall identify a table constraint TC of T. 3) If TC is a unique constraint and there exists a referential constraint RC whose referenced table is T and whose referenced columns are the unique columns of TC, then RC is said to be dependent on TC. 4) If RESTRICT is specified, then no table constraint shall be dependent on TC. Note: If CASCADE is specified, then any such dependent object will be dropped by the effective execution of the specified in the General Rules of this Subclause. Access Rules None. General Rules 1) Let TCN2 be the of any table constraint that is dependent on TC and let T2 be the
of the ta- ble descriptor that includes TCN2. The following is effectively executed without further Access Rule checking: ALTER TABLE T2 DROP CONSTRAINT TCN2 CASCADE 2) The descriptor of TC is removed from the descriptor of T. 3) The identified table constraint and its descriptor are de- stroyed. 292 Database Language SQL X3H2-92-154/DBL CBR-002 11.17 Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . Schema definition and manipulation 293 X3H2-92-154/DBL CBR-002 11.18 11.18 Function Destroy a table. Format ::= DROP TABLE
Syntax Rules 1) Let T be the table identified by the
and let TN be that
. The schema identified by the explicit or implicit schema name of TN shall include the descriptor of T. 2) T shall be a base table. 3) T shall not be a declared local temporary table. 4) If RESTRICT is specified, then T shall not be referenced in the of any view descriptor or the of any constraint descriptor. Note: If CASCADE is specified, then such referencing objects will be dropped by the execution of the spec- ified in the General Rules of this Subclause. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the table identified by TN. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE ALL PRIVILEGES ON TN FROM A CASCADE 2) The identified base table and its descriptor are destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 294 Database Language SQL X3H2-92-154/DBL CBR-002 11.18 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . Schema definition and manipulation 295 X3H2-92-154/DBL CBR-002 11.19 11.19 Function Define a viewed table. Format ::= CREATE VIEW
[ ] AS [ WITH [ ] CHECK OPTION ] ::= CASCADED | LOCAL ::= Syntax Rules 1) The shall not contain a or a . 2) If a is contained in a and the
contains a , then that shall be the same as the specified or implicit of the containing . 3) The schema identified by the explicit or implicit schema name of the
shall not include a table descriptor whose table name is
. 4) The viewed table defined by shall not be identified by any
generally contained in the . 5) Any
that is specified in the shall be different from the
of any . 6) If the is updatable, then the viewed table is an updatable table. Otherwise, it is a read-only table. 7) If the is a that con- tains a or a that is not con- tained in a , then the viewed table defined by the is a grouped view. 8) If any two columns in the table specified by the have the same , or if any column of that table has an implementation-dependent name, then a shall be specified. 296 Database Language SQL X3H2-92-154/DBL CBR-002 11.19 9) The same shall not be specified more than once in the . 10)The number of s in the shall be the same as the degree of the table specified by the . 11)No column in the table specified by shall have a coercibility attribute of No collating sequence. Note: The coercibility attribute is described in Subclause 4.2.3, "Rules determining collating sequence usage". Note: The coercibility attribute for references to the column is defined in Subclause 6.4, "". 12)If WITH CHECK OPTION is specified, then the viewed table shall be updatable. 13)If WITH CHECK OPTION is specified with no , then a of CASCADED is implicit. 14)Let V be the view defined by the . The un- derlying columns of every i-th column of V are the underlying columns of the i-th column of the and the underlying columns of V are the underlying columns of the . Access Rules 1) If a is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the
. General Rules 1) A view descriptor VD is created that describes V. The view de- scriptor includes the
, the , column descriptors taken from the table specified by the , and an indication of whether WITH CHECK OPTION was specified. If a is specified, then the of the i-th column of the view is the i-th in that . Otherwise, the s of the view are the s of the table specified by the . 2) Let VN be the
. Let QE be the . If a is specified, then let VCL be the preceded by a and followed by a ; otherwise, let VCL be the empty string. Case: a) When VN is immediately contained in some SQL-schema state- ment, it identifies the view descriptor VD. Schema definition and manipulation 297 X3H2-92-154/DBL CBR-002 11.19 b) Otherwise, VN references the same table as the
: ( QE ) AS VN VCL 3) Let A be the that owns V. 4) A set of privilege descriptors is created that defines the priv- ilege SELECT on this table to A and SELECT for each column of V to A. This privilege is grantable if and only if the appli- cable SELECT privileges on all
s contained in the are grantable. The grantor of this privilege descriptor is set to the special grantor value "_SYSTEM". 5) If V is updatable, then let T be the leaf underlying table of the . 6) For i ranging from 1 to the number of distinct leaf underlying tables of the of V, let RTi be the
s of those tables. For every column CV of V: a) Let CRij, for j ranging from 1 to the number of columns of RTi that are underlying columns of CV, be the s of those columns. b) If A has REFERENCES(CRij) for all i and for all j, and A has REFERENCES on some column of RTi for all i, then a privilege descriptor is created that defines the privilege REFERENCES (CV) on V to A. That privilege is grantable if and only if the REFERENCES privileges on all of the columns CRTij are grantable. The grantor of that privilege descriptor is set to the special grantor value "_SYSTEM". 7) If V is updatable, then: a) A set of privilege descriptors is created that defines the privileges INSERT, UPDATE, and DELETE on V that are appli- cable privileges on T to A. A privilege on V is grantable if and only if the corresponding privilege on T is grantable. b) For every column in V: i) There is a corresponding column in T from which the column of V is derived. Let CV and CT be the s of the corresponding columns of V and T respectively. ii) A set of privilege descriptors is created that defines the privileges INSERT(CV) and UPDATE(CV) on V, where the privileges INSERT(CT) and UPDATE(CT) on T are the appli- cable privileges to A, respectively. A privilege on V is grantable if and only if the corresponding privilege on T is grantable. The grantor of these privilege descriptors is set to the special grantor value "_SYSTEM". 298 Database Language SQL X3H2-92-154/DBL CBR-002 11.19 8) If V is updatable, then let TLEAF be the leaf generally under- lying table of V. For every row in V there is a corresponding row in TLEAF from which the row of V is derived and for each column in V there is a corresponding column in TLEAF from which the column of V is derived. The insertion of a row into V is an insertion of a corresponding row into TLEAF. The deletion of a row from V is a deletion of the corresponding row in TLEAF. The updating of a column of a row in V is an updating of the corresponding column of the corresponding row in TLEAF. 9) Let V1 be a view. V1 spans V1. V1 spans a view V2 if V2 is a generally underlying table of V1. 10)An update operation is an , , , , or . An update operation on a view V is an update operation whose
identifies V. 11)If a view V1 spans a view VA described by a view descriptor that includes WITH CHECK OPTION and an update operation on V1 would result in a row that would not appear in the result of VA, then a) If the view descriptor of VA includes CASCADED, then an ex- ception condition is raised: with check option violation. b) If the view descriptor of VA includes LOCAL and the update operation would result in a row that would appear in the simply underlying table of the simply underlying table of the contained in VA, then an exception condition is raised: with check option violation. 12)Validation of a WITH CHECK OPTION constraint is effectively performed at the end of each update operation. 13)If the character representation of the cannot be represented in the Information Schema without truncation, then a completion condition is raised: warning-query expression too long for information schema. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any , but the effect shall be that defined for a of CASCADED. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) The in a shall be a . Schema definition and manipulation 299 X3H2-92-154/DBL CBR-002 11.20 11.20 Function Destroy a view. Format ::= DROP VIEW
Syntax Rules 1) Let V be the table identified by the
and let VN be that
. The schema identified by the explicit or implicit schema name of VN shall include the descriptor of V. 2) V shall be a viewed table. 3) If RESTRICT is specified, then V shall not be referenced in the of any view descriptor or the of any assertion descriptor or constraint descriptor. Note: If CASCADE is specified, then any such dependent object will be dropped by the execution of the spec- ified in the General Rules of this Subclause. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the table identified by VN. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE ALL PRIVILEGES ON VN FROM A CASCADE 2) The identified view and its descriptor are destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . 300 Database Language SQL X3H2-92-154/DBL CBR-002 11.21 11.21 Function Define a domain. Format ::= CREATE DOMAIN [ AS ] [ ] [ ... ] [ ] ::= [ ] [ ] Syntax Rules 1) If a is contained in a , and if the contains a , then that shall be the same as the specified or implicit of the containing . The schema identified by the explicit or implicit schema name of the shall not include a domain descriptor whose domain name is . 2) If specifies CHARACTER or CHARACTER VARYING and does not specify , then the character set name of the default character set of the schema identified by the implicit or explicit of is implicit. 3) If specifies a that identi- fies a character set that has a default collation and the does not directly contain a , then the collation of the is the im- plicit collation of the domain. 4) Let D1 be some domain. D1 is in usage by a domain constraint DC if and only if the of DC generally contains the either of D1 or of some domain D2 such that D1 is in usage by some domain constraint of D2. No domain shall be in usage by any of its own constraints. 5) If is specified, then shall be a character string type. 6) for every is specified: a) If is not specified, then INITIALLY IMMEDIATE NOT DEFERRABLE is implicit. Schema definition and manipulation 301 X3H2-92-154/DBL CBR-002 11.21 b) If is not specified, then a that contains an implementation- dependent is implicit. The assigned shall obey the Syntax Rules of an explicit . Access Rules 1) If a is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the . General Rules 1) A defines a domain. Note: Subclause 10.6, " and ", specifies when a constraint is effectively checked. 2) A data type descriptor is created that describes the data type of the domain being created. 3) A domain descriptor is created that describes the domain being created. The domain descriptor contains the name of the domain, the data type descriptor of the data type, the of the if the contains a , the value of the if the immediately contains , and a domain constraint descriptor for every immediately contained . 4) A privilege descriptor is created that defines the USAGE priv- ilege on this domain to the of the or in which the appears. This privilege is grantable if and only if the applicable privi- leges include a grantable REFERENCES privilege for each included in the domain descriptor and a grantable USAGE privilege for each , , , and contained in the of any domain constraint descriptor included in the domain descriptor, and a grantable USAGE privilege for the contained in the included in the domain descriptor. The grantor of the privilege descriptor is set to the special grantor value "_SYSTEM". 5) Let DSC be the included in some domain con- straint descriptor DCD. Let D be the name of the domain whose descriptor includes DCD. Let T be the name of some table whose descriptor includes some column descriptor with column name C whose domain name is D. Let CSC be a copy of DSC in which every instance of the VALUE is replaced by C. 302 Database Language SQL X3H2-92-154/DBL CBR-002 11.21 6) The domain constraint specified by DCD for C is not satisfied if and only if EXISTS ( SELECT * FROM T WHERE NOT ( CSC ) ) is true. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . Schema definition and manipulation 303 X3H2-92-154/DBL CBR-002 11.22 11.22 Function Change a domain and its definition. Format ::= ALTER DOMAIN ::= | | | Syntax Rules 1) Let D be the domain identified by . The schema identified by the explicit or implicit schema name of the shall include the descriptor of D. Access Rules 1) The current shall be equal to the that owns the schema identified by the implicit or explicit of . General Rules 1) The domain descriptor of D is modified as specified by . Note: The changed domain descriptor of D is applicable to every column that is dependent on D. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 304 Database Language SQL X3H2-92-154/DBL CBR-002 11.23 11.23 Function Set the default value in a domain. Format ::= SET Syntax Rules None. Access Rules None. General Rules 1) Let D be the domain identified by the in the con- taining . 2) The default value specified by the is placed in the domain descriptor of D. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 305 X3H2-92-154/DBL CBR-002 11.24 11.24 Function Remove the default clause of a domain. Format ::= DROP DEFAULT Syntax Rules 1) Let D be the domain identified by the in the con- taining . 2) The descriptor of D shall contain a default value. Access Rules None. General Rules 1) Let C be the set of columns whose column descriptors contain the domain descriptor of D. 2) For every column belonging to C, if the column descriptor does not already contain a default value, then the default value from the domain descriptor of D is placed in that column descriptor. 3) The default value is removed from the domain descriptor of D. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 306 Database Language SQL X3H2-92-154/DBL CBR-002 11.25 11.25 Function Add a constraint to a domain. Format ::= ADD Syntax Rules 1) Let D be the domain identified by the in the con- taining . 2) Let D1 be some domain. D1 is in usage by a domain constraint DC if and only if the of DC generally contains the either of D1 or of some domain D2 such that D1 is in usage by some domain constraint of D2. No domain shall be in usage by any of its own constraints. Access Rules None. General Rules 1) The constraint descriptor of the is added to the domain descriptor of D. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 307 X3H2-92-154/DBL CBR-002 11.26 11.26 Function Destroy a constraint on a domain. Format ::= DROP CONSTRAINT Syntax Rules 1) Let D be the domain identified by the in the con- taining . 2) Let DC be the descriptor of the constraint identified by . 3) DC shall be included in the domain descriptor of D. Access Rules None. General Rules 1) The constraint descriptor of DC is removed from the domain de- scriptor of D. 2) The constraint DC and its descriptor are destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 308 Database Language SQL X3H2-92-154/DBL CBR-002 11.27 11.27 Function Destroy a domain. Format ::= DROP DOMAIN Syntax Rules 1) Let D be the domain identified by and let DN be that . The schema identified by the explicit or implicit schema name of DN shall include the descriptor of D. 2) If RESTRICT is specified, then D shall not be referenced by any column descriptor, in the of any view descriptor, or in the of any constraint de- scriptor. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the domain identified by DN. Let UA be the of the current SQL-session. General Rules 1) Let C be any column descriptor that includes DN, let T be the table described by the table descriptor that includes C, and let TN be the column name of T. C is modified as follows: a) DN is removed from C. A copy of the data type descriptor of D is included in C. b) If C does not include a and the domain de- scriptor of D includes a , then a copy of the of D is included in C. c) For every domain constraint descriptor included in the domain descriptor of D: i) Let TCD be a
consisting of a whose is implementation-dependent, whose
is derived from the of the do- main constraint descriptor by replacing every instance of VALUE by the of C, and whose are the of the domain constraint descriptor. Schema definition and manipulation 309 X3H2-92-154/DBL CBR-002 11.27 ii) If the applicable privileges of UA include all of the priv- ileges necessary for UA to successfully execute the ALTER TABLE TN ADD TCD then the following
is effec- tively executed with a current of UA: ALTER TABLE TN ADD TCD d) If C does not include a collation and the of D includes a collation, then i) Let CCN be the of the collation. ii) If the applicable privileges for UA contain USAGE on CCN, then CCN is added to C as the . 2) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE USAGE ON DOMAIN DN FROM A CASCADE 3) The identified domain is destroyed by destroying its descriptor and its data type descriptor. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . 310 Database Language SQL X3H2-92-154/DBL CBR-002 11.28 11.28 Function Define a character set. Format ::= CREATE CHARACTER SET [ AS ] [ | ] ::= GET ::= | | ::= ::= COLLATION FROM Syntax Rules 1) If a is contained in a and if the immediately contained in the contains a , then that shall be the same as the specified or implicit of the . 2) The schema identified by the explicit or implicit schema name of the shall not include a character set descriptor whose character set name is . 3) A shall identify some character set descriptor. 4) If neither nor is specified, then the following is implicit: COLLATION FROM DEFAULT Schema definition and manipulation 311 X3H2-92-154/DBL CBR-002 11.28 Access Rules 1) If a is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the . 2) The applicable privileges for the shall include USAGE. General Rules 1) A defines a character set. 2) A character set descriptor is created for the defined character set. 3) The character set has the same character repertoire as the char- acter set identified by the . 4) A privilege descriptor is created that defines the USAGE privi- lege on this character set to the of the schema or in which the appears. The grantor of the privilege descriptor is set to the special grantor value "_SYSTEM". This privilege is grantable. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) In conforming Intermediate SQL language, shall specify DEFAULT. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not specify a . 312 Database Language SQL X3H2-92-154/DBL CBR-002 11.29 11.29 Function Destroy a character set. Format ::= DROP CHARACTER SET Syntax Rules 1) Let C be the character set identified by the and let CN be the name of C. 2) The schema identified by the explicit or implicit schema name of CN shall include the descriptor of C. 3) C shall not be referenced in the of any view descriptor or in the of any constraint de- scriptor, or be included in any collation descriptor or transla- tion descriptor. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the character set identified by C. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE USAGE ON CHARACTER SET CN FROM A CASCADE 2) The descriptor of C is destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall contain no . Schema definition and manipulation 313 X3H2-92-154/DBL CBR-002 11.30 11.30 Function Define a collating sequence. Format ::= CREATE COLLATION FOR FROM [ ] ::= NO PAD | PAD SPACE ::= | ::= | | DESC | DEFAULT ::= TRANSLATION [ THEN COLLATION ] ::= EXTERNAL ::= ::= | ::= ::= 314 Database Language SQL X3H2-92-154/DBL CBR-002 11.30 Syntax Rules 1) If a is contained in a and if the immediately contained in the contains a , then that shall be the same as the specified or implicit of the . 2) The schema identified by the explicit or implicit schema name of the shall not include a collation descriptor whose collation name is . 3) A shall be the name of a colla- tion defined by a national or international standard. An shall be the name of a collation that is implementation-defined. 4) The s and s that are supported are implementation-defined. Each collation identified by a or by a shall have associated with it a privilege descriptor that was effectively defined by the GRANT USAGE ON COLLATION COLL TO PUBLIC where COLL is the or . 5) A collating sequence specified by or shall be a collating sequence that is defined for the character repertoire of the character set with which the is associated. 6) A shall be the name of a collating se- quence that is defined in the schema identified by the explicit or implicit . 7) If a does not specify , then Case: a) If a is specified that con- tains a that identifies a collation for which the specifies NO PAD, then NO PAD is implicit. b) Otherwise, PAD SPACE is implicit. 8) If NO PAD is specified, then the collation is said to have the NO PAD attribute. If PAD SPACE is specified, then the collation is said to have the PAD SPACE attribute. Schema definition and manipulation 315 X3H2-92-154/DBL CBR-002 11.30 9) If is specified, then let T be the translation named by . Let C1 be the colla- tion being defined by the . The source character set of T shall be the same as the character set of C1. 10)If THEN COLLATION is specified, then let C2 be the collation named by in THEN COLLATION . The target character set of T shall be identical to the character set of C2. Access Rules 1) If a is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the . 2) Let C be a collation identified by any con- tained in . The applicable privileges shall include USAGE on C. 3) If is specified, then the applicable privi- leges shall include USAGE. General Rules 1) A defines a collating sequence. 2) DEFAULT specifies that the collation is to be performed us- ing the order of characters as they appear in the character repertoire. 3) If DESC is specified, then the collation is the reverse of that specified by . 4) A privilege descriptor is created that defines the USAGE priv- ilege on this collation to the current . The grantor of the privilege descriptor is set to the special grantor value "_SYSTEM". 5) This privilege descriptor is grantable if and only if the USAGE privilege for the current on the contained in the is also grantable and if the USAGE privilege for the current on the contained in the , if present, is also grantable. 6) If is specified, then Case: a) If THEN COLLATION is specified, then let C2 be the collating sequence named by the in THEN COLLATION . The collating sequence defined is obtained by effectively translating a character 316 Database Language SQL X3H2-92-154/DBL CBR-002 11.30 string using T, then applying the collating sequence of C2 to the result. b) Otherwise, the collating sequence defined is obtained by ef- fectively translating a character string using T, then apply- ing the default collating sequence for the target character set of T. 7) If is specified, then the collating se- quence defined is that given by: a) If is specified, then the national or international standard collation. b) Otherwise, the implementation-defined collation. 8) A collation descriptor is created for the defined collation. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 317 X3H2-92-154/DBL CBR-002 11.31 11.31 Function Destroy a collating sequence. Format ::= DROP COLLATION Syntax Rules 1) Let C be the collating sequence identified by the and let CN be the name of C. 2) The schema identified by the explicit or implicit schema name of CN shall include the descriptor of C. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the collating sequence identified by C. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE USAGE ON COLLATION CN FROM A CASCADE 2) Let CD be any collation descriptor that includes CN. CD is modi- fied by deleting any occurrences of "THEN COLLATION CN" or "DESC (CN)" 3) Let CSD be any character set descriptor that includes CN. CSD is modified by deleting any occurrences of "COLLATION FROM CN" or "DESC (CN)". 4) Let DD be any column descriptor or domain descriptor that includes CN. DD is modified by deleting any occurrences of "COLLATE CN". 5) Let VD be any view descriptor whose includes "COLLATE CN" or any constraint descriptor whose includes "COLLATE CN". VD is modified by deleting any occurrences of "COLLATE CN". 6) The descriptor of C is destroyed. 318 Database Language SQL X3H2-92-154/DBL CBR-002 11.31 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 319 X3H2-92-154/DBL CBR-002 11.32 11.32 Function Define a character translation. Format ::= CREATE TRANSLATION FOR TO FROM ::= ::= ::= ::= | IDENTITY | ::= EXTERNAL ::= | ::= ::= ::= Syntax Rules 1) If a is contained in a and if the immediately contained in the contains a , then that shall be the same as the specified or implicit of the . 320 Database Language SQL X3H2-92-154/DBL CBR-002 11.32 2) The schema identified by the explicit or implicit schema name of the shall not include a translation descrip- tor whose translation name is . 3) A shall be the name of a trans- lation defined by a national or international standard. An shall be the name of a translation that is implementation-defined. 4) The s and s that are supported are implementation- defined. Each translation identified by a or by a shall have associated with it a privilege descriptor that was effectively defined by the GRANT USAGE ON TRANSLATION TRANS TO PUBLIC where TRANS is the or . 5) A shall identify a translation de- scriptor. Access Rules 1) If a is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the . 2) If is specified, then the applicable privileges shall include USAGE. General Rules 1) A defines a translation. 2) IDENTITY specifies a translation that makes no changes to the characters. 3) A translation descriptor is created for the defined translation. 4) A privilege descriptor PD is created that defines the USAGE privilege on this translation to the of the schema or in which the appears. The grantor of the privilege descriptor is set to the special grantor value "_SYSTEM". 5) PD is grantable if and only if the USAGE privilege for the of the schema or in which the appears is also grantable on every contained in the . Schema definition and manipulation 321 X3H2-92-154/DBL CBR-002 11.32 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 322 Database Language SQL X3H2-92-154/DBL CBR-002 11.33 11.33 Function Destroy a character translation. Format ::= DROP TRANSLATION Syntax Rules 1) Let T be the translation identified by the and let TN be the name of T. 2) The schema identified by the explicit or implicit schema name of TN shall include the descriptor of T. 3) T shall not be referenced in the included in any view descriptor or in the included in any constraint descriptor or be included in any collation descriptor. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the translation identified by T. General Rules 1) Let CD be any collation descriptor that includes a TRANSLATION TN. CD is modified by deleting that . 2) Let CSD be any that references T. CSD is modified by deleting any occurrences of a that contains TN. 3) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE USAGE ON TRANSLATION TN FROM A CASCADE 4) The descriptor of T is destroyed. Schema definition and manipulation 323 X3H2-92-154/DBL CBR-002 11.33 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 324 Database Language SQL X3H2-92-154/DBL CBR-002 11.34 11.34 Function Specify an integrity constraint by means of an assertion and spec- ify the initial default time for checking the assertion. Format ::= CREATE ASSERTION [ ] ::= CHECK Syntax Rules 1) If an is contained in a and if the contains a , then that shall be the same as the explicit or implicit of the containing . 2) The schema identified by the explicit or implicit schema name of the shall not include a constraint descriptor whose constraint name is . 3) If is not specified, then INITIALLY IMMEDIATE NOT DEFERRABLE is implicit. 4) The shall not contain a or a . 5) No in the shall reference a temporary table. 6) The shall not generally contain a or a that is CURRENT_USER, SESSION_USER, or SYSTEM_USER. 7) The of shall be differ- ent from the of the of any other constraint defined in the same schema. 8) The shall not generally contain a or a that is possibly non- deterministic. Schema definition and manipulation 325 X3H2-92-154/DBL CBR-002 11.34 Access Rules 1) If an is contained in a , then the current shall be equal to the that owns the schema identified by the implicit or explicit of the of the . 2) Let TN be any
referenced in the of the . If TN identifies a table described by a base table descriptor or a view descriptor, then Case: a) If a is contained in the , then the applicable privileges shall include REFERENCES for each CN of the table identified by TN, where CN is contained in the . b) Otherwise, the applicable privileges shall include REFERENCES for at least one column of the table identified by TN. General Rules 1) An defines an assertion. Note: Subclause 10.6, " and ", specifies when a constraint is effectively checked. 2) The assertion is not satisfied if and only if the result of evaluating the is false. 3) An assertion descriptor is created that describes the assertion being defined. The name included in the assertion descriptor is . The assertion descriptor includes an indication of whether the constraint is deferrable or not deferrable and whether the ini- tial constraint mode is deferred or immediate. The assertion descriptor includes the of the . 4) If the character representation of the cannot be represented in the Information Schema without truncation, then a completion condition is raised: warning-search condition too long for information schema. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 326 Database Language SQL X3H2-92-154/DBL CBR-002 11.34 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Schema definition and manipulation 327 X3H2-92-154/DBL CBR-002 11.35 11.35 Function Destroy an assertion. Format ::= DROP ASSERTION Syntax Rules 1) Let A be the assertion identified by and let AN be the name of A. 2) The schema identified by the explicit or implicit schema name of AN shall include the descriptor of A. Access Rules 1) The current shall be equal to the that owns the schema identified by the of the assertion identified by AN. General Rules 1) The descriptor of A is destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 328 Database Language SQL X3H2-92-154/DBL CBR-002 11.36 11.36 Function Define privileges. Format ::= GRANT ON TO [ { }... ] [ WITH GRANT OPTION ] ::= [ TABLE ]
| DOMAIN | COLLATION | CHARACTER SET | TRANSLATION Syntax Rules 1) If specifies a , , , or , then shall specify USAGE; otherwise, USAGE shall not be specified. 2) Let O be the object identified by the . 3) Let A be the current . For each specified, a set of privilege descriptors is iden- tified. The privilege descriptors identified are those defining, for each explicitly or implicitly in , that on O held by A with grant option. Access Rules 1) The applicable privileges shall include a privilege identifying O. General Rules 1) The specify one or more privileges on the object identified by the . 2) For every identified privilege descriptor, a privilege descrip- tor is created that specifies the identical , , object O, and grantor A. Let CPD be the set of privilege de- scriptors created. 3) For every identified privilege descriptor whose action is SELECT, INSERT, UPDATE, or REFERENCES without a column name, privilege descriptors are also created for each column C in O Schema definition and manipulation 329 X3H2-92-154/DBL CBR-002 11.36 for which A holds the corresponding privilege with grant op- tion. For each such column, a privilege descriptor is created that specifies the identical , the identical , object C, and grantor A. 4) If WITH GRANT OPTION was specified, each privilege descriptor also indicates that the privilege is grantable. 5) If
is specified, then let T be the table identified by the
. 6) For every updatable view V owned by some grantee G such that T is some leaf underlying table of the of V: a) Let VN be the
of V. b) If WITH GRANT OPTION is specified, then let WGO be "WITH GRANT OPTION"; otherwise, let WGO be a zero-length string. c) For every privilege descriptor PD in CPD, let PA be the ac- tion included in PD. i) If PA is INSERT, UPDATE, or DELETE, then the following is effectively executed as though the current were "_SYSTEM" and with- out further Access Rule checking: GRANT PA ON VN TO G WGO ii) If PA is A(CT), where A is INSERT or UPDATE and CT is the name of some column of T such that there is a correspond- ing column in V, named CVN, that is derived from CT, then the following is effectively executed as though the current were "_ SYSTEM" and without further Access Rule checking: GRANT A(CVN) ON VN TO G WGO 7) For every G and for every view V1 owned by G, if G has been granted SELECT privilege WITH GRANT OPTION on all tables identified by a
contained in the of V1, then for every privilege descriptor with a P that contains SELECT, a of "_SYSTEM", of V1, and G that is not grantable, the following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: GRANT P ON V1 TO G WITH GRANT OPTION 8) For every G and for every domain D1 owned by G, if G has been granted REFERENCES privilege WITH GRANT OPTION on every column referenced in the included in a domain constraint descriptor included in the domain descriptor of D1 and a grantable USAGE privilege on all domains, character sets, collations, and translations whose s, set name>s, s, and s, respec- tively, are included in the domain descriptor, and a grantable USAGE privilege for the contained in the included in the domain descriptor, then for every privilege descriptor with USAGE, a of "_ SYSTEM", D1, and G that is not grantable, the following is effectively executed with a cur- rent of "_SYSTEM" and without further Access Rule checking: GRANT USAGE ON DOMAIN D1 TO G WITH GRANT OPTION 9) For every G and for every collation C1 owned by G, if the USAGE privilege of G for the character set identified by a contained in the of C1 is grantable, then for every privilege descriptor with a P, a of "_SYSTEM", of C1, and G that is not grantable, the following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: GRANT P ON COLLATION C1 TO G WITH GRANT OPTION 10)For every G and for every translation T1 owned by G, if the USAGE privilege of G for every character set identified by a contained in the of T1 is grantable, then for every privilege descriptor with a P, a of "_SYSTEM", of T1, and G that is not grantable, the fol- lowing is effectively executed as though the current were "_SYSTEM" and without further Access Rule checking: GRANT P ON TRANSLATION T1 TO G WITH GRANT OPTION 11)If
is specified, then for each view V owned by some G such that T or some column CT of T, let RTi, for i ranging from 1 to the number of tables identified by the
s contained in the of V, be the
s of those tables. For every column CV of V: a) Let CRij, for j ranging from 1 to the number of columns of RTi that are underlying columns of CV, be the s of those columns. b) If WITH GRANT OPTION was specified, then let WGO be "WITH GRANT OPTION"; otherwise, let WGO be a zero-length string. c) If, following successful execution of the , G will have REFERENCES(CRTij) for all i and for all j, and A has REFERENCES on some column of RTi for all i, the the following is effectively executed as though Schema definition and manipulation 331 X3H2-92-154/DBL CBR-002 11.36 the current were "_SYSTEM" and without further Access Rule checking: GRANT REFERENCES CV ON V TO G WGO 12)If two privilege descriptors are identical except that one in- dicates that the privilege is grantable and the other indicates that the privilege is not grantable, then both privilege de- scriptors are set to indicate that the privilege is grantable. 13)Redundant duplicate privilege descriptors are removed from the multiset of all privilege descriptors. 14)For every combination of and on O specified in , if there is no corresponding privilege de- scriptor in the set of identified privilege descriptors, then a completion condition is raised: warning-privilege not granted. 15)If ALL PRIVILEGES was specified, then for each grantee, if no privilege descriptors were identified, then a completion condi- tion is raised: warning-privilege not granted. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) In Conforming Intermediate SQL language, an shall not specify COLLATION or TRANSLATION. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) In Conforming Entry SQL language, an shall not specify TABLE. b) In Conforming Entry SQL language, an shall not specify CHARACTER SET or DOMAIN. 332 Database Language SQL X3H2-92-154/DBL CBR-002 11.37 11.37 Function Destroy privileges. Format ::= REVOKE [ GRANT OPTION FOR ] ON FROM [ { }... ] Syntax Rules 1) If specifies a , , , or , then shall specify USAGE; otherwise, USAGE shall not be specified. 2) INSERT is equivalent to specifying both the INSERT table priv- ilege and INSERT () for all columns of
. 3) UPDATE is equivalent to specifying both the UPDATE table priv- ilege and UPDATE () for all columns of
. 4) REFERENCES is equivalent to specifying both the REFERENCES ta- ble privilege and REFERENCES () for all columns of
. 5) Let O be the object identified by the . 6) Let A be the current . For every specified, a set of privilege descriptors is iden- tified. A privilege descriptor is said to be identified if it belongs to the set of privilege descriptors that define, for any explicitly or implicitly in , that on O granted by A to . Note: Column privilege descriptors become identified when explicitly or implicitly contains a . 7) A privilege descriptor D is allowed to be created by a grant permitted by P if either: a) The following conditions hold: i) P indicates that the privilege that it represents is grantable, and Schema definition and manipulation 333 X3H2-92-154/DBL CBR-002 11.37 ii) The grantee of P is the same as the grantor of D or the grantee of P is PUBLIC, and iii) Case: 1) P and D are both column privilege descriptors. The ac- tion and the identified column of P are the same as the action and identified column of D, respectively. 2) P is a table privilege descriptor and D is a column privilege descriptor. The identified table of P is the same as the identified table of D and the action of P is the same as the action of D and the action of P is SELECT. 3) Neither P nor D are column privilege descriptors. The action and the identified table, domain, character set, collation, or translation of P are the same as the ac- tion and the identified table, domain, character set, collation, or translation of D, respectively. b) The following conditions hold: i) The privilege descriptor for D indicates that its grantor is the special grantor value "_SYSTEM", and ii) The action of P is the same as the action of D, and iii) The grantee of P is the owner of the table, collation, or translation identified by D, or the grantee of P is PUBLIC, and iv) One of the following conditions hold: 1) P and D are both table privilege descriptors, the priv- ilege descriptor for D identifies the
of a V and either: A) The action of P is SELECT and the identified table of P is contained in the of V, or B) V is an updatable view and the identified table of P is the underlying table of the . 2) P and D are both column privilege descriptors, the priv- ilege descriptor D identifies a CVN ex- plicitly or implicitly contained in the of a V and V is an updatable view. For every column CV identified by a CVN, there is a corresponding column in the underly- ing table of the TN. Let CTN be the of the column of the from which CV is derived. The action for P is UPDATE or INSERT and the identified column of P is TN.CTN. 334 Database Language SQL X3H2-92-154/DBL CBR-002 11.37 3) P is a table privilege descriptor and the column privi- lege descriptor D identifies a CV explic- itly or implicitly contained in the of a V. Let TN be a
con- tained in the of the view. The action for P is SELECT and the identified table of P is TN. 4) The privilege descriptor D identifies the of a CO and the identified character set name of P is contained in the immediately contained in CO. 5) The privilege descriptor D identifies the of a TD and the identi- fied character set name of P is contained in the or the immediately contained in TD. 8) A privilege descriptor D is said to be directly dependent on an- other privilege descriptor P if D represents a privilege allowed to be created by a grant permitted by P. 9) The privilege dependency graph is a directed graph such that: a) Each node represents a privilege descriptor, and b) Each arc from node P1 to node P2 represents the fact that P2 directly depends on P1. An independent node is one that has no incoming arcs. 10)A privilege descriptor P is said to be modified if either P is a SELECT column privilege descriptor and a SELECT table privilege descriptor with the same grantee, grantor, catalog name, schema name, and table name is a modified privilege descriptor, or: a) P indicates that the privilege that it represents is grantable, and b) P directly depends on an identified privilege descriptor or a modified privilege descriptor, and c) Let XO and XA respectively be the identifier of the object identified by a privilege descriptor X and the action of X. Within the set of privilege descriptors upon which P directly depends, there exists some XO and XA for which the set of identified privilege descriptors unioned with the set of mod- ified privilege descriptors include all privilege descriptors specifying the grant of XA on XO with grant option, and d) At least one of the following is true: i) GRANT OPTION FOR is specified and the grantor of P is the special grantor value "_SYSTEM". Schema definition and manipulation 335 X3H2-92-154/DBL CBR-002 11.37 ii) There exists a path to P from an independent node that includes no identified or modified privilege descriptors. P is said to be a marked modified privilege descriptor. iii) P directly depends on a marked modified privilege descrip- tor, and the grantor of P is the special grantor value "_SYSTEM". P is said to be a marked modified privilege descriptor. 11)A privilege descriptor P is abandoned if: a) It is not an independent node, and Case: i) GRANT OPTION FOR is not specified, P is not itself a mod- ified privilege descriptor, and there exists no path to P from any independent node other than paths that include an identified privilege descriptor or a modified privilege descriptor. ii) GRANT OPTION FOR is specified, P is not itself a modi- fied privilege descriptor, and there exists no path to P from any independent node other than paths that include a modified privilege descriptor. b) P is a SELECT column privilege descriptor and there exists a SELECT table privilege descriptor X with the same grantee, grantor, catalog name, schema name, and table name and Case: i) GRANT OPTION FOR is not specified and X is an identified privilege descriptor or an abandoned privilege descriptor. ii) GRANT OPTION FOR is specified and X is an abandoned privi- lege descriptor. 12)Let S1 be the name of any schema and let A1 be the that owns the schema identified by S1. 13)Let V be any view descriptor included in S1. V is said to be abandoned if the destruction of all abandoned privilege descrip- tors and, if GRANT OPTION FOR is not specified, all identified privilege descriptors would result in A1 no longer having SELECT privilege on one or more tables or USAGE privilege on one or more domains, collations, character sets, or translations whose names are contained in the of V. 14)Let TC be any table constraint descriptor included in S1. TC is said to be abandoned if the destruction of all abandoned privi- lege descriptors and, if GRANT OPTION FOR is not specified, all identified privilege descriptors would result in A1 no longer having REFERENCES privilege on one or more referenced columns of TC or USAGE privilege on one or more domains, collations, 336 Database Language SQL X3H2-92-154/DBL CBR-002 11.37 character sets, or translations whose names are contained in any of TC. 15)Let AX be any assertion descriptor included in S1. AX is said to be abandoned if the destruction of all abandoned privilege descriptors and, if GRANT OPTION FOR is not specified, all iden- tified privilege descriptors would result in A1 no longer having REFERENCES privilege on one or more referenced columns of AX or USAGE privilege on one or more domains, collations, character sets, or translations whose names are contained in any of AX. 16)Let DC be any domain constraint descriptor included in S1. DC is said to be abandoned if the destruction of all abandoned privi- lege descriptors and, if GRANT OPTION FOR is not specified, all identified privilege descriptors would result in A1 no longer having REFERENCES privilege on one or more referenced columns of DC or USAGE privilege on one or more domains, collations, character sets, or translations whose names are contained in any of DC. 17)Let DO be any domain descriptor included in S1. DO is said to be abandoned if the destruction of all abandoned privilege descrip- tors and, if GRANT OPTION FOR is not specified, all identified privilege descriptors would result in A1 no longer having USAGE privilege on the collation whose name is contained in the of DO, if any. 18)If RESTRICT is specified, then there shall be no abandoned priv- ilege descriptors, abandoned views, abandoned table constraints, abandoned assertions, abandoned domain constraints, or abandoned domains. Access Rules 1) The applicable privileges shall include a privilege identifying O. General Rules 1) If GRANT OPTION FOR is not specified, then: a) All abandoned privilege descriptors are destroyed, and b) The identified privilege descriptors are destroyed, and c) The modified privilege descriptors are set to indicate that they are not grantable. 2) If GRANT OPTION FOR is specified, then Case: a) If CASCADE is specified, then all abandoned privilege de- scriptors are destroyed. Schema definition and manipulation 337 X3H2-92-154/DBL CBR-002 11.37 b) Otherwise, if there are any privilege descriptors directly dependent on an identified privilege descriptor that are not modified privilege descriptors, then an exception condition is raised: dependent privilege descriptors still exist. The identified privilege descriptors and the modified privilege descriptors are set to indicate that they are not grantable. 3) For every abandoned view descriptor V, let S1.VN be the
of V. The following is effectively executed without further Access Rule checking: DROP VIEW S1.VN CASCADE 4) For every abandoned table constraint descriptor TC, let S1.TCN be the of TC and let S2.T2 be the
of the table that contains TC (S1 and S2 not necessarily dif- ferent). The following is effectively executed without further Access Rule checking: ALTER TABLE S2.T2 DROP CONSTRAINT S1.TCN CASCADE 5) For every abandoned assertion descriptor AX, let S1.AXN be the of AX. The following is effectively executed without further Access Rule check- ing: DROP ASSERTION S1.AXN 6) For every abandoned domain constraint descriptor DC, let S1.DCN be the of DC and let S2.DN be the of the domain that contains DC. The following is effectively executed without further Access Rule checking: ALTER DOMAIN S2.DN DROP CONSTRAINT S1.DCN 7) For every abandoned domain descriptor DO, let S1.DN be the of DO. The following is effectively executed without further Access Rule checking: DROP DOMAIN S1.DN CASCADE 8) For every combination of and on O specified in , if there is no corresponding privilege de- scriptor in the set of identified privilege descriptors, then a completion condition is raised: warning-privilege not revoked. 9) If ALL PRIVILEGES was specified, then for each , if no privilege descriptors were identified, then a completion condition is raised: warning-privilege not revoked. 338 Database Language SQL X3H2-92-154/DBL CBR-002 11.37 Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain a . Schema definition and manipulation 339 X3H2-92-154/DBL CBR-002 340 Database Language SQL X3H2-92-154/DBL CBR-002 12 Module 12.1 Function Define a module. Format ::= [ ... ] ... ::= SCHEMA | AUTHORIZATION | SCHEMA AUTHORIZATION ::= ::= | | Syntax Rules 1) If SCHEMA is not specified, then a equal to is implicit. 2) If the explicit or implicit does not specify a , then an implementation-defined is implicit. 3) The implicit or explicit is the implicit for all unqualified s in the . 4) A or shall precede in the text of the any that references the of the or . Module 341 X3H2-92-154/DBL CBR-002 12.1 5) For every in a , there shall be exactly one in that that contains an that specifies the declared in the . Note: See the Syntax Rules of Subclause 13.1, "". Access Rules None. General Rules 1) If the SQL-agent that performs a call of a in a is not a program that conforms to the programming language standard specified by the of that , then the effect is implementation-dependent. 2) If the SQL-agent performs calls of s from more than one Ada task, then the results are implementation-dependent. 3) Case: a) If a is specified, then it is the current for privilege determination for the execution of each in the . b) Otherwise, the current for privi- lege determination for the execution of each in the is the SQL-session . 4) After the last time that an SQL-agent performs a call of a : a) A or a is effec- tively executed. If an unrecoverable error has occurred, or if the SQL-agent terminated unexpectedly, or if any con- straint is not satisfied, then a is performed. Otherwise, the choice of which of these SQL- statements to perform is implementation-dependent. The deter- mination of whether an SQL-agent has terminated unexpectedly is implementation-dependent. b) Let D be the of any system descriptor area that is currently allocated within an SQL-session associated with the SQL-agent. A that specifies DEALLOCATE DESCRIPTOR D is effectively executed. 342 Database Language SQL X3H2-92-154/DBL CBR-002 12.1 c) All SQL-sessions associated with the SQL-agent are termi- nated. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not contain a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall be associated with an SQL-agent during its execution. An SQL-agent shall be associated with at most one . b) A shall not be a . c) A shall specify AUTHORIZATION and shall not specify SCHEMA. Module 343 X3H2-92-154/DBL CBR-002 12.2 12.2 Function Name a . Format ::= MODULE [ ] [ ] ::= NAMES ARE Syntax Rules 1) If a does not specify a , then the is unnamed. 2) The shall be different from the of any other in the same SQL-environment. Note: An SQL-environment may have multiple s that are unnamed. 3) If the of the containing specifies ADA, then a shall be specified, and that shall be a valid Ada library unit name. 4) If a is not specified, then a that specifies an implementation-defined character set that contains at least every character that is in is implicit. Access Rules None. General Rules 1) If a is specified, then in the SQL-environment the containing has the name given by . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 344 Database Language SQL X3H2-92-154/DBL CBR-002 12.2 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not be speci- fied. Module 345 X3H2-92-154/DBL CBR-002 12.3 12.3 Function Define a procedure. Format ::= PROCEDURE ::= [ { }... ] | ... ::= | ::= SQLCODE | SQLSTATE Syntax Rules 1) The shall be different from the of any other in the containing . Note: The should be a standard-conforming pro- cedure, function, or routine name of the language specified by the subject . Failure to observe this recommen- dation will have implementation-dependent effects. 2) The of each in a shall be different from the of any other in that . 3) Any contained in the of a shall be specified in a in that . Note: s in a without enclos- ing parentheses and without commas separating multiple s is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". 4) A call of a shall supply n parameters, where n is the number of s in the . 346 Database Language SQL X3H2-92-154/DBL CBR-002 12.3 5) A shall contain at least one , at most one that specifies SQLCODE, and at most one that specifies SQLSTATE. A parameter that corresponds with SQLCODE is referred to as an SQLCODE parameter. A parameter that corresponds with SQLSTATE is referred to as an SQLSTATE parameter. The SQLCODE and SQLSTATE parameters are referred to as status parameters. Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". 6) Whether a is for an input parameter, an output parameter, or both is determined as follows: Case: a) A is an output parameter. b) For every that is not a , Case: i) If the of a parameter is contained in a or a that is contained in , but it is not contained in a or a that is contained in , then the parameter is an input parameter. ii) If the of a parameter is contained in a or a that is contained in , but it is not contained in a or a that is contained in , then the parameter is an output parameter. iii) If the of a parameter is contained in a or a that is contained in and it is contained in a or a that is contained in , then the parameter is both an input parameter and an output parameter. iv) Otherwise, the parameter is neither an input parameter nor an output parameter. 7) The Syntax Rules of Subclause 12.4, "Calls to a ", shall be true. Module 347 X3H2-92-154/DBL CBR-002 12.3 Access Rules None. General Rules 1) A defines a procedure that may be called by an SQL- agent. 2) If the that contains the is associated with an SQL-agent that is associated with another that contains a with the same , then the effect is implementation-defined. 3) If the that contains the has an explicit MAI that is different from the SQL-session SAI, then: a) Whether or not SAI can invoke s in a with explicit MAI is implementation-defined, as are any restrictions pertaining to such invocation. b) If SAI is restricted from invoking a in a with explicit MAI, then an exception condition is raised: invalid authorization specification. 4) If the value of any input parameter provided by the SQL-agent falls outside the set of allowed values of the data type of the parameter, or if the value of any output parameter resulting from the execution of the falls outside the set of values supported by the SQL-agent for that parameter, then the effect is implementation-defined. If the implementation- defined effect is the raising of an exception condition, then an exception condition is raised: data exception-invalid parameter value. 5) Let S be the of the . 6) When the is called by an SQL-agent: Case: a) If S is an , then: i) The that contains S is associated with the SQL- agent. ii) The diagnostics area is emptied. iii) S is executed. 348 Database Language SQL X3H2-92-154/DBL CBR-002 12.3 iv) If S successfully initiated or resumed an SQL-session, then subsequent calls to a by the SQL-agent are associated with that SQL-session until the SQL-agent terminates the SQL-session or makes it dormant. b) If S is an , then: i) The that contains S is associated with the SQL- agent. ii) S is executed. c) Otherwise: i) If no SQL-session is current for the SQL-agent, then Case: 1) If the SQL-agent has not executed an and there is no default SQL-session asso- ciated with the SQL-agent, then the following is effectively executed: CONNECT TO DEFAULT 2) If the SQL-agent has not executed an and there is a default SQL-session associated with the SQL-agent, then the following is effectively executed: SET CONNECTION DEFAULT 3) Otherwise, an exception condition is raised: connection exception-connection does not exist. Subsequent calls to a or invocations of s by the SQL-agent are associated with the SQL-session until the SQL-agent terminates the SQL-session or makes it dormant. ii) If an SQL-transaction is active for the SQL-agent, then S is associated with that SQL-transaction. iii) If no SQL-transaction is active for the SQL-agent and S is a transaction-initiating SQL-statement, then 1) An SQL-transaction is effectively initiated and asso- ciated with this call and with subsequent calls of any or invocations of s by that SQL-agent until the SQL-agent terminates that SQL-transaction. 2) Case: A) If a has been executed since the termination of the last SQL-transaction in the SQL-session, then the access mode, constraint Module 349 X3H2-92-154/DBL CBR-002 12.3 mode, and isolation level of the SQL-transaction are set as specified by the . B) Otherwise, the access mode of that SQL-transaction is read-write, the constraint mode for all constraints in that SQL-transaction is immediate, and the isolation level of that SQL-transaction is SERIALIZABLE. 3) The SQL-transaction is associated with the SQL-session. 4) The that contains S is associated with the SQL-transaction. iv) The that contains S is associated with the SQL- agent. v) If S contains an and the access mode of the current SQL-transaction is read-only, then an exception condition is raised: invalid transaction state. vi) The diagnostics area is emptied. vii) The values of all input parameters to the are established. viii)S is executed. 7) If the non-dynamic or dynamic execution of an or the execution of an , , or occurs within the same SQL-transaction as the non-dynamic or dynamic execution of an SQL-schema statement and this is not allowed by the SQL-implementation, then an exception condition is raised: invalid transaction state. 8) When a is called by an SQL-agent, let PDi be the of the i-th parameter and let DTi and PNi be the and the specified in PDi, respectively. Let PIi be the i-th parameter in the proce- dure call. 9) If S is a
| | | | | | | ::= | | | | | | | | | | ::= | | | 13.5 ::= SELECT [ ]
shall be the same as the number of elements in the corresponds with the i-th element of the and
are those specified in the . S shall be a valid . Access Rules None. General Rules 1) Let Q be the result of S. 2) Case: a) If the cardinality of Q is greater than 1, then an ex- ception condition is raised: cardinality violation. It is implementation-dependent whether or not SQL-data values are assigned to the targets identified by the , and a comple- tion condition is raised: no data. 382 Database Language SQL X3H2-92-154/DBL CBR-002 13.5 is in an implementation-dependent order. 5) If an exception condition is raised during the assignment of a value to a target, then the values of targets are implementation- dependent. 6) The target identified by the i-th of the is an exact numeric type, then the data type of the i-th column of the table T shall be an exact numeric type. b) The
shall not include a or a and shall not identify a grouped view. Data manipulation 383 X3H2-92-154/DBL CBR-002 13.6 13.6 Function Delete a row of a table. Format ::= DELETE FROM
WHERE CURRENT OF Syntax Rules 1) The containing shall contain a whose is the same as the in the . Let CR be the cursor specified by . 2) CR shall be an updatable cursor. Note: updatable cursor is defined in Subclause 13.1, "". 3) Let T be the table identified by the
. Let QS be the that is the simply underlying table of the simply underlying table of CR. The simply underlying table of QS shall be T. Note: The simply underlying table of a is defined in Subclause 13.1, "". Access Rules 1) The applicable privileges shall include DELETE for the
. Note: The applicable privileges for a
are defined in Subclause 10.3, "". General Rules 1) If the access mode of the current SQL-transaction is read-only and T is not a temporary table, then an exception condition is raised: invalid transaction state. 2) If cursor CR is not positioned on a row, then an exception con- dition is raised: invalid cursor state. 3) The row from which the current row of CR is derived is marked for deletion. 4) If, while CR is open, the row from which the current row of CR is derived has been marked for deletion by any , marked for deletion by any that identifies any cursor other than CR, updated 384 Database Language SQL X3H2-92-154/DBL CBR-002 13.6 by any , or updated by any that identifies any cursor other than CR, then a completion condition is raised: warning-cursor operation conflict. 5) All rows that are marked for deletion are effectively deleted at the end of the prior to the checking of any integrity constraint. 6) If the deleted the last row of CR, then the position of CR is after the last row; otherwise, the position of CR is before the next row. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Data manipulation 385 X3H2-92-154/DBL CBR-002 13.7 13.7 Function Delete rows of a table. Format ::= DELETE FROM
[ WHERE ] Syntax Rules 1) Let T be the table identified by the
. T shall not be a read-only table. 2) The scope of the
is the entire . Access Rules 1) The applicable privileges shall include DELETE for the
. Note: The applicable privileges for a
are defined in Subclause 10.3, "". General Rules 1) If the access mode of the current SQL-transaction is read-only and T is not a temporary table, then an exception condition is raised: invalid transaction state. 2) Case: a) If is not specified, then all rows of T are marked for deletion. b) If is specified, then it is applied to each row of T with the
bound to that row, and all rows for which the result of the is true are marked for deletion. The is effectively evaluated for each row of T before marking for deletion any row of T. Each in the is effectively executed for each row of T and the results used in the ap- plication of the to the given row of T. If any executed contains an outer reference to a column of T, the reference is to the value of that column in the given row of T. Note: Outer reference is defined in Subclause 6.4, "". 386 Database Language SQL X3H2-92-154/DBL CBR-002 13.7 3) If any row that is marked for deletion by the has been marked for deletion by any that identifies some cursor CR that is still open or updated by any that identifies some cursor CR that is still open, then a completion condition is raised: warning-cursor operation conflict. 4) All rows that are marked for deletion are effectively deleted at the end of the prior to the checking of any integrity constraint. 5) If no row is deleted, then a completion condition is raised: no data. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) No leaf generally underlying table of T shall be an under- lying table of any generally contained in the . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Data manipulation 387 X3H2-92-154/DBL CBR-002 13.8 13.8 Function Create new rows in a table. Format ::= INSERT INTO
::= [ ] | DEFAULT VALUES ::= Syntax Rules 1) The table T identified by the
shall not be a read- only table. 2) An that specifies DEFAULT VALUES is equivalent to an that specifies a of the form VALUES (DEFAULT, . . . ) where the number of "DEFAULT" entries is equal to the number of columns of T. 3) No of T shall be identified more than once. If the is omitted, then an that identifies all columns of T in the ascending sequence of their ordinal positions within T is implicit. 4) A column identified by the is an object column. 5) Let QT be the table specified by the . The degree of QT shall be equal to the number of s in the . The column of table T identified by the i-th in the corresponds with the i-th column of QT. 6) The Syntax Rules of Subclause 9.2, "Store assignment", apply to corresponding columns of T and QT as TARGET and VALUE, respec- tively. 388 Database Language SQL X3H2-92-154/DBL CBR-002 13.8 Access Rules 1) Case: a) If an is specified, then the applicable shall include INSERT for each in the . b) Otherwise, the applicable privileges shall include INSERT for each in T. Note: The applicable privileges for a
are defined in Subclause 10.3, "". 2) Each in the shall identify a column of T. General Rules 1) If the access mode of the current SQL-transaction is read-only and T is not a temporary table, then an exception condition is raised: invalid transaction state. 2) Let B be the leaf generally underlying table of T. 3) The is effectively evaluated before inserting any rows into B. 4) Let Q be the result of that . Case: a) If Q is empty, then no row is inserted and a completion con- dition is raised: no data. b) Otherwise, for each row R of Q: i) A candidate row of B is effectively created in which the value of each column is its default value, as specified in the General Rules of Subclause 11.5, "". The candidate row includes every column of B. ii) For every object column in the candidate row, the value of the object column identified by the i-th in the is replaced by the i-th value of R. iii) Let C be a column that is represented in the candidate row and let SV be its value in the candidate row. The General Rules of Subclause 9.2, "Store assignment", are applied to C and SV as TARGET and VALUE, respectively. iv) The candidate row is inserted into B. Note: The data values allowable in the candidate row may be constrained by a WITH CHECK OPTION constraint. The effect of a WITH CHECK OPTION constraint is defined in the General Rules of Subclause 11.19, "". Data manipulation 389 X3H2-92-154/DBL CBR-002 13.8 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) The leaf generally underlying table of T shall not be gen- erally contained in the immediately contained in the except as the of a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) The that is contained in an shall be a or it shall be a that contains exactly one of the form " ", and each of that shall be a . b) If the data type of the target identified by the i-th is an exact numeric type, then the data type of the i- th item of the shall be an exact numeric type. c) If the data type of the target C identified by the i-th is character string, then the length in characters of the i-th item of the shall be less than or equal to the length of C. d) The shall immediately contain a . 390 Database Language SQL X3H2-92-154/DBL CBR-002 13.9 13.9 Function Update a row of a table. Format ::= UPDATE
SET WHERE CURRENT OF ::= [ { }... ] ::= ::= | | DEFAULT ::= Syntax Rules 1) The containing shall contain a for a cursor whose is the same as the in the . Let CR be the cursor specified by . 2) CR shall be an updatable cursor. Note: updatable cursor is defined in Subclause 13.1, "". 3) Let T be the table identified by the
. Let QS be the that is the simply underlying table of the simply underlying table of CR. The simply underlying table of QS shall be T. Note: The simply underlying table of a is defined in Subclause 13.1, "". 4) If CR is an ordered cursor, then for each OC, the column of T identified by OC shall not be directly or in- directly referenced in the of the defining for CR. Data manipulation 391 X3H2-92-154/DBL CBR-002 13.9 5) No leaf generally underlying table of T shall be an underly- ing table of any generally contained in any immediately contained in any contained in the . 6) A in a shall not directly con- tain a . 7) The same shall not appear more than once in a . 8) If the cursor identified by was specified using an explicit or implicit of FOR UPDATE, then each specified as an shall identify a column in the explicit or implicit associated with the . 9) The scope of the
is the entire . 10)For every , the Syntax Rules of Subclause 9.2, "Store assignment", apply to the column of T identified by the and the of the as TARGET and VALUE, respectively. Access Rules 1) The applicable privileges shall include UPDATE for each . Note: The applicable privileges for a
are defined in Subclause 10.3, "". 2) Each specified as an shall iden- tify a column of T. General Rules 1) If the access mode of the current SQL-transaction is read-only and T is not a temporary table, then an exception condition is raised: invalid transaction state. 2) If cursor CR is not positioned on a row, then an exception con- dition is raised: invalid cursor state. 3) The object row is that row from which the current row of CR is derived. 4) If, while CR is open, the object row has been marked for dele- tion by any , marked for deletion by any that identifies any cursor other than CR, updated by any , or updated by any that identifies any cursor other than CR, then a completion condition is raised: warning-cursor operation conflict. 392 Database Language SQL X3H2-92-154/DBL CBR-002 13.9 5) The value of DEFAULT is the default value indicated in the col- umn descriptor for the in the containing . 6) The s are effectively evaluated before updat- ing the object row. If a contains a reference to a column of T, then the reference is to the value of that column in the object row before any value of the object row is updated. 7) CR remains positioned on its current row, even if an exception condition is raised during derivation of any associated with the object row. 8) A specifies an object column and an update value of that column. The object column is the column identified by the in the . The update value is the value specified by the . Note: The data values allowable in the object row may be con- strained by a WITH CHECK OPTION constraint. The effect of a WITH CHECK OPTION constraint is defined in the General Rules of Subclause 11.19, "". 9) The object row is updated as specified by each . For each , the value of the specified object column, denoted by C, is replaced by the specified update value, denoted by SV. The General Rules of Subclause 9.2, "Store assignment", are applied to C and SV as TARGET and VALUE, respectively. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) CR shall not be an ordered cursor. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If the data type of the column identified by the i-th is an exact numeric type, then the data type of the i-th in the shall be an exact numeric type. b) If the data type of the column identified by the i-th C is character string, then the length in characters of the i-th in the shall be less than or equal to the length of C. c) An shall not specify DEFAULT. Data manipulation 393 X3H2-92-154/DBL CBR-002 13.10 13.10 Function Update rows of a table. Format ::= UPDATE
SET [ WHERE ] Syntax Rules 1) Let T be the table identified by the
. T shall be an updatable table. 2) A in a shall not directly con- tain a . 3) The same shall not appear more than once in a . 4) The scope of the
is the entire . 5) For every , the Syntax Rules of Subclause 9.2, "Store assignment", apply to the column of T identified by the and the of the as TARGET and VALUE, respectively. Access Rules 1) The applicable privileges shall include UPDATE for each . Note: The applicable privileges for a
are defined in Subclause 10.3, "". 2) Each specified as an shall iden- tify a column of T. General Rules 1) If the access mode of the current SQL-transaction is read-only and T is not a temporary table, then an exception condition is raised: invalid transaction state. 2) Case: a) If a is not specified, then all rows of T are the object rows. 394 Database Language SQL X3H2-92-154/DBL CBR-002 13.10 b) If a is specified, then it is applied to each row of T with the
bound to that row, and the object rows are those rows for which the result of the is true. The is effectively evaluated for each row of T before updating any row of T. Each in the is effectively executed for each row of T and the results used in the ap- plication of the to the given row of T. If any executed contains an outer reference to a column of T, the reference is to the value of that column in the given row of T. Note: Outer reference is defined in Subclause 6.4, "". 3) If any row in the set of object rows has been marked for dele- tion by any that identifies some cursor CR that is still open or updated by any that identifies some cursor CR that is still open, then a completion condition is raised: warning-cursor operation conflict. 4) If the set of object rows is empty, then a completion condition is raised: no data. 5) If a completion condition no data has been raised, then no fur- ther General Rules of this Subclause are applied. 6) The s are effectively evaluated for each row of T before updating any row of T. 7) A specifies an object column and an update value of that column. The object column is the column identified by the in the . The update value is the value specified by the . Note: The data values allowable in the object row may be con- strained by a WITH CHECK OPTION constraint. The effect of a WITH CHECK OPTION constraint is defined in the General Rules of Subclause 11.19, "". 8) Each object row is updated as specified by each . For each , the value of the specified object column, denoted by C, is replaced by the specified update value, denoted by SV. The General Rules of Subclause 9.2, "Store assignment", are applied to C and SV as TARGET and VALUE, respectively. Data manipulation 395 X3H2-92-154/DBL CBR-002 13.10 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) No leaf generally underlying table of T shall be an under- lying table of any generally contained in the or in any immedi- ately contained in any contained in the . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) If the data type of the column identified by the i-th is an exact numeric type, then the data type of the i-th in the shall be an exact numeric type. b) If the data type of the column identified by the i-th C is character string, then the length in characters of the i-th in the shall be less than or equal to the length of C. 396 Database Language SQL X3H2-92-154/DBL CBR-002 13.11 13.11 Function Declare a declared local temporary table that will be effectively materialized the first time that any in the that contains the is executed and whose scope is all the s of that executed within the same SQL-session. Format ::= DECLARE LOCAL TEMPORARY TABLE
[ ON COMMIT { PRESERVE | DELETE } ROWS ] Syntax Rules 1) Let T be the of . T shall be different from the of any other contained within the . 2) Let A be the current . 3) The descriptor of the table defined by a includes the name of T and the column descriptor speci- fied by each . The i-th column descriptor is given by the i-th . 4) A shall contain at least one . 5) If ON COMMIT is not specified, then ON COMMIT DELETE ROWS is implicit. Access Rules None. General Rules 1) Let U be the implementation-dependent that is effectively derived from the implementation-dependent SQL- session identifier associated with the SQL-session and an implementation-dependent name associated with the that contains the . 2) The definition of T within a is effectively equivalent to the definition of a persistent base table U.T. Within the module, any reference to MODULE.T is equivalent to a reference to U.T. Data manipulation 397 X3H2-92-154/DBL CBR-002 13.11 3) A set of privilege descriptors is created that define the priv- ileges INSERT, SELECT, UPDATE, DELETE, and REFERENCES on this table and INSERT (), UPDATE (), and REFERENCES () for every in the table definition to A. These privileges are not grantable. The grantor for each of these privilege descriptors is set to the special grantor value "_SYSTEM". 4) The definition of a temporary table persists for the duration of the SQL-session. The termination of the SQL-session is effec- tively followed by the execution of the following with the current and current U without further Access Rule checking: DROP TABLE T 5) The definition of a declared local temporary table does not appear in any view of the Information Schema. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 398 Database Language SQL X3H2-92-154/DBL CBR-002 14 Transaction management 14.1 Function Set the attributes of the next SQL-transaction for the SQL-agent. Format ::= SET TRANSACTION [ { }... ] ::= | | ::= READ ONLY | READ WRITE ::= ISOLATION LEVEL ::= READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE ::= DIAGNOSTICS SIZE ::= Syntax Rules 1) No shall be specified more than once. 2) If an is not specified, then a of ISOLATION LEVEL SERIALIZABLE is implicit. 3) If READ WRITE is specified, then the shall not be READ UNCOMMITTED. Transaction management 399 X3H2-92-154/DBL CBR-002 14.1 4) If a is not specified and a of READ UNCOMMITTED is specified, then READ ONLY is implicit. Otherwise, READ WRITE is implicit. 5) The data type of shall be exact numeric with scale 0. Access Rules None. General Rules 1) If a statement is executed when an SQL-transaction is currently active, then an exception condition is raised: invalid transaction state. 2) If is specified and is less than 1, then an exception condition is raised: invalid condition number. 3) Let TXN be the next SQL-transaction for the SQL-agent. 4) If READ ONLY is specified, then the access mode of TXN is set to read-only. If READ WRITE is specified, then the access mode of TXN is set to read-write. 5) The isolation level of TXN is set to an implementation-defined isolation level that will not exhibit any of the phenomena that the explicit or implicit would not exhibit, as specified in Table 9, "SQL-transaction isolation levels and the three phenomena". 6) If is specified, then the diagnostics area limit of TXN is set to . 7) If is not specified, then the diagnostics area limit of TXN is set to an implementation-dependent value not less than 1. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . 400 Database Language SQL X3H2-92-154/DBL CBR-002 14.2 14.2 Function If an SQL-transaction is currently active, then set the constraint mode for that SQL-transaction in the current SQL-session. If no SQL-transaction is currently active, then set the constraint mode for the next SQL-transaction in the current SQL-session for the SQL-agent. Format ::= SET CONSTRAINTS { DEFERRED | IMMEDIATE } ::= ALL | [ { }... ] Syntax Rules 1) If a is specified, then it shall identify a constraint. 2) The constraint identified by shall be DEFERRABLE. Access Rules None. General Rules 1) If an SQL-transaction is currently active, then let TXN be the currently active SQL-transaction. Otherwise, let TXN be the next SQL-transaction for the SQL-agent. 2) If IMMEDIATE is specified, then Case: a) If ALL is specified, then the constraint mode in TXN of all constraints that are DEFERRABLE is set to immediate. b) Otherwise, the constraint mode in TXN for the constraints identified by the s in the is set to immediate. 3) If DEFERRED is specified, then Transaction management 401 X3H2-92-154/DBL CBR-002 14.2 Case: a) If ALL is specified, then the constraint mode in TXN of all constraints that are DEFERRABLE is set to deferred. b) Otherwise, the constraint mode in TXN for the constraints identified by the s in the is set to deferred. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 402 Database Language SQL X3H2-92-154/DBL CBR-002 14.3 14.3 Function Terminate the current SQL-transaction with commit. Format ::= COMMIT [ WORK ] Syntax Rules None. Access Rules None. General Rules 1) If the current SQL-transaction is part of an encompassing trans- action that is controlled by an agent other than the SQL-agent, then an exception condition is raised: invalid transaction ter- mination. 2) For every open cursor CR in any associated with the current SQL-transaction, the following statement is implicitly executed: CLOSE CR 3) For every temporary table in any associated with the current SQL-transaction that specifies the ON COMMIT DELETE option and that was updated by the current SQL-transaction, the execution of the is effectively preceded by the execution of a that specifies DELETE FROM T, where T is the
of that temporary table. 4) The effects specified in the General Rules of Subclause 14.2, "" occur as if the statement SET CONSTRAINTS ALL IMMEDIATE were executed. 5) Case: a) If any constraint is not satisfied, then any changes to SQL- data or schemas that were made by the current SQL-transaction are canceled and an exception condition is raised: transac- tion rollback-integrity constraint violation. Transaction management 403 X3H2-92-154/DBL CBR-002 14.3 b) If any other error preventing commitment of the SQL- transaction has occurred, then any changes to SQL-data or schemas that were made by the current SQL-transaction are canceled and an exception condition is raised: transaction rollback with an implementation-defined subclass value. c) Otherwise, any changes to SQL-data or schemas that were made by the current SQL-transaction are made accessible to all concurrent and subsequent SQL-transactions. 6) The current SQL-transaction is terminated. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) In conforming Entry SQL language, WORK shall be specified. 404 Database Language SQL X3H2-92-154/DBL CBR-002 14.4 14.4 Function Terminate the current SQL-transaction with rollback. Format ::= ROLLBACK [ WORK ] Syntax Rules None. Access Rules None. General Rules 1) If the current SQL-transaction is part of an encompassing trans- action that is controlled by an agent other than the SQL-agent and the is not being implicitly executed, then an exception condition is raised: invalid transaction ter- mination. 2) For every open cursor CR in any associated with the current SQL-transaction, the following statement is implicitly executed: CLOSE CR 3) Any changes to SQL-data or schemas that were made by the current SQL-transaction are canceled. 4) The current SQL-transaction is terminated. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) In conforming Entry SQL language, WORK shall be specified. Transaction management 405 X3H2-92-154/DBL CBR-002 406 Database Language SQL X3H2-92-154/DBL CBR-002 15 Connection management 15.1 Function Establish an SQL-connection. Format ::= CONNECT TO ::= [ AS ] [ USER ] | DEFAULT Syntax Rules 1) If is not specified, then an implementation-defined for the SQL-connection is implicit. Access Rules None. General Rules 1) If a is executed after the first transaction- initiating SQL-statement executed by the current SQL-transaction and the implementation does not support transactions that affect more than one SQL-server, then an exception condition is raised: feature not supported-multiple server transactions 2) If is specified, then let S be the character string that is the value of and let V be the character string that is the value of TRIM ( BOTH ' ' FROM CV ) 3) If V does not conform to the Format and Syntax Rules of an , then an exception condition is raised: invalid authorization specification. Connection management 407 X3H2-92-154/DBL CBR-002 15.1 4) If the that contains the that contains the specifies a , then whether or not must be identical to that is implementation-defined, as are any other restrictions on the value of . Otherwise, any restrictions on the value of are implementation-defined. 5) If the value of violates the implementation-defined restrictions, then an exception condition is raised: invalid authorization specification. 6) If was specified, then let CV be the value of the immediately contained in . If neither DEFAULT nor were specified, then let CV be the value of . Let CN be the result of TRIM ( BOTH ' ' FROM CV ) If CN does not conform to the Format and Syntax Rules of an , then an exception condition is raised: invalid connection name. 7) If an SQL-connection with name CN has already been established by the current SQL-agent and has not been disconnected, or if DEFAULT is specified and a default SQL-connection has already been established by the current SQL-agent and has not been dis- connected, then an exception condition is raised: connection exception-connection name in use. 8) Case: a) If DEFAULT is specified, then the default SQL-session is initiated and associated with the default SQL-server. The method by which the default SQL-server is determined is implementation-defined. b) Otherwise, an SQL-session is initiated and associated with the SQL-server identified by . The method by which is used to determine the appropriate SQL-server is implementation-defined. 9) If the successfully initiates an SQL- session, then: a) The current SQL-connection and current SQL-session, if any, become a dormant SQL-connection and a dormant SQL-session, respectively. The SQL-server context information is preserved and is not affected in any way by operations performed over the initiated SQL-connection. Note: The SQL-session context information is defined in Subclause 4.30, "SQL-sessions". 408 Database Language SQL X3H2-92-154/DBL CBR-002 15.1 b) The SQL-session initiated by the becomes the current SQL-session and the SQL-connection established to that SQL-session becomes the current SQL-connection. Note: If the fails to initiate an SQL- session, then the current SQL-connection and current SQL- session, if any, remain unchanged. 10)If the SQL-client cannot establish the SQL-connection, then an exception condition is raised: connection exception- SQL-client unable to establish SQL-connection. 11)If the SQL-server rejects the establishment of the SQL- connection, then an exception condition is raised: connection exception- SQL-server rejected establishment of SQL-connection. 12)The SQL-server for the subsequent execution of s in any s associated with the SQL-agent is set to the SQL-server identified by . 13)The SQL-session is set to . Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Connection management 409 X3H2-92-154/DBL CBR-002 15.2 15.2 Function Select an SQL-connection from the available SQL-connections. Format ::= SET CONNECTION ::= DEFAULT | Syntax Rules None. Access Rules None. General Rules 1) If a is executed after the first transaction-initiating SQL-statement executed by the current SQL-transaction and the implementation does not support trans- actions that affect more than one SQL-server, then an excep- tion condition is raised: feature not supported-multiple server transactions. 2) Case: a) If DEFAULT is specified and there is no default SQL- connection that is current or dormant for the current SQL- agent, then an exception condition is raised: connection exception-connection does not exist. b) Otherwise, if does not identify an SQL- session that is current or dormant for the current SQL-agent, then an exception condition is raised: connection exception- connection does not exist. 3) If the SQL-connection identified by cannot be selected, then an exception condition is raised: connection exception-connection failure. 4) The current SQL-connection and current SQL-session become a dor- mant SQL-connection and a dormant SQL-session, respectively. 410 Database Language SQL X3H2-92-154/DBL CBR-002 15.2 The SQL-server context information is preserved and is not af- fected in any way by operations performed over the selected SQL-connection. Note: The SQL-session context information is defined in Subclause 4.30, "SQL-sessions". 5) The SQL-connection identified by becomes the current SQL-connection and the SQL-session associated with that SQL-connection becomes the current SQL-session. All SQL-session context information is restored to the same state as at the time the SQL-connection became dormant. Note: The SQL-session context information is defined in Subclause 4.30, "SQL-sessions". 6) The SQL-server for the subsequent execution of s in any s associated with the SQL-agent is set to that of the current SQL-connection. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Connection management 411 X3H2-92-154/DBL CBR-002 15.3 15.3 Function Terminate an SQL-connection. Format ::= DISCONNECT ::= | ALL | CURRENT Syntax Rules None. Access Rules None. General Rules 1) If is specified and does not identify an SQL-connection that is current or dormant for the current SQL-agent, then an exception condition is raised: connection exception-connection does not exist. 2) If DEFAULT is specified and there is no default SQL-connection that is current or dormant for the current SQL-agent, then an exception condition is raised: connection exception-connection does not exist. 3) If CURRENT is specified and there is no current SQL-connection for the current SQL-agent, then an exception condition is raised: connection exception-connection does not exist. 4) Let C be the current SQL-connection. 5) Let L be a list of SQL-connections. If a is specified, then L is that SQL-connection. If CURRENT is spec- ified, then L is the current SQL-connection, if any. If ALL is specified, then L is a list representing every SQL-connection that is current or dormant for the current SQL-agent, in an implementation-dependent order. If DEFAULT is specified, then L is the default SQL-connection. 6) If any SQL-connection in L is active, then an exception condi- tion is raised: invalid transaction state. 412 Database Language SQL X3H2-92-154/DBL CBR-002 15.3 7) For every SQL-connection C1 in L, treating the SQL-session S1 identified by C1 as the current SQL-session, all of the actions that are required after the last call of a by an SQL-agent, except for the execution of a or a , are performed. C1 is terminated, re- gardless of any exception condition that might occur during the disconnection process. Note: See the General Rules of Subclause 12.1, "", for the actions to be performed after the last call of a by an SQL-agent. 8) If any error is detected during execution of a , then a completion condition is raised: warning- disconnect error. 9) If C is contained in L, then there is no current SQL-connection following the execution of the . Otherwise, C remains the current SQL-connection. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Connection management 413 X3H2-92-154/DBL CBR-002 414 Database Language SQL X3H2-92-154/DBL CBR-002 16 Session management 16.1 Function Set the default catalog name for unqualified s in s that are prepared in the current SQL- session by an or a and in s that are invoked directly. Format ::= SET CATALOG Syntax Rules 1) The of the shall be an SQL character data type. Access Rules None. General Rules 1) Let S be the character string that is the value of the and let V be the character string that is the value of TRIM ( BOTH ' ' FROM S ) 2) If V does not conform to the Format and Syntax Rules of a , then an exception condition is raised: invalid catalog name. 3) The default catalog name of the current SQL-session is set to V. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . Session management 415 X3H2-92-154/DBL CBR-002 16.1 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions None. 416 Database Language SQL X3H2-92-154/DBL CBR-002 16.2 16.2 Function Set the default schema name for unqualified s in s that are prepared in the current SQL- session by an or a and in s that are invoked directly. Format ::= SET SCHEMA Syntax Rules 1) The data type of the shall be an SQL char- acter data type. Access Rules None. General Rules 1) Let S be the character string that is the value of the and let V be the character string that is the value of TRIM ( BOTH ' ' FROM S ) 2) If V does not conform to the Format and Syntax Rules of a , then an exception condition is raised: invalid schema name. 3) Case: a) If V conforms to the Format and Syntax Rules for a that contains a , then let X be the part and let Y be the part of V. The following statement is implicitly executed: SET CATALOG 'X' and the is effectively replaced by: SET SCHEMA 'Y' b) Otherwise, the default unqualified schema name of the current SQL-session is set to V. Session management 417 X3H2-92-154/DBL CBR-002 16.2 Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 418 Database Language SQL X3H2-92-154/DBL CBR-002 16.3 16.3 Function Set the default character set name for s and s in s that are prepared in the current SQL-session by an or a and in s that are invoked directly. Format ::= SET NAMES Syntax Rules 1) The of the shall be an SQL character data type. Access Rules None. General Rules 1) Let S be the character string that is the value of the and let V be the character string that is the value of TRIM ( BOTH ' ' FROM S ) 2) If V does not conform to the Format and Syntax Rules of a , then an exception condition is raised: invalid character set name. 3) The default character set name of the current SQL-session is set to V. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Session management 419 X3H2-92-154/DBL CBR-002 16.4 16.4 Function Set the of the current SQL-session. Format ::= SET SESSION AUTHORIZATION Syntax Rules 1) The of the shall be an SQL character data type. Access Rules None. General Rules 1) If a is ex- ecuted and an SQL-transaction is currently active, then an exception condition is raised: invalid transaction state. 2) Let S be the character string that is the value of the and let V be the character string that is the value of TRIM ( BOTH ' 'FROM S ) 3) If V does not conform to the Format and Syntax Rules of an , then an exception condition is raised: invalid authorization specification. 4) Whether or not the for the SQL- session can be set to an other than the of the SQL-session when the SQL-session is started is implementation-defined, as are any restrictions pertaining to such changes. 5) If the current is restricted from setting the to the specified value, then an exception condition is raised: invalid authorization specification. 6) Let T be any temporary table defined in the currently active SQL-session. In all the privilege descriptors for T and for each of the columns of T, the is set to V. 420 Database Language SQL X3H2-92-154/DBL CBR-002 16.4 7) The of the current SQL-session is set to V. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any . Session management 421 X3H2-92-154/DBL CBR-002 16.5 16.5 Function Set the default local time zone displacement for the current SQL- session. Format ::= SET TIME ZONE ::= | LOCAL Syntax Rules 1) The of the immediately contained in the shall be INTERVAL HOUR TO MINUTE. Access Rules None. General Rules 1) Case: a) If LOCAL is specified, then the default local time zone dis- placement of the current SQL-session is set to the original implementation-defined default local time zone displace- ment that was established when the current SQL-session was started. b) Otherwise, Case: i) If the value of the is not the null value and is between INTERVAL -'12:59' and INTERVAL +'13:00', then the default local time zone displacement of the current SQL-session is set to the value of the . ii) Otherwise, an exception condition is raised: data exception- invalid time zone displacement value. 422 Database Language SQL X3H2-92-154/DBL CBR-002 16.5 Leveling Rules 1) The following restrictions apply for Intermediate SQL; None. 2) The following restrictions apply for Entry SQL; a) Conforming Entry SQL language shall not contain any . Session management 423 X3H2-92-154/DBL CBR-002 424 Database Language SQL X3H2-92-154/DBL CBR-002 17 Dynamic SQL 17.1 Description of SQL item descriptor areas Function Specify the identifiers, data types, and codes used in SQL item descriptor areas. Syntax Rules 1) An SQL item descriptor area comprises the items specified in Table 17, "Data types of s used in SQL item descriptor areas". 2) Let DT be a data type. The data type T of a or a SVT is said to match the data type specified by the item descriptor area if and only if one of the following conditions is true. Case: a) TYPE indicates NUMERIC and T is specified by NUMERIC(P,S), where P is the value of PRECISION and S is the value of SCALE. b) TYPE indicates DECIMAL and T is specified by DECIMAL(P,S), where P is the value of PRECISION and S is the value of SCALE. c) TYPE indicates INTEGER and T is specified by INTEGER. d) TYPE indicates SMALLINT and T is specified by SMALLINT. e) TYPE indicates FLOAT and T is specified by FLOAT(P), where P is the value of PRECISION. f) TYPE indicates REAL and T is specified by REAL. g) TYPE indicates DOUBLE PRECISION and T is specified by DOUBLE PRECISION. h) TYPE indicates BIT and T is specified by BIT(L), where L is the value of LENGTH. i) TYPE indicates BIT VARYING and T is specified by BIT VARYING(L), where Case: i) SVT is a and L is the value of LENGTH. Dynamic SQL 425 X3H2-92-154/DBL CBR-002 17.1 Description of SQL item descriptor areas ii) SVT is a and L is not less than the value of LENGTH. j) TYPE indicates CHARACTER and T is specified by CHARACTER(L), where L is the value of LENGTH and the formed by the values of CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_SET_NAME identifies the character set of SVT. k) TYPE indicates CHARACTER VARYING and T is specified by CHARACTER VARYING(L), where the formed by the values of CHARACTER_SET_CATALOG, CHARACTER_SET_ SCHEMA, and CHARACTER_SET_NAME identifies the character set of SVT and Case: i) SVT is a and L is the value of LENGTH. ii) SVT is a and L is not less than the value of LENGTH. 3) An item descriptor area is valid if and only if TYPE indicates a code defined in Table 18, "Codes used for SQL data types in Dynamic SQL", and one of the following is true: Case: a) TYPE indicates NUMERIC and PRECISION and SCALE are valid precision and scale values for the NUMERIC data type. b) TYPE indicates DECIMAL and PRECISION and SCALE are valid precision and scale values for the DECIMAL data type. c) TYPE indicates FLOAT and PRECISION is a valid precision value for the FLOAT data type. d) TYPE indicates INTEGER, SMALLINT, REAL, or DOUBLE PRECISION. e) TYPE indicates BIT or BIT VARYING and LENGTH is a valid length value for the BIT date type. f) TYPE indicates CHARACTER or CHARACTER VARYING, LENGTH is a valid length value for the CHARACTER data type, and CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_ SET_NAME are a valid qualified character set name for the CHARACTER data type. g) TYPE indicates a , DATETIME_INTERVAL_CODE is a code specified in Table 19, "Codes associated with datetime data types in Dynamic SQL", and PRECISION is a valid value for the
in which the i-th in each is E1 and either: i) P is not an , or ii) P is an and the
is not the simply contained in the . k) P contains an with an in which E1 is both the and the first of the . l) P contains a in which both immediately contained s are E1. m) P contains a or a whose immediately contained is E1. n) P contains a whose operand is E1. o) P contains a whose or is E1. p) P contains a whose is E1. q) P contains a . 444 Database Language SQL X3H2-92-154/DBL CBR-002 17.6 5) Case: a) If E1 is followed by an IQ, then the data type of E1 is assumed to be INTERVAL IQ. b) In OCTET_LENGTH(E1), CHARACTER_LENGTH(E1), and CHARACTER_ LENGTH(E1), the data type of E1 is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. c) In POSITION(X1 IN X2), and SUBSTRING(X1 FROM X3 FOR X4), if X1 (X2) meets the criteria for E1, E2, E3, and E4, then the data type of X1 (X2) is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. If X3 (X4) meets the cri- teria for E1, E2, E3, and E4, then the data type of X3 (X4) is assumed to be NUMERIC(P,0), where P is the implementation- defined maximum value of for NUMERIC. d) In a of the form "X1 X2", if X1 (X2) meets the criteria for E1, E2, E3, and E4, then the data type of X1 (X2) is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. e) In BIT_LENGTH(E1), the data type of E1 is assumed to be BIT VARYING(L), where L is the implementation-defined maximum value of for BIT VARYING. f) In a of the form "E1 + ", " + E1" or " - E1", the data type of E1 is assumed to be Case: i) If the is a date data type, then the data type of E1 is assumed to be INTERVAL YEAR(P) TO MONTH, where P is the implementation-defined maximum . ii) Otherwise, the data type of E1 is assumed to be INTERVAL DAY(P) TO SECOND(F), where P and F are the implementation- defined maximum and max- imum , respectively. g) In a of the form " * E1" or " / E1", the data type of E1 is assumed to be NUMERIC(P,0), where P is the implementation-defined maximum value of for NUMERIC. h) In all other s of the form "E1+ F", "E1- F", "E1* F", "E1/ F", "F + E1", "F - E1", "F * E1", or "F / E1", the data type of E1 is assumed to be the data type of F. Dynamic SQL 445 X3H2-92-154/DBL CBR-002 17.6 i) In a of the form "CAST (E1 AS )", "CAST (E1 AS )", the data type of E1 is the of the specified domain or the explicitly- specified . j) If one or more operands of COALESCE are E1, then the data type of E1 is assumed to be the data type of the first operand. k) If one or more s in a are E1, then the data type of E1 is assumed to be the data type of the first . l) If one operand of NULLIF is E1, then the data type of E1 is assumed to be the data type of the other operand. m) In the first and second operands of a or , or the first and third operands of a , if the i-th value of one operand is E1, then the data type of E1 is the data type of the i-th value of the other operand. n) In the first and second operands of an , if either of the first s is E1, then the data type of E1 is the data type of the first of the other operand. If both of the first s are E1, then the data type of each E1 is assumed to be TIMESTAMP WITH TIME ZONE. o) In a
in which the i-th of some is E1 that contains a whose i-th is not E1, the data type of E1 is the data type of the i-th of the first whose i-th is not E1. p) In a
in which the i-th in each is E1 that is the simply contained in an , the data type of E1 is the data type of the corresponding column of the implicit or explicit con- tained in the . q) In an that specifies a
, the data types of s E1 in the are assumed to be the same as the data types of the respective columns of the
. r) In an that specifies an , if the is not E1, then let D be its data type. Otherwise, let D be the data type of the first of the . The data type of any E1 in the is assumed to be D. 446 Database Language SQL X3H2-92-154/DBL CBR-002 17.6 s) If E1 appears for , , or in , then the data type of E1 is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. t) If any value in the of a or is E1, then the data type of E1 is assumed to be the same as the data type of the respective column of the
. u) If in , , , or is E1, then the data type of E1 is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. v) If in is E1, then the data type of E1 is assumed to be CHARACTER VARYING(L), where L is the implementation-defined maximum value of for CHARACTER VARYING. w) If a in a is E1, then the data type of E1 is assumed to be the same data type as the corresponding . 6) If the value of the identifies an existing prepared statement, then an implicit DEALLOCATE PREPARE SSN is executed, where SSN is the value of the . 7) P is prepared for execution. 8) If is specified for the , then let S be the character string that is the value of the and let V be the character string that is the result of TRIM ( BOTH ' ' FROM S ) If V does not conform to the Format and Syntax Rules of an , then an exception condition is raised: invalid SQL statement identifier. 9) Case: a) If is specified for the , then the value of the is associated with the prepared statement. This value and ex- plicit or implied shall be specified for each or that is to be associated with this prepared statement. Dynamic SQL 447 X3H2-92-154/DBL CBR-002 17.6 b) If is specified for the , then: i) If P is a and is associated with a cursor C through a , then an association is made between C and P. The association is preserved until the prepared statement is destroyed. ii) If P is not a and is associated with a cursor C through a , then an exception condition is raised: dynamic SQL error- prepared statement is not a cursor specification. iii) Otherwise, the same shall be specified for each that is to be associated with this prepared statement. 10)The validity of an value or a in an SQL-transaction different from the one in which the statement was prepared is implementation-dependent. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 448 Database Language SQL X3H2-92-154/DBL CBR-002 17.7 17.7 Function Deallocate SQL-statements that have been prepared with a . Format ::= DEALLOCATE PREPARE Syntax Rules 1) If is a , then the that contains the shall also contain a that specifies the same . Access Rules None. General Rules 1) If the does not identify a statement pre- pared in the scope of the , then an excep- tion condition is raised: invalid SQL statement name. 2) If the value of identifies an existing prepared statement that is the of an open cursor, then an exception condition is raised: invalid cursor state. 3) The prepared statement identified by the is destroyed. Any cursor that was allocated with an that is associated with the prepared state- ment identified by the is destroyed. If the value of the identifies an existing prepared statement that is a , then any prepared statements that reference that cursor are destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to Intermediate SQL restrictions: None. Dynamic SQL 449 X3H2-92-154/DBL CBR-002 17.8 17.8 Function Obtain information about the columns for the prepared statement is stored in the specified SQL descriptor area as follows: a) Let N be the specified when the was allocated. Dynamic SQL 451 X3H2-92-154/DBL CBR-002 17.9 b) If the prepared statement that is being described is a or a , then let T be the table defined by the prepared statement and let D be the degree of T. Otherwise, let D be 0. c) COUNT is set to D. d) If D is greater than N, then a completion condition is raised: warning-insufficient item descriptor areas. e) If D is 0 or D is greater than N, then no item descriptor areas are set. Otherwise, the first D item descriptor areas are set so that the i-th item descriptor area contains the descriptor of the i-th column of T. The descriptor of a col- umn consists of values for TYPE, NULLABLE, NAME, UNNAMED, and other fields depending on the value of TYPE as described be- low. The DATA and INDICATOR fields are not relevant in this case. Those fields and fields that are not applicable for a particular value of TYPE are set to implementation-dependent values. i) TYPE is set to a code, as shown in Table 18, "Codes used for SQL data types in Dynamic SQL", indicating the data type of the column. ii) NULLABLE is set to 1 if the resulting column is possibly nullable and 0 otherwise. iii) If the column name is implementation-dependent, then NAME is set to the implementation-dependent name of the column, and UNNAMED is set to 1. Otherwise, NAME is set to the name for the column and UNNAMED is set to 0. iv) Case: 1) If TYPE indicates a , then: LENGTH is set to the length or maximum length in char- acters of the character string; OCTET_LENGTH is set to the maximum possible length in octets of the character string; CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA and CHARACTER_SET_NAME are set to the of the character string's character set; and COLLATION_ CATALOG, COLLATION_SCHEMA and COLLATION_NAME are set to the of the character string's colla- tion. If the subject specifies C, then the lengths specified in LENGTH and OCTET_LENGTH do not include the implementation-defined null character that terminates a C character string. 452 Database Language SQL X3H2-92-154/DBL CBR-002 17.9 2) If TYPE indicates a , then LENGTH is set to the length or maximum length in bits of the bit string and OCTET_LENGTH is set to the maximum possible length in octets of the bit string. 3) If TYPE indicates an , then PRECISION and SCALE are set to the precision and scale of the exact numeric. 4) If TYPE indicates an , then PRECISION is set to the precision of the approximate numeric. 5) If TYPE indicates a , then LENGTH is set to the length in positions of the datetime type, DATETIME_INTERVAL_CODE is set to a code as specified in Table 19, "Codes associated with datetime data types in Dynamic SQL", to indicate the specific datetime data type, and PRECISION is set to the
of a created or declared local temporary table and if the is not in the same as the that prepared the pre- pared statement, then an exception condition is raised: syntax rule or access rule violation in dynamic SQL statement. Dynamic SQL 459 X3H2-92-154/DBL CBR-002 17.10 4) If P contains s and a is not specified, then an exception condition is raised: dynamic SQL error- using clause required for dynamic parameters. 5) If P is a and a is not specified, then an exception condition is raised: dynamic SQL error-using clause required for result fields. 6) If a that is is specified, then the General Rules specified in Subclause 17.9, "", for a in an are applied. 7) If P is a , then the General Rules specified in Subclause 17.9, "", for a in an are applied. 8) P is executed. Case: a) If P is a , then all General Rules in Subclause 13.5, " of P. b) If the is a , then all General Rules in Subclause 17.19, "", apply to the . c) If the is a , then all General Rules in Subclause 17.20, "", apply to the . d) Otherwise, the results of the execution are the same as if the statement was contained in a and executed; these are described in Subclause 12.3, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 460 Database Language SQL X3H2-92-154/DBL CBR-002 17.10 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Dynamic SQL 461 X3H2-92-154/DBL CBR-002 17.11 17.11 Function Dynamically prepare and execute a preparable statement. Format ::= EXECUTE IMMEDIATE Syntax Rules 1) The data type of shall be character string. Access Rules None. General Rules 1) Let P be the contents of the . 2) If P is a or a , then P refers to either a dynamic cursor with the same or to an extended dynamic cursor whose value is the same as the . Case: a) If both an extended dynamic cursor and a dynamic cursor with the same name as the exist, then an exception condition is raised: ambiguous cursor name. b) If there is neither an extended dynamic cursor nor a dynamic cursor with the name of , then an exception condition is raised: invalid cursor name. 3) If one or more of the following are true, then an exception condition is raised: syntax error or access rule violation in dynamic SQL statement. a) P does not conform to the Format, Syntax Rules, and Access Rules for a or P is a or a . b) P contains a . c) P contains a . 4) The that is the value of the is prepared and executed. 462 Database Language SQL X3H2-92-154/DBL CBR-002 17.11 Case: a) If the is a , then all General Rules in Subclause 17.19, "", apply to the . b) If the is a , then all General Rules in Subclause 17.20, "", apply to the . c) Otherwise, the results of the execution are the same as if the statement was contained in a and executed; these are described in Subclause 12.3, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Dynamic SQL 463 X3H2-92-154/DBL CBR-002 17.12 17.12 Function Declare a cursor to be associated with a , which may in turn be associated with a . Format ::= DECLARE [ INSENSITIVE ] [ SCROLL ] CURSOR FOR Syntax Rules 1) The shall not be identical to the specified in any other or in the same . 2) The containing shall contain a whose is the same as the of the . Access Rules None. General Rules 1) All General Rules of Subclause 13.1, "" apply to , replacing "" with "" and "" with "prepared statement". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no that specifies INSENSITIVE. b) If an of FOR UPDATE with or without a is specified, then neither SCROLL nor ORDER BY shall be specified. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 464 Database Language SQL X3H2-92-154/DBL CBR-002 17.13 17.13 Function Define a cursor based on a for a . Format ::= ALLOCATE [ INSENSITIVE ] [ SCROLL ] CURSOR FOR Syntax Rules None. Access Rules None. General Rules 1) When the is executed, if the value of the does not identify a statement previously prepared in the scope of the , then an exception condition is raised: invalid SQL state- ment name. 2) If the prepared statement associated with the is not a , then an exception condition is raised: dynamic SQL error-prepared statement not a cursor specification. 3) All General Rules of Subclause 13.1, "" apply to , replacing "" with "" and "" with "prepared statement". 4) Let S be the character string that is the value of the immediately contained in . Let V be the character string that is the result of TRIM ( BOTH ' ' FROM S ) If V does not conform to the Format and Syntax Rules of an , then an exception condition is raised: invalid cursor name. Dynamic SQL 465 X3H2-92-154/DBL CBR-002 17.13 5) If the value of the is identical to the value of the of any other cursor al- located in the scope of the , then an exception condition is raised: invalid cursor name. 6) An association is made between the value of the and the prepared statement in the scope of the . The association is preserved until the prepared statement is destroyed, at which time the cursor identified by is also destroyed. Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not contain any . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 466 Database Language SQL X3H2-92-154/DBL CBR-002 17.14 17.14 Function Associate input parameters with a and open the cursor. Format ::= OPEN [ ] Syntax Rules 1) If DCN is a CN, then the containing shall contain a whose is CN. 2) Let CR be the cursor identified by DCN. Access Rules 1) The Access Rules for the simply contained in the prepared statement associated with the are applied. General Rules 1) If is a and the of the associated is not associ- ated with a prepared statement, then an exception condition is raised: invalid SQL statement name. 2) If is an whose value does not identify a cursor allocated in the scope of the , then an exception condition is raised: invalid cursor name. 3) If the prepared statement associated with the contains s and a is not specified, then an exception condition is raised: dynamic SQL error-using clause required for dynamic parameters. 4) The cursor specified by is updatable if and only if the associated specified an updatable cursor. Note: updatable cursor is defined in Subclause 13.1, "". 5) If a is specified, then the General Rules spec- ified in Subclause 17.9, "", for are applied. Dynamic SQL 467 X3H2-92-154/DBL CBR-002 17.14 6) All General Rules of Subclause 13.2, "", apply to the . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 468 Database Language SQL X3H2-92-154/DBL CBR-002 17.15 17.15 Function Fetch a row for a cursor declared with a . Format ::= FETCH [ [ ] FROM ] Syntax Rules 1) If is omitted, then NEXT is implicit. 2) The shall specify INTO. 3) If DCN is a CN, then the containing shall contain a whose is CN. 4) Let CR be the cursor identified by DCN and let T be the table defined by the of CR. 5) If the implicit or explicit is not NEXT, then the or associated with CR shall specify SCROLL. 6) The number of s in or the number of item descriptor areas in the SQL descriptor area referenced by , as appropriate, shall be the same as the degree of T. The i-th in or the i-th item descriptor area of the SQL de- scriptor area, as appropriate, corresponds with the i-th column of T. 7) The Syntax Rules of Subclause 9.1, "Retrieval assignment", apply to each corresponding in and each column of T as TARGET and VALUE, respectively. Access Rules None. General Rules 1) The General Rules specified in Subclause 17.9, "", for are applied. Dynamic SQL 469 X3H2-92-154/DBL CBR-002 17.15 2) All General Rules of Subclause 13.3, "", ap- ply to the , replacing "targets in the " and "targets identified by the " with "s in the or item descriptor areas of the SQL descriptor area, as appropriate". Leveling Rules 1) The following restrictions apply for Intermediate SQL: 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 470 Database Language SQL X3H2-92-154/DBL CBR-002 17.16 17.16 Function Close a cursor. Format ::= CLOSE Syntax Rules 1) If DCN is a CN, then the containing shall contain a whose is CN. 2) Let CR be the cursor identified by DCN. Access Rules None. General Rules 1) All General Rules of Subclause 13.4, "", apply to the . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Dynamic SQL 471 X3H2-92-154/DBL CBR-002 17.17 17.17 Function Delete a row of a table. Format ::= DELETE FROM
WHERE CURRENT OF Syntax Rules 1) If DCN is a CN, then the containing shall contain a whose is CN. 2) Let CR be the cursor identified by DCN. 3) CR shall be an updatable cursor. Note: updatable cursor is defined in Subclause 13.1, "". 4) Let T be the table identified by the
. Let QS be the that is the simply underlying table of the simply underlying table of CR. The simply underlying table of QS shall be T. Note: The simply underlying table of a is defined in Subclause 13.1, "". Access Rules 1) All Access Rules of Subclause 13.6, "", apply to the . General Rules 1) All General Rules of Subclause 13.6, "", apply to the , replacing "" with "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 472 Database Language SQL X3H2-92-154/DBL CBR-002 17.17 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Dynamic SQL 473 X3H2-92-154/DBL CBR-002 17.18 17.18 Function Update a row of a table. Format ::= UPDATE
SET [ { }... ] WHERE CURRENT OF Syntax Rules 1) If DCN is a CN, then the containing shall contain a whose is CN. 2) Let CR be the cursor identified by DCN. 3) CR shall be an updatable cursor. Note: updatable cursor is defined in Subclause 13.1, "". 4) Let T be the table identified by the
. Let QS be the that is the simply underlying table of the simply underlying table of CR. The simply underlying table of QS shall be T. Note: The simply underlying table of a is defined in Subclause 13.1, "". 5) If CR is an ordered cursor, then for each OC, the column of T identified by OC shall not be directly or in- directly referenced in the of the defining for CR. 6) No leaf generally underlying table of T shall be an underly- ing table of any generally contained in any immediately contained in any contained in the . 7) A in a shall not directly con- tain a . 8) The same shall not appear more than once in a . 9) If CR was specified using an explicit or implicit of FOR UPDATE, then each specified as an shall identify a column in the explicit or implicit associated with the . 474 Database Language SQL X3H2-92-154/DBL CBR-002 17.18 10)The scope of the
is the entire . 11)For every , the Syntax Rules of Subclause 9.2, "Store assignment", apply to the column of T identified by the and the of the as TARGET and VALUE, respectively. Access Rules 1) All Access Rules of Subclause 13.9, "", apply to the . General Rules 1) All General Rules of Subclause 13.9, "", apply to the , replacing "" with "" and "" with "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Dynamic SQL 475 X3H2-92-154/DBL CBR-002 17.19 17.19 Function Delete a row of a table through a dynamic cursor. Format ::= DELETE [ FROM
] WHERE CURRENT OF Syntax Rules 1) If
is not specified, then the name of the under- lying table of the identified by is implicit. 2) All Syntax Rules of Subclause 13.6, "", apply to the , replacing "" with " or " and "" with "". Access Rules 1) All Access Rules of Subclause 13.6, "", apply to the . General Rules 1) All General Rules of Subclause 13.6, "", apply to the , replacing "" with "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 476 Database Language SQL X3H2-92-154/DBL CBR-002 17.20 17.20 Function Update a row of a table through a dynamic cursor. Format ::= UPDATE [
] SET WHERE CURRENT OF Syntax Rules 1) If
is not specified, then the name of the under- lying table of the identified by is implicit. 2) All Syntax Rules of Subclause 13.9, "", apply to the , replacing "" with " or " and "" with "". Access Rules 1) All Access Rules of Subclause 13.9, "", apply to the . General Rules 1) All General Rules of Subclause 13.9, "", apply to the , replacing "" with "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall contain no . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Dynamic SQL 477 X3H2-92-154/DBL CBR-002 478 Database Language SQL X3H2-92-154/DBL CBR-002 18 Diagnostics management 18.1 Function Get exception or completion condition information from the diagnos- tics area. Format ::= GET DIAGNOSTICS ::= | ::= [ { }... ] ::= ::= NUMBER | MORE | COMMAND_FUNCTION | DYNAMIC_FUNCTION | ROW_COUNT ::= EXCEPTION [ { }... ] ::= ::= CONDITION_NUMBER | RETURNED_SQLSTATE | CLASS_ORIGIN | SUBCLASS_ORIGIN | SERVER_NAME Diagnostics management 479 X3H2-92-154/DBL CBR-002 18.1 | CONNECTION_NAME | CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | CATALOG_NAME | SCHEMA_NAME | TABLE_NAME | COLUMN_NAME | CURSOR_NAME | MESSAGE_TEXT | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH ::= Syntax Rules 1) The data type of a contained in a or shall be the data type specified in Table 21, "s for use with ", for the corresponding or . 2) The data type of shall be exact numeric with scale 0. 480 Database Language SQL X3H2-92-154/DBL CBR-002 18.1 __Table_21-s_for_use_with___ ____________Data_Type__________________________________ |_________________s_______________| | | | | NUMBER exact numeric with scale 0 | | | | MORE | character string (1) | | | | | COMMAND_FUNCTION | character varying (L) | | | | | DYNAMIC_FUNCTION | character varying (L) | | | | |_ROW_COUNT____________|_exact_numeric_with_scale_0________________| | | | |_________________s_______________| | | | | CONDITION_NUMBER exact numeric with scale 0 | | | | RETURNED_SQLSTATE | character string (5) | | | | | CLASS_ORIGIN | character varying (L) | | | | | SUBCLASS_ORIGIN | character varying (L) | | | | | SERVER_NAME | character varying (L) | | | | | CONNECTION_NAME | character varying (L) | | | | | CONSTRAINT_CATALOG | character varying (L) | | | | | CONSTRAINT_SCHEMA | character varying (L) | | | | | CONSTRAINT_NAME | character varying (L) | | | | | CATALOG_NAME | character varying (L) | | | | | SCHEMA_NAME | character varying (L) | | | | | TABLE_NAME | character varying (L) | | | | | COLUMN_NAME | character varying (L) | | | | | CURSOR_NAME | character varying (L) | | | | | MESSAGE_TEXT | character varying (L) | | | | | MESSAGE_LENGTH | exact numeric with scale 0 | | | | |_MESSAGE_OCTET_LENGTH_|_exact_numeric_with_scale_0________________| | | | | Where L is an impleme|tation-defined integer not less than 128. | |______________________|___________________________________________| | | Access Rules None. Diagnostics management 481 X3H2-92-154/DBL CBR-002 18.1 General Rules 1) Specification of retrieves informa- tion about the statement execution recorded in the diagnostics area into . a) The value of NUMBER is the number of exception or completion conditions that have been stored in the diagnostics area as a result of executing the previous SQL-statement other than a . Note: The itself may return infor- mation via the SQLCODE or SQLSTATE parameters, but does not modify the previous contents of the diagnostics area. b) The value of MORE is: Y More conditions were raised during execution of the SQL-statement than have been stored in the diagnostics area. N All of the conditions that were raised during execution of the SQL-statement have been stored in the diagnostics area. c) The value of COMMAND_FUNCTION is the identification of the SQL-statement executed. Table 22, "SQL-statement character codes for use in the diagnostics area" specifies the identi- fier of the SQL-statements. d) The value of DYNAMIC_FUNCTION is the identification of the prepared statement executed. Table 22, "SQL-statement char- acter codes for use in the diagnostics area", specifies the identifier of the SQL-statements. Table 22-SQL-statement character _______________codes_for_use_in_the_diagnostics_area_______________ _SQL-statement____________________Identifier_______________________ | | ALLOCATE CURSOR | | | | | | | ALTER DOMAIN | | | | | | ALTER TABLE | | | | | | CREATE ASSERTION | | | | | | CREATE CHARACTER SET | | | | | | CLOSE CURSOR | | | | | | CREATE COLLATION | | | | | | COMMIT WORK | | | | 482 Database Language SQL X3H2-92-154/DBL CBR-002 18.1 Table 22-SQL-statement character codes ______________for_use_in_the_diagnostics_area_(Cont.)______________ _SQL-statement____________________Identifier_______________________ | | CONNECT | | | | | | | | | | | | | DELETE CURSOR | | | | | | DELETE WHERE | | | | | | DESCRIBE | | | | | | | DISCONNECT | | | | | | CREATE DOMAIN | | | | | | DROP ASSERTION | | | | | | DROP CHARACTER SET | | | | | | DROP COLLATION | | | | | | DROP DOMAIN | | | | | | DROP SCHEMA | | | | | | DROP TABLE | | | | | | DROP TRANSLATION | | | | | | DROP VIEW | | | | | | DYNAMIC CLOSE | | | | | | | DYNAMIC FETCH | | | | | | DYNAMIC OPEN | | | | | | | | | | | | | EXECUTE IMMEDIATE | | | | | | EXECUTE | | | | | | FETCH | | | | | | GET DESCRIPTOR | | | | Diagnostics management 483 X3H2-92-154/DBL CBR-002 18.1 Table 22-SQL-statement character codes ______________for_use_in_the_diagnostics_area_(Cont.)______________ _SQL-statement____________________Identifier_______________________ | | GET DIAGNOSTICS | | | | | | GRANT | | | | | | INSERT | | | | | | OPEN | | | | | | | | | | | | | PREPARE | | | | | | REVOKE | | | | | | ROLLBACK WORK | | | | | | CREATE SCHEMA | | | | |
| CREATE TABLE | | | | | | CREATE TRANSLATION | | | | | | UPDATE CURSOR | | | | | | UPDATE WHERE | | | | |_______________|_CREATE_VIEW_____________________| | | | e) The value of ROW_COUNT is the number of rows affected as the result of executing a , , or as a direct re- sult of executing the previous SQL-statement. Let S be the , , or statement: searched>. Let T be the table identified by the
directly contained in S. Case: i) If S is an , then the value of ROW_COUNT is the number of rows inserted into T. ii) If S is not an and does not contain a , then the value of ROW_COUNT is the cardinality of T before the execution of S. iii) Otherwise, let SC be the directly con- tained in S. The value of ROW_COUNT is effectively derived by executing the statement: SELECT COUNT(*) FROM T WHERE SC before the execution of S. The value of ROW_COUNT following the execution of an SQL- statement that does not directly result in the execution of a , an , or an is implementation-dependent. 2) If was specified, then let N be the value of . If N is less than 1 or greater than the number of conditions stored in the diagnostics area, then an exception condition is raised: invalid condition number. If has the value 1, then the diagnostics infor- mation retrieved corresponds to the condition indicated by the SQLSTATE or SQLCODE value actually returned by execution of the previous SQL-statement other than a . Otherwise, the association between values and specific conditions raised during evaluation of the General Rules for that SQL-statement is implementation-dependent. 3) Specification of retrieves informa- tion about the N-th condition in the diagnostics area into the . a) The value of CONDITION_NUMBER is the value of . b) The value of CLASS_ORIGIN is the identification of the naming authority that defined the class value of RETURNED_SQLSTATE. That value shall be 'ISO 9075' for any RETURNED_SQLSTATE whose class value is fully defined in Subclause 22.1, "SQLSTATE", and shall be an implementation-defined charac- ter string other than 'ISO 9075' for any RETURNED_SQLSTATE whose class value is an implementation-defined class value. c) The value of SUBCLASS_ORIGIN is the identification of the naming authority that defined the subclass value of RETURNED_SQLSTATE. That value shall be 'ISO 9075' for any RETURNED_SQLSTATE whose subclass value is fully defined in Diagnostics management 485 X3H2-92-154/DBL CBR-002 18.1 Subclause 22.1, "SQLSTATE", and shall be an implementation- defined character string other than 'ISO 9075' for any RETURNED_SQLSTATE whose subclass value is an implementation- defined subclass value. d) The value of RETURNED_SQLSTATE is the SQLSTATE parameter that would have been returned if this were the only completion or exception condition possible. e) If the value of RETURNED_SQLSTATE corresponds to warning with a subclass of cursor operation conflict, then the value of CURSOR_NAME is the name of the cursor that caused the completion condition to be raised. f) If the value of RETURNED_SQLSTATE corresponds to integrity constraint violation, transaction rollback-integrity con- straint violation, or triggered data change violation, then: i) The values of CONSTRAINT_CATALOG and CONSTRAINT_SCHEMA are the and the of the of the schema containing the constraint or assertion. The value of CONSTRAINT_NAME is the of the constraint or assertion. ii) Case: 1) If the violated integrity constraint is a table con- straint, then the values of CATALOG_NAME, SCHEMA_NAME, and TABLE_NAME are the , the of the , and the or , respectively, of the table in which the table constraint is contained. 2) If the violated integrity constraint is an assertion and if only one table referenced by the assertion has been modified as a result of executing the SQL-statement, then the values of CATALOG_NAME, SCHEMA_NAME, and TABLE_ NAME are the , the of the , and the or , respectively, of the modified table. 3) Otherwise, the values of CATALOG_NAME, SCHEMA_NAME, and TABLE_NAME are s. If TABLE_NAME identifies a declared local temporary table, then CATALOG_NAME is s and SCHEMA_NAME is "MODULE". g) If the value of RETURNED_SQLSTATE corresponds to syntax error or access rule violation, syntax error or access rule viola- tion in dynamic SQL statement, or syntax error or access rule violation in direct SQL statement, then: i) The values of CATALOG_NAME, SCHEMA_NAME, and TABLE_NAME 486 Database Language SQL X3H2-92-154/DBL CBR-002 18.1 are the , the of the of the schema that contains the table that caused the syntax error or the access rule viola- tion and the or , respectively. If TABLE_NAME refers to a declared local tem- porary table, then CATALOG_NAME is s and SCHEMA_NAME contains "MODULE". ii) If the syntax error or the access rule violation was for an inaccessible column, then the value of COLUMN_NAME is the of that column. Otherwise, the value of COLUMN_NAME is s. h) If the value of RETURNED_SQLSTATE corresponds to invalid cursor state, then the value of CURSOR_NAME is the name of the cursor that is in the invalid state. i) If the value of RETURNED_SQLSTATE corresponds to with check option violation, then the values of CATALOG_NAME, SCHEMA_ NAME, and TABLE_NAME are the and the of the of the schema that contains the view that caused the violation of the WITH CHECK OPTION, and the of that view, respectively. j) If the value of RETURNED_SQLSTATE does not correspond to syntax error or access rule violation, syntax error or access rule violation in dynamic SQL statement, or syntax error or access rule violation in direct SQL statement, then: i) If the values of CATALOG_NAME, SCHEMA_NAME, TABLE_NAME, and COLUMN_NAME identify a column for which no privileges are granted to the current , then the value of COLUMN_NAME is replaced by a zero-length string. ii) If the values of CATALOG_NAME, SCHEMA_NAME, and TABLE_NAME identify a table for which no privileges are granted to the current , then the values of CATALOG_NAME, SCHEMA_NAME, and TABLE_NAME are replaced by a zero-length string. iii) If the values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME identify a
for some table T and if no privileges for T are granted to the current , then the values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are replaced by a zero-length string. iv) If the values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME identify an assertion contained in some schema S and if the owner of S is not the of the current SQL-session, then the values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are replaced by a zero-length string. Diagnostics management 487 X3H2-92-154/DBL CBR-002 18.1 k) The value of MESSAGE_TEXT is an implementation-defined char- acter string. Note: An implementation may set this to s, to a zero- length string, or to a character string describing the condi- tion indicated by RETURNED_SQLSTATE. l) The value of MESSAGE_LENGTH is the length in characters of the character string value in MESSAGE_TEXT. m) The value of MESSAGE_OCTET_LENGTH is the length in octets of the character string value in MESSAGE_TEXT. n) The values of CONNECTION_NAME and SERVER_NAME are Case: i) If COMMAND_FUNCTION or DYNAMIC_FUNCTION identifies an , then the explicit or implicit and the associated , respectively, referenced by the . ii) Otherwise, the explicit or implicit and the associated , respectively, corre- sponding to the most-recently executed explicit or implicit or . o) The values of character string items where not otherwise specified by the preceding rules are set to a zero-length string. Note: There are no numeric items that are not set by these rules. Leveling Rules 1) The following restrictions apply for Intermediate SQL; None. 2) The following restrictions apply for Entry SQL; a) Conforming Entry SQL language shall not contain any . 488 Database Language SQL X3H2-92-154/DBL CBR-002 19 Embedded SQL 19.1 Function Specify an . Format ::= | | | | | | ::= [ ] ::= | | | | ::= EXEC SQL | SQL ::= END-EXEC | | ::= [ ] [ ... ] | ::= Embedded SQL 489 X3H2-92-154/DBL CBR-002 19.1 SQL NAMES ARE ::= BEGIN DECLARE SECTION [ ] ::= END DECLARE SECTION [ ] ::= BEGIN DECLARE SECTION [ ] [ ... ] END DECLARE SECTION ::= | | | | | | ::= ::= | | | | | | Syntax Rules 1) An is a compilation unit that con- sists of programming language text and SQL text. The programming language text shall conform to the requirements of a specific standard programming language. The SQL text shall consist of one or more s and, optionally, one or more s, as defined in this International Standard. Note: Compilation unit is defined in Subclause 4.16, "Modules". 2) Case: a) An or that is contained in an shall 490 Database Language SQL X3H2-92-154/DBL CBR-002 19.1 contain an that is "SQL". There shall be no between the and "SQL" nor between "SQL" and the . b) An , , or that is not contained in an shall contain an that is "EXEC SQL". 3) Case: a) An , , or contained in an shall contain an that is END-EXEC. b) An , , or contained in an shall not contain an . c) An , , or contained in an , , , or shall contain an that is a . d) An or that is contained in an shall contain an that is a . 4) Case: a) An that is contained in an shall be an . b) An that is not contained in an shall not be an . Note: There is no restriction on the number of s that may be contained in an . 5) The s comprising an , , or shall be separated by characters and shall be specified on one line. Otherwise, the rules for the continuation of lines and tokens from one line to the next and for the placement of host language comments are those of the programming language of the containing . Embedded SQL 491 X3H2-92-154/DBL CBR-002 19.1 6) If an is not specified, then an that specifies an implementation-defined character set that contains at least every character that is in is implicit. 7) A that is contained in an shall precede in the text of that any SQL-statement or that references the
of the . 8) A that is contained in an shall precede in the text of that any SQL-statement that references the of the . 9) A that is contained in an shall precede in the text of that any SQL-statement that references the of the . 10)Any that is contained in an in an shall be defined in exactly one contained in that . In programming languages that support s in subprograms, two s with different, non-overlapping scope in the host language are to be regarded as defining different host vari- ables, even if they specify the same variable name. That shall appear in the text of the prior to any that references the . The shall be such that a host language reference to the is valid at every that contains the . 11)A defines the host language data type of the . For every such host language data type an equivalent SQL is specified in Subclause 19.3, "", Subclause 19.4, "", Subclause 19.5, "", Subclause 19.6, "", Subclause 19.7, "", Subclause 19.8, "", and Subclause 19.9, "". 12)If one or more s that specify SQLSTATE or SQLCODE appear in an , then the s shall be such that a host language reference to SQLSTATE or SQLCODE, respectively, is valid at every , including s that appear in any subprograms contained in that . No shall precede 492 Database Language SQL X3H2-92-154/DBL CBR-002 19.1 any of its applicable status code definitions in the text of the main program or subprograms that comprise the . 13)Given an H, there is an implied standard-conforming SQL M and an implied standard- conforming host program P derived from H. The derivation of the implied program P and the implied M of an H effectively precedes the processing of any host language program text manipulation commands such as inclusion or copying of text. Given an H with an implied M and an implied program P defined as above: a) The implied M of H shall be a standard-conforming SQL . b) If H is an , an , an , an , an , an , or an , then the implied program P shall be a standard-conforming Ada program, a standard-conforming C program, a standard- conforming COBOL program, a standard-conforming Fortran program, a standard-conforming MUMPS program, a standard- conforming Pascal program, or standard-conforming PL/I pro- gram, respectively. 14)M is derived from H as follows: a) M contains a whose is either implementation-dependent or is omitted. b) M contains a that is identical to the explicit or implicit with the keyword "SQL" removed. c) M contains a that specifies either ADA, C, COBOL, FORTRAN, MUMPS, PASCAL, or PLI, where H is re- spectively an , an , an , an , an , an , or an . d) M contains a that specifies SCHEMA , where the value of is implementation-dependent. e) For every EC contained in H, M contains one PC and one PS that contains an that references PC. The of PS is implementation-dependent. PC is a copy of EC in which each distinct has been replaced with Embedded SQL 493 X3H2-92-154/DBL CBR-002 19.1 a distinct implementation-dependent . PS con- tains a for each contained in PC. The that corresponds to a given V that is contained in EC specifies the with which V was replaced, and the SQL data type that corresponds to the host language data type of V. If H contains a that specifies SQLSTATE or SQLCODE, then PS contains a that specifies SQLSTATE or SQLCODE, respec- tively. If H contains neither a that specifies SQLSTATE nor a that specifies SQLCODE, then PS contains a that specifies SQLCODE. The order of s in PS is implementation-dependent. f) For every EC in H, M contains one PC that is a copy of EC. g) M contains one for each contained in H. Each of M is a copy of the corresponding of H. h) M contains a for each contained in H. The PS of M corresponding with an ES of H is defined as follows: Case: i) If ES is not an , then: 1) The of PS is implementation-dependent. 2) The of PS is a copy of ES in which each distinct has been replaced with the same distinct implementation-dependent . 3) PS contains a for each dis- tinct contained in the of PS. 4) The corresponding to a given V that is contained in ES spec- ifies the with which V was replaced and the SQL that corresponds to the host language data type of V. 5) Whether one of M can correspond to more than one of H is implementation- dependent. 494 Database Language SQL X3H2-92-154/DBL CBR-002 19.1 6) If H contains a that spec- ifies SQLSTATE or SQLCODE, then PS contains a that specifies SQLSTATE or SQLCODE, respectively. If H contains neither a that specifies SQLSTATE nor a that specifies SQLCODE, then PS contains a that specifies SQLCODE. 7) The order of the s is implementation- dependent. ii) If ES is an , then: 1) Let EC be the in H referenced by ES. 2) PS is the procedure in M that contains an that references the in M corre- sponding to EC. 15)P is derived from H as follows: a) Each , , and has been deleted. If the embedded host language is MUMPS, then each has been deleted. b) Each in an has been replaced by a valid data definition in the target host language according to the Syntax Rules specified in an , , , , , or an clause. c) Each that contains a , a , or a has been deleted, and every that contains an has been replaced with statements of the host language that will have the effect specified by the General Rules of Subclause 19.2, "". d) Each that contains an has been replaced by host language statements that perform the following actions: i) A host language procedure or subroutine call of the of the implied M of H that corresponds with the . If the is not an , then the arguments of the call include each distinct contained in the together with the SQLCODE , or the Embedded SQL 495 X3H2-92-154/DBL CBR-002 19.1 SQLSTATE , or both. If H contains nei- ther a that specifies SQLSTATE nor a that specifies SQLCODE, then the arguments of the call include SQLCODE. If the is an , then the arguments of the call include each distinct contained in the corresponding of H together with the SQLCODE , or the SQLSTATE , or both. If H contains neither a that specifies SQLSTATE nor a that specifies SQLCODE, then the arguments of the call include SQLCODE. The order of the arguments in the call corresponds with the order of the corresponding s in the corresponding . Note: In an , the "SQLCODE" variable is abbreviated to "SQLCOD" and the "SQLSTATE" variable may be abbreviated to "SQLSTA". See the Syntax Rules of Subclause 19.6, "". ii) Exception actions, as specified in Subclause 19.2, "". Note: SQLSTATE is the preferred status parameter. The SQLCODE sta- tus parameter is a deprecated feature that is supported for compat- ibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) The interpretation of an H is de- fined to be equivalent to the interpretation of the implied program P of H and the implied M of H. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) An shall not contain an . b) No two s shall specify the same variable name. 496 Database Language SQL X3H2-92-154/DBL CBR-002 19.2 19.2 Function Specify the action to be taken when an SQL-statement causes a spe- cific class of condition to be raised. Format ::= WHENEVER ::= SQLERROR | NOT FOUND ::= CONTINUE | ::= { GOTO | GO TO } ::= | | ::= !!See the Syntax Rules. ::= !!See the Syntax Rules. Syntax Rules 1) An contained in an applies to an contained in that if and only if the appears after the in the text sequence of the and no other that specifies the same appears between the and the in the text sequence of the . 2) If an specifies a , then the , , or of the shall be such that a host lan- guage GO TO statement specifying that , , or is valid at every to which the applies. Embedded SQL 497 X3H2-92-154/DBL CBR-002 19.2 Note: - If an is contained in an , then the of a should specify a that is a label_ name in the containing . - If an is contained in an , then the of a should specify a that is a label in the containing . - If an is contained in an , then the of a should specify a that is a section-name or an unqualified paragraph-name in the contain- ing . - If an is contained in an , then the of a should be an that is the statement label of an executable statement that appears in the same program unit as the . - If an is contained in an , then the of a should be a gotoargument that is the statement label of an executable statement that appears in the same . - If an is contained in an , then the of a should be an that is a label. - If an is contained in an , then the of a should specify either a or a . Case: o If is specified, then the should be a label constant in the con- taining . o If is specified, then the should be a PL/I label variable de- clared in the containing . Access Rules None. 498 Database Language SQL X3H2-92-154/DBL CBR-002 19.2 General Rules 1) Immediately after the execution of an in an : Case: a) If the value of the status variable(s) indicates the comple- tion condition no data and the contains an that applies to the and whose is NOT FOUND and whose is a , then a GO TO statement of the host language is performed, specifying the , , or of the . b) If the value of the status variable(s) indicates an excep- tion condition and the contains an that applies to the and whose is SQLERROR and whose is a , then a GO TO state- ment of the host language is performed, specifying the , , or of the . c) If the contains no that applies to the , or if it contains an that applies to the and that specifies CONTINUE, then no further action is performed for the . Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Embedded SQL 499 X3H2-92-154/DBL CBR-002 19.3 19.3 Function Specify an . Format ::= !! See the Syntax Rules. ::= [ { }... ] : [ ] ::= ... ::= ::= !! See the Syntax Rules. ::= | ::= SQL_STANDARD.CHAR [ CHARACTER SET [ IS ] ] 1 | SQL_STANDARD.BIT 1 | SQL_STANDARD.SMALLINT | SQL_STANDARD.INT | SQL_STANDARD.REAL | SQL_STANDARD.DOUBLE_PRECISION | SQL_STANDARD.SQLCODE_TYPE | SQL_STANDARD.SQLSTATE_TYPE | SQL_STANDARD.INDICATOR_TYPE ::= CHAR 1 | BIT 1 | SMALLINT | INT | REAL | DOUBLE_PRECISION | SQLCODE_TYPE | SQLSTATE_TYPE | INDICATOR_TYPE 500 Database Language SQL X3H2-92-154/DBL CBR-002 19.3 Syntax Rules 1) An is a compilation unit that con- sists of Ada text and SQL text. The Ada text shall conform to the Ada standard ISO/IEC 8652. The SQL text shall consist of one or more s and, optionally, one or more s. 2) An may be specified wherever an Ada statement may be specified. An may be prefixed by an Ada label. 3) An is any valid Ada identifier. An shall be contained in an . 4) An defines one or more host variables. 5) An shall be modified as follows before it is placed into the program derived from the (see the Syntax Rules of Subclause 19.1, ""): a) Any optional CHARACTER SET specification shall be removed from an . b) The specified in a CHAR declaration of any that contains a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . The modified shall be a valid Ada object-declaration in the program derived from the . 6) An shall be specified within the scope of Ada with and use clauses that specify the following: with SQL_STANDARD; use SQL_STANDARD; use SQL_STANDARD.CHARACTER_SET; 7) The sequence in an specifies an initial value to be assigned to the Ada variable. It shall be a valid Ada specification of an initial value. 8) CHAR describes a character string variable whose equivalent SQL data type is CHARACTER with the same length and character set specified by . If is not specified, then an implementation-defined is implicit. Embedded SQL 501 X3H2-92-154/DBL CBR-002 19.3 9) BIT describes a bit string variable. The equivalent SQL data type is BIT with the same length. 10)INT and SMALLINT describe exact numeric variables. The equiv- alent SQL data types are INTEGER and SMALLINT, respectively. 11)REAL and DOUBLE_PRECISION describe approximate numeric vari- ables. The equivalent SQL data types are REAL and DOUBLE PRECISION, respectively. 12)SQLCODE_TYPE describes an exact numeric variable whose preci- sion is the implementation-defined precision defined for the SQLCODE parameter. SQLSTATE_TYPE describes a character string variable whose length is the length of the SQLSTATE parameter (five characters). 13)INDICATOR_TYPE describes an exact numeric variable whose spe- cific data type is any with a scale of 0. 14)If an contains neither an that specifies SQLSTATE and that is de- fined with an that specifies SQL_ STANDARD.CHAR or CHAR with 5, nor an that specifies SQLCODE and that is defined with an that specifies SQL_STANDARD.INTEGER or INTEGER, then it is assumed that the contains a variable named SQLCODE defined with a data type of INTEGER. Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) An shall not specify a bit string variable. 502 Database Language SQL X3H2-92-154/DBL CBR-002 19.3 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) An shall not contain a . Embedded SQL 503 X3H2-92-154/DBL CBR-002 19.4 19.4 Function Specify an . Format ::= !! See the Syntax Rules. ::= [ ] [ ] ::= | | ::= auto | extern | static ::= const | volatile ::= { long | short | float | double } [ ] [ { [ ] }... ] ::= char [ CHARACTER SET [ IS ] ] [ ] [ { [ ] }... ] ::= ::= !! See the Syntax Rules. ::= | ::= VARCHAR [ CHARACTER SET [ IS ] ] 504 Database Language SQL X3H2-92-154/DBL CBR-002 19.4 [ ] [ { [ ] }... ] ::= BIT [ ] [ { [ ] }... ] ::= ... Syntax Rules 1) An is a compilation unit that consists of C text and SQL text. The C text shall conform to the C stan- dard ISO/IEC 9899. The SQL text shall consist of one or more s and, optionally, one or more s. 2) An may be specified wherever a C statement may be specified within a function block. If the C statement could include a label prefix, then the may be immediately preceded by a label prefix. 3) A is any valid C variable identifier. A shall be contained in an . 4) A defines one or more host variables. 5) A shall be modified as follows before it is placed into the program derived from the (see the Syntax Rules of Subclause 19.1, ""): a) Any optional CHARACTER SET specification shall be removed from a or a . b) The syntax "VARCHAR" shall be replaced by "char" in any . c) The syntax "BIT" shall be replaced by "char" in any . d) The specified in a in any shall be replaced by a length equal to the smallest integer not less than L/B, as defined in the Syntax Rules of this Subclause. Embedded SQL 505 X3H2-92-154/DBL CBR-002 19.4 e) The specified in a in any or in any that contained a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . The modified shall be a valid C data declaration in the program derived from the . 6) The sequence contained in a specifies an initial value to be assigned to the C variable. It shall be a valid C specification of an initial value. 7) Except for array specifications for character strings and bit strings, a shall specify a scalar type. 8) In a , the words "VARCHAR", "CHARACTER", "SET", "IS", "BIT", and "VARYING" may be specified in any com- bination of upper case and lower case letters (see the Syntax Rules of Subclause 5.2, " and "). 9) In a or a , if a is specified, then the equivalent SQL data type is CHARACTER or CHARACTER VARYING whose charac- ter repertoire is the same as the repertoire specified by the . If is not specified, then an implementation-defined is implicit. 10)Each specified in a describes a fixed-length character string. The length is speci- fied by the of the . The value in the host variable is terminated by a null character and the position occupied by this null character is included in the length of the host variable. The equivalent SQL data type is CHARACTER whose length is one less than the of the and whose value does not include the terminating null character. The shall be greater than 1. 11)Each specified in a describes a variable-length character string. The maximum length is specified by the of the . The value in the host variable is terminated by a null character and the position occupied by this null character is included in the maximum length of the host variable. The equivalent SQL data type is CHARACTER VARYING whose maximum length is 1 less than the of the and whose value does not include the terminating null character. The shall be greater than 1. 506 Database Language SQL X3H2-92-154/DBL CBR-002 19.4 12)Each specified in a de- scribes a fixed-length bit string. The value in the host vari- able has a BIT_LENGTH of . Let B be the number of bits in a C char and let L be the of the . The length of an equivalent C char variable is the smallest integer that is not less than the result of L/B. The equivalent SQL data type is BIT whose length is L. 13)"long" describes an exact numeric variable. The equivalent SQL data type is INTEGER. 14)"short" describes an exact numeric variable. The equivalent SQL data type is SMALLINT. 15)"float" describes an approximate numeric variable. The equiva- lent SQL data type is REAL. 16)"double" describes an approximate numeric variable. The equiva- lent SQL data type is DOUBLE PRECISION. 17)If an contains neither a that specifies SQLSTATE and that is defined with a that specifies "char" with a that is 6, nor a that specifies SQLCODE and that is defined with a that specifies "long", then it is assumed that the contains a variable named SQLCODE defined with a data type of "long". Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not be a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not be a . b) A shall not contain a . Embedded SQL 507 X3H2-92-154/DBL CBR-002 19.5 19.5 Function Specify an . Format ::= !! See the Syntax Rules. ::= {01|77} [ ... ] ::= !! See the Syntax Rules. ::= | | | ::= [ CHARACTER SET [ IS ] ] { PIC | PICTURE } [ IS ] { X [ ] }... ::= { PIC | PICTURE } [ IS ] { B [ ] }... ::= { PIC | PICTURE } [ IS ] S [ USAGE [ IS ] ] DISPLAY SIGN LEADING SEPARATE ::= [ V [ ] ] | V ::= | ::= { PIC | PICTURE } [ IS ] S [ USAGE [ IS ] ] { COMP | COMPUTATIONAL } ::= { PIC | PICTURE } [ IS ] S [ USAGE [ IS ] ] BINARY ::= { 9 [ ] }... 508 Database Language SQL X3H2-92-154/DBL CBR-002 19.5 Syntax Rules 1) An is a compilation unit that con- sists of COBOL text and SQL text. The COBOL text shall conform to the COBOL standard ISO 1989. The SQL text shall consist of one or more s and, optionally, one or more s. 2) An in an may be specified wherever a COBOL statement may be specified in the Procedure Division of the . If the COBOL statement could be immediately preceded by a paragraph-name, then the may be immediately preceded by a paragraph-name. 3) A is any valid COBOL data-name. A shall be contained in an . 4) A is a restricted form of COBOL data description entry that defines a host variable. 5) A shall be modified as follows be- fore it is placed into the program derived from the (see the Syntax Rules of Subclause 19.1, "". a) Any optional CHARACTER SET specification shall be removed from a . b) The syntax "B" shall be replaced by "X" in any . c) The specified in any shall be re- placed by a length equal to the smallest integer not less than L/B, as defined in the Syntax Rules of this Subclause. d) The specified in any that contained a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . The modified shall be a valid data description entry in the Data Division of the program derived from the . 6) The optional sequence in a may specify a VALUE clause. Whether other clauses may be specified is implementation-defined. The sequence shall be such that the is a valid COBOL data description entry. Embedded SQL 509 X3H2-92-154/DBL CBR-002 19.5 7) A describes a character string vari- able whose equivalent SQL data type is CHARACTER with the same length and character set specified by . If is not specified, then an implementation-defined is implicit. 8) A describes a bit string variable. Let B be the number of bits in a COBOL character and let L be the of the . The length of an equivalent COBOL char- acter variable is the smallest integer not less than L/B. The equivalent SQL data type is BIT whose length is the of the . 9) A describes an exact numeric variable. The equivalent SQL data type is NUMERIC of the same precision and scale. 10)A describes an exact numeric vari- able. Note: This is supported only for SQLCODE for compatibility with earlier versions of this International Standard. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". 11)A describes an exact numeric variable. The equivalent SQL data type is SMALLINT or INTEGER. 12)If an contains neither a that specifies SQLSTATE and that is defined with a that specifies {01|77} SQLSTATE PICTURE X(5) nor a that specifies SQLCODE and that is defined with a that specifies {01|77} SQLCODE PICTURE S9(PC) USAGE COMP where PC is the implementation-defined precision specified for a COBOL SQLCODE parameter in Subclause 12.4, "Calls to a ", then it is assumed that the contains a variable named SQLCODE defined with a data type of {01|77} SQLCODE PICTURE S9(PC) USAGE COMP where PC is the implementation-defined precision specified for a COBOL SQLCODE parameter in Subclause 12.4, "Calls to a ". Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". 510 Database Language SQL X3H2-92-154/DBL CBR-002 19.5 Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not be a . 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not contain a . Embedded SQL 511 X3H2-92-154/DBL CBR-002 19.6 19.6 Function Specify an . Format ::= !! See the Syntax Rules. ::= [ { }... ] ::= !! See the Syntax Rules. ::= CHARACTER [ ] [ CHARACTER SET [ IS ] ] | BIT [ ] | INTEGER | REAL | DOUBLE PRECISION Syntax Rules 1) An is a compilation unit that consists of Fortran text and SQL text. The Fortran text shall conform to the Fortran standard ISO/IEC 1539. The SQL text shall consist of one or more s and, option- ally, one or more s. 2) An may be specified wherever an exe- cutable Fortran statement may be specified. An that precedes any executable Fortran statement in the containing shall not have a Fortran statement number. Otherwise, if the Fortran statement could have a statement number then the can have a statement number. 3) Blanks are significant in s. The rules for s in an are as specified in Subclause 5.2, " and ". 4) A is any valid Fortran variable name with all characters removed. A shall be contained in an . 5) A is a restricted form of Fortran type-statement that defines one or more host variables. 512 Database Language SQL X3H2-92-154/DBL CBR-002 19.6 6) A shall be modified as follows before it is placed into the program derived from the (see the Syntax Rules Subclause 19.1, "". a) Any optional CHARACTER SET specification shall be removed from the CHARACTER alternative in a . b) The specified in the CHARACTER alternative of any that contained a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . c) The syntax "BIT" shall be replaced by "CHARACTER" in any BIT alternative of a . d) The specified in any BIT alternative of a shall be replaced by a length equal to the smallest integer not less than L/B, as defined in the Syntax Rules of this Subclause. The modified shall be a valid Fortran type-statement in the program derived from the . 7) CHARACTER describes a character string variable whose equivalent SQL data type is CHARACTER with the same length and character set specified by . If is not specified, then an implementation- defined is implicit. 8) BIT describes a bit string variable. Let B be the number of bits in a Fortran CHARACTER and let L be the of the bit string variable. The length of an equivalent Fortran character variable is the smallest integer not less than L/B. The equiv- alent SQL data type is BIT whose length is the of the bit string variable. 9) INTEGER describes an exact numeric variable. The equivalent SQL data type is INTEGER. 10)REAL describes an approximate numeric variable. The equivalent SQL data type is REAL. 11)DOUBLE PRECISION describes an approximate numeric variable. The equivalent SQL data type is DOUBLE PRECISION. 12)If an contains neither a that specifies SQLSTATE or SQLSTA and that is defined with a that specifies CHARACTER with 5, nor a that specifies SQLCOD and that is defined with a specification> that specifies INTEGER, then it is assumed that the contains a variable named SQLCOD defined with a data type of INTEGER. Note: SQLSTATE (which may be abbreviated "SQLSTA") is the pre- ferred status parameter. The SQLCODE (SQLCOD) status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not specify BIT. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not contain a . 514 Database Language SQL X3H2-92-154/DBL CBR-002 19.7 19.7 Function Specify an . Format ::= !! See the Syntax Rules. ::= { | } ::= VARCHAR [ { }... ] ::= !! See the Syntax Rules. ::= ::= [ { }... ] ::= INT | DEC [ [ ] ] | REAL Syntax Rules 1) An is a compilation unit that con- sists of MUMPS text and SQL text. The MUMPS text shall conform to the MUMPS standard ISO/IEC 11756. The SQL text shall consist of one or more s and, optionally, one or more s. 2) A is any valid MUMPS variable name. A shall be contained in an . 3) An may be specified wherever a MUMPS command may be specified. 4) A defines one or more host vari- ables. Embedded SQL 515 X3H2-92-154/DBL CBR-002 19.7 5) The describes a variable-length char- acter string. The equivalent SQL data type is CHARACTER VARYING whose maximum length is the of the and whose character set is implementation-defined. 6) INT describes an exact numeric variable. The equivalent SQL data type is INTEGER. 7) DEC describes an exact numeric variable. The shall not be greater than the . The equivalent SQL data type is DECIMAL with the same and . 8) REAL describes an approximate numeric variable. The equivalent SQL data type is REAL. 9) If an contains neither a that specifies SQLSTATE and that is defined with a that specifies VARCHAR with a that specifies 5, nor a that specifies SQLCODE and that is defined with a that specifies INT, then it is assumed that the contains a variable named SQLCODE defined with a data type of INT. Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall contain no . 516 Database Language SQL X3H2-92-154/DBL CBR-002 19.8 19.8 Function Specify an . Format ::= !! See the Syntax Rules. ::= [ { }... ] ::= !! See the Syntax Rules. ::= PACKED ARRAY 1 OF CHAR [ CHARACTER SET [ IS ] ] | PACKED ARRAY 1 OF BIT | INTEGER | REAL | CHAR [ CHARACTER SET [ IS ] ] | BIT Syntax Rules 1) An is a compilation unit that consists of Pascal text and SQL text. The Pascal text shall conform to one of the Pascal standards ISO 7185 and ISO/IEC 10206. The SQL text shall consist of one or more s and, optionally, one or more s. 2) An may be specified wherever a Pascal statement may be specified. An may be prefixed by a Pascal label. 3) A is a Pascal variable-identifier whose applied instance denotes a defining instance within an and an . 4) A defines one or more s. Embedded SQL 517 X3H2-92-154/DBL CBR-002 19.8 5) A shall be modified as follows before it is placed into the program derived from the (see the Syntax Rules of Subclause 19.1, ""). a) Any optional CHARACTER SET specification shall be removed from the PACKED ARRAY OF CHAR or CHAR alternatives of a . b) The specified in the PACKED ARRAY OF CHAR alter- native of any that contained a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . c) If any specifies the syntax "CHAR" and contains a CHARACTER SET specification, then let L be a length equal to the length in octets of PN and PN be the specified in the containing . If L is greater than 1, then "CHAR" shall be replaced by "PACKED ARRAY [1..L] OF CHAR". d) The syntax "BIT" shall be replaced by "CHAR" in any PACKED ARRAY OF BIT or BIT alternatives of a . e) The specified in any PACKED ARRAY OF BIT alterna- tive in a shall be replaced by a length equal to the smallest integer not less than L/B, as defined in the Syntax Rules of this Subclause. The modified shall be a valid Pascal variable-declaration in the program derived from the . 6) CHAR specified without a CHARACTER SET specification is the ordinal-type-identifier of PASCAL. The equivalent SQL data type is CHARACTER with length 1. 7) BIT describes a single-bit variable. It is mapped to a Pascal CHAR ordinal-type-identifier whose most significant bit contains either 0 or 1 and whose least significant bits contain 0. The equivalent SQL data type is BIT with length 1. 8) PACKED ARRAY [1..] OF CHAR describes a character string having 2 or more components of the simple type CHAR. The equiva- lent SQL data type is CHARACTER with the same length and charac- ter set specified by . If is not specified, then an implementation- defined is implicit. 518 Database Language SQL X3H2-92-154/DBL CBR-002 19.8 9) PACKED ARRAY [1..] OF BIT describes a bit string vari- able. Let B be the number of bits in a Pascal CHAR and let L be the of the bit string variable. The length of an equiv- alent Pascal character variable is the smallest integer not less than L/B. The equivalent SQL data type is BIT whose length is the of the bit string variable. 10)INTEGER describes an exact numeric variable. The equivalent SQL data type is INTEGER. 11)REAL describes an approximate numeric variable. The equivalent SQL data type is REAL. 12)If an contains neither a that specifies SQLSTATE and that is defined with a that specifies PACKED ARRAY [1..] OF CHAR with 5, nor a that specifies SQLCODE and that is defined with a that specifies INTEGER, then it is assumed that the contains a variable named SQLCODE defined with a data type of INTEGER. Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. General Rules 1) See Subclause 19.1, "". Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not specify BIT or PACKED ARRAY [1..] OF BIT. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not contain a . Embedded SQL 519 X3H2-92-154/DBL CBR-002 19.9 19.9 Function Specify an . Format ::= !! See the Syntax Rules. ::= {DCL | DECLARE} { | [ { }... ] } [ ... ] ::= !! See the Syntax Rules. ::= { CHAR | CHARACTER } [ VARYING ] [ CHARACTER SET [ IS ] ] | BIT [ VARYING ] | [ ] | [ ] | ::= { DEC | DECIMAL } FIXED | FIXED { DEC | DECIMAL } ::= { BIN | BINARY } FIXED | FIXED { BIN | BINARY } ::= { BIN | BINARY } FLOAT | FLOAT { BIN | BINARY } 520 Database Language SQL X3H2-92-154/DBL CBR-002 19.9 Syntax Rules 1) An is a compilation unit that con- sists of PL/I text and SQL text. The PL/I text shall conform to the PL/I standard ISO 6160. The SQL text shall consist of one or more s and, optionally, one or more s. 2) An may be specified wherever a PL/I statement may be specified within a procedure block. If the PL/I statement could include a label prefix, the may be immediately preceded by a label prefix. 3) A is any valid PL/I variable identifier. A shall be contained in an . 4) A defines one or more host variables. 5) A shall be modified as follows before it is placed into the program derived from the (see the Syntax Rules of Subclause 19.1, ""). a) Any optional CHARACTER SET specification shall be removed from the CHARACTER or CHARACTER VARYING alternatives of a . b) The specified in the CHARACTER or CHARACTER VARYING alternatives of any that contains a CHARACTER SET specification shall be replaced by a length equal to the length in octets of PN, where PN is the specified in the containing . The modified shall be a valid PL/I data declaration in the program derived from the . 6) A shall specify a scalar variable, not an array or structure. 7) The optional sequence in a may specify an INITIAL clause. Whether other clauses may be specified is implementation-defined. The sequence shall be such that the is a valid PL/I DECLARE statement. 8) CHARACTER describes a character string variable whose equiva- lent SQL data type has the character set specified by . If is not specified, then an implementation-defined is implicit. Embedded SQL 521 X3H2-92-154/DBL CBR-002 19.9 Case: a) If VARYING is not specified, the length of the variable is fixed. The equivalent SQL data type is CHARACTER with the same length. b) If VARYING is specified, the variable is of variable length, with maximum size the value of . The equivalent SQL data type is CHARACTER VARYING with the same maximum length. 9) BIT describes a bit string variable. Case: a) If VARYING is not specified, then the length of the variable is fixed. The equivalent SQL data type is BIT with the same length. b) If VARYING is specified, then the variable is of variable length with maximum size of the value of . The equiv- alent SQL data type is BIT VARYING with the same maximum length. 10)FIXED DECIMAL describes an exact numeric variable. The shall not be greater than the . The equivalent SQL data type is DECIMAL with the same and . 11)FIXED BINARY describes an exact numeric variable. The equivalent SQL data type is SMALLINT or INTEGER. 12)FLOAT BINARY describes an approximate numeric variable. The equivalent SQL data type is FLOAT with the same . 13)If an contains neither a that specifies SQLSTATE and that is de- fined with a that specifies CHAR or CHARACTER with 5 and does not specify VARYING, nor a that specifies SQLCODE and that is defined with a that specifies FIXED BIN(PP) or FIXED BINARY(PP), where PP is the implementation- defined precision specified for a PL/I SQLCODE parameter in Subclause 12.4, "Calls to a ", then it is assumed that the contains a variable named SQLCODE defined with a data type of FIXED BINARY(PP), where PP is the implementation-defined precision specified for a PL/I SQLCODE parameter in Subclause 12.4, "Calls to a ". Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features". Access Rules None. 522 Database Language SQL X3H2-92-154/DBL CBR-002 19.9 General Rules 1) See Subclause 19.1, "" Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) A shall not specify BIT or BIT VARYING. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not specify CHARACTER VARYING. b) A shall not contain a . Embedded SQL 523 X3H2-92-154/DBL CBR-002 524 Database Language SQL X3H2-92-154/DBL CBR-002 20 Direct invocation of SQL 20.1 Function Specify direct execution of SQL. Format ::= ::= | | | | | ::= | | | | ::= !!See the Syntax Rules Syntax Rules 1) The shall not contain any , , or . 2) The that represents the null value is implementation-defined. 3) The Format and Syntax Rules for are implementation-defined. Access Rules 1) The Access Rules for are implementation-defined. Direct invocation of SQL 525 X3H2-92-154/DBL CBR-002 20.1 General Rules 1) The following s are transaction-initiating s: a) s that are transaction-initiating s; b) ; and c) s that are transaction- initiating. 2) After the last invocation of an SQL-statement by an SQL-agent in an SQL-session: a) A or a is effectively executed. If an unrecoverable error has occurred, or if the direct invocation of SQL terminated unexpectedly, or if any constraint is not satisfied, then a is performed. Otherwise, the choice of which of these SQL- statements to perform is implementation-dependent. The deter- mination of whether a direct invocation of SQL has terminated unexpectedly is implementation-dependent. b) Let D be the of any system descriptor area that is currently allocated within the current SQL-session. A that specifies DEALLOCATE DESCRIPTOR D is effectively executed. c) All SQL-sessions associated with the SQL-agent are termi- nated. 3) Let S be the . 4) The current for privilege determi- nation for the execution of S is the SQL-session . 5) If S does not conform to the Format, Syntax Rules, and Access Rules for a , then an exception condition is raised: syntax error or access rule violation in direct SQL statement. 6) When S is invoked by the SQL-agent: Case: a) If S is an , then: i) The diagnostics area is emptied. ii) S is executed. 526 Database Language SQL X3H2-92-154/DBL CBR-002 20.1 iii) If S successfully initiated or resumed an SQL-session, then subsequent invocations of a by the SQL-agent are associated with that SQL-session until the SQL-agent terminates the SQL-session or makes it dormant. b) Otherwise: i) If no SQL-session is current for the SQL-agent, then Case: 1) If the SQL-agent has not executed an and there is no default SQL-session asso- ciated with the SQL-agent, then the following is effectively executed: CONNECT TO DEFAULT 2) If the SQL-agent has not executed an and there is a default SQL-session associated with the SQL-agent, then the following is effectively executed: SET CONNECTION DEFAULT 3) Otherwise, an exception condition is raised: connection exception-connection does not exist. Subsequent calls to a or invocations of a by the SQL-agent are associated with the SQL-session until the SQL-agent terminates the SQL- session or makes it dormant. ii) If an SQL-transaction is active for the SQL-agent, then S is associated with that SQL-transaction. If S is a , then it is implementation-defined whether or not S may be associated with an active SQL-transaction; if not, then an exception condition is raised: invalid transaction state. iii) If no SQL-transaction is active for the SQL-agent, then 1) Case: A) If S is a transaction-initiating , then an SQL-transaction is initiated. B) If S is a , then it is implementation-defined whether or not S initiates an SQL-transaction. If an implementation defines S to be transaction-initiating, then an SQL- transaction is initiated. 2) If S initiated an SQL-transaction, then: A) Let T be the SQL-transaction initiated by S. Direct invocation of SQL 527 X3H2-92-154/DBL CBR-002 20.1 B) T is associated with this invocation and any subse- quent invocations of s or calls to a by the SQL-agent until the SQL-agent terminates T. C) Case: I) If a has been executed since the termination of the last SQL-transaction in the SQL-session (or if there has been no previ- ous SQL-transaction in the SQL-session and a has been executed), then the access mode, constraint mode, and isolation level of T are set as specified by the . II) Otherwise, the access mode, constraint mode for all constraints, and isolation level for T are read- write, immediate, and SERIALIZABLE, respectively. D) T is associated with the SQL-session. iv) If S contains an and the access mode of the current SQL-transaction is read-only, then an exception condition is raised: invalid transaction state. v) The diagnostics area is emptied. vi) S is executed. 7) If the execution of a occurs within the same SQL-transaction as the execution of an SQL-schema statement and this is not allowed by the SQL-implementation, then an exception condition is raised: invalid transaction state. 8) Case: a) If S executed successfully, then either a completion condi- tion is raised: successful execution, or a completion condi- tion is raised: warning, or a completion condition is raised: no data, as determined by the General Rules in this and other Subclauses of this International Standard. b) If S did not execute successfully, then all changes made to SQL-data or schemas by the execution of S are canceled and an exception condition is raised as determined by the General Rules in this and other Subclauses of this International Standard. Note: The method of raising a condition is implementation- defined. 528 Database Language SQL X3H2-92-154/DBL CBR-002 20.1 9) Diagnostics information resulting from the execution of S is placed into the diagnostics area as specified in Clause 18, "Diagnostics management". Note: The method of accessing the diagnostics information is implementation-defined, but does not alter the contents of the diagnostics area. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not be an . Direct invocation of SQL 529 X3H2-92-154/DBL CBR-002 20.2 20.2 Function Specify a statement to retrieve multiple rows from a specified table. Format ::= [ ] Syntax Rules 1) All Syntax Rules of Subclause 7.10, "", apply to the . 2) The or of a shall not contain any other than a , CURRENT_USER, SESSION_USER, or SYSTEM_USER. 3) Let T be the table specified by the . 4) If ORDER BY is specified, then each in the shall identify a column of T. Case: a) If a contains a , then T shall contain exactly one column with that and the identifies that column. b) If a contains an , then the shall be greater than 0 and not greater than the degree of T. The iden- tifies the column of T with the ordinal position specified by the . Access Rules None. General Rules 1) All General Rules of Subclause 7.10, "", apply to the . 2) Let Q be the result of the . 3) If Q is empty, then a completion condition is raised: no data. 4) If an is not specified, then the ordering of the rows of Q is implementation-dependent. 530 Database Language SQL X3H2-92-154/DBL CBR-002 20.2 5) If an is specified, then the ordering of rows of the result is effectively determined by the as follows: a) Each specifies the sort direction for the corresponding sort key Ki. If ASC is specified or implied in the i-th , then the sort direction for Ki is ascending and the applicable is the . Otherwise, the sort direction for Ki is de- scending and the applicable is the . b) Let X and Y be distinct rows in the result table, and let XVi and YVi be the values of Ki in these rows, respectively. The relative position of rows X and Y in the result is de- termined by comparing XVi and YVi according to the rules of Subclause 8.2, "", where the is the applicable for Ki, with the following spe- cial treatment of null values. Whether a sort key value that is null is considered greater or less than a non-null value is implementation-defined, but all sort key values that are null shall either be considered greater than all non-null values or be considered less than all non-null values. XVi is said to precede YVi if the value of the "XVi YVi" is true for the applicable . c) In the result table, the relative position of row X is before row Y if and only if XVn precedes YVn for some n greater than 0 and less than the number of s and XVi = YVi for all i < n. The relative order of two rows for which XVi = YVi for all i is implementation-dependent. 6) If Q is not empty, then Q is returned. The method of returning Q is implementation-defined. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Direct invocation of SQL 531 X3H2-92-154/DBL CBR-002 532 Database Language SQL X3H2-92-154/DBL CBR-002 21 Information Schema and Definition Schema 21.1 Introduction The views of the Information Schema are defined in terms of base tables. The only purpose of the Definition Schema is to provide a data model to support the Information Schema and to assist under- standing. An implementation need do no more than simulate the exis- tence of the Definition Schema, as viewed through the Information Schema views. The Information Schema views are defined as being in a schema named INFORMATION_SCHEMA, enabling these views to be accessed in the same way as any other tables in any other schema. SELECT on all of these views is granted to PUBLIC WITH GRANT OPTION, so that they can be queried by any user and so that SELECT privilege can be further granted on views that reference these Information Schema views. No other privilege is granted on them, so they cannot be updated. The Information Schema also contains a small number of domains on which the columns of the Definition Schema are based. USAGE on all these domains is granted to PUBLIC WITH GRANT OPTION, so that they can be used by any user. An implementation may define objects that are associated with INFORMATION_SCHEMA that are not defined in this Clause. An im- plementation may also add columns to tables that are defined in this Clause. The base tables are defined as being in a schema named DEFINITION_ SCHEMA. Because s are prohibited from specifying DEFINITION_SCHEMA, the Definition Schema cannot be ac- cessed in an SQL-statement. Note: The Information Schema tables may be supposed to be rep- resented in the Definition Schema in the same way as any other tables, and are hence self-describing. Note: The Information Schema is a definition of the SQL data model, specified as an SQL-schema, in terms of s as defined in this International Standard. Constraints defined in this Clause are not actual SQL constraints. s are represented in the tables of the Information Schema by s corresponding to their s (in the case of s) or their s (in the case of s). Comparison of s is defined in Subclause 8.2, "". Where an has many equivalent forms, the one encountered at definition time is stored (of course, any lower case letters appearing in a will have Information Schema and Definition Schema 533 X3H2-92-154/DBL CBR-002 21.1 Introduction been converted to the corresponding upper case letter before the is stored in any table of the Information Schema). 534 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2 Information Schema 21.2.1 INFORMATION_SCHEMA Schema Function Identify the schema that is to contain the Information Schema ta- bles. Definition CREATE SCHEMA INFORMATION_SCHEMA AUTHORIZATION INFORMATION_SCHEMA Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 535 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.2 INFORMATION_SCHEMA_CATALOG_NAME base table Function Identify the catalog that contains the Information Schema. Definition CREATE TABLE INFORMATION_SCHEMA_CATALOG_NAME ( CATALOG_NAME SQL_IDENTIFIER, CONSTRAINT INFORMATION_SCHEMA_CATALOG_NAME_PRIMARY_KEY PRIMARY KEY ( CATALOG_NAME ) ) Definition 1) The value of CATALOG_NAME is the name of the catalog in which this Information Schema resides. Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 536 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.3 INFORMATION_SCHEMA_CATALOG_NAME_CARDINALITY assertion Function The assertion INFORMATION_SCHEMA_CATALOG_NAME_CARDINALITY ensures that there is exactly one row in the INFORMATION_SCHEMA_CATALOG_ NAME table. Definition CREATE ASSERTION INFORMATION_SCHEMA_CATALOG_NAME_CARDINALITY CHECK ( 1 = ( SELECT COUNT(*) FROM INFORMATION_SCHEMA_CATALOG_NAME ) ) Description 1) The INFORMATION_SCHEMA_CATALOG_NAME_CARDINALITY assertion en- sures that there is exactly one row in the INFORMATION_SCHEMA_ CATALOG_NAME table. Information Schema and Definition Schema 537 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.4 SCHEMATA view Function Identify the schemata that are owned by a given user. Definition CREATE VIEW SCHEMATA AS SELECT CATALOG_NAME, SCHEMA_NAME, SCHEMA_OWNER, DEFAULT_CHARACTER_SET_CATALOG, DEFAULT_CHARACTER_SET_ SCHEMA, DEFAULT_CHARACTER_SET_NAME FROM DEFINITION_SCHEMA.SCHEMATA WHERE SCHEMA_OWNER = CURRENT_USER AND CATALOG_NAME = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 538 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.5 DOMAINS view Function Identify the domains defined in this catalog that are accessible to a given user. Definition CREATE VIEW DOMAINS AS SELECT DISTINCT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_ LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA,COLLATION_NAME, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_ NAME, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, DOMAIN_DEFAULT FROM DEFINITION_SCHEMA.DOMAINS JOIN DEFINITION_SCHEMA.DATA_TYPE_DESCRIPTOR AS D LEFT JOIN DEFINITION_SCHEMA.COLLATIONS AS S USING ( COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) ON ( ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, '' ) = ( TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME ) ) WHERE ( ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, 'DOMAIN' ) IN ( SELECT OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_ NAME, OBJECT_TYPE FROM DEFINITION_SCHEMA.USAGE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) OR ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ) IN ( SELECT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_ NAME FROM COLUMNS ) ) AND DOMAIN_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Information Schema and Definition Schema 539 X3H2-92-154/DBL CBR-002 21.2 Information Schema Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 540 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.6 DOMAIN_CONSTRAINTS view Function Identify the domain constraints of domains in this catalog that are accessible to a given user. Definition CREATE VIEW DOMAIN_CONSTRAINTS AS SELECT DISTINCT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, IS_DEFERRABLE, INITIALLY_DEFERRED FROM DEFINITION_SCHEMA.DOMAIN_CONSTRAINTS JOIN DEFINITION_SCHEMA.SCHEMATA AS S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, SCHEMA_NAME S) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 541 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.7 TABLES view Function Identify the tables defined in this catalog that are accessible to a given user. Definition CREATE VIEW TABLES AS SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE FROM DEFINITION_SCHEMA.TABLES WHERE ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM DEFINITION_SCHEMA.TABLE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) UNION SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM DEFINITION_SCHEMA.COLUMN_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) AND TABLE_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 542 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.8 VIEWS view Function Identify the viewed tables defined in this catalog that are acces- sible to a given user. Definition CREATE VIEW VIEWS AS SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CASE WHEN ( TABLE_CATALOG, TABLE_SCHEMA, CURRENT_USER ) IN ( SELECT CATALOG_NAME, SCHEMA_NAME, SCHEMA_ OWNER FROM DEFINITION_SCHEMA.SCHEMATA ) THEN VIEW_DEFINITION ELSE NULL END AS VIEW_DEFINITION, CHECK_OPTION, IS_UPDATABLE FROM DEFINITION_SCHEMA.VIEWS WHERE ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES ) AND TABLE_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 543 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.9 COLUMNS view Function Identify the columns of tables defined in this catalog that are accessible to a given user. Definition CREATE VIEW COLUMNS AS SELECT DISTINCT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, C.COLUMN_NAME, ORDINAL_POSITION, CASE WHEN EXISTS ( SELECT * FROM DEFINITION_SCHEMA.SCHEMATA AS S WHERE ( TABLE_CATALOG, TABLE_SCHEMA ) = (S.CATALOG_NAME, S.SCHEMA_NAME ) AND SCHEMA_OWNER = USER ) THEN COLUMN_DEFAULT ELSE NULL END AS COLUMN_DEFAULT, IS_NULLABLE, COALESCE (D1.DATA_TYPE, D2.DATA_TYPE) AS DATA_TYPE, COALESCE (D1.CHARACTER_MAXIMUM_LENGTH, D2.CHARACTER_ MAXIMUM_LENGTH) AS CHARACTER_MAXIMUM_LENGTH, COALESCE (D1.CHARACTER_OCTET_LENGTH, D2.CHARACTER_OCTET_ LENGTH) AS CHARACTER_OCTET_LENGTH, COALESCE (D1.NUMERIC_PRECISION, D2.NUMERIC_PRECISION) AS NUMERIC_PRECISION, COALESCE (D1.NUMERIC_PRECISION_RADIX, D2.NUMERIC_PRECISION_ RADIX) AS NUMERIC_PRECISION_RADIX, COALESCE (D1.NUMERIC_SCALE, D2.NUMERIC_SCALE) AS NUMERIC_ SCALE, COALESCE (D1.DATETIME_PRECISION, D2.DATETIME_PRECISION) AS DATETIME_PRECISION, COALESCE (C1.CHARACTER_SET_CATALOG, C2.CHARACTER_SET_ CATALOG) AS CHARACTER_SET_CATALOG, COALESCE (C1.CHARACTER_SET_SCHEMA, C2.CHARACTER_SET_SCHEMA) AS CHARACTER_SET_SCHEMA, COALESCE (C1.CHARACTER_SET_NAME, C2.CHARACTER_SET_NAME) AS CHARACTER_SET_NAME, COALESCE (D1.COLLATION_CATALOG, D2.COLLATION_CATALOG) AS COLLATION_CATALOG, COALESCE (D1.COLLATION_SCHEMA, D2.COLLATION_SCHEMA) AS COLLATION_SCHEMA, COALESCE (D1.COLLATION_NAME, D2.COLLATION_NAME) AS COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME 544 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema FROM DEFINITION_SCHEMA.COLUMNS AS C LEFT JOIN DEFINITION_SCHEMA.DATA_TYPE_DESCRIPTOR AS D1 LEFT JOIN DEFINITION_SCHEMA.COLLATIONS AS C1 ON ( ( C1.COLLATION_CATALOG, C1.COLLATION_SCHEMA, C1.COLLATION_ NAME ) = ( D1.COLLATION_CATALOG, D1.COLLATION_SCHEMA, D1.COLLATION_ NAME ) ) ON ( ( C.TABLE_CATALOG, C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_ NAME ) = ( D1.TABLE_OR_DOMAIN_CATALOG, D1.TABLE_OR_DOMAIN_ SCHEMA, D1.TABLE_OR_DOMAIN_NAME, D1.COLUMN_NAME ) ) LEFT JOIN DEFINITION_SCHEMA.DATA_TYPE_DESCRIPTOR AS D2 LEFT JOIN DEFINITION_SCHEMA.COLLATIONS AS C2 ON ( ( C2.COLLATION_CATALOG, C2.COLLATION_SCHEMA, C2.COLLATION_ NAME ) = ( D2.COLLATION_CATALOG, D2.COLLATION_SCHEMA, D2.COLLATION_ NAME ) ) ON ( ( C.DOMAIN_CATALOG, C.DOMAIN_SCHEMA, C.DOMAIN_NAME ) = ( D2.TABLE_OR_DOMAIN_CATALOG, D2.TABLE_OR_DOMAIN_ SCHEMA, D2.TABLE_OR_DOMAIN_NAME ) ) WHERE ( C.TABLE_CATALOG, C.TABLE_SCHEMA, C.TABLE_ NAME, C.COLUMN_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME, COLUMN_NAME FROM DEFINITION_SCHEMA.COLUMN_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) AND C.TABLE_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 545 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.10 TABLE_PRIVILEGES view Function Identify the privileges on tables defined in this catalog that are available to or granted by a given user. Definition CREATE VIEW TABLE_PRIVILEGES AS SELECT GRANTOR, GRANTEE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, PRIVILEGE_TYPE, IS_GRANTABLE FROM DEFINITION_SCHEMA.TABLE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) OR GRANTOR = CURRENT_USER AND TABLE_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 546 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.11 COLUMN_PRIVILEGES view Function Identify the privileges on columns of tables defined in this cata- log that are available to or granted by a given user. Definition CREATE VIEW COLUMN_PRIVILEGES AS SELECT GRANTOR, GRANTEE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME, COLUMN_NAME, PRIVILEGE_TYPE, IS_GRANTABLE FROM DEFINITION_SCHEMA.COLUMN_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) OR GRANTOR = CURRENT_USER AND TABLE_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 547 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.12 USAGE_PRIVILEGES view Function Identify the USAGE privileges on objects defined in this catalog that are available to or granted by a given user. Definition CREATE VIEW USAGE_PRIVILEGES AS SELECT GRANTOR, GRANTEE, OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_ NAME, OBJECT_TYPE, 'USAGE' AS PRIVILEGE_TYPE, IS_GRANTABLE FROM DEFINITION_SCHEMA.USAGE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) OR GRANTOR = CURRENT_USER AND OBJECT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 548 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.13 TABLE_CONSTRAINTS view Function Identify the table constraints defined in this catalog that are owned by a given user. Definition CREATE VIEW TABLE_CONSTRAINTS AS SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_TYPE, IS_DEFERRABLE, INITIALLY_DEFERRED FROM DEFINITION_SCHEMA.TABLE_CONSTRAINTS JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 549 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.14 REFERENTIAL_CONSTRAINTS view Function Identify the referential constraints defined in this catalog that are owned by a given user. Definition CREATE VIEW REFERENTIAL_CONSTRAINTS AS SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_ CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE FROM DEFINITION_SCHEMA.REFERENTIAL_CONSTRAINTS JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 550 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.15 CHECK_CONSTRAINTS view Function Identify the check constraints defined in this catalog that are owned by a given user. Definition CREATE VIEW CHECK_CONSTRAINTS AS SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME, CHECK_CLAUSE FROM DEFINITION_SCHEMA.CHECK_CONSTRAINTS JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 551 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.16 KEY_COLUMN_USAGE view Function Identify the columns defined in this catalog that are constrained as keys by a given user. Definition CREATE VIEW KEY_COLUMN_USAGE AS SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME, ORDINAL_POSITION FROM DEFINITION_SCHEMA.KEY_COLUMN_USAGE JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 552 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.17 ASSERTIONS view Function Identify the assertions defined in this catalog that are owned by a given user. Definition CREATE VIEW ASSERTIONS AS SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, IS_DEFERRABLE, INITIALLY_DEFERRED FROM DEFINITION_SCHEMA.ASSERTIONS JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 553 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.18 CHARACTER_SETS view Function Identify the character sets defined in this catalog that are acces- sible to a given user. Definition CREATE VIEW CHARACTER_SETS AS SELECT CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_ NAME, FORM_OF_USE, NUMBER_OF_CHARACTERS, DEFAULT_COLLATE_CATALOG, DEFAULT_COLLATE_SCHEMA, DEFAULT_ COLLATE_NAME FROM DEFINITION_SCHEMA.CHARACTER_SETS WHERE ( CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_ SET_NAME, 'CHARACTER SET') IN ( SELECT OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_ NAME, OBJECT_TYPE FROM DEFINITION_SCHEMA.USAGE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) AND CHARACTER_SET_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 554 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.19 COLLATIONS view Function Identify the character collations defined in this catalog that are accessible to a given user. Definition CREATE VIEW COLLATIONS AS SELECT COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_ NAME, PAD_ATTRIBUTE FROM DEFINITION_SCHEMA.COLLATIONS WHERE ( COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME, 'COLLATION') IN ( SELECT OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_ NAME, OBJECT_TYPE FROM DEFINITION_SCHEMA.USAGE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) AND COLLATION_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not reference the COLLATIONS view. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Information Schema and Definition Schema 555 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.20 TRANSLATIONS view Function Identify the character translations defined in this catalog that are accessible to a given user. Definition CREATE VIEW TRANSLATIONS AS SELECT TRANSLATION_CATALOG, TRANSLATION_SCHEMA, TRANSLATION_NAME, SOURCE_CHARACTER_SET_CATALOG, SOURCE_CHARACTER_SET_SCHEMA, SOURCE_CHARACTER_SET_NAME, TARGET_CHARACTER_SET_CATALOG, TARGET_CHARACTER_SET_SCHEMA, TARGET_CHARACTER_SET_NAME FROM DEFINITION_SCHEMA.TRANSLATIONS WHERE ( TRANSLATION_CATALOG, TRANSLATION_SCHEMA, TRANSLATION_ NAME, 'TRANSLATION') IN ( SELECT OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_ NAME, OBJECT_TYPE FROM DEFINITION_SCHEMA.USAGE_PRIVILEGES WHERE GRANTEE IN ( 'PUBLIC', CURRENT_USER ) ) AND TRANSLATION_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: a) Conforming Intermediate SQL language shall not reference the TRANSLATIONS view. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 556 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.21 VIEW_TABLE_USAGE view Function Identify the tables on which viewed tables defined in this catalog and owned by a given user are dependent. Definition CREATE VIEW VIEW_TABLE_USAGE AS SELECT VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM DEFINITION_SCHEMA.VIEW_TABLE_USAGE JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( TABLE_CATALOG, TABLE_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND VIEW_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 557 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.22 VIEW_COLUMN_USAGE view Function Identify the columns on which viewed tables defined in this catalog and owned by a given user are dependent. Definition CREATE VIEW VIEW_COLUMN_USAGE AS SELECT VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM DEFINITION_SCHEMA.VIEW_COLUMN_USAGE JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( TABLE_CATALOG, TABLE_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND VIEW_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 558 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.23 CONSTRAINT_TABLE_USAGE view Function Identify the tables that are used by referential constraints, unique constraints, check constraints, and assertions defined in this catalog and owned by a given user. Definition CREATE VIEW CONSTRAINT_TABLE_USAGE AS SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM ( ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM DEFINITION_SCHEMA.CHECK_COLUMN_USAGE ) UNION ( SELECT PK.TABLE_CATALOG, PK.TABLE_SCHEMA, PK.TABLE_NAME, FK.CONSTRAINT_CATALOG, FK.CONSTRAINT_SCHEMA, FK.CONSTRAINT_ NAME FROM DEFINITION_SCHEMA.REFERENTIAL_CONSTRAINTS AS FK JOIN DEFINITION_SCHEMA.TABLE_CONSTRAINTS AS PK ON ( FK.UNIQUE_CONSTRAINT_CATALOG, FK.UNIQUE_ CONSTRAINT_SCHEMA, FK.UNIQUE_CONSTRAINT_NAME ) = ( PK.CONSTRAINT_CATALOG, PK.CONSTRAINT_SCHEMA, PK.CONSTRAINT_ NAME ) ) ) JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( TABLE_CATALOG, TABLE_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) WHERE S.SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Information Schema and Definition Schema 559 X3H2-92-154/DBL CBR-002 21.2 Information Schema Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 560 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.24 CONSTRAINT_COLUMN_USAGE view Function Identify the columns used by referential constraints, unique con- straints, check constraints, and assertions defined in this catalog and owned by a given user. Definition CREATE VIEW CONSTRAINT_COLUMN_USAGE AS SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM DEFINITION_SCHEMA.CHECK_COLUMN_USAGE ) UNION ( SELECT K.TABLE_CATALOG, K.TABLE_SCHEMA, K.TABLE_ NAME, K.COLUMN_NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM DEFINITION_SCHEMA.TABLE_CONSTRAINTS JOIN DEFINITION_SCHEMA.KEY_COLUMN_USAGE AS K USING ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) ) JOIN DEFINITION_SCHEMA.SCHEMATA ON ( ( TABLE_CATALOG, TABLE_SCHEMA ) = ( CATALOG_NAME, SCHEMA_NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND CONSTRAINT_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 561 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.25 COLUMN_DOMAIN_USAGE view Function Identify the columns defined in this catalog that are dependent on a domain defined in this catalog and owned by a user. Definition CREATE VIEW COLUMN_DOMAIN_USAGE AS SELECT D.DOMAIN_CATALOG, D.DOMAIN_SCHEMA, D.DOMAIN_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM DEFINITION_SCHEMA.COLUMNS C JOIN DEFINITION_SCHEMA.DOMAINS D JOIN DEFINITION_SCHEMA.SCHEMATA S ON ( ( DOMAIN_CATALOG, DOMAIN_SCHEMA ) = ( S.CATALOG_NAME, S.SCHEMA_NAME ) ) ON ( ( D.DOMAIN_CATALOG, D.DOMAIN_SCHEMA, D.DOMAIN_ NAME ) = ( C.DOMAIN_CATALOG, C.DOMAIN_SCHEMA, C.DOMAIN_ NAME ) ) WHERE SCHEMA_OWNER = CURRENT_USER AND C.DOMAIN_NAME IS NOT NULL AND D.DOMAIN_CATALOG = ( SELECT CATALOG_NAME FROM INFORMATION_SCHEMA_ CATALOG_NAME ) Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. 562 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.26 SQL_LANGUAGES view Function Identify the conformance levels, options, and dialects supported by the SQL-implementation processing data defined in this catalog. Definition CREATE VIEW SQL_LANGUAGES AS SELECT SQL_LANGUAGE_SOURCE, SQL_LANGUAGE_YEAR, SQL_LANGUAGE_ CONFORMANCE, SQL_LANGUAGE_INTEGRITY, SQL_LANGUAGE_IMPLEMENTATION, SQL_LANGUAGE_BINDING_STYLE, SQL_LANGUAGE_PROGRAMMING_ LANGUAGE FROM DEFINITION_SCHEMA.SQL_LANGUAGES Leveling Rules 1) The following restrictions apply for Intermediate SQL: None. 2) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) Conforming Entry SQL language shall not reference the Information Schema. Information Schema and Definition Schema 563 X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.27 SQL_IDENTIFIER domain Function Define a domain that contains all valid s Definition CREATE DOMAIN SQL_IDENTIFIER AS CHARACTER VARYING (L) CHARACTER SET SQL_TEXT Description 1) This domain specifies any variable-length character value that conforms to the rules for an SQL . Note: There is no way in SQL to specify a that would be true for any valid SQL and false for all other values. 2) L is the implementation-defined maximum length of . 21.2.28 CHARACTER_DATA domain Function Define a domain that contains any character data. Definition CREATE DOMAIN CHARACTER_DATA AS CHARACTER VARYING (ML) CHARACTER SET SQL_TEXT Description 1) This domain specifies any character data. 2) ML is the implementation-defined maximum length of a variable- length character string. 564 Database Language SQL X3H2-92-154/DBL CBR-002 21.2 Information Schema 21.2.29 CARDINAL_NUMBER domain Function Define a domain that contains a non-negative number. Definition CREATE DOMAIN CARDINAL_NUMBER AS INTEGER CONSTRAINT CARDINAL_NUMBER_DOMAIN_CHECK CHECK ( VALUE >= 0 ) Description 1) The domain CARDINAL_NUMBER contains any non-negative number that is less than the implementation-defined maximum for INTEGER (i.e., the implementation-defined value of NUMERIC_PRECISION_ RADIX raised to the power of implementation-defined NUMERIC_ PRECISION). Information Schema and Definition Schema 565 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3 Definition Schema 21.3.1 Introduction The base tables are all defined in a for the schema named DEFINITION_SCHEMA. The table definitions are as com- plete as the definitional power of SQL allows. The table defi- nitions are supplemented with assertions where appropriate; see Subclause 21.4, "Assertions on the base tables". Each description comprises three parts: 1) The function of the definition is stated. 2) The SQL definition of the object is presented as a
. 3) An explanation of the object. The specification provides only a model of the base tables that are required, and does not imply that an implementation shall provide the functionality in the manner described in this clause. An instance of a definition schema describes an instance of a clus- ter of catalogs (see Subclause 4.13, "Clusters of catalogs"). 566 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.2 DEFINITION_SCHEMA Schema Function Create the schema that is to contain the base tables that underlie the Information Schema Definition CREATE SCHEMA DEFINITION_SCHEMA AUTHORIZATION DEFINITION_SCHEMA Description None. Information Schema and Definition Schema 567 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.3 USERS base table Function The USERS table has one row for each referenced in the Information Schema of the catalog. These are all those s that may grant or receive privileges as well as those that may create a schema, or currently own a schema created through a . Definition CREATE TABLE USERS ( USER_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT USERS_PRIMARY_KEY PRIMARY KEY ) Description 1) The values of USER_NAME are s that are known. 568 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.4 SCHEMATA base table Function The SCHEMATA table has one row for each schema. Definition CREATE TABLE SCHEMATA ( CATALOG_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER, SCHEMA_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER, SCHEMA_OWNER INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT SCHEMA_OWNER_NOT_NULL NOT NULL, DEFAULT_CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER, DEFAULT_CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER, DEFAULT_CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER, CONSTRAINT SCHEMATA_PRIMARY_KEY PRIMARY KEY ( CATALOG_ NAME, SCHEMA_NAME ), CONSTRAINT SCHEMATA_FOREIGN_KEY FOREIGN KEY ( SCHEMA_OWNER ) REFERENCES USERS ) Description 1) All the values of CATALOG_NAME are the name of the catalog in which the schemata are included. 2) The values of SCHEMA_NAME are the unqualified schema names of the schemata in the catalog. 3) The values of SCHEMA_OWNER are the authorization identifiers that own the schemata. 4) The values of DEFAULT_CHARACTER_SET_CATALOG, DEFAULT_CHARACTER_ SET_SCHEMA, and DEFAULT_CHARACTER_SET_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the default character set for columns and domains in the schemata. Information Schema and Definition Schema 569 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.5 DATA_TYPE_DESCRIPTOR base table Function The DATA_TYPE_DESCRIPTOR table has one row for each domain and one row for each column (in each table) that is defined as hav- ing a data type rather than a domain. It effectively contains a representation of the data type descriptors. Definition CREATE TABLE DATA_TYPE_DESCRIPTOR ( TABLE_OR_DOMAIN_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_OR_DOMAIN_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_OR_DOMAIN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, DATA_TYPE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_OR_DOMAIN_DATA_TYPE_NOT_NULL NOT NULL, CHARACTER_MAXIMUM_LENGTH INFORMATION_SCHEMA.CARDINAL_ NUMBER, CHARACTER_OCTET_LENGTH INFORMATION_SCHEMA.CARDINAL_ NUMBER, COLLATION_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, COLLATION_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, COLLATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, NUMERIC_PRECISION INFORMATION_SCHEMA.CARDINAL_ NUMBER, NUMERIC_PRECISION_RADIX INFORMATION_SCHEMA.CARDINAL_ NUMBER, NUMERIC_SCALE INFORMATION_SCHEMA.CARDINAL_ NUMBER, DATETIME_PRECISION INFORMATION_SCHEMA.CARDINAL_ NUMBER, CONSTRAINT TABLE_OR_DOMAIN_CHECK_COMBINATIONS CHECK ( DATA_TYPE IN ( 'CHARACTER', 'CHARACTER VARYING', 'BIT', 'BIT VARYING' ) AND ( CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_ LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) IS NOT NULL AND ( NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION ) IS NULL 570 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema OR DATA_TYPE IN ( 'REAL', 'DOUBLE PRECISION', 'FLOAT' ) AND ( CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_ LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) IS NULL AND NUMERIC_PRECISION IS NOT NULL AND NUMERIC_PRECISION_RADIX = 2 AND NUMERIC_SCALE IS NULL AND DATETIME_PRECISION IS NULL OR DATA_TYPE IN ( 'INTEGER', 'SMALLINT', 'NUMERIC', 'DECIMAL' ) AND ( CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_ LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) IS NULL AND NUMERIC_SCALE IS NOT NULL AND ( NUMERIC_SCALE <> 0 AND NUMERIC_PRECISION_ RADIX = 10 OR NUMERIC_SCALE = 0 AND NUMERIC_PRECISION_RADIX IN ( 2, 10 ) ) AND DATETIME_PRECISION IS NULL OR DATA_TYPE IN ( 'DATE', 'TIME', 'TIMESTAMP', 'TIME WITH TIME ZONE', 'TIMESTAMP WITH TIME ZONE', 'INTERVAL' ) AND ( CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) IS NULL AND ( NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX ) IS NULL AND NUMERIC_SCALE IS NULL AND DATETIME_PRECISION IS NOT NULL ), CONSTRAINT DATA_TYPE_DESCRIPTOR_PRIMARY_KEY PRIMARY KEY ( TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_ SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME ), CONSTRAINT DATA_TYPE_CHECK_REFERENCES_COLLATION CHECK ( COLLATION_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ) IN Information Schema and Definition Schema 571 X3H2-92-154/DBL CBR-002 21.3 Definition Schema ( SELECT COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME FROM COLLATIONS ) ), CONSTRAINT DATA_TYPE_DESCRIPTOR_CHECK_USED CHECK ( (TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME FROM COLUMNS UNION SELECT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, '' FROM DOMAINS ) ) ) Description 1) The values of TABLE_OR_DOMAIN_CATALOG and TABLE_OR_DOMAIN_ SCHEMA are the catalog name and the unqualified schema name, respectively, of the schema that contains the object (domain or column) to which the data type descriptor belongs. 2) Case: a) If the length of COLUMN_NAME is 0, then the value of TABLE_ OR_DOMAIN_NAME is the name of the domain to which the data type descriptor belongs. b) Otherwise, TABLE_OR_DOMAIN_NAME is the name of the table and COLUMN_NAME is the name of the column in that table to which the data type descriptor belongs. 3) The values of DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_ OCTET_LENGTH, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, and DATETIME_PRECISION contain the data type of the domain or column being defined, the maximum length in characters or bits of the column if it is a character or bit type respectively, maximum length in octets of the column if it is a character type, the qualified name of the applicable collation if it is a character type, the precision and radix of the precision if it is a numeric type, and the precision if it is a datetime or interval type. 572 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.6 DOMAINS base table Function The DOMAINS table has one row for each domain. It effectively con- tains a representation of the domain descriptors. Definition CREATE TABLE DOMAINS ( DOMAIN_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_DEFAULT INFORMATION_SCHEMA.CHARACTER_DATA, CONSTRAINT DOMAINS_PRIMARY_KEY PRIMARY KEY ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ), CONSTRAINT DOMAINS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( DOMAIN_CATALOG, DOMAIN_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT DOMAINS_CHECK_DATA_TYPE CHECK ( DOMAIN_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, '' ) IN ( SELECT TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_ SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME FROM DATA_TYPE_DESCRIPTOR ) ) ) Description 1) The values of DOMAIN_CATALOG and DOMAIN_SCHEMA are the catalog name and unqualified schema name, respectively, of the schema in which the domain is defined. 2) The value of DOMAIN_NAME is the name of the domain. 3) The value of DOMAIN_DEFAULT is null if the domain being de- scribed has no default value. Otherwise, the value of DOMAIN_ DEFAULT is a character representation of the default value for the domain that obeys the rules specified for in Subclause 11.5, "". Information Schema and Definition Schema 573 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.7 DOMAIN_CONSTRAINTS base table Function The DOMAIN_CONSTRAINTS table has one row for each domain constraint associated with a domain. It effectively contains a representation of the domain constraint descriptors. Definition CREATE TABLE DOMAIN_CONSTRAINTS ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT DOMAIN_CATALOG_NOT_NULL NOT NULL, DOMAIN_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT DOMAIN_SCHEMA_NOT_NULL NOT NULL, DOMAIN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT DOMAIN_NAME_NOT_NULL NOT NULL, IS_DEFERRABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT DOMAIN_CONSTRAINTS_DEFERRABLE_NOT_NULL NOT NULL, INITIALLY_DEFERRED INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT DOMAIN_CONSTRAINTS_INITIALLY_DEFERRED_NOT_NULL NOT NULL, CONSTRAINT DOMAIN_CONSTRAINTS_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ), CONSTRAINT DOMAIN_CONSTRAINTS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT DOMAIN_CONSTRAINTS_FOREIGN_KEY_CHECK_CONSTRAINTS FOREIGN KEY ( DOMAIN_CATALOG, DOMAIN_SCHEMA, CONSTRAINT_ NAME ) REFERENCES CHECK_CONSTRAINTS, CONSTRAINT DOMAIN_CONSTRAINTS_FOREIGN_KEY_DOMAINS FOREIGN KEY ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ) REFERENCES DOMAINS, CONSTRAINT DOMAIN_CONSTRAINTS_CHECK_DEFERRABLE CHECK ( ( IS_DEFERRABLE, INITIALLY_DEFERRED ) IN ( VALUES ( 'NO', 'NO' ), ( 'YES', 'NO' ), ( 'YES', 'YES' ) ) ) ) 574 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema Description 1) The values of CONSTRAINT_CATALOG and CONSTRAINT_SCHEMA are the catalog name and unqualified schema name of the schema in which the domain constraint is defined. 2) The value of CONSTRAINT_NAME is the name of the domain con- straint. 3) The values of DOMAIN_CATALOG, DOMAIN_SCHEMA and DOMAIN_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the domain in which the domain constraint is defined. 4) The values of IS_DEFERRABLE have the following meanings: YES The domain constraint is deferrable. NO The domain constraint is not deferrable. 5) The values of INITIALLY_DEFERRED have the following meanings: YES The domain constraint is initially deferred. NO The domain constraint is initially immediate. Information Schema and Definition Schema 575 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.8 TABLES base table Function The TABLES table contains one row for each table including views. It effectively contains a representation of the table descriptors. Definition CREATE TABLE TABLES ( TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_TYPE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_TYPE_NOT_NULL NOT NULL, CONSTRAINT TABLE_TYPE_CHECK CHECK ( TABLE_TYPE IN ( 'BASE TABLE', 'VIEW', 'GLOBAL TEMPORARY', 'LOCAL TEMPORARY' ) ), CONSTRAINT CHECK_TABLE_IN_COLUMNS CHECK ( ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM COLUMNS ) ), CONSTRAINT TABLES_PRIMARY_KEY PRIMARY KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ), CONSTRAINT TABLES_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( TABLE_CATALOG, TABLE_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT TABLES_CHECK_NOT_VIEW CHECK ( NOT EXCEPTIONEXISTS ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES WHERE TABLE_TYPE = 'VIEW' EXCEPT SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM VIEWS ) ) ) Description 1) The values of TABLE_CATALOG and TABLE_SCHEMA are the catalog name and unqualified schema name, respectively, of the schema in which the table is defined. 2) The value of TABLE_NAME is the name of the table. 3) The values of TABLE_TYPE have the following meanings: 576 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema BASE TABLE The table being described is a persistent base table. VIEW The table being described is a viewed table. GLOBAL The table being described is a global temporary TEMPORARY table. LOCAL The table being described is a created local TEMPORARY temporary table. Information Schema and Definition Schema 577 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.9 VIEWS base table Function The VIEWS table contains one row for each row in the TABLES ta- ble with a TABLE_TYPE of 'VIEW'. Each row describes the query expression that defines a view. The table effectively contains a representation of the view descriptors. Definition CREATE TABLE VIEWS ( TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, VIEW_DEFINITION INFORMATION_SCHEMA.CHARACTER_DATA, CHECK_OPTION INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT CHECK_OPTION_NOT_NULL NOT NULL CONSTRAINT CHECK_OPTION_CHECK CHECK ( CHECK_OPTION IN ( 'CASCADED', 'LOCAL', 'NONE' ) ), IS_UPDATABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT IS_UPDATABLE_NOT_NULL NOT NULL CONSTRAINT IS_UPDATABLE_CHECK CHECK ( IS_UPDATABLE IN ( 'YES', 'NO' ) ), CONSTRAINT VIEWS_PRIMARY_KEY PRIMARY KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ), CONSTRAINT VIEWS_IN_TABLES_CHECK CHECK ( ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES WHERE TABLE_TYPE = 'VIEW' ) ), CONSTRAINT VIEWS_IS_UPDATABLE_CHECK_OPTION_CHECK CHECK ( ( IS_UPDATABLE, CHECK_OPTION ) NOT IN ( VALUES ( 'NO', 'CASCADED' ), ( 'NO', 'LOCAL' ) ) ) ) Description 1) The values of TABLE_CATALOG and TABLE_SCHEMA are the catalog name and unqualified schema name, respectively, of the schema in which the viewed table is defined. 2) The value of TABLE_NAME is the name of the viewed table. 578 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 3) Case: a) If the character representation of the contained in the that defined the view be- ing described can be represented without truncation, then the value of VIEW_DEFINITION is that character representation. b) Otherwise, the value of VIEW_DEFINITION is the null value. Note: Any implicit s that were contained in the associated with the are replaced by explicit s in VIEW_DEFINITION. 4) The values of CHECK_OPTION have the following meanings: CASCADED The contains WITH CASCADED CHECK OPTION. LOCAL The contains WITH LOCAL CHECK OPTION. NONE The does not contain WITH CHECK OPTION. 5) The values of IS_UPDATABLE have the following meanings: YES The simply contains a that is updatable. NO The simply contains a that is not updatable. Information Schema and Definition Schema 579 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.10 COLUMNS base table Function The COLUMNS table has one row for each column. It effectively con- tains a representation of the column descriptors. Definition CREATE TABLE COLUMNS ( TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, ORDINAL_POSITION INFORMATION_SCHEMA.CARDINAL_NUMBER CONSTRAINT COLUMN_POSITION_NOT_NULL NOT NULL, DOMAIN_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, DOMAIN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_DEFAULT INFORMATION_SCHEMA.CHARACTER_DATA, IS_NULLABLE INFORMATION_SCHEMA.CHARACTER_DATA, CONSTRAINT COLUMNS_PRIMARY_KEY PRIMARY KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ), CONSTRAINT COLUMNS_UNIQUE UNIQUE ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, ORDINAL_ POSITION ), CONSTRAINT COLUMNS_FOREIGN_KEY_TABLES FOREIGN KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) REFERENCES TABLES, CONSTRAINT COLUMNS_CHECK_REFERENCES_DOMAIN CHECK ( DOMAIN_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ) IN ( SELECT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME FROM DOMAINS ) ), CONSTRAINT COLUMNS_CHECK_DATA_TYPE CHECK ( DOMAIN_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ) IS NOT NULL AND ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) NOT IN 580 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema ( SELECT TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_ SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME FROM DATA_TYPE_DESCRIPTOR ) OR ( DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME ) IS NULL AND ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) IN ( SELECT TABLE_OR_DOMAIN_CATALOG, TABLE_OR_DOMAIN_ SCHEMA, TABLE_OR_DOMAIN_NAME, COLUMN_NAME FROM DATA_TYPE_DESCRIPTOR ) ) ) ) Description 1) Case: a) If a column is described by a column descriptor included in a table descriptor, then the table descriptor and the column descriptor are associated with that column. b) If a column is described by a column descriptor included in a view descriptor, then the view descriptor and the correspond- ing column descriptor of the table of the are associated with that column. 2) The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the catalog name, unqualified schema name, and qualified iden- tifier, respectively, of the table containing the column being described. 3) The value of COLUMN_NAME is the name of the column being de- scribed. 4) The values of DOMAIN_CATALOG, DOMAIN_SCHEMA, and DOMAIN_NAME are null if the column being described is not defined using a . Otherwise, the values of DOMAIN_CATALOG, DOMAIN_ SCHEMA, and DOMAIN_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the domain used by the column being described. 5) The value of ORDINAL_POSITION is the ordinal position of the column in the table. 6) The value of COLUMN_DEFAULT is null if the column being de- scribed has no default value or if its default value comes only from a domain. Otherwise, the value of COLUMN_DEFAULT is a character representation of the default value for the col- umn that obeys the rules specified for in Subclause 11.5, "". Information Schema and Definition Schema 581 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 7) The values of IS_NULLABLE have the following meanings: YES The columns is possibly nullable. NO The column is known not nullable. 582 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.11 VIEW_TABLE_USAGE base table Function The VIEW_TABLE_USAGE table has one row for each table referenced in the of a view. Definition CREATE TABLE VIEW_TABLE_USAGE ( VIEW_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, VIEW_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, VIEW_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT VIEW_TABLE_USAGE_PRIMARY_KEY PRIMARY KEY ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ), CONSTRAINT VIEW_TABLE_USAGE_CHECK_REFERENCES_TABLES CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES ) ), CONSTRAINT VIEW_TABLE_USAGE_FOREIGN_KEY_VIEWS FOREIGN KEY ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME ) REFERENCES VIEWS ) Description 1) The values of VIEW_CATALOG, VIEW_SCHEMA, and VIEW_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the view being described. 2) The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the catalog name, unqualified schema name, and qualified identi- fier, respectively, of a table view requires. Information Schema and Definition Schema 583 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.12 VIEW_COLUMN_USAGE base table Function The VIEW_COLUMN_USAGE table has one row for each column referenced by a view. Definition CREATE TABLE VIEW_COLUMN_USAGE ( VIEW_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, VIEW_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, VIEW_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT VIEW_COLUMN_USAGE_PRIMARY_KEY PRIMARY KEY ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ), CONSTRAINT VIEW_COLUMN_USAGE_CHECK_REFERENCES_COLUMNS CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME, COLUMN_NAME FROM COLUMNS ) ), CONSTRAINT VIEW_COLUMN_USAGE_FOREIGN_KEY_VIEWS FOREIGN KEY ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME ) REFERENCES VIEWS ) Description 1) The values of VIEW_CATALOG, VIEW_SCHEMA, and VIEW_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the view being described. 2) The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME are the catalog name, unqualified schema name, qual- ified identifier, and identifier, respectively, of a column that is explicitly or implicitly referenced in the of the view being described. 584 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.13 TABLE_CONSTRAINTS base table Function The TABLE_CONSTRAINTS table has one row for each table constraint associated with a table. It effectively contains a representation of the table constraint descriptors. Definition CREATE TABLE TABLE_CONSTRAINTS ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_TYPE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT CONSTRAINT_TYPE_NOT_NULL NOT NULL CONSTRAINT CONSTRAINT_TYPE_CHECK CHECK ( CONSTRAINT_TYPE IN ( 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY', 'CHECK' ) ), TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT TABLE_CONSTRAINTS_TABLE_CATALOG_NOT_NULL NOT NULL, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT TABLE_CONSTRAINTS_TABLE_SCHEMA_NOT_NULL NOT NULL, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT TABLE_CONSTRAINTS_TABLE_NAME_NOT_NULL NOT NULL, IS_DEFERRABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_CONSTRAINTS_IS_DEFERRABLE_NOT_NULL NOT NULL, INITIALLY_DEFERRED INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_CONSTRAINTS_INITIALLY_DEFERRED_NOT_ NULL NOT NULL, CONSTRAINT TABLE_CONSTRAINTS_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ), CONSTRAINT TABLE_CONSTRAINTS_CHECK_REFERENCES_TABLES CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES ) ), CONSTRAINT TABLE_CONSTRAINTS_DEFERRED_CHECK CHECK ( ( IS_DEFERRABLE, INITIALLY_DEFERRED ) IN Information Schema and Definition Schema 585 X3H2-92-154/DBL CBR-002 21.3 Definition Schema ( VALUES ( 'NO', 'NO' ), ( 'YES', 'NO' ), ( 'YES', 'YES' ) ) ), CONSTRAINT TABLE_CONSTRAINTS_CHECK_VIEWS CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES WHERE TABLE_TYPE <> 'VIEW' ) ), CONSTRAINT TABLE_CONSTRAINTS_UNIQUE_CHECK CHECK ( 1 = ( SELECT COUNT (*) FROM ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE IN ( 'UNIQUE', 'PRIMARY KEY' ) UNION ALL SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM REFERENTIAL_CONSTRAINTS UNION ALL SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM CHECK_CONSTRAINTS ) AS X WHERE ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) = ( X.CONSTRAINT_CATALOG, X.CONSTRAINT_SCHEMA, X.CONSTRAINT_ NAME ) ) ), CONSTRAINT UNIQUE_TABLE_PRIMARY_KEY_CHECK CHECK ( UNIQUE ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME FROM TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. If the
or that defined the constraint did not spec- ify a , then the values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are implementation- defined. 586 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 2) The values of CONSTRAINT_TYPE have the following meanings: FOREIGN The constraint being described is a foreign key KEY constraint. UNIQUE The constraint being described is a unique con- straint. PRIMARY The constraint being described is a primary key KEY constraint. CHECK The constraint being described is a check con- straint. 3) The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the catalog name, the unqualified schema name, and the qual- ified identifier of the name of the table to which the table constraint being described applies. 4) The values of IS_DEFERRABLE have the following meanings: YES The table constraint is deferrable. NO The table constraint is not deferrable. 5) The values of INITIALLY_DEFERRED have the following meanings: YES The table constraint is initially deferred. NO The table constraint is initially immediate. Information Schema and Definition Schema 587 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.14 KEY_COLUMN_USAGE base table Function The KEY_COLUMN_USAGE table has one or more rows for each row in the TABLE_CONSTRAINTS table that has a CONSTRAINT_TYPE of "UNIQUE", "PRIMARY KEY", or "FOREIGN KEY". The rows list the columns that constitute each unique constraint, and the referencing columns in each foreign key constraint. Definition CREATE TABLE KEY_COLUMN_USAGE ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT KEY_COLUMN_TABLE_CATALOG_NOT_NULL NOT NULL, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT KEY_COLUMN_TABLE_SCHEMA_NOT_NULL NOT NULL, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT KEY_COLUMN_TABLE_NAME_NOT_NULL NOT NULL, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, ORDINAL_POSITION INFORMATION_SCHEMA.CARDINAL_NUMBER CONSTRAINT KEY_COLUMN_ORDINAL_POSITION_NOT_NULL NOT NULL, CONSTRAINT KEY_COLUMN_USAGE_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME, COLUMN_NAME ), CONSTRAINT KEY_COLUMN_USAGE_UNIQUE UNIQUE ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, ORDINAL_POSITION ), CONSTRAINT KEY_COLUMN_USAGE_FOREIGN_KEY_COLUMNS FOREIGN KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) REFERENCES COLUMNS, CONSTRAINT KEY_COLUMN_CONSTRAINT_TYPE_CHECK CHECK ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) IN ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE IN ( 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY' ) ) ) ) 588 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. 2) The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME are the catalog name, unqualified schema name, qual- ified identifier of the table name, and the column name of the column that participates in the unique, primary key, or foreign key constraint being described. 3) The value of ORDINAL_POSITION is the ordinal position of the specific column in the constraint being described. If the con- straint described is a key of cardinality 1, then the value of ORDINAL_POSITION is always 1. If the constraint being described is a foreign key constraint, then ORDINAL_POSITION also identi- fies the position within the uniqueness constraint of the column that this column references. Information Schema and Definition Schema 589 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.15 REFERENTIAL_CONSTRAINTS base table Function The REFERENTIAL_CONSTRAINTS table has one row for each row in the TABLE_CONSTRAINTS table that has a CONSTRAINT_TYPE value of "FOREIGN KEY". Definition CREATE TABLE REFERENTIAL_CONSTRAINTS ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER, UNIQUE_CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT UNIQUE_CONSTRAINT_CATALOG_NOT_NULL NOT NULL, UNIQUE_CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT UNIQUE_CONSTRAINT_SCHEMA_NOT_NULL NOT NULL, UNIQUE_CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT UNIQUE_CONSTRAINT_NAME_NOT_NULL NOT NULL, MATCH_OPTION INFORMATION_SCHEMA.CHARACTER_ DATA CONSTRAINT REFERENTIAL_MATCH_OPTION_NOT_NULL NOT NULL CONSTRAINT REFERENTIAL_MATCH_OPTION_CHECK CHECK ( MATCH_OPTION IN ( 'NONE', 'PARTIAL', 'FULL' ) ), UPDATE_RULE INFORMATION_SCHEMA.CHARACTER_ DATA CONSTRAINT REFERENTIAL_UPDATE_RULE_NOT_NULL NOT NULL CONSTRAINT REFERENTIAL_UPDATE_RULE_CHECK CHECK ( UPDATE_RULE IN ('CASCADE', 'SET NULL', 'SET DEFAULT', 'NO ACTION' ) ), DELETE_RULE INFORMATION_SCHEMA.CHARACTER_ DATA CONSTRAINT REFERENTIAL_DELETE_RULE_NOT_NULL NOT NULL CONSTRAINT REFERENTIAL_DELETE_RULE_CHECK CHECK ( DELETE_RULE IN ('CASCADE', 'SET NULL', 'SET DEFAULT', 'NO ACTION' ) ), CONSTRAINT REFERENTIAL_CONSTRAINTS_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ), CONSTRAINT REFERENTIAL_CONSTRAINTS_CONSTRAINT_TYPE_CHECK CHECK ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) 590 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema IN ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'FOREIGN KEY' ) ), CONSTRAINT UNIQUE_CONSTRAINT_CHECK_REFERENCES_UNIQUE_ CONSTRAINT CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( ( UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_ SCHEMA, UNIQUE_CONSTRAINT_NAME ) IN ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_ SCHEMA, CONSTRAINT_NAME FROM TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE IN ( 'UNIQUE', 'PRIMARY KEY' ) ) ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. 2) The values of UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_ SCHEMA, and UNIQUE_CONSTRAINT_NAME are the catalog name, unqual- ified schema name, and qualified identifier, respectively, of the unique or primary key constraint applied to the referenced column list being described. 3) The values of MATCH_OPTION have the following meanings: NONE No was specified. PARTIAL A of PARTIAL was specified. FULL A of FULL was specified. 4) The values of UPDATE_RULE have the following meanings for a referential constraint that has an update rule: CASCADE A of CASCADE was specified. SET NULL A of SET NULL was specified. SET DEFAULT A of SET DEFAULT was speci- fied. NO ACTION A of NO ACTION was speci- fied. Information Schema and Definition Schema 591 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 5) The values of DELETE_RULE have the following meanings for a referential constraint that has a : CASCADE A of CASCADE was specified. SET NULL A of SET NULL was specified. SET DEFAULT A of SET DEFAULT was speci- fied. NO ACTION A of NO ACTION was speci- fied. 592 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.16 CHECK_CONSTRAINTS base table Function The CHECK_CONSTRAINTS table has one row for each domain constraint, table check constraint, and assertion. Definition CREATE TABLE CHECK_CONSTRAINTS ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CHECK_CLAUSE INFORMATION_SCHEMA.CHARACTER_DATA, CONSTRAINT CHECK_CONSTRAINTS_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ), CONSTRAINT CHECK_CONSTRAINTS_SOURCE_CHECK CHECK ( ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) IN ( SELECT * FROM ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM ASSERTIONS UNION SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM TABLE_CONSTRAINTS UNION SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM DOMAIN_CONSTRAINTS ) ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. 2) Case: a) If the character representation of the contained in the , , or that de- fined the check constraint being described can be represented without truncation, then the value of CHECK_CLAUSE is that character representation. Information Schema and Definition Schema 593 X3H2-92-154/DBL CBR-002 21.3 Definition Schema b) Otherwise, the value of CHECK_CLAUSE is the null value. Note: Any implicit s that were contained in the associated with a or an are replaced by explicit s in CHECK_CONSTRAINTS. 594 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.17 CHECK_TABLE_USAGE base table Function The CHECK_TABLE_USAGE table has one row for each table referenced by the of a check constraint, domain constraint, or assertion. Definition CREATE TABLE CHECK_TABLE_USAGE ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT CHECK_TABLE_USAGE_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ), CONSTRAINT CHECK_TABLE_USAGE_FOREIGN_KEY_CHECK_CONSTRAINTS FOREIGN KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) REFERENCES CHECK_CONSTRAINTS, CONSTRAINT CHECK_TABLE_USAGE_CHECK_REFERENCES_TABLES CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM TABLES ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. 2) The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the catalog name, unqualified schema name, and qualified iden- tifier, respectively, of a table that is referenced by the constraint being described. Information Schema and Definition Schema 595 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.18 CHECK_COLUMN_USAGE base table Function The CHECK_COLUMN_USAGE table has one row for each column referenced by the of a check constraint, domain constraint, or assertion. Definition CREATE TABLE CHECK_COLUMN_USAGE ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT CHECK_COLUMN_USAGE_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ), CONSTRAINT CHECK_COLUMN_USAGE_FOREIGN_KEY_CHECK_CONSTRAINTS FOREIGN KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) REFERENCES CHECK_CONSTRAINTS, CONSTRAINT CHECK_COLUMN_USAGE_CHECK_REFERENCES_COLUMNS CHECK ( TABLE_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) IN ( SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME, COLUMN_NAME FROM COLUMNS ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the constraint being described. 596 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 2) The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of a column that is referenced by the constraint being described. Information Schema and Definition Schema 597 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.19 ASSERTIONS base table Function The ASSERTIONS table has one row for each assertion. It effectively contains a representation of the assertion descriptors. Definition CREATE TABLE ASSERTIONS ( CONSTRAINT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CONSTRAINT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, IS_DEFERRABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT ASSERTIONS_IS_DEFERRABLE_NOT_NULL NOT NULL, INITIALLY_DEFERRED INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT ASSERTIONS_INITIALLY_DEFERRED_NOT_NULL NOT NULL, CONSTRAINT ASSERTIONS_PRIMARY_KEY PRIMARY KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ), CONSTRAINT ASSERTIONS_FOREIGN_KEY_CHECK_CONSTRAINTS FOREIGN KEY (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) REFERENCES CHECK_CONSTRAINTS, CONSTRAINT ASSERTIONS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT ASSERTIONS_DEFERRED_CHECK CHECK ( ( IS_DEFERRABLE, INITIALLY_DEFERRED ) IN VALUES ( ( 'NO', 'NO' ), ( 'YES', 'NO' ), ( 'YES', 'YES' ) ) ) ) Description 1) The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the assertion being described. 2) The values of IS_DEFERRABLE have the following meanings: YES The assertion is deferrable. NO The assertion is not deferrable. 598 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 3) The values of INITIALLY_DEFERRED have the following meanings: YES The assertion is initially deferred. NO The assertion is initially immediate. Information Schema and Definition Schema 599 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.20 TABLE_PRIVILEGES base table Function The TABLE_PRIVILEGES table has one row for each table privilege descriptor. It effectively contains a representation of the table privilege descriptors. Definition CREATE TABLE TABLE_PRIVILEGES ( GRANTOR INFORMATION_SCHEMA.SQL_IDENTIFIER, GRANTEE INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, PRIVILEGE_TYPE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_PRIVILEGES_TYPE_CHECK CHECK ( PRIVILEGE_TYPE IN ( 'SELECT', 'INSERT', 'DELETE', 'UPDATE' 'REFERENCES' ) ), IS_GRANTABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT TABLE_PRIVILEGES_GRANTABLE_NOT_NULL NOT NULL CONSTRAINT TABLE_PRIVILEGES_GRANTABLE_CHECK CHECK ( IS_GRANTABLE IN ( 'YES', 'NO' ) ), CONSTRAINT TABLE_PRIVILEGES_PRIMARY_KEY PRIMARY KEY ( GRANTOR, GRANTEE, TABLE_CATALOG, TABLE_ SCHEMA, TABLE_NAME, PRIVILEGE_TYPE ), CONSTRAINT TABLE_PRIVILEGES_FOREIGN_KEY_TABLES FOREIGN KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) REFERENCES TABLES, CONSTRAINT TABLE_PRIVILEGES_GRANTOR_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTOR ) REFERENCES USERS, CONSTRAINT TABLE_PRIVILEGES_GRANTEE_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTEE ) REFERENCES USERS ) Description 1) The value of GRANTOR is the of the user who granted table privileges, on the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME, to the user iden- tified by the value of GRANTEE for the table privilege being described. 600 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema 2) The value of GRANTEE is the of some user, or "PUBLIC" to indicate all users, to whom the table priv- ilege being described is granted. 3) The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the catalog name, unqualified schema name, and qualified iden- tifier, respectively, of the table on which the privilege being described has been granted. 4) The values of PRIVILEGE_TYPE have the following meanings: SELECT The user has SELECT privileges on the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME. DELETE The user has DELETE privileges on the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME. INSERT The user will automatically be granted INSERT priv- ileges on any columns that may be added to the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_ NAME in the future. UPDATE The user will automatically be granted UPDATE priv- ileges on any columns that may be added to the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_ NAME in the future. REFERENCESThe user will automatically be granted REFERENCES privileges on any columns that may be added to the table identified by TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME in the future. 5) The values of IS_GRANTABLE have the following meanings: YES The privilege being described was granted WITH GRANT OPTION and is thus grantable. NO The privilege being described was not granted WITH GRANT OPTION and is thus not grantable. Information Schema and Definition Schema 601 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.21 COLUMN_PRIVILEGES base table Function The COLUMN_PRIVILEGES table has one row for each column privilege descriptor. It effectively contains a representation of the column privilege descriptors. Definition CREATE TABLE COLUMN_PRIVILEGES ( GRANTOR INFORMATION_SCHEMA.SQL_IDENTIFIER, GRANTEE INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, COLUMN_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, PRIVILEGE_TYPE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT COLUMN_PRIVILEGES_TYPE_CHECK CHECK ( PRIVILEGE_TYPE IN ( 'SELECT', 'INSERT', 'UPDATE', 'REFERENCES' ) ), IS_GRANTABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT COLUMN_PRIVILEGES_IS_GRANTABLE_NOT_NULL NOT NULL CONSTRAINT COLUMN_PRIVILEGES_IS_GRANTABLE_CHECK CHECK ( IS_GRANTABLE IN ( 'YES', 'NO' ) ), CONSTRAINT COLUMN_PRIVILEGES_PRIMARY_KEY PRIMARY KEY ( GRANTOR, GRANTEE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_ NAME, PRIVILEGE_TYPE, COLUMN_NAME ), CONSTRAINT COLUMN_PRIVILEGES_FOREIGN_KEY_COLUMNS FOREIGN KEY ( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_ NAME ) REFERENCES COLUMNS, CONSTRAINT COLUMN_PRIVILEGES_GRANTOR_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTOR ) REFERENCES USERS, CONSTRAINT COLUMN_PRIVILEGES_GRANTEE_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTEE ) REFERENCES USERS ) 602 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema Description 1) The value of GRANTOR is the of the user who granted column privileges, on the column identified by TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME, to the user identified by the value of GRANTEE for the column privilege being described. 2) The value of GRANTEE is the of some user, or "PUBLIC" to indicate all users, to whom the column privilege being described is granted. 3) The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the column to which the privilege being described was granted. 4) The values of PRIVILEGE_TYPE have the following meanings: SELECT The user has SELECT privilege on the column identified by TABLE_CATALOG.TABLE_SCHEMA.TABLE_NAME.COLUMN_NAME. INSERT The user has INSERT privilege on the column identified by TABLE_CATALOG.TABLE_SCHEMA.TABLE_NAME.COLUMN_NAME. UPDATE The user has UPDATE privilege on the column identified by TABLE_CATALOG.TABLE_SCHEMA.TABLE_NAME.COLUMN_NAME. REFERENCE The user has REFERENCES privilege on the column identified by TABLE_CATALOG.TABLE_SCHEMA.TABLE_ NAME.COLUMN_NAME. 5) The values of IS_GRANTABLE have the following meanings: YES The privilege being described was granted WITH GRANT OPTION and is thus grantable. NO The privilege being described was not granted WITH GRANT OPTION and is thus not grantable. Information Schema and Definition Schema 603 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.22 USAGE_PRIVILEGES base table Function The USAGE_PRIVILEGES table has one row for each usage privilege descriptor. It effectively contains a representation of the usage privilege descriptors. Definition CREATE TABLE USAGE_PRIVILEGES ( GRANTOR INFORMATION_SCHEMA.SQL_IDENTIFIER, GRANTEE INFORMATION_SCHEMA.SQL_IDENTIFIER, OBJECT_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, OBJECT_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, OBJECT_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, OBJECT_TYPE INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT USAGE_PRIVILEGES_OBJECT_TYPE_CHECK CHECK ( OBJECT_TYPE IN ( 'DOMAIN', 'CHARACTER SET', 'COLLATION', 'TRANSLATION' ) ), IS_GRANTABLE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT USAGE_PRIVILEGES_IS_GRANTABLE_NOT_NULL NOT NULL CONSTRAINT USAGE_PRIVILEGES_IS_GRANTABLE_CHECK CHECK ( IS_GRANTABLE IN ( 'YES', 'NO' ) ), CONSTRAINT USAGE_PRIVILEGES_PRIMARY_KEY PRIMARY KEY ( GRANTOR, GRANTEE, OBJECT_CATALOG, OBJECT_ SCHEMA, OBJECT_NAME, OBJECT_TYPE ), CONSTRAINT USAGE_PRIVILEGES_CHECK_REFERENCES_OBJECT CHECK ( ( OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_NAME, OBJECT_ TYPE ) IN ( SELECT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME,'DOMAIN' FROM DOMAINS UNION SELECT CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_ SET_NAME, 'CHARACTER SET' FROM CHARACTER_SETS UNION SELECT COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME, 'COLLATION' FROM COLLATIONS UNION SELECT TRANSLATION_CATALOG, TRANSLATION_SCHEMA, TRANSLATION_ NAME, 'TRANSLATION' FROM TRANSLATIONS ) ), 604 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema CONSTRAINT USAGE_PRIVILEGES_GRANTOR_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTOR ) REFERENCES USERS, CONSTRAINT USAGE_PRIVILEGES_GRANTEE_FOREIGN_KEY_USERS FOREIGN KEY ( GRANTEE ) REFERENCES USERS ) Description 1) The value of GRANTOR is the of the user who granted usage privileges, on the object of the type identified by OBJECT_TYPE that is identified by OBJECT_CATALOG, OBJECT_SCHEMA, and OBJECT_NAME, to the user identified by the value of GRANTEE for the usage privilege being described. 2) The value of GRANTEE is the of some user, or "PUBLIC" to indicate all users, to whom the usage priv- ilege being described is granted. 3) The values of OBJECT_CATALOG, OBJECT_SCHEMA, and OBJECT_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the object to which the privilege applies. 4) The values of OBJECT_TYPE has the following meanings: DOMAIN The object to which the privilege applies is a domain. CHARACTER The object to which the privilege applies is a SET character set. COLLATION The object to which the privilege applies is a collation. TRANSLATION The object to which the privilege applies is a translation. 5) The values of IS_GRANTABLE have the following meanings: YES The privilege being described was granted WITH GRANT OPTION and is thus grantable. NO The privilege being described was not granted WITH GRANT OPTION and is thus not grantable. Information Schema and Definition Schema 605 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.23 CHARACTER_SETS base table Function The CHARACTER_SETS table has one row for each character set de- scriptor. Definition CREATE TABLE CHARACTER_SETS ( CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, FORM_OF_USE INFORMATION_SCHEMA.SQL_IDENTIFIER, NUMBER_OF_CHARACTERS INFORMATION_SCHEMA.CARDINAL_ NUMBER, DEFAULT_COLLATE_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT CHARACTER_SETS_DEFAULT_COLLATE_CATALOG_NOT_ NULL NOT NULL, DEFAULT_COLLATE_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT CHARACTER_SETS_DEFAULT_COLLATE_SCHEMA_NOT_ NULL NOT NULL, DEFAULT_COLLATE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT CHARACTER_SETS_DEFAULT_COLLATE_NAME_NOT_ NULL NOT NULL, CONSTRAINT CHARACTER_SETS_PRIMARY_KEY PRIMARY KEY ( CHARACTER_SET_CATALOG, CHARACTER_SET_ SCHEMA, CHARACTER_SET_NAME ), CONSTRAINT CHARACTER_SETS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT CHARACTER_SETS_CHECK_REFERENCES_COLLATIONS CHECK ( CHARACTER_SET_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( DEFAULT_COLLATE_CATALOG, DEFAULT_COLLATE_SCHEMA, DEFAULT_COLLATE_NAME ) IN ( SELECT COLLATION_CATALOG, COLLATION_ SCHEMA, COLLATION_NAME FROM COLLATIONS ) ) ) 606 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema Description 1) The values of CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_SET_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the character set being described. 2) The value of FORM_OF_USE is the name of the form-of-use of the character set. 3) The value of NUMBER_OF_CHARACTERS is the number of characters in the character repertoire. 4) Case: a) If the default collation for the character repertoire is the order of characters in the repertoire, then the val- ues of DEFAULT_COLLATE_CATALOG and DEFAULT_COLLATE_SCHEMA are the values of CHARACTER_SET_CATALOG and CHARACTER_SET_ SCHEMA, respectively, and the value of DEFAULT_COLLATE_NAME is implementation-dependent. b) Otherwise, the values of DEFAULT_COLLATE_CATALOG, DEFAULT_ COLLATE_SCHEMA, and DEFAULT_COLLATE_NAME are catalog name, unqualified schema name, and qualified identifier, respec- tively, of the default collation. 5) There is a row in this table for the character set INFORMATION_ SCHEMA.SQL_TEXT. In that row: a) CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_ SET_NAME are the name of the catalog, 'INFORMATION_SCHEMA', and 'SQL_TEXT', respectively. b) FORM_OF_USE is implementation-defined. c) NUMBER_OF_CHARACTERS is implementation-defined. d) DEFAULT_COLLATE_CATALOG, DEFAULT_COLLATE_SCHEMA, and DEFAULT_ COLLATE_NAME are the name of the catalog, 'INFORMATION_ SCHEMA', and 'SQL_TEXT', respectively. Information Schema and Definition Schema 607 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.24 COLLATIONS base table Function The COLLATIONS table has one row for each character collation de- scriptor. Definition CREATE TABLE COLLATIONS ( COLLATION_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, COLLATION_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, COLLATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT COLLATIONS_CHARACTER_SET_CATALOG_NOT_NULL NOT NULL, CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT COLLATIONS_CHARACTER_SET_SCHEMA_NOT_NULL NOT NULL, CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER CONSTRAINT COLLATIONS_CHARACTER_SET_NAME_NOT_NULL NOT NULL, PAD_ATTRIBUTE INFORMATION_SCHEMA.CHARACTER_DATA CONSTRAINT COLLATIONS_PAD_ATTRIBUTE_CHECK CHECK ( PAD_ATTRIBUTE IN ( 'NO PAD', 'PAD SPACE' ) ), CONSTRAINT COLLATIONS_PRIMARY_KEY PRIMARY KEY ( COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_ NAME ), CONSTRAINT COLLATIONS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( COLLATION_CATALOG, COLLATION_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT COLLATIONS_CHECK_REFERENCES_CHARACTER_SETS CHECK ( COLLATION_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_ SET_NAME ) IN ( SELECT CHARACTER_SET_CATALOG, CHARACTER_ SET_SCHEMA, CHARACTER_SET_NAME FROM CHARACTER_SETS ) ) ) 608 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema Description 1) The values of COLLATION_CATALOG, COLLATION_SCHEMA, and COLLATION_ NAME are the catalog name, unqualified schema name, and quali- fied identifier, respectively, of the collation being defined. 2) The values of CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_SET_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the character set on which the collation is defined. 3) The values of PAD_ATTRIBUTE have the following meanings: NO PAD The collation being described has the NO PAD at- tribute. PAD SPACE The collation being described has the PAD SPACE attribute. 4) A row always exists in this table for the collation SQL_TEXT. That row contains the definition of the collation corresponding to the default collation for the characters in the character set SQL_TEXT. In that row: a) COLLATION_CATALOG, COLLATION_SCHEMA, and COLLATION_NAME are the name of the catalog, 'INFORMATION_SCHEMA', and 'SQL_ TEXT', respectively. b) CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, and CHARACTER_ SET_NAME are the name of the catalog, 'INFORMATION_SCHEMA', and 'SQL_TEXT', respectively. c) PAD_ATTRIBUTE is implementation-defined. Information Schema and Definition Schema 609 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.25 TRANSLATIONS base table Function The TRANSLATIONS table has one row for each character translation descriptor. Definition CREATE TABLE TRANSLATIONS ( TRANSLATION_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER, TRANSLATION_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER, TRANSLATION_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER, SOURCE_CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_SOURCE_CHARACTER_SET_CATALOG_NOT_ NULL NOT NULL, SOURCE_CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_SOURCE_CHARACTER_SET_SCHEMA_NOT_ NULL NOT NULL, SOURCE_CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_SOURCE_CHARACTER_SET_NAME_NOT_ NULL NOT NULL, TARGET_CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_TARGET_CHARACTER_SET_CATALOG_NOT_ NULL NOT NULL, TARGET_CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_TARGET_CHARACTER_SET_SCHEMA_NOT_ NULL NOT NULL, TARGET_CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_ IDENTIFIER CONSTRAINT TRANSLATIONS_TARGET_CHARACTER_SET_NAME_NOT_ NULL NOT NULL, CONSTRAINT TRANSLATIONS_PRIMARY_KEY PRIMARY KEY ( TRANSLATION_CATALOG, TRANSLATION_SCHEMA, TRANSLATION_ NAME ), CONSTRAINT TRANSLATIONS_FOREIGN_KEY_SCHEMATA FOREIGN KEY ( TRANSLATION_CATALOG, TRANSLATION_SCHEMA ) REFERENCES SCHEMATA, CONSTRAINT TRANSLATIONS_CHECK_REFERENCES_SOURCE CHECK ( SOURCE_CHARACTER_SET_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) 610 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema OR ( SOURCE_CHARACTER_SET_CATALOG, SOURCE_CHARACTER_ SET_SCHEMA, SOURCE_CHARACTER_SET_NAME ) IN ( SELECT CHARACTER_SET_CATALOG, CHARACTER_SET_ SCHEMA, CHARACTER_SET_NAME FROM CHARACTER_SETS ) ), CONSTRAINT TRANSLATIONS_CHECK_REFERENCES_TARGET CHECK ( TARGET_CHARACTER_SET_CATALOG <> ANY ( SELECT CATALOG_NAME FROM SCHEMATA ) OR ( TARGET_CHARACTER_SET_CATALOG, TARGET_CHARACTER_ SET_SCHEMA, TARGET_CHARACTER_SET_NAME ) IN ( SELECT CHARACTER_SET_CATALOG, CHARACTER_SET_ SCHEMA, CHARACTER_SET_NAME FROM CHARACTER_SETS ) ) ) Description 1) The values of TRANSLATION_CATALOG, TRANSLATION_SCHEMA, and TRANSLATION_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the translation being described. 2) The values of SOURCE_CHARACTER_SET_CATALOG, SOURCE_CHARACTER_ SET_SCHEMA, and SOURCE_CHARACTER_SET_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the character set specified as the source for the transla- tion. 3) The values of TARGET_CHARACTER_SET_CATALOG, TARGET_CHARACTER_ SET_SCHEMA, and TARGET_CHARACTER_SET_NAME are the catalog name, unqualified schema name, and qualified identifier, respectively, of the character set specified as the target for the transla- tion. Information Schema and Definition Schema 611 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 21.3.26 SQL_LANGUAGES base table Function The SQL_LANGUAGES table has one row for each ISO and implementation- defined SQL language binding and programming language for which conformance is claimed. Definition CREATE TABLE SQL_LANGUAGES ( SQL_LANGUAGE_SOURCE INFORMATION_SCHEMA.CHARACTER_ DATA CONSTRAINT SQL_LANGUAGES_SOURCE_NOT_NULL NOT NULL, SQL_LANGUAGE_YEAR INFORMATION_SCHEMA.CHARACTER_ DATA, SQL_LANGUAGE_CONFORMANCE INFORMATION_SCHEMA.CHARACTER_ DATA, SQL_LANGUAGE_INTEGRITY INFORMATION_SCHEMA.CHARACTER_ DATA, SQL_LANGUAGE_IMPLEMENTATION INFORMATION_SCHEMA.CHARACTER_ DATA, SQL_LANGUAGE_BINDING_STYLE INFORMATION_SCHEMA.CHARACTER_ DATA, SQL_LANGUAGE_PROGRAMMING_LANGUAGE INFORMATION_SCHEMA.CHARACTER_ DATA, CONSTRAINT SQL_LANGUAGES_STANDARD_VALID_CHECK CHECK ( ( SQL_LANGUAGE_SOURCE = 'ISO 9075' AND SQL_LANGUAGE_YEAR IS NOT NULL AND SQL_LANGUAGE_CONFORMANCE IS NOT NULL AND SQL_LANGUAGE_IMPLEMENTATION IS NULL AND ( ( SQL_LANGUAGE_YEAR = '1987' AND SQL_LANGUAGE_CONFORMANCE IN ( '1', '2' ) AND SQL_LANGUAGE_INTEGRITY IS NULL AND ( ( SQL_LANGUAGE_BINDING_STYLE = 'DIRECT' AND SQL_LANGUAGE_PROGRAMMING_LANGUAGE IS NULL ) OR ( SQL_LANGUAGE_BINDING_STYLE IN ( 'EMBEDDED', 'MODULE' ) AND SQL_LANGUAGE_PROGRAMMING_LANGUAGE IN ( 'COBOL', 'FORTRAN', 'PASCAL', 'PLI' ) ) ) ) OR ( SQL_LANGUAGE_YEAR = '1989' AND AND SQL_LANGUAGE_CONFORMANCE IN ( '1', '2' ) AND SQL_LANGUAGE_INTEGRITY IN ( 'NO', 'YES' ) AND 612 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema ( ( SQL_LANGUAGE_BINDING_STYLE = 'DIRECT' AND SQL_LANGUAGE_PROGRAMMING_LANGUAGE IS NULL ) OR ( SQL_LANGUAGE_BINDING_STYLE IN ( 'EMBEDDED', 'MODULE' ) AND SQL_LANGUAGE_PROGRAMMING_LANGUAGE IN ( 'COBOL', 'FORTRAN', 'PASCAL', 'PLI' ) ) ) ) OR ( SQL_LANGUAGE_YEAR = '1992' AND SQL_LANGUAGE_CONFORMANCE IN ( 'ENTRY', 'INTERMEDIATE', 'FULL' ) AND SQL_LANGUAGE_INTEGRITY IS NULL AND ( ( SQL_LANGUAGE_BINDING = 'DIRECT' AND SQL_LANGUAGE_PROGRAMMING_LANGUGE IS NULL ) OR ( SQL_LANGUAGE_BINDING IN ( 'EMBEDDED', 'MODULE' ) AND SQL_LANGUAGE_PROGRAMMING_LANGUAGE IN ( 'ADA', 'C', 'COBOL', 'FORTRAN', 'MUMPS', 'PASCAL', 'PLI' ) ) ) ) ) ) OR ( SQL_LANGUAGE_SOURCE <> 'ISO 9075' ) ) ) Description 1) Each row represents one binding of an ISO or implementation- defined SQL language to a standard module language, direct invocation, or an embedded programming language. 2) The value of SQL_LANGUAGE_SOURCE is the name of the source of the language definition. The source of standard SQL language is the value 'ISO 9075', while the source of an implementation- defined version of SQL is implementation-defined. 3) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075', then the value of SQL_LANGUAGE_YEAR is the year that the ISO standard was approved. Otherwise, the value of SQL_LANGUAGE_YEAR is implementation-defined. Note: As each new ISO SQL standard revision is approved, a new valid value of SQL_LANGUAGE_YEAR must be added to the CHECK constraint for this column. Information Schema and Definition Schema 613 X3H2-92-154/DBL CBR-002 21.3 Definition Schema 4) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075', then the value of SQL_LANGUAGE_CONFORMANCE is the conformance level to which conformance is claimed for the ISO standard. Otherwise, the value of SQL_LANGUAGE_CONFORMANCE is implementation-defined. 5) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075' and that language contains an optional integrity enhancement feature, then the value of SQL_LANGUAGE_INTEGRITY is 'YES' if confor- mance is claimed to the integrity enhancement feature, and 'NO' otherwise. Otherwise, the value of SQL_LANGUAGE_INTEGRITY is implementation-defined. 6) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075', then the value of SQL_LANGUAGE_IMPLEMENTATION is null. Otherwise, the value of SQL_LANGUAGE_IMPLEMENTATION is an implementation- defined character string value. 7) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075', then the value of SQL_LANGUAGE_BINDING_STYLE is the style of binding of the SQL language. If the value of SQL_LANGUAGE_BINDING_STYLE is 'MODULE', then the binding style of is supported. If the value of SQL_LANGUAGE_BINDING_STYLE is 'EMBEDDED', then the binding style of is supported. If the value of SQL_LANGUAGE_BINDING_STYLE is 'DIRECT', then the binding style of is supported. Otherwise, the value of SQL_LANGUAGE_BINDING_STYLE is implementation- defined. 8) If the value of SQL_LANGUAGE_SOURCE is 'ISO 9075', then the value of SQL_LANGUAGE_PROGRAMMING_LANGUAGE is the program- ming language supported by the binding style indicated by the value of SQL_LANGUAGE_BINDING_STYLE. If the value of SQL_LANGUAGE_BINDING_STYLE is 'DIRECT', then SQL_LANGUAGE_ PROGRAMMING_LANGUAGE is the null value. If the value of SQL_ LANGUAGE_BINDING_STYLE is 'MODULE' or 'EMBEDDED', then SQL_ LANGUAGE_PROGRAMMING_LANGUAGE has the value 'ADA', 'C', 'COBOL', 'FORTRAN', 'MUMPS', 'PASCAL', or 'PLI'. Case: a) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'ADA', then Ada is supported with the given binding style. b) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'C', then C is sup- ported with the given binding style. c) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'COBOL', then COBOL is supported with the given binding style. d) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'FORTRAN', then Fortran is supported with the given binding style. e) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'MUMPS', then MUMPS is supported with the given binding style. 614 Database Language SQL X3H2-92-154/DBL CBR-002 21.3 Definition Schema f) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'PASCAL', then Pascal is supported with the given binding style. g) If SQL_LANGUAGE_PROGRAMMING_LANGUAGE is 'PLI', then PL/I is supported with the given binding style. Otherwise, the value of SQL_LANGUAGE_PROGRAMMING_LANGUAGE is implementation-defined. Information Schema and Definition Schema 615 X3H2-92-154/DBL CBR-002 21.4 Assertions on the base tables 21.4 Assertions on the base tables The following clauses specify assertions that apply to the base tables specified in Subclause 21.3, "Definition Schema". The paramount criterion in formulating these assertions (after cor- rectness) is ease of understanding for the human reader. There may well be formulations of the same assertions that are more effi- cient for some SQL-implementation, and quite possibly for all such implementations. 21.4.1 UNIQUE_CONSTRAINT_NAME assertion Function The UNIQUE_CONSTRAINT_NAME assertion ensures that the same combi- nation of and is not used by more than one constraint. Note: The UNIQUE_CONSTRAINT_NAME assertion avoids the need for separate checks on DOMAINS, TABLE_CONSTRAINTS, and ASSERTIONS. Definition CREATE ASSERTION UNIQUE_CONSTRAINT_NAME CHECK ( 1 = ( SELECT MAX ( OCCURRENCES ) FROM ( SELECT COUNT (*) AS OCCURRENCES FROM ( SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM DOMAIN_CONSTRAINTS UNION ALL SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM TABLE_CONSTRAINTS UNION ALL SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME FROM ASSERTIONS ) GROUP BY CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) ) ) Description 1) The UNIQUE_CONSTRAINT_NAME assertion checks that no combination of (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME) appears more than once in the tables DOMAINS, TABLE_CONSTRAINTS and ASSERTIONS. 616 Database Language SQL X3H2-92-154/DBL CBR-002 21.4 Assertions on the base tables 21.4.2 EQUAL_KEY_DEGREES assertion Function The assertion EQUAL_KEY_DEGREES ensures that every foreign key is of the same degree as the corresponding unique constraint. Definition CREATE ASSERTION EQUAL_KEY_DEGREES CHECK ( NOT EXISTS ( SELECT * FROM ( SELECT COUNT ( DISTINCT FK.COLUMN_NAME ), COUNT ( DISTINCT PK.COLUMN_NAME ) FROM KEY_COLUMN_USAGE AS FK, REFERENTIAL_CONSTRAINTS AS RF, KEY_COLUMN_USAGE AS PK WHERE ( FK.CONSTRAINT_CATALOG, FK.CONSTRAINT_ SCHEMA, FK.CONSTRAINT_NAME ) = ( RF.CONSTRAINT_CATALOG, RF.CONSTRAINT_ SCHEMA, RF.CONSTRAINT_NAME ) AND ( PK.CONSTRAINT_CATALOG, PK.CONSTRAINT_ SCHEMA, PK.CONSTRAINT_NAME ) = ( RF.UNIQUE_CONSTRAINT_CATALOG, RF.UNIQUE_ CONSTRAINT_SCHEMA, RF.UNIQUE_CONSTRAINT_NAME ) GROUP BY RF.CONSTRAINT_CATALOG, RF.CONSTRAINT_SCHEMA, RF.CONSTRAINT_ NAME ) AS REF ( FK_DEGREE, PK_DEGREE ) WHERE FK_DEGREE <> PK_DEGREE ) ) Information Schema and Definition Schema 617 X3H2-92-154/DBL CBR-002 21.4 Assertions on the base tables 21.4.3 KEY_DEGREE_GREATER_THAN_OR_EQUAL_TO_1 assertion Function The assertion KEY_DEGREE_GREATER_THAN_OR_EQUAL_TO_1 ensures that every unique or primary key constraint has at least one unique column and that every referential constraint has at least one ref- erencing column. Definition CREATE ASSERTION KEY_DEGREE_GREATER_THAN_OR_EQUAL_TO_1 CHECK ( NOT EXISTS ( SELECT * FROM TABLE_CONSTRAINTS FULL OUTER JOIN KEY_COLUMN_USAGE USING ( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_ NAME ) WHERE COLUMN_NAME IS NULL AND CONSTRAINT_TYPE IN ( 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY' ) ) ) 618 Database Language SQL X3H2-92-154/DBL CBR-002 22 Status codes 22.1 SQLSTATE The character string value returned in an SQLSTATE parameter com- prises a 2-character class value followed by a 3-character subclass value, each with an implementation-defined character set that has a one-octet form-of-use and is restricted to s and s. Table 23, "SQLSTATE class and sub- class values", specifies the class value for each condition and the subclass value or values for each class value. Class values that begin with one of the s '0', '1', '2', '3', or '4' or one of the s 'A', 'B', 'C', 'D', 'E', 'F', 'G', or 'H' are returned only for con- ditions defined in this International Standard or in any other International Standard. The class value 'HZ' is reserved for con- ditions defined in ISO/IEC DIS 9579-2. Subclass values associated with such classes that also begin with one of those 13 characters are returned only for conditions defined in this International Standard; subclass values associated with such classes that begin with one of the s '5', '6', '7', '8', or '9' or one of the s 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', or 'Z' are reserved for implementation-specified conditions and are called implementation-defined subclasses. Class values that begin with one of the s '5', '6', '7', '8', or '9' or one of the s 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', or 'Z' are reserved for implementation-specified conditions and are called implementation-defined classes. All sub- class values except '000', which means no subclass, associated with such classes are reserved for implementation-specified conditions and are called implementation-defined subclasses. If a subclass value is not specified for a condition, then either subclass '000' or an implementation-defined subclass is returned. An implementation-specified condition may duplicate a condition de- fined in this International Standard; however, if such a condition occurs as a result of executing a statement, then the corresponding implementation-defined SQLSTATE value shall not be returned in the SQLSTATE parameter but may be returned in the diagnostics area. ____________Table_23-SQLSTATE_class_and_subclass_values____________ _Condition__________________Class_Subcondition_______________Subclass | ambiguous cursor name | 3C | (no subclass) | 000 | | | | | | | | | | | Status codes 619 X3H2-92-154/DBL CBR-002 22.1 SQLSTATE ________Table_23-SQLSTATE_class_and_subclass_values_(Cont.)________ _Condition__________________Class_Subcondition_______________Subclass | cardinality violation | 21 | (no subclass) | 000 | | | | | | | connection exception | 08 | (no subclass) | 000 | | | | | | | | | connection does not | 003 | exist | | | connection failure | 006 | | | | | | | | | connection name in use | 002 | | | | | | | | | SQL-client unable to | 001 | establish SQL-connection | | | SQL-server rejected | 004 | | | | establishment of SQL- | | connection | | | transaction resolution | 007 | | | | unknown | | | | | | | | data exception | 22 | (no subclass) | 000 | | | | | | | | | character not in reper- | 021 | toire | | | datetime field overflow | 008 | | | | | | | | | division by zero | 012 | | | | | | | | | error in assignment | 005 | | | | | | | | | indicator overflow | 022 | | | | | | | | | interval field overflow | 015 | | | | | | | | | invalid character value | 018 | for cast | | | invalid datetime format | 007 | | | | | | | | | invalid escape character | 019 | | | | | | | | | invalid escape sequence | 025 | | | | | | | | | invalid parameter value | 023 | | | | | | | | | invalid time zone dis- | 009 | placement value | | | null value, no indicator | 002 | | | | parameter | | | | | | | | | | numeric value out of | 003 | | | | range | | | | | | | | | | string data, length | 026 | | | | mismatch | | | | | | | 620 Database Language SQL X3H2-92-154/DBL CBR-002 22.1 SQLSTATE ________Table_23-SQLSTATE_class_and_subclass_values_(Cont.)________ _Condition__________________Class_Subcondition_______________Subclass | | | string data, right | 001 | truncation | | | substring error | 011 | | | | | | | | | trim error | 027 | | | | | | | | | unterminated C string | 024 | | | | | | | dependent privilege | 2B | (no subclass) | 000 | descriptors still exist | dynamic SQL error | 07 | (no subclass) | 000 | | | | | | | | | cursor specification | 003 | cannot be executed | | | invalid descriptor count | 008 | | | | | | | | | invalid descriptor index | 009 | | | | | | | | | prepared statement not a | 005 | cursor specification | | | restricted data type | 006 | | | | attribute violation | | | | | | | | | | using clause does not | 001 | | | | match dynamic parameter | | specifications | | | using clause does not | 002 | | | | match target specifica- | | | | | tions | | | | | | | | | | using clause required | 004 | | | | for dynamic parameters | | | | | | | | | | using clause required | 007 | | | | for result fields | | | | | | | | feature not supported | 0A | (no subclass) | 000 | | | | | | | | | multiple server transac- | 001 | tions | integrity constraint | 23 | (no subclass) | 000 | | violation | | | | | | | | | | invalid authorization | 28 | (no subclass) | 000 | | specification | | | | | | | | | | invalid catalog name | 3D | (no subclass) | 000 | | | | | | | invalid character set | 2C | (no subclass) | 000 | name | invalid condition number | 35 | (no subclass) | 000 | | | | | | Status codes 621 X3H2-92-154/DBL CBR-002 22.1 SQLSTATE ________Table_23-SQLSTATE_class_and_subclass_values_(Cont.)________ _Condition__________________Class_Subcondition_______________Subclass | invalid connection name | 2E | (no subclass) | 000 | | | | | | | invalid cursor name | 34 | (no subclass) | 000 | | | | | | | invalid cursor state | 24 | (no subclass) | 000 | | | | | | | invalid schema name | 3F | (no subclass) | 000 | | | | | | | invalid SQL descriptor | 33 | (no subclass) | 000 | name | invalid SQL statement | 26 | (no subclass) | 000 | | name | | | | | | | | | | invalid transaction | 25 | (no subclass) | 000 | | state | | | | | | | | | | invalid transaction | 2D | (no subclass) | 000 | | termination | | | | | | | | | | no data | 02 | (no subclass) | 000 | | | | | | | Remote Database Access | HZ | (See ISO/IEC 9579-2 for | | the definition of pro- tocol subconditions and subclass code values) | successful completion | 00 | (no subclass) | 000 | | | | | | | syntax error or access | 42 | (no subclass) | 000 | | rule violation | | | | | | | | | | syntax error or access | 2A | (no subclass) | 000 | | rule violation in direct | | | | SQL statement | syntax error or ac- | 37 | (no subclass) | 000 | | cess rule violation in | | | | | dynamic SQL statement | | | | | | | | | | transaction rollback | 40 | (no subclass) | 000 | | | | | | | | | integrity constraint | 002 | | | | violation | | | | | serialization failure | 001 | | | | | | | | | statement completion | 003 | unknown | triggered data change | 27 | (no subclass) | 000 | | violation | | | | | | | | | | warning | 01 | (no subclass) | 000 | | | | | | | | | cursor operation con- | 001 | flict 622 Database Language SQL X3H2-92-154/DBL CBR-002 22.1 SQLSTATE ________Table_23-SQLSTATE_class_and_subclass_values_(Cont.)________ _Condition__________________Class_Subcondition_______________Subclass | | | disconnect error | 002 | | | | | | | | | implicit zero-bit | 008 | padding | | | insufficient item de- | 005 | | | | scriptor areas | | | | | | | | | | null value eliminated in | 003 | | | | set function | | | | | | | | | | privilege not granted | 007 | | | | | | | | | privilege not revoked | 006 | | | | | | | | | query expression too | 00A | long for information schema | | | search condition too | 009 | | | | long for information | | | | | schema | | | | | | | | | | string data, right | 004 | | | | truncation | | | | | | | | with check option viola- | 44 | (no subclass) | 000 | |_tion_____________________|_____|__________________________|______| | | | | | | | | | | | | | | | Status codes 623 X3H2-92-154/DBL CBR-002 22.2 SQLCODE 22.2 SQLCODE Table 24, "SQLCODE values", specifies the integer value returned in an SQLCODE parameter for each condition. The negative values that indicate exception conditions are implementation-defined. ______________________Table_24-SQLCODE_values______________________ _Value__Condition__________________________________________________ | 0 | successful completion | | | | | +100 | no data | | | | |_-n___|_exception_________________________________________________| | | | Note: SQLSTATE is the preferred status parameter. The SQLCODE sta- tus parameter is a deprecated feature that is supported for compat- ibility with earlier versions of this International Standard. See Annex D, "Deprecated features". 624 Database Language SQL X3H2-92-154/DBL CBR-002 23 Conformance 23.1 Introduction This International Standard specifies conforming SQL language and conforming SQL-implementations. Conforming SQL language shall abide by the BNF Format, associated Syntax Rules and Access Rules, definitions, and descriptions. A conforming SQL-implementation shall process conforming SQL lan- guage according to the associated General Rules, definitions, and descriptions. The object identifier for Database Language SQL is specified in Subclause 3.4, "Object identifier for Database Language SQL". 23.2 Claims of conformance Claims of conformance to this International Standard shall state: 1) Which level of conformance is claimed: a) Full SQL (The complete database language specified in this International Standard.) b) Intermediate SQL (Intermediate SQL is a subset of Full SQL as specified in the Leveling Rules.) c) Entry SQL (Entry SQL is a subset of Intermediate SQL as spec- ified in the Leveling Rules.) 2) Which of the following binding styles are supported: a) Module () b) Embedded syntax () c) Direct invocation and processing of SQL language () 3) For the binding styles module or embedded syntax, which of the following programming languages are supported: a) Ada b) C c) COBOL d) Fortran Conformance 625 X3H2-92-154/DBL CBR-002 23.2 Claims of conformance e) MUMPS f) Pascal g) PL/I 4) The definitions for all elements and actions that this Standard specifies as implementation-defined. 23.3 Extensions and options A conforming implementation may provide additional facilities or options not specified by this International Standard. This may im- ply an implementation-defined extension of the list of reserved words () and thereby may prevent proper process- ing of some programs that otherwise meet the requirements of this International Standard. An implementation remains conforming even if it provides user op- tions to process nonconforming SQL language or to process conform- ing SQL language in a nonconforming manner. 23.4 Flagger requirements Implementations that claim conformance only to Entry SQL may, but are not required to, provide an SQL Flagger (see Subclause 4.34, "SQL Flagger"). Implementations that claim conformance to Intermediate SQL shall provide an SQL Flagger (see Subclause 4.34, "SQL Flagger") that supports the following "level of flagging" options: - Entry SQL Flagging - Intermediate SQL Flagging and the following "extent of checking" option: - Syntax Only Implementations that claim conformance to Full SQL shall provide an SQL Flagger (see Subclause 4.34, "SQL Flagger") that supports the following "level of flagging" options: - Entry SQL Flagging - Intermediate SQL Flagging - Full SQL Flagging and the following "extent of checking" options: - Syntax Only 626 Database Language SQL X3H2-92-154/DBL CBR-002 23.4 Flagger requirements - Catalog Lookup 23.5 Processing methods This International Standard does not define the method by which an is processed. Although the processing of is defined in terms of derivation of a program compliant with a programming language standard and a , implementations of SQL are not constrained to follow that method, provided that effect is achieved. Although the processing of is defined in terms of calls to s in a , implementations of Direct Invocation are not constrained to follow that method, so long as the same effect is achieved. Conformance 627 628 Database Language SQL X3H2-92-154/DBL CBR-002 Annex A (informative) Leveling the SQL Language This Annex describes the restrictions placed on conforming Intermediate SQL and Entry SQL language. A.1 Intermediate SQL Specifications 1) Subclause 5.2, " and ": a) In conforming Intermediate SQL language, a or a shall not comprise more than 18 s. b) A shall not be a or a . c) Conforming Intermediate SQL language shall contain no that ends in an . 2) Subclause 5.3, "": a) An that is a shall not contain more than 6 s. b) A or shall not be a or a . c) A shall not specify a . 3) Subclause 5.4, "Names and identifiers": a) Conforming Intermediate SQL language shall not contain any or . b) Conforming Intermediate SQL language shall not contain any . c) Conforming Intermediate SQL language shall not contain any explicit . Leveling the SQL Language 629 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications d) Conforming Intermediate SQL language shall not contain any or . e) An shall not specify a . 4) Subclause 6.1, "": a) A shall not specify a
": a) A
shall not be a . 7) Subclause 6.5, "": a) If a specifies DISTINCT, then the shall be a . 8) Subclause 6.6, "": a) A shall not be a . b) A shall not contain a that is a . 9) Subclause 6.7, "": a) A shall not be a . b) Conforming Intermediate SQL language shall contain no . c) Conforming Intermediate SQL language shall contain no . d) Conforming Intermediate SQL language shall contain no . 10)Subclause 6.8, "": a) Conforming Intermediate SQL language shall contain no
shall not contain more than one . 13)Subclause 7.2, "
": a) A
shall contain exactly one that shall be of the form "()". b) A
shall be the of an . 14)Subclause 7.3, "
": a) If the table identified in the is a grouped view, then the
shall not contain a , , or . 15)Subclause 7.4, "": a) A
shall not be a . b) If the table identified by
is a grouped view, then the shall contain exactly one
. 16)Subclause 7.5, "": a) Conforming Intermediate SQL language shall contain no . b) Conforming Intermediate SQL language shall not specify UNION JOIN. 17)Subclause 7.7, "": a) Conforming Intermediate SQL language shall not contain any . 18)Subclause 7.9, "": a) The DISTINCT shall not be specified more than once in a , excluding any of that . Leveling the SQL Language 631 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications b) If the
of the is a grouped view, then the
except in an . b) Conforming Intermediate SQL shall contain no . 20)Subclause 7.11, ", , and
": a) The contained in a shall be a . 21)Subclause 8.1, "": a) A shall not be a . 22)Subclause 8.4, "": a) Conforming Intermediate SQL language shall not contain a in an that is not a . 23)Subclause 8.10, "": a) Conforming Intermediate SQL language shall not contain any . 24)Subclause 8.12, "": a) A shall not specify a . 25)Subclause 10.3, "": a) An that specifies INSERT shall not contain a . 26)Subclause 10.5, "": a) Conforming Intermediate SQL language shall not contain any . 27)Subclause 11.1, "": a) A shall not be an . b) Conforming Intermediate SQL language shall not contain any . c) Conforming Intermediate SQL language shall not contain any . 632 Database Language SQL X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 28)Subclause 11.3, "
": a) Conforming Intermediate SQL language shall not specify GLOBAL TEMPORARY and shall not reference any global temporary table. 29)Subclause 11.4, "": a) A shall not be specified, but INITIALLY IMMEDIATE and NOT DEFERRABLE are implicit. b) Conforming Intermediate SQL language shall not contain any . 30)Subclause 11.6, "
": a) A shall not be specified, but INITIALLY IMMEDIATE and NOT DEFERRABLE are implicit. 31)Subclause 11.8, "": a) A shall not specify MATCH. b) A shall not contain an . 32)Subclause 11.9, "": a) The contained in a shall not contain a . b) The REFERENCES privilege is not required for access. 33)Subclause 11.19, "": a) Conforming Intermediate SQL shall not contain any , but the effect shall be that defined for a of CASCADED. 34)Subclause 11.21, "": a) Conforming Intermediate SQL language shall not contain any . 35)Subclause 11.22, "": a) Conforming Intermediate SQL language shall contain no . 36)Subclause 11.23, "": a) Conforming Intermediate SQL language shall contain no . Leveling the SQL Language 633 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 37)Subclause 11.24, "": a) Conforming Intermediate SQL language shall contain no . 38)Subclause 11.25, "": a) Conforming Intermediate SQL language shall contain no . 39)Subclause 11.26, "": a) Conforming Intermediate SQL language shall contain no . 40)Subclause 11.30, "": a) Conforming Intermediate SQL language shall not contain any . 41)Subclause 11.31, "": a) Conforming Intermediate SQL language shall not contain any . 42)Subclause 11.32, "": a) Conforming Intermediate SQL language shall contain no . 43)Subclause 11.33, "": a) Conforming Intermediate SQL language shall contain no . 44)Subclause 11.34, "": a) Conforming Intermediate SQL language shall not contain any . 45)Subclause 11.35, "": a) Conforming Intermediate SQL language shall not contain any . 46)Subclause 11.36, "": a) In Conforming Intermediate SQL language, an shall not specify COLLATION or TRANSLATION. 47)Subclause 12.1, "": a) A shall not contain a . 634 Database Language SQL X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 48)Subclause 12.3, "": a) A shall not specify a that is BIT or BIT VARYING. 49)Subclause 12.5, "": a) An shall not be a . b) An shall not be an . c) An shall not be a . d) An shall not be an statement. e) An shall not be a , a , or a . f) An shall not be a , a , a , or a . g) An , or a . h) An shall not be an . 50)Subclause 13.1, "": a) Conforming Intermediate SQL language shall not specify INSENSITIVE. b) If an of FOR UPDATE with or without a is specified, then neither SCROLL nor ORDER BY shall be specified. 51)Subclause 13.3, "": a) A shall not contain a . 52)Subclause 13.5, "
shall not include a or a and shall not identify a grouped view. 53)Subclause 13.6, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the referenced by the . Leveling the SQL Language 635 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 54)Subclause 13.7, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the . 55)Subclause 13.8, "": a) The base table that would be changed as a result of executing the shall not be identified in any generally contained in the . 56)Subclause 13.9, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the referenced by the . 57)Subclause 13.10, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the or contained in the of the . 58)Subclause 13.11, "": a) Conforming Intermediate SQL language shall not contain any . 59)Subclause 14.2, "": a) Conforming Intermediate SQL language shall not contain any . 60)Subclause 15.1, "": a) Conforming Intermediate SQL language shall not contain any . 61)Subclause 15.2, "": a) Conforming Intermediate SQL language shall not contain any . 62)Subclause 15.3, "": a) Conforming Intermediate SQL language shall not contain any . 63)Subclause 16.1, "": a) Conforming Intermediate SQL language shall not contain any . 636 Database Language SQL X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 64)Subclause 16.2, "": a) Conforming Intermediate SQL language shall not contain any . 65)Subclause 16.3, "": a) Conforming Intermediate SQL language shall not contain any . 66)Subclause 17.2, "": a) An and a shall be a . 67)Subclause 17.3, "": a) A shall be a . 68)Subclause 17.4, "": a) A shall be a . 69)Subclause 17.5, "": a) A shall be a . 70)Subclause 17.6, "": a) A shall not be an or a . b) A shall not be a , a , a , or a . c) A shall not be a . d) A shall not be a . e) A shall not be a . f) A shall not be a . g) A shall not be a . 71)Subclause 17.7, "": a) Conforming Intermediate SQL language shall contain no . Leveling the SQL Language 637 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 72)Subclause 17.8, "": a) Conforming Intermediate SQL language shall not contain any . 73)Subclause 17.9, "": a) A shall be a . 74)Subclause 17.10, "": a) Conforming Intermediate SQL language shall contain no . 75)Subclause 17.12, "": a) Conforming Intermediate SQL language shall contain no that specifies INSENSITIVE. b) If an of FOR UPDATE with or without a is specified, then neither SCROLL nor ORDER BY shall be specified. 76)Subclause 17.13, "": a) Conforming Intermediate SQL language shall not contain any . 77)Subclause 17.15, "": a) A shall not contain a . 78)Subclause 17.17, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the referenced by the . 79)Subclause 17.18, "": a) Let T be the table identified by the
. T shall not be a table that is identified in the of any contained in the referenced by the . 80)Subclause 17.19, "": a) Conforming Intermediate SQL language shall contain no . 638 Database Language SQL X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications 81)Subclause 17.20, "": a) Conforming Intermediate SQL language shall contain no . 82)Subclause 19.1, "": a) An shall not contain a . 83)Subclause 19.3, "": a) An shall not specify a bit string variable. 84)Subclause 19.4, "": a) A shall not be a . 85)Subclause 19.5, "": a) A shall not be a . 86)Subclause 19.6, "": a) A shall not specify BIT. 87)Subclause 19.8, "": a) A shall not specify BIT or PACKED ARRAY [1..] OF BIT. 88)Subclause 19.9, "": a) A shall not specify BIT or BIT VARYING. 89)Subclause 20.1, "": a) A shall not be a . b) An shall not be a , a , or a . c) An shall not be a . d) An shall not be an or a . e) An shall not be a , a , a or a . Leveling the SQL Language 639 X3H2-92-154/DBL CBR-002 A.1 Intermediate SQL Specifications f) A shall not be an . 90)Subclause 21.2, "Information Schema": a) Conforming Intermediate SQL language shall reference only the following Information Schema tables: SCHEMATA, DOMAINS, TABLES, VIEWS, COLUMNS, TABLE_PRIVILEGES, COLUMN_PRIVILEGES, USAGE_PRIVILEGES, REFERENTIAL_CONSTRAINTS, CHECK_CONSTRAINTS, KEY_COLUMN_USAGE, ASSERTIONS, CHARACTER_SETS, COLLATIONS, VIEW_COLUMN_USAGE, CONSTRAINT_TABLE_USAGE, CONSTRAINT_COLUMN_ USAGE, SQL_LANGUAGES, COLUMN_DOMAIN_USAGE, and VIEW_TABLE_ USAGE. A.2 Entry SQL Specifications 1) All Intermediate SQL specifications are included as Entry SQL specifications. 2) Subclause 5.2, " and ": a) A shall not be a . b) An shall contain no . 3) Subclause 5.3, "": a) A or shall not be a . b) A or shall not be a or an . 4) Subclause 5.4, "Names and identifiers": a) Conforming Entry SQL language shall not contain any , , , or . 5) Subclause 6.1, "": a) A shall not specify VARYING or VARCHAR. b) A shall not be a or an . c) A shall not be a nor specify CHARACTER SET. 640 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 6) Subclause 6.2, " and ": a) A shall not be a . b) A shall not specify VALUE. c) A shall not specify SESSION_ USER, SYSTEM_USER, or CURRENT_USER. 7) Subclause 6.3, "
": a) A
shall not be a . b) The optional AS shall not be specified. c) shall not be specified. 8) Subclause 6.5, "": a) If a specifies or implies ALL, then COUNT shall not be specified. b) If a specifies or implies ALL, then the shall include a that references a column of T. c) If the contains a that is an outer reference, then the shall be a . d) No contained in a shall reference a column derived from a that generally contains a . 9) Subclause 6.6, "": a) A shall not be a . b) A shall not be an . 10)Subclause 6.7, "": a) A shall not be a . b) A shall not be a . 11)Subclause 6.8, "": a) Conforming Entry SQL language shall not contain any . Leveling the SQL Language 641 X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 12)Subclause 6.9, "": a) Conforming Entry SQL language shall not contain any . 13)Subclause 6.10, "": a) Conforming Entry SQL language shall not contain any . 14)Subclause 6.11, "": a) A shall not be a . b) A shall not be an . c) A shall not be a . d) A shall not be a . e) A shall not be a except when the is simply con- tained in a that is simply contained in the second of a . 15)Subclause 6.13, "": a) A shall not be a . 16)Subclause 6.14, "": a) Conforming Entry SQL language shall not contain any . 17)Subclause 6.15, "": a) Conforming Entry SQL language shall not contain any . 18)Subclause 7.1, "": a) A that is contained in the that is contained in the
that is contained in the of an shall be a . b) A shall not specify DEFAULT. 642 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 19)Subclause 7.5, "": a) Conforming Entry SQL language shall not contain any . 20)Subclause 7.6, "": a) A directly contained in the shall not include a reference to a column derived from a function. 21)Subclause 7.9, "": a) A is not updatable if the of the
contains a . b) A
": a) If a is contained in a , then the
in the shall not contain a or a and shall not identify a grouped view. 24)Subclause 8.1, "": a) Conforming Entry SQL language shall not contain any . b) Conforming Entry SQL language shall not contain any . 25)Subclause 8.5, "": a) The shall be a . b) A shall be a . c) An shall be a . Leveling the SQL Language 643 X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 26)Subclause 8.6, "": a) A shall be a . 27)Subclause 8.9, "": a) Conforming Entry SQL language shall not contain any . 28)Subclause 8.11, "": a) Conforming Entry SQL language shall not contain any . 29)Subclause 10.1, "": a) Conforming Entry SQL language shall not contain any . 30)Subclause 10.2, "": a) Conforming Entry SQL language shall not contain a that specifies MUMPS. 31)Subclause 10.4, "": a) Conforming Entry SQL language shall not contain a . 32)Subclause 11.1, "": a) A shall not be a . b) A shall specify AUTHORIZATION and shall not specify a . c) A shall not be speci- fied. d) Conforming Intermediate SQL language shall not contain any . 33)Subclause 11.2, "": a) Conforming Entry SQL language shall not contain a . 34)Subclause 11.18, "": a) Conforming Entry SQL language shall not contain any . 35)Subclause 11.4, "": a) A shall not contain a . 644 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications b) A shall not contain a . c) Conforming Entry SQL language shall not contain any . 36)Subclause 11.5, "": a) A shall not specify CURRENT_DATE, CURRENT_ TIME, CURRENT_TIMESTAMP, SYSTEM_USER, SESSION_USER, or CURRENT_USER. 37)Subclause 11.6, "
": a) Conforming Entry SQL language shall not contain any . 38)Subclause 11.7, "": a) If PRIMARY KEY or UNIQUE is specified, then the for each column whose is in the shall specify NOT NULL. 39)Subclause 11.8, "": a) A shall not contain a . 40)Subclause 11.10, "": a) Conforming Entry SQL language shall not contain an . 41)Subclause 11.11, "": a) Conforming Entry SQL language shall not contain an . 42)Subclause 11.12, "": a) Conforming Entry SQL language shall not contain an . 43)Subclause 11.13, "": a) Conforming Entry SQL language shall not contain a . 44)Subclause 11.14, "": a) Conforming Entry SQL language shall not contain a . 45)Subclause 11.15, "": a) Conforming Entry SQL language shall not contain a . Leveling the SQL Language 645 X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 46)Subclause 11.16, "": a) Conforming Entry SQL language shall not contain an . 47)Subclause 11.17, "": a) Conforming Entry SQL language shall not contain a . 48)Subclause 11.19, "": a) The in a shall be a . 49)Subclause 11.20, "": a) Conforming Entry SQL language shall not contain a . 50)Subclause 11.36, "": a) An shall not specify TABLE. b) In Conforming Entry SQL language, an shall not specify CHARACTER SET or DOMAIN. 51)Subclause 11.37, "": a) Conforming Entry SQL language shall not contain a . 52)Subclause 11.21, "": a) Conforming Entry SQL language shall not contain any . 53)Subclause 11.27, "": a) Conforming Entry SQL language shall not contain a . 54)Subclause 11.28, "": a) Conforming Entry SQL language shall not specify any . 55)Subclause 11.29, "": a) Conforming Entry SQL language shall contain no . 56)Subclause 12.1, "": a) A shall be associated with an SQL-agent during its execution. An SQL-agent shall be associated with at most one . 646 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications b) A shall not be a . 57)Subclause 12.2, "": a) A shall not be speci- fied. 58)Subclause 12.3, "": a) A shall not specify a that is CHARACTER VARYING. 59)Subclause 12.5, "": a) An shall not be an . b) An shall not be an . c) An shall not be a or a . d) An shall not be a . e) An shall not be an . 60)Subclause 13.1, "": a) A shall not specify SCROLL. b) A shall not contain an . 61)Subclause 13.3, "": a) A shall not specify FROM. b) If the data type of the target identified by the i-th in the is an exact numeric type, then the data type of the i-th column of the table T shall be an exact numeric type. 62)Subclause 13.5, "
that specifies VALUES and contains exactly one or it shall be a . b) If the data type of the target identified by the i-th is an exact numeric type, then the data type of the i- th item of the shall be an exact numeric type. c) If the data type of the target C identified by the i-th is character string, then the length in characters of the i-th item of the shall be less than or equal to the length of C. d) The shall immediately contain a . 64)Subclause 13.9, "": a) If the data type of the column identified by the i-th is an exact numeric type, then the data type of the i-th in the shall be an exact numeric type. b) If the data type of the column identified by the i-th C is character string, then the length in characters of the i-th in the shall be less than or equal to the length of C. c) An shall not specify DEFAULT. 65)Subclause 13.10, "": a) If the data type of the column identified by the i-th is an exact numeric type, then the data type of the i-th in the shall be an exact numeric type. b) If the data type of the column identified by the i-th C is character string, then the length in characters of the i-th in the shall be less than or equal to the length of C. 66)Subclause 14.1, "": a) Conforming Entry SQL language shall not contain any . 67)Subclause 14.3, "": a) In conforming Entry SQL language, WORK shall be specified. 648 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 68)Subclause 14.4, "": a) In conforming Entry SQL language, WORK shall be specified. 69)Subclause 16.4, "": a) Conforming Intermediate SQL language shall not contain any . 70)Subclause 16.5, "": a) Conforming Entry SQL language shall not contain any . 71)Subclause 17.2, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 72)Subclause 17.3, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 73)Subclause 17.4, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 74)Subclause 17.5, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 75)Subclause 17.6, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 76)Subclause 17.7, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 77)Subclause 17.8, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 78)Subclause 17.9, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. Leveling the SQL Language 649 X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 79)Subclause 17.10, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 80)Subclause 17.11, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 81)Subclause 17.12, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 82)Subclause 17.13, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 83)Subclause 17.14, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 84)Subclause 17.15, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 85)Subclause 17.16, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 86)Subclause 17.17, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 87)Subclause 17.18, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 88)Subclause 17.19, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 89)Subclause 17.20, "": a) Conforming Entry SQL language shall not contain any Dynamic SQL language. 650 Database Language SQL X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications 90)Subclause 18.1, "": a) Conforming Entry SQL language shall not contain any . 91)Subclause 19.1, "": a) An shall not contain a . b) An shall not contain an . 92)Subclause 19.3, "": a) An shall not specify a . 93)Subclause 19.4, "": a) A shall not be a or a . 94)Subclause 19.5, "": a) A shall not specify a . b) A shall not be a . 95)Subclause 19.6, "": a) A shall not specify a . 96)Subclause 19.8, "": a) A shall not specify a . 97)Subclause 19.9, "": a) A shall not specify CHARACTER VARYING. b) A shall not specify a . 98)Subclause 20.1, "": a) A shall not be an . b) An shall not be a or a . Leveling the SQL Language 651 X3H2-92-154/DBL CBR-002 A.2 Entry SQL Specifications c) A shall not be a . 99)Subclause 21.2, "Information Schema": a) Conforming Entry SQL language shall not reference any views from the Information Schema. 652 Database Language SQL Annex B (informative) Implementation-defined elements This Annex references those features that are identified in the body of this International Standard as implementation-defined. The term implementation-defined is used to identify characteristics that may differ between implementations, but that shall be defined for each particular implementation. 1) Subclause 4.2.1, "Character strings and collating sequences": The specific character set associated with the subtype of char- acter string represented by the s NATIONAL CHARACTER is implementation-defined. 2) Subclause 4.4.1, "Characteristics of numbers": Whether trunca- tion or rounding is performed when trailing digits are removed from a numeric value is implementation-defined. 3) Subclause 4.4.1, "Characteristics of numbers": When an approxi- mation is obtained by truncation or rounding and there are more than one approximation, then it is implementation-defined which approximation is chosen. 4) Subclause 4.4.1, "Characteristics of numbers": It is implementation- defined which numerical values have approximations obtained by rounding or truncation for a given approximate numeric type. 5) Subclause 4.4.1, "Characteristics of numbers": The bound- aries within which the normal rules of arithmetic apply are implementation-defined. 6) Subclause 4.6, "Type conversions and mixing of data types": When converting between numeric data types, if least significant dig- its are lost, then it is implementation-defined whether rounding or truncation occurs. 7) Subclause 4.11, "SQL-schemas": The default schema for s that are dynamically prepared in the current SQL-session through the execution of s and s is initially implementation- defined but may be changed by the use of s. Implementation-defined elements 653 X3H2-92-154/DBL CBR-002 8) Subclause 4.12, "Catalogs": The creation and destruction of catalogs is accomplished by implementation-defined means. 9) Subclause 4.12, "Catalogs": The set of catalogs that can be referenced in any SQL-statement, during any particular SQL-transaction, or during the course of an SQL-session is implementation-defined. 10)Subclause 4.12, "Catalogs": The default catalog for s whose does not specify an explicit to qualify and the default catalog name substitution value for execution of s that are dynamically prepared in the current SQL-session through the execution of s and s are implementation-defined. 11)Subclause 4.13, "Clusters of catalogs": A cluster is an implementation-defined collection of catalogs. 12)Subclause 4.13, "Clusters of catalogs": Whether or not any catalog can occur simultaneously in more than one cluster is implementation-defined. 13)Subclause 4.15, "SQL-environment": The constituents of an SQL- environment beyond those specified in Subclause 4.15, "SQL- environment", are implementation-defined. 14)Subclause 4.15, "SQL-environment": The rules determining whether a is within the environment are implementation-defined. 15)Subclause 4.16, "Modules": The mechanisms by which s are created or destroyed are implementation-defined. 16)Subclause 4.16, "Modules": The manner in which an associ- ation between a and an SQL-agent is defined is implementation-defined. 17)Subclause 4.16, "Modules": Whether a compilation unit may invoke or transfer control to other compilation units, written in the same or a different programming language is implementation- defined. 18)Subclause 4.18.1, "Status parameters": The negative (exception) values for the SQLCODE status parameter are implementation- defined. 19)Subclause 4.22.1, "Classes of SQL-statements": This International Standard permits implementations to provide additional, implementation-defined, statements that may fall into any of these categories; the classification of such statements is also implementation-defined. 654 Database Language SQL X3H2-92-154/DBL CBR-002 20)Subclause 4.23, "Embedded syntax": Whether a portion of the name space is reserved by an implementation for the names of procedures, subroutines, program variables, branch labels, s, or s is implementation-defined; if a portion of the name space is so reserved, the portion reserved is also implementation-defined. 21)Subclause 4.25, "Direct invocation of SQL": The method of in- voking s, the method of raising conditions as a result of s, the method of accessing diagnostic information, and the method of returning the results are all implementation-defined. 22)Subclause 4.28, "SQL-transactions": It is implementation-defined whether or not the non-dynamic or dynamic execution of an SQL- data statement or the execution of an is permitted to occur within the same SQL-transaction as the non-dynamic or dynamic execution of an SQL-schema state- ment. If it does occur, then the effect on any open cursor, prepared dynamic statement, or deferred constraint is also implementation-defined. 23)Subclause 4.28, "SQL-transactions": If an implementation detects unrecoverable errors and implicitly initiates the execution of a , an exception condition is raised: transaction rollback with an implementation-defined subclass code. 24)Subclause 4.29, "SQL-connections": It is implementation-defined how an implementation uses to determine the location, identity, and communication protocol required to ac- cess the SQL-environment and create an SQL-session. 25)Subclause 4.30, "SQL-sessions": When an SQL-session is initiated other than through the use of an explicit , then an SQL-session associated with an implementation-defined SQL-environment is initiated. The default SQL-environment is implementation-defined. 26)Subclause 4.30, "SQL-sessions": The mechanism and rules by which an environment determines whether a call to a is the last call within the last active is implementation- defined. 27)Subclause 4.30, "SQL-sessions": An SQL-session uses one or more implementation-defined schemas that contain the instances of any global temporary tables, created local temporary tables, or declared local temporary tables within the SQL-session. 28)Subclause 4.30, "SQL-sessions": When an SQL-session is initiated other than through the use of an explicit , there is an implementation-defined default that is used to for privilege checking for the execution Implementation-defined elements 655 X3H2-92-154/DBL CBR-002 of s contained in s not having an explicit . 29)Subclause 4.30, "SQL-sessions": When an SQL-session is initi- ated, there is an implementation-defined default catalog whose name is used to effectively qualify all unqualified s contained in s that are dynamically prepared in the current SQL-session through the execution of s and s or are contained in s when those statements are invoked directly. 30)Subclause 4.30, "SQL-sessions": When an SQL-session is initi- ated, there is an implementation-defined default schema whose name is used to effectively qualify all unqualified s contained in s that are dynamically prepared in the current SQL-session through the execution of s and s or are contained in s when those statements are invoked directly. 31)Subclause 4.30, "SQL-sessions": When an SQL-session is initi- ated, there is an implementation-defined default character set that is used to identify the character set implicit for s and s that are contained in s when those statements are prepared in the current SQL-session by either an or a or are contained in s when those statements are invoked directly. 32)Subclause 4.30, "SQL-sessions": When an SQL-session is ini- tiated, there is an implementation-defined default time zone displacement that is used as the current default time zone dis- placement of the SQL-session. 33)Subclause 4.31, "Client-server operation": When an SQL-agent is active, it is bound in some implementation-defined manner to a single SQL-client. 34)Subclause 4.34, "SQL Flagger": If an SQL-implementation provides user options to process conforming SQL language in a noncon- forming manner, then it is required that the implementation also provide a flagger option, or some other implementation-defined means, to detect SQL conforming language that may be processed differently under the various user options. 35)Subclause 5.2, " and ": The end-of-line indi- cator () is implementation-defined. 36)Subclause 5.3, "": The character set used to represent national characters is implementation- defined. 656 Database Language SQL X3H2-92-154/DBL CBR-002 37)Subclause 5.4, "Names and identifiers": If a con- tained in a but not contained in a does not contain a , then an implementation- defined is implicit. 38)Subclause 5.4, "Names and identifiers": If a con- tained in a does not contain a , then an implementation-defined is implicit. 39)Subclause 5.4, "Names and identifiers": The data type of the of shall be character string with an implementation-defined character set. 40)Subclause 5.4, "Names and identifiers": The data type of the of shall be character string with an implementation-defined character set. 41)Subclause 5.4, "Names and identifiers": Those s that are valid s are implementation- defined. 42)Subclause 5.4, "Names and identifiers": Those s that are valid s are implementation-defined. 43)Subclause 5.4, "Names and identifiers": All s are implementation-defined. 44)Subclause 6.1, "": The associ- ated with NATIONAL CHARACTER is implementation-defined. 45)Subclause 6.1, "": If a is omitted, then an implementation-defined is implicit. 46)Subclause 6.1, "": The decimal precision of a data type defined as DECIMAL for each value specified by is implementation-defined. 47)Subclause 6.1, "": The precision of a data type de- fined as INTEGER is implementation-defined, but has the same radix as that for SMALLINT. 48)Subclause 6.1, "": The precision of a data type de- fined as SMALLINT is implementation-defined, but has the same radix as that for INTEGER. 49)Subclause 6.1, "": The binary precision of a data type defined as FLOAT for each value specified by is implementation-defined. 50)Subclause 6.1, "": The precision of a data type de- fined as REAL is implementation-defined. Implementation-defined elements 657 X3H2-92-154/DBL CBR-002 51)Subclause 6.1, "": The precision of a data type de- fined as DOUBLE PRECISION is implementation-defined, but greater than that for REAL. 52)Subclause 6.1, "": For every , the limits of the are implementation-defined. 53)Subclause 6.1, "": The maximum lengths for character string types, variable-length character string types, bit string types, and variable-length bit string types are implementation- defined. 54)Subclause 6.1, "": If CHARACTER SET is not speci- fied for , then the character set is implementation-defined. 55)Subclause 6.1, "": The character set named SQL_TEXT is an implementation-defined character set that contains every character that is in and all characters that are in other character sets supported by the implementa- tion. 56)Subclause 6.1, "": For the s DECIMAL and NUMERIC, the maximum values of and of are implementation-defined. 57)Subclause 6.1, "": For the FLOAT, the maximum value of is implementation- defined. 58)Subclause 6.1, "": For the s FLOAT, REAL, and DOUBLE PRECISION, the maximum and mini- mum values of the exponent are implementation-defined. 59)Subclause 6.1, "": The maximum value of
": The of a constraint that does not specify a is implementation-dependent. 39)Subclause 11.8, "": The spe- cific value to use for cascading among various values that are not distinct is implementation-dependent. 40)Subclause 11.21, "": The of a constraint that does not specify a is implementation-dependent. 41)Subclause 12.1, "": If the SQL-agent that performs a call of a in a is not a standard program in the language specified in the of the , then the results are implementation-dependent. 670 Database Language SQL X3H2-92-154/DBL CBR-002 42)Subclause 12.1, "": If the SQL-agent that performs a call of a in a is not a program that conforms to the programming language standard specified by the of that , then the effect is implementation-dependent. 43)Subclause 12.3, "": The should be a standard-conforming procedure, function, or routine name of the language specified by the subject . Failure to observe this recommendation will have implementation-dependent effects. 44)Subclause 12.3, "": After the execution of the last , if an unrecoverable error has not occurred, and the SQL-agent did not terminate unexpectedly, and no constraint is not satisfied, then the choice of whether to perform a or a is implementation- dependent. The determination of whether an SQL-agent has termi- nated unexpectedly is implementation-dependent. 45)Subclause 12.3, "": If there are more than one status parameter, then the order in which values are assigned to these status parameters is implementation-dependent. 46)Subclause 13.1, "": If a does not contain an , then the ordering of rows in the table associated with that is implementation-dependent. 47)Subclause 13.1, "": If a con- tains an and a group of two or more rows in the table associated with that contain val- ues that are the null value or compare equal according to Subclause 8.2, "", in all columns spec- ified in the , then the order in which rows in that group are returned is implementation-dependent. 48)Subclause 13.3, "": The order of assign- ment to targets in the of values returned by a , other than status parameters, is implementation-dependent. 49)Subclause 13.3, "": If an error occurs during assignment of a value to a target during the execution of a , then the values of targets other than status parameters are implementation-dependent. 50)Subclause 13.5, ". Implementation-dependent elements 671 X3H2-92-154/DBL CBR-002 51)Subclause 13.5, " of values returned by a ": If an error occurs during assignment of a value to a target during the ex- ecution of a column, if the column name is implementation-dependent, then NAME is the implementation-dependent name for the column and UNNAMED is set to 1. 57)Subclause 17.4, "": For a , the values of NAME and UNNAMED are implementation-dependent. 58)Subclause 17.5, "": Item descriptor area fields not relevant to the data type of the item being de- scribed according to the General Rules of Subclause 17.5, "", are set to implementation-dependent values. 59)Subclause 17.5, "": If an exception condition is raised in a , then the values of all elements of the descriptor specified in the are implementation-dependent. 60)Subclause 17.6, "": The validity of an value or a in an SQL- transaction different from the one in which the statement was prepared is implementation-dependent. 672 Database Language SQL X3H2-92-154/DBL CBR-002 61)Subclause 17.9, "": When a is executed, the values of DATA and INDICATOR, as well as the value of other fields not relevant to the data type of the described item, are implementation-dependent. If the col- umn name is implementation-dependent, then NAME is set to that implementation-dependent name. 62)Subclause 17.9, "": When a is used, the values for NAME, DATA, and INDICATOR, as well as the value of other fields not relevant to the data type of the described item, in the SQL dynamic descriptor area structure are implementation-dependent. 63)Subclause 18.1, "": The value of ROW_COUNT following the execution of an SQL-statement that does not directly result in the execution of a , an , or an is implementation-dependent. 64)Subclause 18.1, "": If has a value other than 1, then the association between values and specific conditions raised dur- ing evaluation of the General Rules for that SQL-statement is implementation-dependent. 65)Subclause 19.1, "": The of the implied derived from an is implementation-dependent. 66)Subclause 19.1, "": The of the implied derived from an is implementation-dependent. 67)Subclause 19.1, "": In each in the implied derived from an , each has been re- placed consistently with a distinct that is implementation-dependent. 68)Subclause 19.1, "": The of each in the implied derived from an is implementation-dependent. 69)Subclause 19.1, "": In each in the implied derived from an , each has been re- placed consistently with a distinct that is implementation-dependent. 70)Subclause 19.1, "": For s other than s, whether one in the implied derived from an can correspond to more than one in the is implementation- dependent. 71)Subclause 19.1, "": In each in the implied derived from an , the order of the instances of is implementation-dependent. 72)Subclause 20.1, "": If an unrecoverable error has occurred, or if the direct invocation of SQL termi- nated unexpectedly, or if any constraint is not satisfied, then a is performed. Otherwise, the choice of which of these SQL-statements to perform is implementation- dependent. The determination of whether a direct invocation of SQL has terminated unexpectedly is implementation-dependent. 73)Subclause 20.2, "": If an is not specified, then the ordering of rows in the table associated with that is implementation-dependent. 74)Subclause 20.2, "": If an is specified and a group of two or more rows in the resulting table contain values that are the null value or compare equal according to Subclause 8.2, "", in all columns specified in the , then the order in which rows in that group are returned is implementation-dependent. 75)Subclause 21.3.23, "CHARACTER_SETS base table": The values of DEFAULT_COLLATE_SCHEMA, DEFAULT_COLLATE_CATALOG, and DEFAULT_ COLLATE_NAME for default collations specifying the order of characters in a repertoire are implementation-dependent. 674 Database Language SQL Annex D (informative) Deprecated features It is intended that the following features will be removed at a later date from a revised version of this International Standard: 1) SQLCODE 2) s in s. 3) The option of of . 4) The s in a without enclosing parentheses and without commas separating multiple s. Deprecated features 675 676 Database Language SQL X3H2-92-154/DBL CBR-002 Annex E (informative) Incompatibilities with ISO/IEC 9075:1989 This International Standard introduces some incompatibilities with the earlier version of Database Language SQL as specified in ISO/IEC 9075:1989. Unless specified in this Annex, features and capabilities of Database Language SQL are compatible with the earlier version of this International Standard. 1) In Subclause 4.12, "Cursors", and Subclause 8.3, "", General Rule 3)a)iii) of ISO/IEC 9075:1989, a requirement was made that multiple openings of an unordered cursor within a single SQL-transaction return the rows in the same order every time. In this International Standard, the order of rows returned for an unordered cursor is always implementation-dependent. 2) In ISO/IEC 9075:1989, s were simple s. In this International Standard, colons are now required to delimit s. 3) In ISO/IEC 9075:1989, the specification of the enforcement of WITH CHECK OPTION for a view was ambiguous. This International Standard clarifies the intent of WITH CHECK OPTION. 4) In ISO/IEC 9075:1989, the had no rule to prevent defining two unique constraints with identical unique column lists on a table. This International Standard adds a Syntax Rule to require that all unique column lists be distinct. 5) In ISO/IEC 9075:1989, there were no requirements that users have SELECT privileges on tables that were referenced in contexts other than
s, s, and s. 6) In ISO/IEC 9075:1989, the specification of a view did not preclude the possibility of defining a view in terms of it- self. This International Standard adds a Syntax Rule in Incompatibilities with ISO/IEC 9075:1989 677 X3H2-92-154/DBL CBR-002 Subclause 11.19, "" to preclude that possi- bility. 7) In ISO/IEC 9075:1989, the specification did not preclude the possibility of using outer references in s in s contained in the of a , but did not define the semantics of such a construction. This International Standard adds a Syntax Rule in Subclause 6.5, "", and a Syntax Rule in Subclause 7.6, "", to preclude that possibil- ity. 8) In ISO/IEC 9075:1989, the derived from an had an implementor-defined . As the time of binding was not specified, this meant that the authorization identifier for privilege checking could be determined at either compile-time or run-time. In this International Standard, the derived has no and the authorization identifier for privilege checking is determined at run-time. 9) In ISO/IEC 9075:1989, if a cursor is on or before a row and that row is deleted, then the cursor is positioned before the row that is immediately after the position of the deleted row. In this International Standard, if the deletion is not made through that cursor, then the effect of the deletion is implementation- dependent. 10)A number of additional s have been added to the language. These s are: - ABSOLUTE - ACTION - ADD - ALLOCATE - ALTER - ARE - ASSERTION - AT - BETWEEN - BIT - BIT_LENGTH - BOTH - CASCADE 678 Database Language SQL X3H2-92-154/DBL CBR-002 - CASCADED - CASE - CAST - CATALOG - CHAR_LENGTH - CHARACTER_LENGTH - COALESCE - COLLATE - COLLATION - COLUMN - CONNECT - CONNECTION - CONSTRAINT - CONSTRAINTS - CONVERT - CORRESPONDING - CROSS - CURRENT_DATE - CURRENT_TIME - CURRENT_TIMESTAMP - CURRENT_USER - DATE - DAY - DEALLOCATE - DEFERRABLE - DEFERRED - DESCRIBE - DESCRIPTOR - DIAGNOSTICS - DISCONNECT Incompatibilities with ISO/IEC 9075:1989 679 X3H2-92-154/DBL CBR-002 - DOMAIN - DROP - ELSE - END-EXEC - EXCEPT - EXCEPTION - EXECUTE - EXTERNAL - EXTRACT - FALSE - FIRST - FULL - GET - GLOBAL - HOUR - IDENTITY - IMMEDIATE - INITIALLY - INNER - INPUT - INSENSITIVE - INTERSECT - INTERVAL - ISOLATION - JOIN - LAST - LEADING - LEFT - LEVEL - LOCAL 680 Database Language SQL X3H2-92-154/DBL CBR-002 - LOWER - MATCH - MINUTE - MONTH - NAMES - NATIONAL - NATURAL - NCHAR - NEXT - NO - NULLIF - OCTET_LENGTH - ONLY - OUTER - OUTPUT - OVERLAPS - PAD - PARTIAL - POSITION - PREPARE - PRESERVE - PRIOR - READ - RELATIVE - RESTRICT - REVOKE - RIGHT - ROWS - SCROLL - SECOND Incompatibilities with ISO/IEC 9075:1989 681 X3H2-92-154/DBL CBR-002 - SESSION - SESSION_USER - SIZE - SPACE - SQLSTATE - SUBSTRING - SYSTEM_USER - TEMPORARY - THEN - TIME - TIMESTAMP - TIMEZONE_HOUR - TIMEZONE_MINUTE - TRAILING - TRANSACTION - TRANSLATE - TRANSLATION - TRIM - TRUE - UNKNOWN - UPPER - USAGE - USING - VALUE - VARCHAR - VARYING - WHEN - WRITE - YEAR 682 Database Language SQL X3H2-92-154/DBL CBR-002 - ZONE Incompatibilities with ISO/IEC 9075:1989 683 684 Database Language SQL X3H2-92-154/DBL CBR-002 Annex F (informative) Maintenance and interpretation of SQL ISO/IEC JTC1 provides formal procedures for revision, maintenance, and interpretation of JTC1 Standards. Section 6.13 of the JTC1 Directives, "Maintenance/correction of defects in JTC1 Standards", specifies procedures for creating and processing "defect reports". Defect reports may result in technical corrigendum, amendments, interpretations, or other commentary on an existing International Standard. In addition, SC21, the JTC1 subcommittee that devel- oped this International Standard, provides procedures for raising new "questions" about topics related to existing SC21 projects. Questions may result in interpretations, new project proposals, or possibly new defect reports. Since publication of ISO/IEC 9075:1989, the following SC21 ques- tions have resulted in formal interpretations of Database Language SQL. The first number in parentheses identifies the SC21 document in which the question was first raised, and the second number iden- tifies the SC21 document in which the proposed interpretation was formally adopted. 1) Expression Evaluation (SC21 N5142, SC21 N5468) 2) Read-Only Cursors (SC21 N5143, SC21 N5469) 3) Working Viewed Tables (SC21 N5144, SC21 N5470) 4) Authorization Id (SC21 N5145, SC21 N5471) Since publication of ISO/IEC 9075:1989, several new defects have been discovered in the SQL language, leading to creation of the following defect reports. 1) General Clarifications, Defect Report 9075/5 (WG3 N1150, N1160) 2) General Clarifications, Defect Report 9075/6 (WG3 N1161) The SQL language corrections proposed in each defect report were accepted by SC21/WG3 in May 1991 (see SC21 N6249, Arles WG3 Resolutions). Further processing within SC21 was superseded by adoption of ISO/IEC 9075:1992 as a replacement standard for ISO/IEC Maintenance and interpretation of SQL 685 X3H2-92-154/DBL CBR-002 9075:1989. All corrections to SQL proposed by these defect reports are included in this International Standard. Potential new questions or new defect reports addressing the spec- ifications of this International Standard should be communicated to: Secretariat, ISO/IEC JTC1/SC21/WG3 Standards Council of Canada Ottawa, Ontario Canada. 686 Database Language SQL Index . . . , 8 a completion condition is !!, 8 raised, 10 |, 22, 27 ACTION, 84, 274, 276, 590, ::=, 7 591, 592, 678 <1987>, 16 , 64, 245, 246, <1989>, 16 329, 330, 332, 333, 338, <1992>, 16, 17 632 < >, 7 , 245 [ ], 8 , 98 { }, 8 Ada, 3, 49, 61, 342, 344, |, 8 352, 356, 357, 489, 490, - A - 491, 493, 495, 498, 500, abandoned, 336, 337, 338 501, 502, 503, 614, 625, ABSOLUTE, 84, 377, 378, 639, 651, 661 379, 678 ADA, 83, 243, 344, 352, access mode, 67, 74, 350, 362, 493, 613, 614 384, 386, 389, 392, 394, , 400, 528 500 Access Rules, 9, 10, 12, , 490, 13, 15, 38, 64, 77, 289, 500, 501 290, 292, 294, 300, 310, , 500, 313, 318, 323, 330, 331, 501 332, 338, 375, 398, 443, , 500, 477, 525, 526, 625, 665, 501, 503, 651 677 , 500, 502 Index 1 , specification>, 500 266, 283, 286, 287, 288, , 645 490, 500, 501, 502, 639 , 304 ADD, 84, 284, 291, 307, , 310, 678 52, 281, 304, 305, 306, , 307, 308, 338, 368, 482, 283, 284, 285, 645 633 , 283 definition>, 304, 307, , 634 52, 262, 263, 265, 272, Additional common elements, 274, 281, 283, 284, 286, 239 289, 291, 292, 338, 368, , 272, 283, ambiguous cursor name, 443, 291, 310, 586, 646, 665 462, 619 AFTER, 85 , 79, 80, 489, ALIAS, 85 491 ALL, 84, 124, 126, 176, AND, 84, 211, 228, 229, 183, 184, 196, 197, 200, 230, 272, 538, 539, 542, 201, 202, 220, 245, 246, 543, 544, 545, 546, 547, 294, 300, 332, 338, 401, 548, 549, 550, 551, 552, 402, 403, 412, 586, 616, 553, 554, 555, 556, 557, 641, 672 558, 559, 561, 562, 570, , 220 571, 580, 581, 612, 613, ALLOCATE, 84, 431, 465, 617, 618 482, 678 an exception condition is raised, 10 , 49, 53, 55, 57, 58, ANSI/IEEE 770/X3.160, 517 59, 62, 104, 369, 447, ANSI/IEEE 770/X3.97, 517 449, 465, 466, 469, 476, ANSI/MDC X11.1, 515 477, 482, 635, 638 ANSI/MIL-STD-1815A, 3, 501 , 54, 60, 76, 85, 677, 678 62, 104, 369, 431, 482 ANSI X3.159, 505 ALTER, 84, 283, 286, 292, ANSI X3.198, 512 304, 310, 338, 482, 678 ANSI X3.23, 3, 509 , 286 ANSI X3.53, 3, 521 ANSI X3.9, 512 2 Database Language SQL ANY, 84, 212, 220, 571, AS, 84, 118, 120, 122, 144, 573, 580, 583, 584, 585, 146, 147, 169, 170, 182, 586, 591, 595, 596, 606, 191, 202, 209, 296, 298, 608, 610, 611 301, 311, 362, 363, 364, applicable, 66, 119, 122, 365, 366, 407, 446, 456, 135, 145, 246, 249, 251, 457, 458, 538, 539, 541, 264, 276, 282, 298, 302, 542, 543, 544, 545, 546, 304, 310, 312, 316, 321, 547, 548, 549, 550, 551, 326, 329, 337, 373, 384, 552, 553, 554, 555, 556, 386, 389, 392, 394, 452, 557, 558, 559, 561, 562, 453, 454, 455, 493, 531, 563, 564, 565, 586, 616, 572 617, 641 applicable privileges, 66, ASC, 84, 371, 531 119, 122, 135, 145, 246, , 191, 192, 670 249, 251, 264, 276, 282, assertion, 43 298, 302, 310, 312, 316, ASSERTION, 84, 259, 325, 321, 326, 329, 337, 384, 328, 338, 482, 537, 617, 386, 389, 392, 394 618, 678 application program, 2, 77 , 325 , 52, literal>, 90, 94, 95, 255, 257, 325, 326, 368, 148, 150 482, 593, 594, 632, 634, , 635, 637, 639 29, 107, 108, 110, 453, assertion descriptor, 40, 454, 658 43, 44, 300, 326, 337, approximate numeric value, 338, 598 28 Assertions, 43 , 16 ASSERTIONS, 553, 593, 598, , 16 616, 640 , 16 ASSERTIONS base table, 598 ARE, 84, 344, 490, 678 Assertions on the base , 451, 455, 456, tables, 616 457, 460 ASSERTIONS view, 553 ASSERTIONS_DEFERRED_CHECK, 598 ASSERTIONS_FOREIGN_KEY_ CHECK_CONSTRAINTS, 598 Index 3 ASSERTIONS_FOREIGN_KEY_ BETWEEN, 84, 211, 678 SCHEMATA, 598 , 205, ASSERTIONS_INITIALLY_ 211, 444, 446 DEFERRED_NOT_NULL, 598 BIT, 19, 35, 84, 107, 109, ASSERTIONS_IS_DEFERRABLE_ 351, 352, 356, 357, 358, NOT_NULL, 598 359, 360, 361, 362, 363, ASSERTIONS_PRIMARY_KEY, 598 364, 366, 425, 429, 440, assignable, 5, 34, 35, 231 445, 500, 502, 505, 506, , 79, 80, 124, 507, 510, 512, 513, 514, 157, 158, 168, 191, 512 517, 518, 519, 520, 522, ASYNC, 85 AT, 84, 165, 166, 678 523, 570, 635, 639, 678 AUTHORIZATION, 84, 255, , 89, 90, 92 257, 341, 343, 420, 484, , 27, 535, 567, 644 160, 162, 163 , , 160, 162, 163 44, 46, 64, 65, 66, 72, , 73, 98, 102, 103, 116, 128, 131, 630 245, 246, 255, 256, 258, , 160, 161, 260, 261, 283, 289, 290, 163 294, 297, 298, 300, 302, bit string, 26 Bit string comparison and 304, 309, 310, 312, 313, assignment, 27 316, 318, 321, 323, 326, bit string data type 328, 329, 330, 331, 332, descriptor, 26 333, 336, 341, 342, 348, , 82, 397, 398, 407, 409, 420, 86, 89, 92, 93, 95, 97, 421, 487, 526, 568, 600, 266, 267, 629 601, 603, 605, 655, 657, Bit strings, 26 663, 669 , 107, AVG, 84, 124, 125, 126, 659 109, 113, 453, 454, 630 bit string variable, 27 - B - , Backus Naur Form, 7 27, 133, 134, 137 Backus Normal Form, 7 , <1989 base>, 16 133, 134, 137, 160, 162, base table, 45 163, 631 base table descriptor, 39 , 132, BEFORE, 85 137, 630 BEGIN, 84, 490 4 Database Language SQL BIT_LENGTH, 84, 128, 131, CARDINAL_NUMBER_DOMAIN_ 148, 151, 152, 445, 507, CHECK, 565 678 , BNF, 7 504, 505, 506, 507 BOOLEAN, 85 CASCADE, 84, 258, 274, 277, , 36, 229 278, 279, 289, 290, 292, , 229 294, 300, 310, 313, 318, , 229 323, 337, 338, 590, 591, , 229, 230, 592, 678 632 CASCADED, 40, 84, 296, 297, BOTH, 84, 132, 134, 136, 299, 578, 579, 633, 679 152, 153, 154, 407, 408, CASE, 76, 84, 141, 142, 415, 417, 419, 420, 431, 543, 544, 679 447, 465, 678 , 141 BREADTH, 85 , 26, 141, BY, 84, 187, 196, 371, 372, 143, 155, 156, 237, 642 374, 464, 530, 616, 617, , 141, 142 635, 638 , 141, - C - 142, 143, 444, 446 C, 3, 49, 61, 83, 243, 357, CAST, 35, 84, 144, 146, 358, 362, 363, 452, 454, 147, 169, 170, 192, 202, 489, 490, 491, 493, 495, 209, 353, 362, 363, 364, 498, 504, 505, 506, 507, 365, 366, 446, 456, 457, 613, 614, 625, 639, 651, 458, 679 661, 664 , 144, 145 calendar, 5 , 43, CALL, 85 49, 144, 145, 146, 147, Calls to a , 352 154, 155, 156, 456, 457, cardinality, 5, 37, 125, 458, 642 126, 174, 178, 191, 194, , 144 203, 222, 382, 485, 537, catalog, 45, 46 589, 671 CATALOG, 84, 415, 417, 484, cardinality violation, 203, 679 382, 620 , 15, 44, 45, CARDINAL_NUMBER, 565, 570, 64, 98, 101, 102, 104, 580, 588, 606 256, 258, 341, 415, 417, CARDINAL_NUMBER domain, 565 486, 487, 629, 654, 657, 661 Index 5 Catalogs, 45 , 160, CATALOG_NAME, 83, 480, 481, 161, 162 486, 487, 536, 538, 539, Characteristics of numbers, 541, 542, 543, 544, 545, 28 546, 547, 548, 549, 550, character not in repertoire 551, 552, 553, 554, 555, , 111, 620 556, 557, 558, 559, 561, , 160, 562, 569, 571, 573, 580, 162 583, 584, 585, 586, 591, character repertoire, 5, 7, 595, 596, 606, 608, 610, 20, 21, 23, 24, 35, 46, 611 74, 85, 86, 92, 93, 100, , 504, 505, 109, 111, 129, 133, 134, 507, 639 136, 145, 160, 208, 237, , 248, 249, 250, 266, 312, 504, 505, 506, 507, 664 315, 316, 506, 607, 660, , 504 669 , 504, , 507, 639, 651 88, 89, 92, 93, 95, 97, CHAR, 84, 107, 108, 356, 216, 500, 501, 505, 506, 360, 361, 500, 501, 502, 508, 509, 520, 521, 629 517, 518, 519, 520, 522, , 664 52, 255, 257, 311, 312, character, 5 323, 368, 482, 644, 646 CHARACTER, 19, 20, 21, 35, character set descriptor, 49, 84, 107, 108, 109, 21, 44, 250, 311, 312, 113, 248, 255, 259, 263, 318, 606 301, 311, 313, 329, 332, , 44, 351, 352, 356, 357, 358, 93, 99, 103, 104, 105, 359, 360, 361, 362, 363, 108, 248, 249, 259, 302, 364, 365, 366, 367, 426, 311, 312, 313, 316, 321, 429, 440, 445, 447, 482, 329, 331, 333, 419, 452, 483, 500, 501, 504, 505, 454, 656, 657 506, 508, 509, 510, 512, , 311 513, 516, 517, 518, 520, 521, 522, 523, 564, 570, 604, 605, 640, 646, 647, 651, 653, 657, 658, 664 6 Database Language SQL , 85, 86, 87, 89, expression>, 23, 24, 92, 93, 97, 98, 100, 128, 129, 130, 132, 133, 105, 107, 109, 248, 249, 135, 136, 160, 161, 162, 250, 255, 256, 263, 301, 164, 214, 444, 642 314, 320, 331, 335, 344, , 426, 490, 500, 501, 503, 132, 137, 138, 630, 641 504, 506, 507, 508, 510, CHARACTER_DATA, 564, 570, 511, 512, 513, 514, 517, 573, 574, 576, 578, 580, 518, 519, 520, 521, 523, 585, 590, 593, 598, 600, 629, 630, 644, 651, 660, 602, 604, 608, 612 663, 664 CHARACTER_DATA domain, 564 character string, 20 CHARACTER_LENGTH, 84, 128, character string data type 151, 445, 679 descriptor, 20 CHARACTER_MAXIMUM_LENGTH, , 539, 544, 570, 571, 572 73, 82, 86, 87, 89, 92, CHARACTER_OCTET_LENGTH, 93, 95, 97, 100, 266, 539, 544, 570, 571, 572 419, 629, 656 CHARACTER_SETS, 554, 604, character strings, 6 606, 608, 611, 640 Character strings, 20 CHARACTER_SETS base table, Character strings and 606 collating sequences, CHARACTER_SETS view, 554 20 CHARACTER_SETS_CHECK_ , REFERENCES_COLLATIONS, 107, 108, 109, 113, 263, 606 301, 452, 454, 640, 658 CHARACTER_SETS_DEFAULT_ , 22, 27, 132, NULL, 606 133, 135, 137, 444, 641 CHARACTER_SETS_DEFAULT_ , COLLATE_NAME_NOT_NULL, 22, 132, 134, 136, 137, 606 444, 630, 659 CHARACTER_SETS_DEFAULT_ COLLATE_SCHEMA_NOT_NULL, 606 CHARACTER_SETS_FOREIGN_KEY_ SCHEMATA, 606 Index 7 CHARACTER_SETS_PRIMARY_KEY, , 262, 264, CHARACTER_SET_CATALOG, 83, 270, 271, 281, 282, 301, 426, 427, 428, 434, 436, 309, 593, 594, 633 439, 440, 441, 452, 454, Checking of constraints, 41 456, 457, 538, 539, 544, CHECK_CLAUSE, 551, 593, 594 554, 555, 556, 569, 604, CHECK_COLUMN_USAGE, 559, 606, 607, 608, 609, 610, 561, 596 611, 663 CHECK_COLUMN_USAGE base CHARACTER_SET_NAME, 83, table, 596 354, 426, 427, 428, 434, CHECK_COLUMN_USAGE_CHECK_ 436, 439, 440, 441, 452, REFERENCES_COLUMNS, 596 454, 456, 457, 538, 539, CHECK_COLUMN_USAGE_FOREIGN_ 544, 554, 555, 556, 569, KEY_CHECK_CONSTRAINTS, 604, 606, 607, 608, 609, 596 CHECK_COLUMN_USAGE_PRIMARY_ 610, 611, 663 KEY, 596 CHARACTER_SET_SCHEMA, 83, CHECK_CONSTRAINTS, 551, 426, 427, 428, 434, 436, 574, 586, 593, 594, 595, 439, 440, 441, 452, 454, 596, 598, 640 456, 457, 538, 539, 544, CHECK_CONSTRAINTS base 554, 555, 556, 569, 604, table, 593 606, 607, 608, 609, 610, CHECK_CONSTRAINTS view, 551 611, 663 CHECK_CONSTRAINTS_PRIMARY_ , KEY, 593 128, 130 CHECK_CONSTRAINTS_SOURCE_ CHAR_LENGTH, 84, 128, 679 CHECK, 593 CHECK, 40, 75, 84, 264, CHECK_OPTION, 356, 543, 281, 296, 297, 299, 325, 578, 579 389, 393, 395, 487, 537, CHECK_OPTION_CHECK, 578 565, 570, 571, 572, 573, CHECK_OPTION_NOT_NULL, 578 574, 576, 578, 579, 580, CHECK_TABLE_IN_COLUMNS, 576 CHECK_TABLE_USAGE, 595 583, 584, 585, 586, 587, CHECK_TABLE_USAGE base 588, 590, 591, 593, 595, table, 595 596, 598, 600, 602, 604, CHECK_TABLE_USAGE_CHECK_ 606, 608, 610, 611, 612, REFERENCES_TABLES, 595 613, 616, 617, 618, 677 8 Database Language SQL CHECK_TABLE_USAGE_FOREIGN_ , KEY_CHECK_CONSTRAINTS, 508, 509, 510, 511, 651, 595 664 CHECK_TABLE_USAGE_PRIMARY_ , 508, 510, , 490, 675 504, 505, 506, 507 , , 504, 490, 508, 509 505, 506 , 508, Claims of conformance, 625 651 Classes of SQL-statements, , 508 51 CLASS_ORIGIN, 83, 84, 479, , 508 481, 485, 663 , 508, Client-server operation, 74 510 CLOSE, 84, 381, 403, 405, , 471, 482, 483 508, 510, 511, 639, 664 , 50, 53, 55, 57, 58, 59, 368, , 490, 508, 509, 510, 381, 482 664 cluster, 45, 566, 654 Codes associated with Clusters of catalogs, 45 datetime data types , 504, in Dynamic SQL, 429 507 Codes used for s in Dynamic 182, 444, 446, 544, 679 SQL, 429 COBOL, 3, 49, 61, 83, 243, Codes used for SQL data 358, 359, 363, 364, 489, types in Dynamic SQL, 490, 491, 493, 495, 498, 428 508, 509, 510, 511, 612, coercibility, 5, 21, 23, 613, 614, 625, 639, 651, 24, 25, 35, 115, 122, 661, 662, 664, 675 125, 133, 134, 145, 155, , 161, 187, 208, 214, 237, 508, 510, 651 264, 297, 372 , 508, 509, Coercible, 23, 24, 25, 26, 510, 511, 639 115, 145, 208, 264 COLLATE, 84, 251, 318, 444, 679 Index 9 , 21, 23, , 53, 24, 36, 37, 160, 161, 255, 257, 314, 315, 316, 163, 187, 188, 251, 262, 317, 331, 335, 368, 482, 263, 264, 265, 301, 302, 632, 634, 635, 637, 639, 303, 311, 331, 337, 372, 661 631, 632, 633 collation descriptor, 21, Collating coercibility 44, 313, 315, 317, 318, rules for dyadic 323, 608 operators, 24 , 36, 37, Collating coercibility 99, 103, 104, 251, 259, rules for monadic 265, 302, 310, 314, 315, operators, 24 316, 318, 329, 331, 333, collating sequence, 6 335, 444, 452, 454, 629 , 314, 315 572, 604, 606, 608, 640 Collating sequence usage COLLATIONS base table, 608 for comparisons, 25 , 311, collation, 6, 20, 21, 24, 312, 314, 315, 316 35, 36, 37, 44, 53, 64, COLLATIONS view, 555 65, 66, 87, 99, 103, COLLATIONS_CHARACTER_SET_ 104, 251, 255, 256, 257, CATALOG_NOT_NULL, 608 258, 259, 263, 265, 301, COLLATIONS_CHARACTER_SET_ 302, 310, 311, 312, 314, NAME_NOT_NULL, 608 315, 316, 317, 318, 319, COLLATIONS_CHARACTER_SET_ 323, 329, 330, 331, 333, SCHEMA_NOT_NULL, 608 334, 335, 336, 337, 368, COLLATIONS_CHECK_ 436, 444, 452, 454, 482, REFERENCES_CHARACTER_ 483, 555, 572, 605, 607, SETS, 608 COLLATIONS_FOREIGN_KEY_ 608, 609, 629, 632, 634, SCHEMATA, 608 635, 637, 639, 661, 665, COLLATIONS_PAD_ATTRIBUTE_ 674 CHECK, 608 COLLATION, 84, 259, 311, COLLATIONS_PRIMARY_KEY, 608 314, 315, 316, 318, 329, COLLATION_CATALOG, 83, 427, 331, 332, 482, 679 434, 436, 438, 452, 454, 539, 544, 545, 555, 570, 571, 572, 604, 606, 608, 609 10 Database Language SQL COLLATION_NAME, 83, 428, column, 14, 15, 21, 23, 24, 434, 436, 438, 452, 454, 35, 36, 37, 38, 39, 41, 539, 544, 545, 555, 570, 42, 43, 50, 61, 62, 63, 571, 572, 604, 606, 608, 64, 65, 66, 75, 98, 103, 609 109, 118, 119, 120, 121, COLLATION_SCHEMA, 83, 427, 122, 123, 124, 125, 126, 434, 436, 438, 452, 454, 127, 155, 156, 174, 176, 539, 544, 545, 555, 570, 177, 178, 179, 180, 181, 571, 572, 604, 606, 608, 182, 183, 184, 185, 186, 609 187, 189, 190, 191, 192, collection, 5, 6, 14 193, 194, 195, 196, 197, , 80, 91, 99, 242, 198, 199, 200, 201, 202, 490, 500, 517 203, 208, 217, 219, 220, 223, 224, 227, 228, 230, 234, 236, 245, 246, 256, 260, 261, 262, 263, 264, 265, 266, 267, 268, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 288, 289, 290, 292, 296, 297, 298, 299, 301, 302, 304, 306, 309, 318, 325, 326, 329, 330, 331, 333, 334, 335, 336, 337, 371, 372, 373, 374, 377, 379, 380, 383, 386, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 420, 436, 446, 447, 450, 451, 452, 457, 464, 469, 474, 475, 487, 530, 533, 544, 547, 552, 558, 561, 562, 569, 570, 572, 579, 580, 581, 582, 584, 588, 589, 591, 594, 596, 597, 601, 602, 603, 613, 618, 641, 643, 644, 645, 647, 648, 665, 669, 670, 671, 672, 673, 674, 677 Index 11 COLUMN, 84, 284, 286, 289, , 21, 679 121, 122, 123, 124, 125, , 262, 126, 127, 155, 156, 177, 264, 265, 645 181, 185, 187, 189, 190, , 262, 263, 230, 264, 284, 302, 390, 264 579, 594, 630, 641, 643, , 109, 644, 669, 670 256, 260, 261, 262, 263, Columns, 36 264, 265, 266, 273, 284, COLUMNS, 539, 544, 545, 325, 397, 398, 644, 645 562, 572, 576, 580, 584, column descriptor, 37, 39, 588, 596, 602, 640 187, 192, 197, 198, 199, COLUMNS base table, 580 200, 265, 267, 268, 286, COLUMNS view, 544 287, 288, 297, 302, 306, COLUMNS_CHECK_DATA_TYPE, 309, 318, 372, 393, 397, 580 451, 580, 581 COLUMNS_CHECK_REFERENCES_ , 36, 98, 103, DOMAIN, 580 118, 119, 121, 174, 181, COLUMNS_FOREIGN_KEY_TABLES, 182, 191, 192, 197, 198, 580 199, 200, 245, 246, 262, COLUMNS_PRIMARY_KEY, 580 265, 272, 273, 276, 282, COLUMNS_UNIQUE, 580 COLUMN_DEFAULT, 544, 580, 284, 286, 287, 288, 289, 581 296, 297, 298, 309, 326, COLUMN_DOMAIN_USAGE, 562, 331, 334, 335, 371, 372, 640 373, 388, 389, 390, 391, COLUMN_DOMAIN_USAGE view, 392, 394, 398, 474, 487, 562 530, 645, 648, 670 COLUMN_NAME, 83, 480, 481, , 64, 65, 487, 539, 544, 545, 547, 66, 118, 180, 196, 245, 552, 558, 561, 562, 570, 272, 274, 296, 371, 372, 571, 572, 573, 580, 581, 373, 374, 388, 392, 464, 584, 588, 589, 596, 597, 474, 635, 638 602, 603, 617, 618 column privilege descriptor COLUMN_POSITION_NOT_NULL, , 66 580 COLUMN_PRIVILEGES, 542, 545, 547, 602, 640 12 Database Language SQL COLUMN_PRIVILEGES base COMMITTED, 68, 69, 83, 399 table, 602 common column name, 121, COLUMN_PRIVILEGES view, 547 122, 181 COLUMN_PRIVILEGES_FOREIGN_ comparable, 6, 21, 27, 31, KEY_COLUMNS, 602 33, 34, 35, 134, 142, COLUMN_PRIVILEGES_GRANTEE_ 169, 181, 207, 209, 211, FOREIGN_KEY_USERS, 602 214, 220, 224, 227, 231, COLUMN_PRIVILEGES_GRANTOR_ 234, 237 FOREIGN_KEY_USERS, 602 , COLUMN_PRIVILEGES_IS_ 156, 203, 205, 207, 209, GRANTABLE_CHECK, 602 220, 221, 373, 444, 446, COLUMN_PRIVILEGES_IS_ 531, 642, 643 GRANTABLE_NOT_NULL, compilation unit, 1, 2, 46, 602 47, 61, 67, 490, 501, COLUMN_PRIVILEGES_PRIMARY_ 505, 509, 512, 515, 517, KEY, 602 521, 654 COLUMN_PRIVILEGES_TYPE_ COMPLETION, 85 CHECK, 602 completion condition, 10 , 80, 107, 108, 118, , 207, 208, 209, 141, 173, 176, 178, 187, 210, 220, 221, 373, 531 191, 212, 239, 245, 260, , 160, 161, 329, 333, 346, 371, 377, 162, 163, 164, 642 382, 391, 399, 401, 434, , 438, 451, 474, 479, 500, 22, 83, 160, 445 504, 505, 512, 515, 517, Concepts, 19 520 , 497, 499 COMMAND_FUNCTION, 83, 479, , 497, 481, 482, 488 499 , 83, 86, 444, 462 Conditional rules, 13 , 83 , , 83, 479, 485 86 , 479, 480, 485 275, 281, 397, 403, 482 , 41, 50, name>, 479, 480, 481 52, 54, 67, 69, 71, 253, , 479, 342, 369, 403, 413, 482, 480, 485, 673 526, 671 Index 13 CONDITION_NUMBER, 83, 354, CONSTRAINT, 84, 292, 308, 479, 481, 485 338, 484, 536, 565, 568, conformance, 9, 12, 16, 17, 569, 570, 571, 572, 573, 75, 76, 563, 612, 614, 574, 576, 578, 580, 583, 625, 626, 627 584, 585, 586, 588, 590, Conformance, 625 591, 593, 595, 596, 598, CONNECT, 84, 349, 407, 483, 600, 602, 604, 605, 606, 527, 679 608, 610, 611, 612, 679 CONNECTION, 84, 349, 410, , 484, 527, 679 252, 253, 262, 263, 270, connection does not exist, 301, 309, 325, 633 349, 410, 412, 527, 620 , connection exception, 71, 252, 253 349, 408, 409, 410, 412, constraint mode, 40, 41, 527, 620 67, 74, 253, 270, 326, connection failure, 71, 350, 401, 402, 528 410, 620 , 99, 103, Connection management, 407 105, 252, 259, 270, 292, , 71, 99, 103, 104, 407, 408, 410, 302, 308, 309, 325, 326, 412, 488 328, 338, 401, 402, 586, connection name in use, 616, 640, 670 408, 620 , 410, definition>, 252, 253, 411, 412 262, 263, 265, 270, 271, , 407 301, 302, 309, 645, 665, CONNECTION_NAME, 83, 352, 670 354, 480, 481, 488 , 54, definition> and 65, 70, 71, 72, 74, 349, , 369, 407, 408, 409, 483, 252 488, 527, 636, 655, 662, , 669, 672 401, 402 consistent, 673 CONSTRAINTS, 84, 401, 403, constraint, 45 679 14 Database Language SQL CONSTRAINT_CATALOG, 83, Conventions, 9 480, 481, 486, 487, 541, CONVERT, 84, 132, 679 549, 550, 551, 552, 553, Coordinated Universal Time, 559, 561, 574, 575, 585, 5 586, 588, 589, 590, 591, , 99, 593, 595, 596, 598, 616, 102, 103, 118, 119, 121, 617, 618, 665 122 CONSTRAINT_COLUMN_USAGE, CORRESPONDING, 84, 196, 561, 640 198, 199, 202, 289, 643, CONSTRAINT_COLUMN_USAGE 679 view, 561 CONSTRAINT_NAME, 83, 480, , 196, 198 481, 486, 487, 541, 549, corresponding join columns, 550, 551, 552, 553, 559, 181, 182, 183 561, 574, 575, 585, 586, , 196 588, 589, 590, 591, 593, COUNT, 62, 84, 124, 125, 595, 596, 598, 616, 617, 126, 192, 434, 435, 436, 618, 665 438, 439, 452, 453, 455, CONSTRAINT_SCHEMA, 83, 480, 457, 485, 537, 586, 616, 481, 486, 487, 541, 549, 617, 641, 659 550, 551, 552, 553, 559, CREATE, 84, 255, 260, 296, 561, 574, 575, 585, 586, 301, 311, 314, 320, 325, 588, 589, 590, 591, 593, 482, 483, 484, 535, 536, 595, 596, 598, 616, 617, 537, 538, 539, 541, 542, 618, 665 543, 544, 546, 547, 548, CONSTRAINT_TABLE_USAGE, 549, 550, 551, 552, 553, 559, 640 554, 555, 556, 557, 558, CONSTRAINT_TABLE_USAGE 559, 561, 562, 563, 564, view, 559 565, 567, 568, 569, 570, CONSTRAINT_TYPE, 549, 585, 573, 574, 576, 578, 580, 586, 587, 588, 590, 591, 583, 584, 585, 588, 590, 618 593, 595, 596, 598, 600, CONSTRAINT_TYPE_CHECK, 585, 602, 604, 606, 608, 610, 588, 590 612, 616, 617, 618 CONSTRAINT_TYPE_NOT_NULL, 585 CONTINUE, 84, 497, 499 Index 15 created local temporary CURRENT_USER, 70, 84, 114, table, 37, 38, 39, 72, 115, 116, 117, 266, 267, 258, 260, 261, 275, 281, 268, 269, 282, 325, 375, 655, 668 530, 538, 539, 541, 542, CROSS, 84, 180, 182, 679 543, 545, 546, 547, 548, , 180, 183, 549, 550, 551, 552, 553, 184, 631 554, 555, 556, 557, 558, , 504 559, 561, 562, 641, 645, CURRENT, 84, 384, 391, 412, 658, 679 472, 474, 476, 477 cursor, 49 , 139 482, 483, 484 current SQL-connection, 71, , 62, 99, 103, 72, 408, 409, 410, 411, 341, 342, 371, 375, 377, 412, 413 381, 384, 391, 392, 443, current SQL-session, 44, 462, 464, 467, 469, 471, 45, 72, 73, 93, 100, 472, 474, 475, 476, 477, 101, 103, 104, 115, 309, 492, 635, 636 401, 408, 409, 410, 411, cursor operation conflict, 415, 417, 419, 420, 421, 279, 385, 387, 392, 395, 422, 487, 526, 653, 654, 486, 622 656 Cursors, 49 , 62, function>, 139 119, 371, 372, 373, 374, , 139 442, 448, 449, 464, 465, CURRENT_DATE, 70, 84, 139, 467, 469, 472, 474, 476, 153, 645, 669, 679 477, 635, 636, 638, 647 CURRENT_TIME, 84, 139, 645, cursor specification cannot 669, 679 be executed, 459, 621 CURRENT_TIMESTAMP, 84, 139, CURSOR_NAME, 83, 352, 354, 645, 669, 679 480, 481, 486, 487 , 504, 505, 506, 507, 651, 664 , 490, 504, 505, 506, 507 16 Database Language SQL , DATA_TYPE, 354, 539, 544, 504 545, 570, 571, 572, 573, CYCLE, 85 580, 581 - D - DATA_TYPE_CHECK_REFERENCES_ DATA, 83, 85, 427, 434, COLLATION, 571 435, 436, 439, 452, 453, DATA_TYPE_DESCRIPTOR, 539, 455, 456, 458, 673 545, 570, 571, 572, 573, Data assignment rules, 231 581 database, 1, 2, 7, 14, 45, DATA_TYPE_DESCRIPTOR base 61, 63, 70, 625 table, 570 data exception, 111, 112, DATA_TYPE_DESCRIPTOR_CHECK_ 126, 135, 136, 137, 146, USED, 572 147, 148, 149, 150, 151, DATA_TYPE_DESCRIPTOR_ 152, 153, 154, 158, 163, PRIMARY_KEY, 571 167, 215, 231, 233, 234, date, 5 235, 348, 363, 422, 435, DATE, 19, 31, 84, 90, 94, 439, 620 108, 110, 111, 139, 152, Data manipulation, 371 166, 429, 440, 571, 679 Data parameters, 48 , 90, 94 data type, 19 , 82, 90 , 47, 63, 93, datetime data type 103, 107, 113, 115, 144, descriptor, 29 192, 262, 263, 264, 265, , 165 , 31, 33, 301, 346, 350, 351, 352, 94, 96, 111, 112, 128, 356, 357, 358, 359, 360, 129, 130, 145, 152, 153, 361, 362, 415, 419, 420, 154, 165, 166, 167, 168, 422, 446, 492, 494, 630, 169, 170, 209, 227, 238, 635, 640, 647, 658 239, 240, 241, 267, 659 data type descriptor, 19, datetime field overflow, 20, 26, 27, 29, 30, 36, 167, 620 37, 192, 265, 290, 302, , 89, 90, 309, 310, 570, 572 95, 96, 97, 267, 640 Data types, 19 , 165, Data types of s 166, 167 used in SQL item Datetimes, 30 descriptor areas, 427 Datetimes and intervals, 29 , 165, 166, 167, 168, 169, 171, 445 Index 17 , 107, 108, , 50, 54, 630, 640 60, 61, 63, 369, 449, , 91, 92, 483, 635, 637 95 DEC, 84, 108, 366, 515, 516, 520 , 128, 129, 130, 155, DECIMAL, 19, 27, 34, 84, 156, 165, 166, 167, 168, 107, 108, 109, 110, 360, 169, 170, 642 361, 425, 426, 429, 440, , 516, 520, 522, 571, 657, 139, 140, 165, 266, 267, 658 268, 269, 282, 325, 375, DECLARE, 84, 371, 397, 464, 641 490, 520, 521 DATETIME_INTERVAL_CODE, 83, , 46, 49, 426, 427, 434, 436, 439, 50, 53, 56, 57, 58, 60, 440, 441, 453, 454, 455, 341, 342, 371, 374, 375, 456, 457, 663 377, 381, 384, 391, 464, DATETIME_INTERVAL_PRECISION 476, 477, 489, 492, 493, , 83, 427, 434, 436, 495, 496, 647, 662, 665, 439, 440, 441, 453, 455, 668, 671, 673, 674, 675, 456, 457, 663 677 DATETIME_PRECISION, 539, declared local temporary 544, 570, 571, 572 table, 37, 39, 72, 101, , 90, 91, 96 103, 245, 275, 281, 283, DAY, 30, 31, 32, 33, 84, 294, 397, 398, 459, 486, 95, 112, 167, 238, 239, 487, 655 240, 430, 441, 445, 679 DEFAULT, 84, 173, 175, 255, , 91, 94 266, 274, 278, 279, 288, , 91 306, 311, 312, 314, 316, , 91, 95 DEALLOCATE, 84, 342, 433, 349, 388, 391, 393, 407, 447, 449, 483, 526, 679 408, 410, 412, 527, 590, , 54, 60, 62, , 35, 262, 342, 369, 433, 483, 526 266, 267, 268, 287, 301, 302, 305, 309 default collating sequence, 5 18 Database Language SQL , 36, 37, Definitions, 5 266, 268, 269, 573, 581, Definitions, notations, and 645 conventions, 5 , definition schema, 45 173, 174 Definition Schema, 75, 77, default SQL-connection, 71, 86, 100, 533, 566 72, 408, 412 Definitions provided in default SQL-session, 72, this International 349, 408, 527 Standard, 5 default time zone, 73, 94, Definitions taken from 96, 112, 122, 656 ISO/IEC 10646, 5 DEFAULT_CHARACTER_SET_ Definitions taken from ISO CATALOG, 538, 569 8601, 5 DEFAULT_CHARACTER_SET_NAME, DEFINITION_SCHEMA, 75, 101, 538, 569 538, 539, 541, 542, 543, DEFAULT_CHARACTER_SET_ 544, 545, 546, 547, 548, SCHEMA, 538, 569 549, 550, 551, 552, 553, DEFAULT_COLLATE_CATALOG, 554, 555, 556, 557, 558, 554, 606, 607, 674 559, 561, 562, 563, 566, DEFAULT_COLLATE_NAME, 554, 567 606, 607, 674 DEFINITION_SCHEMA Schema, DEFAULT_COLLATE_SCHEMA, 567 554, 606, 607, 674 degree, 37, 39, 68, 119, deferrable, 36, 40, 41, 174, 176, 179, 183, 191, 253, 270, 275, 326, 575, 199, 203, 207, 211, 218, 587, 598 220, 224, 227, 261, 265, DEFERRABLE, 84, 252, 253, 284, 290, 297, 372, 377, 270, 301, 325, 401, 402, 378, 388, 452, 457, 469, 541, 549, 553, 574, 575, 530, 617, 618 585, 587, 598, 633, 679 DELETE, 64, 66, 84, 245, deferred, 40, 41, 67, 76, 260, 261, 274, 275, 281, 253, 270, 326, 402, 575, 298, 330, 384, 386, 397, 587, 599, 655 398, 403, 472, 476, 483, DEFERRED, 84, 252, 253, 401, 541, 549, 553, 574, 484, 550, 590, 592, 600, 575, 585, 587, 598, 599, 601 679 , 274, 276, Definition, 10 277, 278, 279, 592 Index 19 , 50, 53, 19, 37, 39, 40, 48, 49, 55, 57, 59, 279, 369, 50, 51, 64, 65, 66, 69, 384, 385, 387, 392, 395, 72, 74, 122, 140, 171, 472, 476, 483 174, 192, 197, 199, 200, , 53, 55, 56, 292, 296, 300, 302, 304, 58, 59, 119, 122, 369, 309, 335, 338, 342, 346, 384, 386, 387, 392, 403, 350, 351, 373, 379, 380, 442, 483, 484, 485, 525, 382, 383, 397, 400, 412, 673 435, 436, 440, 441, 448, DELETE_RULE, 550, 590, 592 452, 454, 485, 493, 494, , 76, 495, 526, 530, 531, 557, 82, 86, 87, 98, 533 558, 562, 607, 667, 668, 669, 670, 671, 672, 673, , 82, 86, 87, 88, 100, 674, 677, 678 533, 629 dependent privilege descriptors still exist, , 82, 86 338, 621 , 82, 86, deprecated, 47, 75, 346, 629, 640 347, 356, 357, 358, 359, depend, 12, 35, 41, 44, 59, 335, 336, 452 360, 361, 496, 502, 507, dependency graph, 335 510, 514, 516, 519, 522, dependend on, 292 624 Deprecated features, 675 DEPTH, 85 , 122, 182, 191, 192, 195, 379, 452 , 118, 119, 120, 641 derived table, 37 , 118, 119, 120, 178, 193, 200, 630, 631 derived table descriptor, 40 20 Database Language SQL DESC, 84, 314, 316, 371, Diagnostics area, 48 373 diagnostics area limit, 67, DESCRIBE, 84, 450, 483, 679 74, 400 , Diagnostics management, 479 54, 60, 61, 450, 453, , 399 456, 635, 638, 673 DICTIONARY, 85 , 79, 82, 90, 94, , 54, 60, 61, 450, 451, 96, 98, 148, 150, 619, 457, 673 629, 666 , 369, , 525, Description, 10 526, 527, 665 Description of SQL item Direct invocation of SQL, descriptor areas, 425 64, 525 descriptor, 6, 14 directly, 37, 45, 49, 51, DESCRIPTOR, 84, 342, 353, 58, 61, 64, 70, 73, 74, 354, 355, 431, 433, 434, 93, 100, 101, 121, 125, 438, 451, 482, 483, 484, 156, 167, 181, 185, 186, 526, 539, 545, 570, 571, 189, 190, 192, 193, 194, 572, 573, 581, 679 230, 264, 301, 335, 336, , 338, 391, 392, 394, 415, 434, 435, 438, 439 417, 419, 474, 485, 525, , 62, 99, 643, 656, 673 102, 104, 105, 342, 431, directly contain, 11, 121, 432, 433, 434, 435, 436, 125, 156, 167, 181, 185, 437, 438, 439, 441, 451, 186, 189, 190, 192, 193, 453, 455, 457, 458, 526, 230, 264, 301, 392, 394, 637, 638 474, 485, 643 Descriptors, 14 directly dependent on, 335 deterministic, 40, 189, Directly executable SQL- 193, 200, 282, 325 statements, 58 DIAGNOSTICS, 84, 399, 479, , 525 diagnostics area, 41, 48, , 53, 56, 351, 400, 479, 482, 485, 57, 58, 59, 119, 483, 526, 528, 529, 619, 663, 525, 526, 530 668, 669 Index 21 domain, 15, 35, 36, 37, 40, , 525, 528, 639, 652 43, 44, 45, 47, 52, 64, , 64, 65, 66, 75, 76, 98, 103, 67, 71, 73, 74, 93, 100, 105, 109, 115, 144, 145, 101, 349, 415, 417, 419, 154, 192, 236, 255, 256, 525, 526, 527, 528, 529, 257, 258, 262, 263, 264, 614, 625, 627, 640, 651, 265, 266, 267, 268, 281, 655, 656 282, 290, 301, 302, 303, dirty read, 68 304, 305, 306, 307, 308, DISCONNECT, 84, 355, 412, 309, 310, 318, 329, 330, 483, 679 331, 333, 334, 336, 337, disconnect error, 413, 623 338, 368, 446, 482, 483, , 412 , 54, 533, 539, 540, 541, 562, 71, 369, 412, 413, 483, 564, 565, 569, 570, 572, 636, 672 573, 574, 575, 581, 593, distinct, 5, 6, 7, 19, 20, 595, 596, 605, 633, 634, 22, 29, 38, 39, 183, 640, 644, 646 187, 273, 277, 278, 279, DOMAIN, 84, 258, 301, 304, 298, 373, 493, 494, 495, 309, 329, 338, 482, 564, 496, 531, 668, 670, 673, 565, 680 677 domain constraint, 40, 43 DISTINCT, 84, 124, 126, , 35, 193, 194, 195, 208, 539, 115, 154, 301, 302, 307, 541, 544, 617, 630, 631, 564 670 domain constraint division by zero, 158, 620 descriptor, 36, 40, 43, 302, 309, 337, 338 Domain constraints, 43 domain definition, 35 , 52, 109, 115, 255, 256, 257, 266, 281, 301, 302, 303, 310, 368, 483, 644, 646 22 Database Language SQL domain descriptor, 36, 44, DOMAIN_CONSTRAINTS_FOREIGN_ 75, 236, 267, 268, 301, KEY_CHECK_CONSTRAINTS, 302, 304, 305, 306, 307, 574 308, 318, 330, 331, 337, DOMAIN_CONSTRAINTS_FOREIGN_ 338, 573 KEY_DOMAINS, 574 , 35, 98, 103, DOMAIN_CONSTRAINTS_FOREIGN_ 105, 144, 145, 154, 192, KEY_SCHEMATA, 574 258, 262, 263, 264, 265, DOMAIN_CONSTRAINTS_ 301, 302, 304, 305, 306, INITIALLY_DEFERRED_ 307, 308, 309, 329, 331, NOT_NULL, 574 333, 338, 446, 581, 640, DOMAIN_CONSTRAINTS_PRIMARY_ 644 KEY, 574 Domains, 35 DOMAIN_DEFAULT, 539, 573 DOMAINS, 539, 562, 572, DOMAIN_NAME, 539, 541, 544, 573, 574, 580, 604, 616, 545, 562, 570, 571, 572, 640 573, 574, 575, 580, 581, DOMAINS base table, 573 604 DOMAINS view, 539 DOMAIN_NAME_NOT_NULL, 574 DOMAINS_CHECK_DATA_TYPE, DOMAIN_SCHEMA, 539, 541, 573 544, 545, 562, 570, 571, DOMAINS_FOREIGN_KEY_ 572, 573, 574, 575, 580, SCHEMATA, 573 581, 604 DOMAINS_PRIMARY_KEY, 573 DOMAIN_SCHEMA_NOT_NULL, 574 DOMAIN_CATALOG, 539, 541, dormant SQL-connection, 71, 544, 545, 562, 570, 571, 72, 408 572, 573, 574, 575, 580, dormant SQL-session, 72, 581, 604 408, 411 DOMAIN_CATALOG_NOT_NULL, DOUBLE, 19, 27, 34, 84, 574 108, 110, 352, 357, 358, DOMAIN_CONSTRAINTS, 541, 359, 425, 426, 429, 440, 574, 593, 616 500, 502, 507, 512, 513, DOMAIN_CONSTRAINTS base 571, 658 table, 574 , 83, 500, DOMAIN_CONSTRAINTS view, 517 541 , 79, 80, 82, DOMAIN_CONSTRAINTS_CHECK_ 86, 87 DEFERRABLE, 574 , 82, 86, 87 Index 23 DROP, 84, 258, 259, 288, , 53, 259, 306, 308, 309, 313, 318, 323, 324, 368, 483, 634, 323, 328, 338, 398, 483, 635, 637, 639 680 , 52, , 258, 290, 300, 338, 368, 52, 259, 328, 338, 368, 483, 646 483, 634, 635, 637, 639 duplicate, 6, 7, 126, 181, , 258, 289, 194, 195, 201, 202, 223, 292, 294, 300, 309, 333 332, 619 , 52, 259, 443 313, 368, 483, 646 dyadic operator, 6, 24, 443 , DYNAMIC, 483 53, 259, 318, 319, 368, , 483, 634, 635, 637, 639 50, 53, 55, 57, 58, 59, , 286, 288, 645 , 99, , 104, 105, 467, 469, 471, 283, 289, 290, 645 472, 474, 475, 638, 640 , definition>, 304, 308, 49, 53, 56, 57, 58, 60, 634 62, 341, 343, 448, 464, , 304, 306, 634 476, 477, 489, 492, 494, , 495, 638, 647, 651 52, 258, 309, 310, 338, , 50, 53, , 55, 57, 59, 60, 62, 369, 52, 258, 259, 368, 483, 472, 483 644 , , 283, 292, 62, 369, 441, 451, 456, 293, 646 457, 469, 470, 483, 638, , 52, 663 258, 294, 295, 368, 398, 483, 644 24 Database Language SQL , effective, 12, 13, 19, 23, 50, 53, 55, 57, 58, 59, 26, 31, 33, 34, 35, 38, 62, 369, 441, 455, 464, 39, 41, 49, 51, 72, 73, 465, 467, 468, 483, 663 74, 87, 94, 96, 112, , 63, 183, 184, 185, 190, 198, 114, 115, 116, 168, 281, 208, 209, 236, 248, 253, 296, 325, 436, 439, 443, 256, 258, 259, 273, 276, 450, 453, 454, 455, 456, 280, 282, 289, 290, 292, 460, 462, 467, 525, 641, 294, 299, 300, 302, 310, 672 313, 315, 317, 318, 321, , 323, 326, 330, 331, 332, 53, 56, 57, 58, 59, 60, 338, 342, 349, 373, 375, 61, 62, 350, 442, 452, 376, 385, 386, 387, 389, 455, 456, 459, 462 393, 395, 397, 398, 403, , 53, 56, 57, 458, 485, 493, 526, 527, 58, 59, 61, 62, 350, 531, 570, 573, 574, 576, 442, 452, 456, 459, 460, 578, 580, 585, 598, 600, 462, 483, 637 602, 604, 656, 668, 669 Dynamic SQL, 425 effectively, 12 dynamic SQL error, 431, ELSE, 84, 141, 142, 543, 435, 439, 448, 455, 456, 544, 680 457, 458, 459, 460, 465, , 141, 142, 467, 621 143 , 50, 53, Embeddable SQL-statements, 55, 57, 59, 60, 62, 299, 55 369, 474, 475, 483 DYNAMIC_FUNCTION, 83, 479, 481, 482, 488 - E - EACH, 85 Index 25 embedded, 1, 2, 49, 51, , 61, 489, 490, 61, 62, 63, 75, 79, 114, 491, 495, 496, 501, 505, 115, 116, 489, 490, 491, 509, 512, 515, 517, 521 492, 493, 494, 495, 496, , 497, 498, 499, 500, 501, 61, 489, 490, 491, 495, 502, 504, 505, 506, 507, 517 508, 509, 510, 512, 513, , 61, 489, 491, 519, 520, 521, 522, 613, 493, 495, 496, 498, 512, 614, 625, 627, 639, 651, 513, 514 655, 661, 662, 663, 673, 674, 675, 678 , 61, 63, 489, 490, 491, , 489, 490, 614, 625, 627, 673, 674, 492, 493, 495, 496, 651, 678 663 , 489, 490, declaration>, 55, 489, 491, 495 495, 497, 498, 499 , 61, 489, 491, , 493, 498, 515, 516 61, 489, 491, 493, 495, , 61, 489, 491, , 61, 489, 490, 519 491, 495, 517 , 61, 489, 491, 495, 498, 520, 521, 522 493, 495, 498, 508, 509, , 510, 675 61, 115, 489, 490, 491, , 492, 493, 495, 501, 505, 61, 489, 491, 493, 495, 509, 512, 515, 517, 521, 498, 504, 505, 506, 507 639, 651 Embedded syntax, 61 26 Database Language SQL , , 214, 114, 115, 116, 490, 493, 215, 217, 447, 643 494, 673 , END, 84, 141, 142, 490, 90, 94, 95, 147, 149, 543, 544 267 END-EXEC, 84, 489, 491, 680 , 28, , 171, 238, 239, 107, 109, 356, 453, 454, 240, 241, 242 502, 658, 661 end-of-line indicator, 83, exact numeric value, 28 656 EXCEPT, 84, 196, 197, 201, Entry SQL, 625, 629, 640 202, 576, 643, 680 Entry SQL Specifications, exception, 10, 12, 13, 34, 640 35, 36, 41, 47, 48, 52, environment, 2, 14, 16, 45, 55, 56, 57, 58, 60, 64, 46, 70, 71, 72, 74, 75, 67, 69, 71, 86, 95, 111, 77, 246, 344, 654, 655, 112, 126, 135, 136, 137, 663, 669 146, 147, 148, 149, 150, EQUALS, 85 151, 152, 153, 154, 158, , 80, 207, 163, 167, 203, 215, 231, 391, 434, 438, 479, 500, 233, 234, 235, 236, 253, 505 279, 299, 338, 348, 349, EQUAL_KEY_DEGREES, 617 EQUAL_KEY_DEGREES assertion 350, 363, 375, 378, 379, , 617 380, 381, 382, 383, 384, equivalent, 1, 14, 15, 61, 386, 389, 392, 393, 394, 62, 71, 86, 87, 92, 93, 400, 403, 404, 405, 407, 94, 100, 108, 121, 142, 408, 409, 410, 412, 413, 146, 147, 174, 191, 197, 415, 417, 419, 420, 422, 198, 211, 212, 214, 229, 431, 433, 435, 439, 441, 241, 245, 246, 263, 264, 443, 447, 448, 449, 450, 333, 388, 397, 492, 496, 451, 455, 456, 457, 458, 501, 502, 506, 507, 510, 459, 460, 462, 465, 466, 513, 516, 518, 519, 521, 467, 479, 482, 485, 486, 522, 533 489, 495, 497, 498, 499, error in assignment, 435, 526, 527, 528, 624, 654, 439, 620 655, 662, 666, 667, 672 ESCAPE, 84, 214, 215, 353 EXCEPTION, 84, 479, 680 exception condition, 10 Index 27 Exceptions, 10 explicit, 8, 10, 15, 20, EXEC, 84, 489, 491 23, 31, 35, 41, 44, 45, EXECUTE, 84, 354, 459, 462, 50, 66, 67, 68, 69, 70, 483, 680 71, 72, 74, 86, 101, , 14, 44, 143, 152, 153, 174, 196, 45, 54, 59, 61, 63, 64, 197, 198, 202, 241, 242, 73, 93, 100, 101, 115, 253, 256, 258, 260, 270, 369, 415, 417, 419, 462, 272, 283, 284, 292, 294, 483, 653, 654, 656 296, 297, 300, 301, 302, , 14, 304, 309, 311, 312, 313, 54, 59, 61, 64, 369, 315, 316, 318, 321, 323, 441, 447, 448, 455, 456, 325, 326, 328, 329, 333, 457, 459, 460, 483, 663 334, 335, 341, 348, 377, , 311, 312 469, 474, 488, 493, 579, EXISTS, 84, 222, 271, 273, 303, 544, 576, 617, 618 584, 594, 629, 632, 654, , 191, 655, 656, 661, 662, 667 205, 222 Explicit, 23, 24, 25, 26, 35, 161, 187, 372 , 196, 197, 202, 632 explicit type conversion, 35 , 90, 95 exposed, 118, 119 , 62, 99, 102, 104, 443, 462, 465, 466, 467, 629, 657 , 62, 99, 102, 104, 447, 448, 465, 629, 657, 672 Extensions and options, 626 EXTERNAL, 84, 314, 320, 661, 680 , 314, 317 28 Database Language SQL , fixed-length, 93, 94, 115, 314, 315 145, 147, 148, 150, 151, , 320 161, 162, 163, 231, 232, 234, 235, 237, 268, 506, , 320, 321 507, 658 EXTRACT, 84, 128, 130, 444, fixed-length coding, 5, 6 680 flagger, 76, 77, 626, 656 , 29, Flagger requirements, 626 34, 128, 129, 130, 131, FLOAT, 19, 27, 34, 84, 108, 641, 659 110, 361, 425, 426, 429, , 128, 129, 440, 520, 522, 571, 657, 130, 444 658 , 128, 129, , 22, 132, 133, 135, 130 136, 137, 444, 630 - F - FOR, 84, 132, 133, 149, , 157, 168, 169 151, 314, 320, 333, 335, FALSE, 84, 229, 230, 356, 336, 337, 362, 363, 364, 680 366, 371, 372, 373, 374, feature not supported, 407, 392, 445, 464, 465, 474, 410, 621 635, 638 FETCH, 84, 377, 469, 483 FOREIGN, 84, 264, 274, 569, , 377, 573, 574, 576, 580, 583, 378, 379, 380, 469, 635, 584, 585, 587, 588, 590, 638 591, 595, 596, 598, 600, , 50, 53, 602, 605, 606, 608, 610, 55, 57, 58, 59, 350, 618 368, 377, 380, 483, 635, Format, 9, 11, 12, 15, 86, 647, 671, 677 407, 408, 415, 417, 419, , 377, 420, 431, 443, 447, 459, 379, 380, 470, 647, 671 462, 465, 525, 526, 625, Fields in datetime items, 663, 665, 667 30 form-of-use, 6, 20, 21, 22, Fields in day-time INTERVAL 99, 103, 104, 132, 133, items, 32 134, 136, 137, 148, 149, Fields in year-month INTERVAL items, 32 151, 248, 249, 250, 444, FIRST, 84, 352, 377, 378, 607, 619, 630, 657, 659, 379, 680 660 Index 29 form-of-use conversion, 6, FROM, 84, 128, 130, 132, 20, 22, 103, 104, 133, 133, 134, 149, 151, 152, 134, 136, 137, 444, 630, 153, 154, 178, 180, 182, 657, 659 183, 184, 197, 198, 271, , 272, 273, 276, 289, 294, 22, 132, 133, 136, 137, 300, 303, 310, 311, 313, 444, 630, 659 314, 318, 320, 323, 333, , 99, 103, 104, 380, 384, 386, 403, 407, 132, 133, 134, 136, 630, 408, 415, 417, 419, 420, 657 431, 442, 444, 445, 447, FORM_OF_USE, 554, 606, 607, 465, 469, 472, 476, 485, 665 537, 538, 539, 541, 542, FORTRAN, 83, 243, 359, 364, 543, 544, 545, 546, 547, 493, 612, 613, 614 548, 549, 550, 551, 552, , 490, 512, 513 553, 554, 555, 556, 557, , 512, 513, 514, 571, 572, 573, 576, 578, 639, 651 580, 581, 583, 584, 585, , 490, 512, 596, 604, 606, 608, 610, 513 611, 616, 617, 618, 647 FOUND, 84, 352, 497, 499 , 118, 177, 178, 179, 185, 187, 189, 193, 631, 635, 636, 638 FULL, 42, 84, 180, 182, 184, 224, 225, 274, 276, 277, 278, 590, 591, 613, 618, 680 Full SQL, 625 Function, 9, 10 30 Database Language SQL - G - GENERAL, 85 , 54, 369, 479, 481, , 89, 97 482, 484, 485, 488, 651 generally contain, 11, 127, , 434 139, 186, 281, 282, 296, GLOBAL, 38, 84, 99, 104, 301, 307, 325, 375, 387, 260, 261, 576, 577, 633, 390, 392, 396, 474, 636, 680 641 global temporary table, 37, generally underlying table, 38, 39, 72, 258, 260, 38, 193, 299, 372, 387, 261, 275, 281, 633, 655, 389, 390, 392, 396, 474 668 General Rules, 9, 10, 12, GO, 84, 497, 499 13, 14, 15, 40, 44, 69, GOTO, 84, 497 70, 76, 146, 187, 202, , 497, 498, 499 , 497, 498 205, 253, 258, 261, 278, GRANT, 65, 75, 84, 248, 279, 282, 284, 289, 292, 315, 321, 329, 330, 331, 294, 300, 350, 351, 376, 332, 333, 335, 336, 337, 379, 383, 389, 393, 395, 484, 533, 601, 603, 605 403, 413, 441, 443, 456, grantable privilege, 66 457, 458, 460, 463, 464, GRANTEE, 539, 542, 545, 465, 467, 468, 469, 470, 546, 547, 548, 554, 555, 471, 472, 475, 476, 477, 556, 600, 601, 602, 603, 485, 495, 528, 530, 625, 604, 605 662, 663, 672, 673, 677 , 245, 246, 329, , 330, 331, 332, 333, 338 124, 126, 630, 641 GRANTOR, 546, 547, 548, , 114, 116, 117, , 52, 65, 302, 362, 641, 658 66, 245, 248, 255, 315, GET, 84, 311, 434, 479, 321, 329, 330, 331, 332, 483, 484, 680 368, 484 , 434 , , 434 , operator>, 83, 207 54, 60, 62, 369, 434, GROUP, 84, 187, 616, 617 435, 436, 483, 672 Index 31 , 38, 118, - I - 177, 187, 189, 193, 203, identified privilege 296, 383, 631, 635, 643 descriptor, 335 grouped table, 38, 124, , 44, 46, 62, 177, 187, 189, 192, 194 71, 73, 98, 99, 100, grouped view, 177, 179, 102, 105, 408, 419, 431, 195, 203, 296, 383, 631, 447, 451, 465, 481, 533, 632, 635, 643 534, 564, 630, 656, 657, 677 , 187 s for use , 187 statement>, 481 - H - , 82, 86, HAVING, 84, 189 87, 88, 100, 533, 629, , 38, 118, 640 125, 177, 181, 185, 189, , 82, 86 193, 203, 296, 383, 631, , 82, 85, 635, 643, 678 86 , 89, 90, 92, 94 IDENTITY, 84, 320, 321, 680 , 82, IF, 85 86, 89, 92, 94, 95, 97, IGNORE, 85 266, 267, 629 immediate, 40, 41, 253, , 16, 17 270, 326, 350, 401, 528, , 490, 575, 587, 599 492, 495, 496 IMMEDIATE, 84, 252, 253, , 270, 301, 325, 401, 403, 497, 498, 499 462, 483, 633, 680 , immediate base, 299 497, 498, 499 immediately contain, 11, host variable, 23, 24 14, 118, 119, 122, 129, , 155, 157, 166, 167, 173, 489, 490, 492, 494, 495, 174, 191, 192, 193, 200, 496 203, 263, 271, 272, 297, HOUR, 30, 31, 32, 33, 73, 302, 311, 315, 320, 335, 84, 95, 112, 113, 123, 390, 392, 396, 408, 422, 130, 166, 167, 238, 239, 431, 444, 465, 474, 648 240, 422, 430, 441, 680 , 91, 94 32 Database Language SQL immediately-executable , 314, implementation-defined, 6, 315, 661 20, 21, 28, 29, 34, 44, Implementation-defined 45, 46, 47, 51, 56, 61, elements, 653 64, 67, 69, 71, 72, 73, , 320, 102, 103, 104, 108, 109, 321, 661 110, 112, 115, 116, 125, , 248, 233, 235, 238, 240, 248, 249, 660 249, 250, 256, 311, 314, implementation-dependent, 315, 317, 320, 321, 341, 6, 10, 12, 13, 19, 37, 344, 348, 356, 357, 358, 39, 40, 48, 49, 50, 51, 359, 360, 361, 362, 363, 64, 65, 66, 69, 72, 74, 364, 365, 366, 373, 400, 122, 140, 171, 174, 192, 404, 407, 408, 420, 422, 197, 199, 200, 208, 237, 431, 432, 440, 441, 442, 270, 279, 296, 302, 309, 443, 445, 447, 452, 454, 342, 346, 350, 351, 373, 481, 485, 486, 488, 492, 379, 380, 382, 383, 397, 501, 502, 506, 509, 510, 400, 412, 435, 436, 440, 513, 516, 518, 521, 522, 441, 448, 452, 454, 485, 525, 526, 527, 528, 529, 493, 494, 495, 526, 530, 531, 564, 565, 586, 607, 531, 607, 667, 668, 669, 609, 612, 613, 614, 615, 670, 671, 672, 673, 674, 619, 624, 626, 630, 653, 677, 678 654, 655, 656, 657, 658, Implementation-dependent 659, 660, 661, 662, 663, elements, 667 664, 665, 666 , 20, 248, 249, 311, 660 Index 33 implicit, 13, 20, 31, 41, IN, 84, 128, 212, 445, 539, 44, 67, 69, 70, 71, 72, 542, 543, 545, 546, 547, 73, 74, 101, 102, 103, 548, 554, 555, 556, 570, 104, 108, 109, 110, 111, 571, 572, 573, 574, 576, 115, 121, 122, 124, 125, 578, 580, 581, 583, 584, 130, 134, 142, 143, 149, 585, 586, 588, 590, 591, 151, 152, 153, 166, 174, 593, 595, 596, 598, 600, 181, 182, 232, 240, 241, 602, 604, 606, 608, 611, 242, 252, 253, 255, 256, 612, 613, 618 258, 260, 263, 266, 268, include, 6, 13, 14, 15, 19, 270, 272, 275, 276, 283, 21, 22, 30, 32, 34, 36, 284, 292, 294, 296, 297, 37, 39, 40, 41, 42, 43, 300, 301, 302, 304, 309, 44, 48, 50, 75, 76, 86, 311, 312, 313, 315, 316, 100, 111, 119, 121, 122, 318, 320, 321, 323, 325, 126, 135, 145, 153, 186, 326, 328, 329, 333, 334, 192, 193, 194, 236, 246, 335, 341, 344, 362, 363, 248, 249, 250, 251, 253, 364, 365, 366, 367, 372, 260, 261, 264, 265, 268, 377, 379, 388, 392, 397, 270, 271, 273, 275, 276, 399, 400, 403, 405, 407, 282, 283, 284, 288, 289, 417, 431, 446, 447, 469, 291, 292, 294, 296, 297, 474, 476, 477, 488, 492, 299, 300, 301, 302, 304, 493, 501, 506, 510, 513, 308, 309, 310, 311, 312, 518, 521, 579, 584, 594, 313, 315, 316, 318, 321, 633, 655, 656, 657, 660, 323, 325, 326, 328, 329, 661, 662, 663, 664, 669, 330, 331, 335, 336, 337, 672 372, 383, 384, 386, 389, Implicit, 23, 24, 25, 26, 392, 394, 397, 452, 454, 35, 122, 134 495, 496, 505, 506, 521, implicit type conversion, 569, 581, 635, 640, 641, 35 643, 668, 686 implicit zero-bit padding, Incompatibilities with 149, 151, 152, 232, 268, ISO/IEC 9075:1989, 677 623 independent, 14, 335, 336 independent node, 335, 336 Index typography, 15 indicator, 231, 656 34 Database Language SQL INDICATOR, 84, 114, 352, INFORMATION_SCHEMA, 20, 45, 353, 427, 434, 435, 436, 75, 103, 249, 355, 533, 439, 452, 453, 455, 456, 535, 536, 537, 538, 539, 458, 500, 502, 673 541, 542, 543, 545, 546, indicator overflow, 231, 547, 548, 549, 550, 551, 620 552, 553, 554, 555, 556, indicator parameter, 48, 557, 558, 559, 561, 562, 114, 115, 116, 192, 231, 568, 569, 570, 573, 574, 356, 435, 436, 439, 630, 576, 578, 580, 583, 584, 659, 661 585, 588, 590, 593, 595, , 114, 596, 598, 600, 602, 604, 115, 116, 192, 436, 439, 606, 607, 608, 609, 610, 630, 659 612, 665 Indicator parameters, 48 INFORMATION_SCHEMA Schema, indicator variable, 47, 48, 535 114, 115, 116 INFORMATION_SCHEMA_CATALOG_ , 114, NAME, 536, 537, 538, 115, 116, 192, 630, 659 539, 541, 542, 543, 545, Information Schema, 1, 10, 45, 63, 66, 69, 75, 77, 546, 547, 548, 549, 550, 282, 299, 326, 398, 533, 551, 552, 553, 554, 555, 534, 535, 536, 538, 540, 556, 557, 558, 559, 561, 541, 542, 543, 545, 546, 562 547, 548, 549, 550, 551, INFORMATION_SCHEMA_CATALOG_ 552, 553, 554, 557, 558, NAME base table, 536 560, 561, 562, 563, 567, INFORMATION_SCHEMA_CATALOG_ 568, 640, 652, 667 NAME_CARDINALITY, 537 Information Schema and INFORMATION_SCHEMA_ Definition Schema, 533 CATALOG_NAME_CARDINALITY assertion, 537 INFORMATION_SCHEMA_CATALOG_ NAME_PRIMARY_KEY, 536 Informative elements, 9 INITIALLY, 84, 252, 253, 270, 301, 325, 541, 549, 553, 574, 575, 585, 587, 598, 599, 633, 680 Index 35 initially deferred, 575, insufficient item 587, 599 descriptor areas, 452, initially immediate, 253, 453, 623 575, 587, 599 INT, 84, 108, 356, 357, INITIALLY_DEFERRED, 541, 366, 500, 502, 515, 516 549, 553, 574, 575, 585, INTEGER, 19, 27, 34, 84, 587, 598, 599 108, 110, 209, 352, 357, INNER, 84, 180, 181, 182, 358, 359, 360, 361, 425, 183, 680 426, 429, 440, 502, 507, innermost, 8, 11, 118 510, 512, 513, 514, 516, , 205, 212, 517, 519, 522, 565, 571, 444, 446 657, 662 , 212 integrity constraint, 1, INPUT, 84, 450, 680 40, 67, 69, 74, 154, input parameter, 61, 62, 347, 348, 350, 357, 362, 236, 253, 270, 325, 385, 363, 364, 365, 366, 367, 387, 403, 486 459, 467, 661 Integrity constraints, 40 INSENSITIVE, 50, 84, 371, integrity constraint 372, 374, 376, 464, 465, violation, 154, 236, 635, 638, 680 253, 403, 486, 621, 622 INSERT, 64, 66, 84, 245, , 16, 17 246, 261, 284, 289, 298, , 16, 17 329, 330, 333, 334, 388, , 16, 17 Intermediate SQL, 625, 629 389, 398, 484, 600, 601, Intermediate SQL 602, 603, 632 Specifications, 629 , 174, INTERSECT, 84, 196, 197, 388, 389, 446 200, 201, 202, 208, 643, 670, 680 , 388, 390, 648 INTERVAL, 19, 30, 31, 32, , 53, 55, 33, 49, 73, 83, 84, 91, 56, 58, 59, 119, 173, 94, 108, 112, 113, 123, 174, 176, 202, 299, 369, 166, 167, 169, 170, 209, 388, 390, 442, 444, 446, 227, 228, 353, 422, 426, 484, 485, 525, 631, 632, 427, 429, 434, 436, 439, 636, 642, 648, 673 440, 441, 445, 453, 454, 455, 456, 457, 571, 663, 680 36 Database Language SQL interval data type descriptor, 29, 30 , 128, 129, 130, 155, , 168, 169 156, 165, 166, 167, 168, interval field overflow, 169, 170, 171, 422, 642 154, 233, 235, 620 intervening, 11, 36, 118, , INTO, 84, 377, 382, 388, 33, 96, 113, 129, 239, 451, 459, 469 240, 241, 242, 427, 445, , 46, 89, 93, 453, 455, 660 98, 100 , 32, 112, in usage by, 301, 307 170, 209, 239, 240, 241, invalid authorization 242, 427, 445, 453, 455, specification, 348, 660 407, 408, 420, 621 , 89, 91, invalid catalog name, 415, 94, 95, 96, 97, 267, 640 621 , 168, invalid character set name, 169 419, 621 , 30, invalid character value 32, 91, 94, 95, 96, 108, for cast, 146, 147, 148, 111, 113, 168, 170, 171, 149, 150, 151, 152, 153, 239, 240, 241, 242, 267, 154, 620 427, 429, 445, 453, 455, invalid condition number, 644 400, 485, 621 Intervals, 32 invalid connection name, , 82, 86, 408, 622 91 invalid cursor name, 443, , 168, 462, 465, 466, 467, 622 169, 170 invalid cursor state, 375, , 168, 169 378, 381, 384, 392, 449, , 165, 166, 487, 622 167, 168, 169, 445 invalid datetime format, , 107, 108, 112, 620 111, 113, 427, 453, 455, invalid descriptor count, 640 455, 457, 621 , 168, 169, 170 431, 435, 439, 621 Index 37 invalid escape character, ISO/IEC 9075, xi, xiii, 215, 620 xvi, 75, 76, 85, 677, invalid escape sequence, 678, 685, 686 215, 620 ISO/IEC 9579-2, 3, 619, 622 invalid parameter value, ISO/IEC 9899, 3, 243, 505 348, 620 ISO/IEC DIS 10032, 1 invalid schema name, 417, ISO 1989, 3, 243, 509 622 ISO 2022, 3, 249 invalid SQL descriptor ISO 6160, 3, 243, 521 name, 431, 433, 435, ISO 7185, 3, 243, 517 439, 451, 622 ISO 8601, 3, 5 invalid SQL statement name, ISO 8652, 3, 243, 501 ISO 9075, 612, 613, 614, 449, 450, 459, 465, 467, 663, 665 622 ISOLATION, 84, 399, 680 invalid time zone isolation level, 68, 69, displacement value, 70, 74, 76, 350, 399, 167, 422, 620 400, 528, 662 invalid transaction state, , 399 350, 384, 386, 389, 392, IS_DEFERRABLE, 541, 549, 394, 400, 412, 420, 527, 553, 574, 575, 585, 587, 528, 622 598 invalid transaction IS_GRANTABLE, 546, 547, termination, 403, 405, 548, 600, 601, 602, 603, 622 604, 605 , 212, 213, IS_NULLABLE, 544, 580, 582 444, 446, 632 IS_UPDATABLE, 543, 578, 579 IS, 36, 84, 142, 218, 229, IS_UPDATABLE_CHECK, 578 230, 264, 272, 500, 504, IS_UPDATABLE_NOT_NULL, 578 506, 508, 512, 517, 520, , 434, 435, 562, 570, 571, 580, 581, 436, 438, 439 612, 613, 618 - J - ISO/IEC 10206, 3, 243, 517 JOIN, 84, 180, 182, 184, ISO/IEC 10646, 3, 5, 249 539, 541, 545, 549, 550, ISO/IEC 11756, 4, 243, 515 551, 552, 553, 557, 558, ISO/IEC 1539, 3, 243, 512 559, 561, 562, 631, 680 ISO/IEC 646, 3 , 180, ISO/IEC 8824, 3 181 join columns, 181, 182, 183 38 Database Language SQL , 118, 180, KEY_COLUMN_USAGE view, 552 181, 183, 200 KEY_COLUMN_USAGE_FOREIGN_ , 45, 118, KEY_COLUMNS, 588 120, 121, 178, 180, 181, KEY_COLUMN_USAGE_PRIMARY_ 182, 184, 191, 196, 198, KEY, 588 199, 200, 201, 202, 641, KEY_COLUMN_USAGE_UNIQUE, 643 588 , 180, KEY_DEGREE_GREATER_THAN_OR_ 181 EQUAL_TO_1, 618 , 180, 181, 183 KEY_DEGREE_GREATER_THAN_ - K - OR_EQUAL_TO_1 assertion, KEY, 36, 41, 42, 84, 264, 618 270, 272, 273, 274, 275, known not nullable, 36, 481, 536, 552, 561, 568, 199, 200, 582 569, 571, 573, 574, 576, - L - 578, 580, 583, 584, 585, LANGUAGE, 84, 243, 563, 586, 587, 588, 590, 591, 612, 613, 614, 615, 640, 593, 595, 596, 598, 600, 665 602, 604, 605, 606, 608, , 46, 243, 610, 617, 618, 640, 645 244, 341, 342, 344, 346, , 19, 21, 82, 83, 352, 357, 358, 359, 360, 85, 87, 101, 120, 427, 361, 362, 363, 364, 365, 631, 641, 653, 666 366, 367, 452, 454, 493, KEY_COLUMN_CONSTRAINT_TYPE_ 644, 670, 671 CHECK, 588 , 243 KEY_COLUMN_ORDINAL_ LAST, 84, 377, 378, 379, POSITION_NOT_NULL, 588 680 KEY_COLUMN_TABLE_CATALOG_ LEADING, 84, 132, 137, 680 NOT_NULL, 588 leaf generally underlying KEY_COLUMN_TABLE_NAME_NOT_ table, 38, 372, 387, NULL, 588 389, 390, 392, 396, 474 KEY_COLUMN_TABLE_SCHEMA_ leaf underlying table, 38, NOT_NULL, 588 298, 330 KEY_COLUMN_USAGE, 552, 561, LEAVE, 85 588, 617, 618, 640 LEFT, 84, 180, 182, 183, KEY_COLUMN_USAGE base table 539, 545, 680 , 588 , 79, 80, 83, 504, 517 Index 39 , 16, 79, 80, levels of conformance, 75 107, 108, 118, 124, 128, Lexical elements, 79 132, 133, 139, 141, 144, LIKE, 23, 84, 214, 215, 216 155, 168, 173, 180, 196, , 23, 205, 203, 212, 229, 239, 245, 214, 216, 447 260, 272, 274, 281, 296, LIMIT, 85 297, 314, 320, 325, 346, , 311 literal, 23, 24 508, 515, 520 , 19, 89, 102, LENGTH, 83, 356, 425, 426, 114, 116, 146, 147, 149, 427, 434, 436, 439, 440, 151, 152, 153, 154, 191, 441, 452, 453, 454, 455, 266, 267, 268, 432, 433, 456, 457, 663 437, 441, 443, 458, 530, , 63, 93, 107, 108, 629, 637, 638, 640 109, 356, 357, 358, 359, LOCAL, 38, 40, 84, 99, 102, 360, 361, 445, 447, 500, 104, 165, 166, 167, 260, 501, 502, 504, 505, 506, 261, 296, 299, 397, 422, 507, 508, 509, 510, 512, 576, 577, 578, 579, 680 513, 515, 516, 517, 518, , 98, 519, 520, 521, 522, 639 103, 397, 486, 487 , 23, local temporary table, 37, 27, 29, 128, 129, 131, 38, 39, 72, 101, 103, 630, 641, 659 245, 258, 260, 261, 275, LESS, 85 281, 283, 294, 397, 398, , 80, 459, 486, 487, 577, 655, 207, 373, 531 668 , 83, 207 , 16, 17 LEVEL, 84, 399, 680 LOWER, 22, 84, 132, 136, Leveling, 75 681 Leveling Rules, 9, 12, 15, lower case, 22, 81, 87, 88, 625 135, 136, 506, 534, 640 Leveling the SQL Language, 629 , 399, 400, 662 , 296, 297, 299, 633 40 Database Language SQL - M - MINUTE, 30, 31, 32, 33, 73, Maintenance and interpreta- 84, 95, 112, 113, 123, tion of SQL, 685 130, 166, 238, 239, 240, , 90, 94, 95, 422, 430, 441, 681 148, 150 , 91, 94 marked modified privilege mixing of data types, 34 descriptor, 336 modified, 335 MATCH, 42, 43, 84, 224, modified privilege 274, 276, 280, 353, 354, descriptor, 335 550, 590, 591, 633, 681 MODIFY, 85 matching rows, 224, 277, module, 38, 39, 45, 46, 47, 278, 279 48, 49, 55, 56, 61, 62, , 205, 63, 65, 67, 71, 72, 73, 206, 224, 225, 226, 276, 74, 76, 85, 86, 92, 93, 447, 632 99, 100, 101, 102, 103, , 42, 271, 274, 104, 115, 116, 256, 260, 276, 277, 278, 591 261, 297, 302, 312, 316, , 214, 217, 321, 326, 341, 342, 343, 447, 643 344, 345, 346, 348, 349, MATCH_OPTION, 550, 590, 591 350, 352, 371, 375, 377, MAX, 84, 124, 125, 126, 381, 384, 391, 397, 403, 189, 193, 208, 431, 539, 405, 408, 409, 411, 449, 544, 570, 571, 572, 616, 450, 459, 464, 467, 469, 663, 670 471, 472, 474, 490, 493, MESSAGE_LENGTH, 83, 480, 495, 496, 613, 614, 625, 481, 488 627, 634, 646, 647, 654, MESSAGE_OCTET_LENGTH, 83, 655, 656, 657, 658, 661, 480, 481, 488 662, 668, 669, 670, 671, MESSAGE_TEXT, 83, 480, 481, 488, 663 673, 674, 678 MIN, 84, 124, 125, 126, Module, 341 189, 193, 208, 670 MODULE, 39, 84, 98, 344, , 80, 83, 86, 397, 486, 487, 612, 613, 90, 91, 157, 158, 165, 614 168, 169, 241, 242 Index 41 , 38, 39, 45, 46, , 341, 47, 48, 49, 51, 55, 56, 344, 493 61, 62, 63, 65, 67, 71, Modules, 46 72, 73, 74, 93, 100, monadic, 24, 95, 133, 134, 101, 103, 104, 115, 116, 158 256, 260, 261, 297, 302, monadic operator, 6, 24, 312, 316, 321, 326, 341, 133, 134 342, 343, 344, 346, 348, MONTH, 30, 31, 32, 33, 84, 349, 350, 352, 371, 375, 95, 111, 112, 113, 238, 377, 381, 384, 391, 397, 239, 240, 430, 445, 681 , 91, 94, 241 403, 405, 408, 409, 411, MORE, 83, 479, 481, 482 449, 450, 459, 464, 467, multiple server transac- 469, 471, 472, 474, 493, tions, 407, 410, 621 495, 496, 614, 625, 627, multiset, 6, 7, 36, 37, 38, 634, 646, 654, 655, 656, 178, 183, 184, 332 657, 658, 661, 662, 668, MUMPS, 4, 61, 83, 243, 244, 669, 670, 671, 673, 674, 359, 360, 365, 489, 490, 678 491, 493, 495, 498, 515, , 45, 46, 72, 664 101, 102, 341, 343, 493, , 654, 657, 669 515, 516, 664 , identifier>, 46, 65, 490, 515 256, 341, 342, 348, 408, , 515, 516 , specification>, 46, 515, 516 , 85, 86, 92, 93, 100, 515 344, 345, 493, 647, 661 , 341, , 490, 515, 516 343, 647 module language, 46, 75 , 46, 61, 74, 99, 103, 344, 352, 493, 669, 673 42 Database Language SQL - N - , n-adic operator, 6 82, 86 NAME, 84, 427, 434, 438, NONE, 85 452, 454, 673 , 180, , 196, 197, 198, 199, 181, 183, 184 200 NAMES, 84, 344, 419, 484, , 490, 681 196, 197, 198, 199, 670 Names and identifiers, 98 , 196, NATIONAL, 20, 21, 84, 107, 197, 198, 199, 670 108, 653, 657, 681 non-null, 223, 277 , 82, 86, 89, 111, 208, 225, 234, 278, 92, 93, 97, 640 279, 373, 531, 662, 665 , 83, type>, 107, 113, 640 89, 92 NATURAL, 84, 180, 181, 183, non-repeatable read, 68 184, 289, 352, 681 , 83 NCHAR, 84, 107, 108, 681 NEW, 85 , 239, 241 , 83, 86, 92, 656 Normative references, 3 NEXT, 84, 377, 378, 379, no subclass, 619, 620, 621, 469, 681 622, 623 NO, 21, 35, 84, 208, 249, NOT, 23, 36, 84, 142, 211, 250, 274, 276, 314, 315, 212, 214, 218, 228, 229, 590, 591, 592, 608, 609, 230, 252, 253, 262, 264, 660, 670, 681 270, 271, 272, 273, 301, No collating sequence, 23, 303, 325, 497, 499, 562, 24, 25, 26, 297 569, 570, 571, 574, 576, no data, 47, 350, 351, 379, 578, 580, 585, 588, 590, 382, 383, 387, 389, 395, 598, 600, 602, 604, 606, 435, 499, 528, 530, 622, 608, 610, 612, 617, 618, 624 633, 645 non-deferrable, 36, 41 Notation, 7 , 82, , 83, 86 207 non-deterministic, 40, 189, 193, 200, 282, 325 Index 43 null, 6, 7, 19, 36, 42, 43, semantics, 48, 116, 126, 129, 130, 218 131, 135, 136, 137, 142, , 173, 145, 156, 158, 162, 163, 174, 391 166, 169, 173, 174, 182, null value, 6, 7, 19, 36, 183, 192, 205, 207, 215, 42, 126, 129, 130, 131, 218, 224, 225, 228, 231, 135, 136, 137, 142, 145, 234, 267, 268, 278, 279, 156, 158, 162, 163, 166, 373, 391, 422, 436, 444, 169, 174, 183, 207, 215, 452, 454, 456, 458, 506, 218, 224, 225, 228, 231, 525, 531, 573, 579, 581, 234, 267, 268, 278, 279, 594, 614, 644, 662, 665, 435, 436, 454, 456, 458, 668, 671, 674 525, 579, 594, 614, 662, NULL, 19, 36, 84, 141, 142, 665, 668, 671, 674 144, 145, 173, 192, 218, null value, no indicator 262, 264, 266, 267, 272, parameter, 231, 435, 620 273, 274, 278, 279, 543, null value eliminated in 544, 562, 569, 570, 571, set function, 126, 623 574, 576, 578, 580, 581, number, 27 NUMBER, 84, 479, 481, 482 585, 588, 590, 591, 592, , 598, 600, 602, 604, 606, 399, 400, 672 608, 610, 612, 613, 618, Numbers, 27 645 NUMBER_OF_CHARACTERS, 554, nullability, 36, 265 606, 607, 665 nullability characteristic, NUMERIC, 19, 27, 34, 84, 36, 37, 265 107, 109, 110, 353, 358, nullable, 42, 47, 182, 192, 425, 426, 429, 440, 445, 199, 200, 452, 582 510, 539, 544, 565, 570, NULLABLE, 84, 427, 434, 571, 572, 658 436, 438, 452, 453, 454, numeric data type 544, 580, 582 descriptor, 27 null character, 363, 506, , 157, 158 661 , 107 NULLIF, 84, 141, 142, 444, , 446, 681 133, 155, 157, 158 , 205, 218, , 444 128, 131, 157, 630, 641 44 Database Language SQL numeric value out of range, octet, 3, 5, 22, 23, 27, 126, 146, 147, 158, 233, 102, 103, 128, 131, 250, 235, 620 356, 357, 358, 359, 360, NUMERIC_PRECISION, 539, 361, 362, 363, 364, 365, 544, 565, 570, 571, 572 366, 367, 436, 452, 453, NUMERIC_PRECISION_RADIX, 454, 458, 488, 501, 506, 539, 544, 565, 570, 571, 509, 513, 518, 521, 572, 572 619 NUMERIC_SCALE, 539, 544, , 570, 571, 572 128, 131 - O - OCTET_LENGTH, 83, 84, 128, OBJECT, 85 130, 427, 434, 436, 438, , 391, 392, 445, 452, 453, 454, 458, 393, 394, 395, 396, 447, 488, 539, 544, 570, 571, 474, 475, 648 572, 681 object identifier, 16, 625 OF, 84, 360, 361, 371, 384, Object identifier for 391, 472, 474, 476, 477, Database Language SQL, 517, 518, 519, 639 16 OFF, 85 , 245, 246, OID, 85 329, 332, 333, 634, 646 OLD, 85 OBJECT_CATALOG, 539, 548, ON, 84, 180, 248, 260, 274, 554, 555, 556, 604, 605 275, 281, 289, 294, 300, OBJECT_NAME, 539, 548, 554, 310, 313, 315, 318, 321, 555, 556, 604, 605 323, 329, 330, 331, 332, OBJECT_SCHEMA, 539, 548, 333, 397, 403, 539, 541, 554, 555, 556, 604, 605 545, 549, 550, 551, 552, OBJECT_TYPE, 539, 548, 554, 553, 557, 558, 559, 561, 555, 556, 604, 605 562 , 431, 432, ONLY, 84, 371, 372, 399, 435, 439, 451, 453, 455, 400, 681 457, 637, 663 OPEN, 84, 375, 467, 483, 484 Index 45 , 50, 53, OPTION, 40, 65, 75, 84, 55, 57, 58, 59, 342, 248, 296, 297, 299, 329, 368, 371, 375, 464, 465, 330, 331, 333, 335, 336, 484, 493, 494, 495, 496, 337, 356, 389, 393, 395, 673 487, 533, 543, 550, 578, OPERATION, 85 579, 590, 591, 601, 603, Operations involving bit 605, 677 strings, 27 OR, 36, 84, 228, 229, 230, Operations involving 539, 546, 547, 548, 571, character strings, 22 573, 580, 581, 583, 584, Operations involving 585, 586, 591, 595, 596, datetimes and intervals, 606, 608, 611, 612, 613 34 ORDER, 84, 371, 372, 374, Operations involving 464, 530, 635, 638 numbers, 29 , 50, 371, operator, 6, 7, 8, 12, 13, 372, 373, 391, 474, 530, 22, 23, 24, 27, 29, 34, 531, 668, 671, 674 35, 80, 83, 95, 133, , 134, 157, 158, 160, 161, 371 166, 169, 170, 197, 198, ORDINAL_POSITION, 544, 552, 200, 201, 202, 207, 208, 580, 581, 588, 589 229, 237, 373, 391, 434, Other operators involving 438, 443, 445, 479, 500, bit strings, 27 505, 531, 659, 670 Other operators involving OPERATORS, 85 character strings, 23 Operators that operate on OTHERS, 85 bit strings and return Other terms, 14 bit strings, 27 OUTER, 84, 180, 618, 681 Operators that operate , 180 on character strings outermost, 11, 118 and return character outer reference, 122, 124, strings, 22 126, 181, 185, 189, 190, 192, 194, 386, 395, 641, 678 OUTPUT, 84, 450, 681 output parameter, 347, 348, 357, 362, 363, 364, 365, 366, 367, 661 46 Database Language SQL OVERLAPS, 34, 84, 227, 681 , 34, list>, 346 205, 206, 227, 228, 444, , 75, 99, 446, 643, 644 103, 114, 115, 116, 346, - P - 347, 350, 371, 494, 673, <1989 package>, 16, 17 677 PAD, 21, 35, 85, 208, 249, Parameters, 47 250, 314, 315, 608, 609, PARAMETERS, 85 660, 670, 681 , , 314, 315 114, 115, 116, 525 PAD_ATTRIBUTE, 555, 608, , 609, 665 455, 459, 460 parameter, 28, 29, 47, 48, PARTIAL, 42, 43, 85, 224, 61, 62, 63, 70, 75, 99, 225, 274, 276, 277, 278, 103, 114, 115, 116, 168, 279, 590, 591, 681 192, 231, 281, 296, 325, Pascal, 3, 49, 61, 360, 346, 347, 348, 350, 351, 361, 366, 489, 490, 491, 352, 356, 357, 358, 359, 493, 495, 498, 517, 518, 360, 361, 362, 363, 364, 519, 615, 626, 639, 651, 365, 366, 367, 371, 435, 662 PASCAL, 84, 243, 360, 366, 436, 439, 443, 450, 453, 493, 518, 612, 613, 614, 454, 455, 456, 459, 460, 615 462, 467, 482, 486, 494, , 495, 496, 502, 507, 510, 490, 517, 518 514, 516, 519, 522, 525, 619, 624, 630, 635, 641, , 517, 518, 519, 639, 647, 654, 659, 661, 662, 651 664, 665, 666, 671, 672, , 490, 517, , 518, 519 47, 346, 347, 350, 351, , 214, 217, 447, 352, 356, 357, 358, 359, 643 360, 361, 362, 371, 494, PENDANT, 85 495, 496, 635, 647, 674, , 79, 80, 215 , 80, 90, 91, 94, 675 98, 99, 121, 148, 150, 191, 242, 508 Index 47 persist, 37, 39, 44, 51, possibly non-deterministic, 52, 67, 72, 258, 260, 40, 189, 193, 200, 282, 261, 275, 281, 397, 398, 325 577 possibly nullable, 36, 182, persistent, 7, 37, 39, 44, 192, 452, 582 46, 51, 52, 67, 258, precede, 12, 242, 297, 341, 260, 261, 275, 281, 397, 363, 373, 403, 492, 493, 577 505, 509, 512, 521, 531, persistent base table, 37 667 persistent table, 44 PRECISION, 19, 27, 34, 85, phantom, 68 108, 110, 352, 357, 358, , 359, 425, 426, 427, 429, 490, 520, 521 434, 436, 439, 440, 441, , 453, 454, 455, 456, 457, 520 500, 502, 507, 512, 513, , 539, 544, 565, 570, 571, 520 572, 658, 663 , , 63, 107, 108, 520 109, 110, 358, 361, 445, , 520, 521, 522, 523, 639, 515, 516, 520, 522, 657, 651, 664, 665 658 , , 205, 206, 216, 490, 520, 521, 522, 664 229, 632 PLI, 84, 243, 355, 361, Predicates, 205 367, 493, 612, 613, 614, PREORDER, 85 615 Preparable and immediately , 80, 90, 157, executable SQL- 158, 165, 168 statements, 56 POSITION, 85, 128, 445, , 589, 681 53, 56, 59, 60, 62, 442, , 23, 443, 460, 462, 463, 476, 27, 29, 128, 129, 130, 484, 638 131, 444, 630, 659 possible qualifiers, 121 48 Database Language SQL , 270, 272, 273, 275, 536, 54, 56, 59, 60, 62, 299, 568, 569, 571, 573, 574, 442, 443, 460, 462, 463, 576, 578, 580, 583, 584, 477, 484, 639 585, 586, 587, 588, 590, , 56, 600, 602, 604, 606, 608, 442, 443, 663 610, 618, 645 , 442, 637 681 , 442, 637 privilege, 44, 64, 65, 66, , 442, 637 135, 145, 234, 245, 246, preparable SQL-statement, 248, 249, 251, 256, 261, 56, 57 264, 276, 282, 284, 298, , 442, 637 321, 326, 329, 330, 331, , 332, 333, 334, 335, 336, 44, 45, 64, 73, 93, 100, 337, 338, 342, 384, 386, 101, 115, 415, 417, 419, 389, 392, 394, 398, 420, 442, 443, 460, 462, 463, 487, 526, 533, 546, 547, 653, 654, 656 548, 568, 600, 601, 602, PREPARE, 85, 354, 442, 447, 449, 462, 483, 484, 681 603, 604, 605, 632, 633, prepared statement not a 655, 660, 669, 677, 678 cursor specification, , 465, 621 245, 246, 333, 632 , 14, privilege dependency graph, 44, 45, 54, 60, 61, 63, 335 64, 73, 93, 101, 103, privilege descriptor, 44, 104, 115, 369, 415, 417, 65, 66, 246, 248, 261, 419, 442, 449, 450, 459, 284, 298, 302, 312, 315, 464, 465, 484, 653, 654, 316, 321, 329, 330, 331, 656 332, 333, 334, 335, 336, PRESERVE, 85, 260, 281, 337, 338, 398, 420, 600, 397, 681 602, 604 Index 49 privilege not granted, 332, PUBLIC, 66, 75, 85, 102, 623 245, 246, 248, 315, 321, privilege not revoked, 338, 334, 533, 539, 542, 545, 623 546, 547, 548, 554, 555, Privileges, 64 556, 601, 603, 605 PRIVILEGES, 85, 245, 246, 294, 300, 332, 338, 539, - Q - 542, 545, 546, 547, 548, , 98, 554, 555, 556, 600, 602, 102, 119, 252, 325, 486, 604, 605, 640 487 , 245, 329, , 180, 181 330, 331, 332, 333, 338, , 98, 101, 104, 397 PRIVILEGE_TYPE, 546, 547, , 39, 44, 548, 600, 601, 602, 603 73, 98, 99, 101, 102, procedure, 47 417, 656 PROCEDURE, 85, 346 , 121, 125, 191, , 14, 39, 46, 390, 643 47, 48, 49, 55, 56, 61, , 205, 220, 103, 256, 341, 342, 346, 447 347, 348, 349, 350, 352, , 220, 221 371, 397, 408, 409, 411, , 11, 413, 460, 463, 493, 494, 15, 37, 38, 40, 75, 119, 495, 496, 527, 528, 627, 173, 176, 193, 196, 197, 655, 661, 662, 670, 671, 200, 202, 203, 204, 237, 673, 674, 675 282, 284, 289, 294, 296, , 47, 61, 297, 298, 299, 300, 309, 99, 103, 346, 348, 352, 313, 318, 323, 325, 330, 493, 494, 661, 671, 673 331, 334, 335, 336, 371, Procedures, 47 372, 375, 387, 388, 389, Processing methods, 627 390, 392, 396, 444, 446, programming languages, 49, 467, 474, 530, 579, 581, 243 583, 584, 631, 632, 636, PROTECTED, 85 642, 643, 646, 648, 671, 677 Query expressions, 173 50 Database Language SQL query expression too long RECURSIVE, 85 for information schema, redundant duplicates, 7 299, 623 REF, 85 , 196, 198, , 643 274, 275, 280, 289 , 40, referenced columns, 42, 102, 118, 191, 192, 193, 271, 275, 276, 292, 336, 194, 195, 196, 197, 200, 337 203, 204, 282, 296, 299, referenced table, 42, 43, 325, 382, 384, 390, 391, 271, 274, 275, 276, 277, 442, 460, 472, 474, 631, 278, 279, 280, 289, 292 632, 643, 646, 648, 670 , 196, 199, columns>, 42, 271, 274, 202, 643 275, 276, 289 , 63, 80, Reference Model of Data 114 Management, 1 , 79, 80, 83, 87, REFERENCES, 65, 66, 85, 89, 90, 91, 92, 93, 97, 245, 246, 261, 274, 276, 314, 320 282, 284, 289, 298, 302, , 87, 89, 93 326, 329, 330, 331, 332, - R - 333, 336, 337, 398, 569, READ, 68, 69, 85, 371, 372, 571, 573, 574, 576, 580, 399, 400, 681 583, 584, 585, 588, 591, read-only, 38, 40, 50, 67, 595, 596, 598, 600, 601, 70, 182, 296, 350, 372, 602, 603, 604, 605, 606, 384, 386, 388, 389, 392, 608, 610, 611, 633 394, 400, 528 , READ ONLY, 372, 400 262, 264, 274, 280, 633 read-write, 67, 70, 350, REFERENCING, 85 400, 528 referencing columns, 42, READ WRITE, 399, 400 271, 274, 275, 276, 588 REAL, 19, 27, 34, 85, 108, , 42, 110, 352, 357, 358, 359, 271, 274, 275, 276 360, 361, 366, 425, 426, referencing table, 42, 43, 429, 440, 500, 502, 507, 274, 275, 276, 277 512, 513, 515, 516, 517, , 274, 519, 571, 657, 658 276, 278, 279, 591, 592 Index 51 referential constraint, 41, Remote Database Access, 3, 42 622 , 42, 45, repertoire, 5, 7, 20, 21, 270, 271, 274, 276, 280, 23, 24, 35, 46, 74, 76, 645 85, 86, 92, 93, 100, , 265, 274, 280, 135, 136, 145, 147, 148, 633, 645 149, 150, 151, 160, 208, REFERENTIAL_CONSTRAINTS, 237, 248, 249, 250, 266, 550, 559, 586, 590, 617, 311, 312, 315, 316, 506, 640 607, 660, 669, 674 REFERENTIAL_CONSTRAINTS REPLACE, 85 base table, 590 requires, 6, 42, 71, 583 REFERENTIAL_CONSTRAINTS reserved, 61, 73, 83, 84, view, 550 85, 87, 100, 408, 411, REFERENTIAL_CONSTRAINTS_ 448, 466, 619, 626, 655, CONSTRAINT_TYPE_CHECK, 678 590 , 83, 84, REFERENTIAL_CONSTRAINTS_ 85, 87, 100, 626, 678 PRIMARY_KEY, 590 RESIGNAL, 85 REFERENTIAL_DELETE_RULE_ RESTRICT, 85, 258, 289, CHECK, 590 292, 294, 300, 309, 337, REFERENTIAL_DELETE_RULE_ 354, 681 NOT_NULL, 590 restricted data type REFERENTIAL_MATCH_OPTION_ attribute violation, CHECK, 590 456, 458, 621 REFERENTIAL_MATCH_OPTION_ , 141, 142, 143 NOT_NULL, 590 , 141, REFERENTIAL_UPDATE_RULE_ 142 CHECK, 590 , 451, REFERENTIAL_UPDATE_RULE_ 456, 457, 459, 460, 638 NOT_NULL, 590 Retrieval assignment, 231 , 82, RETURN, 85 86, 87, 88, 98, 533, RETURNED_LENGTH, 84, 427, 534, 629 434, 436, 438, 458 RELATIVE, 85, 377, 378, RETURNED_OCTET_LENGTH, 84, 379, 681 427, 434, 436, 438, 458 52 Database Language SQL RETURNED_SQLSTATE, 84, 479, , 481, 485, 486, 487, 488 227, 228 RETURNS, 85 , REVOKE, 85, 289, 294, 300, 36, 156, 173, 174, 175, 310, 313, 318, 323, 333, 176, 207, 211, 212, 218, 355, 484, 681 219, 220, 224, 227, 390, , 52, 444, 446, 447, 631, 642, 245, 289, 294, 300, 310, 644, 648, 669 313, 318, 323, 333, 339, , 173, 174, 175, RIGHT, 85, 180, 182, 184, 390, 444, 446, 631, 642 353, 356, 681 , 79, 81, list>, 173, 174, 176, 83, 504, 517 390, 669 , 16, 79, 80, ROW_COUNT, 84, 479, 481, 107, 108, 118, 124, 128, 484, 485, 673 132, 133, 139, 141, 144, Rule evaluation order, 12 155, 168, 173, 180, 196, Rules determining collating 203, 212, 229, 239, 245, sequence usage, 23 260, 272, 274, 281, 296, - S - 297, 314, 320, 325, 346, SAVEPOINT, 85 388, 390, 489, 491, 500, Scalar expressions, 107 508, 515, 520 , 155, ROLE, 85 156, 203, 642 ROLLBACK, 68, 70, 85, 355, , , and
, 41, subquery>, 203 50, 54, 67, 69, 70, 342, SCALE, 84, 425, 426, 427, 369, 405, 484, 526, 655, 434, 436, 439, 440, 441, 671, 674 453, 454, 455, 456, 457, ROUTINE, 85 539, 544, 570, 571, 572, ROW, 85 663 ROWS, 85, 260, 275, 281, , 63, 107, 108, 109, 397, 681 110, 358, 361, 515, 516, , 173, 174, 520, 522, 658 203 SCHEMA, 85, 255, 258, 341, , 417, 483, 484, 535, 567 227, 228 Index 53 , 65, 255, 544, 549, 550, 551, 552, 256 553, 557, 558, 559, 561, 562, 569, 571, 573, 574, , 311 576, 580, 583, 584, 585, , 93, 606, 608, 610, 611, 640 100, 255, 256, 257, 263, SCHEMATA base table, 569 644, 660 SCHEMATA view, 538 , SCHEMATA_FOREIGN_KEY, 569 314, 315 SCHEMATA_PRIMARY_KEY, 569 , 44, , 52, 65, 93, 100, 101, 320, 321 252, 255, 256, 260, 261, SCHEMA_NAME, 84, 354, 480, 263, 296, 301, 311, 315, 481, 486, 487, 538, 541, 320, 325, 368, 484, 566, 543, 544, 549, 550, 551, 568, 660 552, 553, 557, 558, 559, Schema definition and 561, 562, 569 manipulation, 255 SCHEMA_OWNER, 538, 541, , 255, 256, 543, 544, 549, 550, 551, 632, 644 552, 553, 557, 558, 559, , 15, 39, 44, 561, 562, 569 45, 46, 64, 72, 73, 98, SCHEMA_OWNER_NOT_NULL, 569 99, 101, 102, 103, 104, scope, 1, 10, 14, 39, 62, 249, 252, 255, 256, 257, 63, 70, 99, 102, 103, 258, 260, 263, 283, 294, 104, 118, 119, 121, 122, 296, 297, 300, 301, 302, 125, 260, 283, 356, 386, 304, 309, 311, 312, 313, 392, 394, 397, 431, 433, 315, 316, 318, 320, 321, 447, 449, 450, 451, 459, 323, 325, 326, 328, 341, 465, 466, 467, 475, 492, 397, 398, 415, 417, 486, 501, 669 487, 493, 616, 644, 654, Scope, 1 656, 657, 661, 668, 669 scope clause, 118, 119, , 101, 431, 433 255, 257, 644, 657 , 99, 102, 104, 431, 433, 447, 451 54 Database Language SQL SCROLL, 85, 371, 372, 374, SELECT, 65, 66, 75, 85, 377, 464, 465, 469, 635, 119, 122, 180, 182, 183, 638, 647, 681 184, 191, 197, 198, 245, SEARCH, 85 261, 271, 272, 273, 276, , 15, 36, 284, 289, 298, 303, 329, 42, 43, 68, 119, 122, 330, 334, 335, 336, 382, 141, 142, 143, 180, 181, 398, 483, 484, 485, 533, 183, 185, 186, 187, 189, 537, 538, 539, 541, 542, 190, 229, 230, 264, 271, 543, 544, 545, 546, 547, 272, 281, 282, 284, 289, 548, 549, 550, 551, 552, 294, 300, 301, 302, 307, 553, 554, 555, 556, 557, 309, 313, 318, 323, 325, 558, 559, 561, 562, 563, 326, 330, 337, 386, 387, 571, 572, 573, 576, 578, 394, 395, 396, 485, 593, 580, 581, 583, 584, 585, 594, 595, 596, 633, 636, 586, 588, 591, 593, 595, 643, 677, 678 596, 600, 601, 602, 603, search condition too long 604, 606, 608, 610, 611, for information schema, 616, 617, 618, 677 282, 326, 623 , 53, 55, 57, 58, , 91, 94, 59, 102, 118, 119, 350, 95, 96, 242, 629 368, 382, 484, 672, 677 , , 382, SECTION, 85, 490 383, 671, 672 , 80, 346, 489, 491, 504, 515, 517, 520, 525 SENSITIVE, 85 Index 55 , 82, 83, 86, set, 3, 5, 6, 7, 11, 19, 89, 92, 93, 100, 491, 20, 21, 22, 23, 30, 32, 512 35, 36, 37, 38, 41, 44, sequence, 5, 7, 9, 12, 20, 45, 46, 47, 48, 52, 54, 21, 22, 23, 24, 25, 26, 60, 62, 64, 65, 66, 67, 32, 35, 37, 47, 67, 69, 68, 70, 71, 72, 73, 74, 72, 92, 95, 97, 104, 80, 85, 86, 87, 89, 92, 115, 122, 125, 133, 134, 93, 97, 98, 99, 100, 145, 155, 161, 187, 191, 102, 103, 104, 105, 107, 207, 208, 214, 215, 216, 108, 109, 115, 124, 126, 220, 224, 237, 249, 250, 127, 133, 134, 136, 142, 251, 264, 297, 314, 315, 153, 155, 173, 176, 178, 316, 317, 318, 372, 388, 181, 183, 184, 185, 186, 497, 501, 506, 509, 521, 187, 189, 190, 191, 192, 660, 661 193, 194, 195, 197, 198, SEQUENCE, 85 199, 200, 201, 202, 208, SERIALIZABLE, 68, 69, 84, 222, 231, 232, 233, 234, 350, 399, 528 235, 237, 238, 246, 248, serialization failure, 69, 249, 250, 253, 255, 256, 622 257, 258, 259, 261, 263, SERVER_NAME, 84, 479, 481, 488 267, 273, 275, 278, 279, SESSION, 85, 420, 484, 682 281, 286, 287, 298, 301, Session management, 415 302, 304, 305, 306, 311, SESSION_USER, 85, 114, 115, 312, 313, 314, 315, 316, 116, 117, 266, 267, 268, 317, 318, 320, 321, 323, 269, 282, 325, 375, 530, 329, 330, 331, 332, 333, 641, 645, 658, 682 334, 335, 336, 337, 338, 344, 345, 348, 349, 350, 351, 362, 363, 364, 365, 366, 367, 368, 369, 382, 391, 392, 393, 394, 395, 396, 398, 399, 400, 401, 402, 403, 409, 410, 411, 415, 417, 418, 419, 420, 421, 422, 423, 426, 427, 428, 436, 438, 439, 440, 441, 444, 447, 450, 452, 453, 454, 455, 456, 457, 458, 474, 475, 477, 482, 483, 484, 488, 489, 490, 56 Database Language SQL 492, 493, 495, 496, 500, 501, 503, 504, 506, 507, 508, 510, 511, 512, 513, 514, 516, 517, 518, 519, 520, 521, 523, 527, 528, 554, 569, 605, 606, 607, 609, 611, 619, 625, 629, 630, 632, 633, 635, 636, 637, 639, 641, 644, 645, 646, 647, 648, 649, 651, 653, 654, 656, 657, 658, 660, 661, 662, 663, 664, 665, 670, 672, 673, 674, 678 SET, 85, 107, 108, 113, 248, 255, 259, 274, 278, , 304, 305, 633 279, 287, 305, 311, 313, , 11, 124, 127, 401, 403, 410, 415, 417, 155, 181, 185, 186, 189, 419, 420, 422, 438, 474, 190, 192, 193, 194, 195, 477, 482, 484, 500, 501, 281, 392, 394, 444, 474, 504, 505, 506, 508, 509, 632, 641, 678 512, 513, 517, 518, 520, , 124 521, 527, 564, 590, 591, , 592, 604, 640, 658 438, 439 , , 54, 73, 415, 447, 484, 635, 636, 369, 422, 423, 447, 484, 637, 639 649, 651 , 391, 392, , 54, 393, 394, 395, 447, 474, 64, 73, 369, 419, 447, 475, 636 484, 635, 637, 639 , 391, Set operation result data 392, 394, 396, 474, 477 types, 237 , 124, 191, , 286, 287, 645 193, 194, 195, 382 , , 44, 54, 71, 72, 74, 349, 54, 64, 73, 369, 417, 369, 410, 411, 484, 488, 418, 447, 484, 635, 637, 527, 636 639, 653 , 41, 54, identifier statement>, 253, 369, 401, 402, 484, 54, 65, 369, 420, 421, 635, 636, 637, 639 447, 484, 647, 649, 651 , 438 , 422 tion>, 438 , 48, 54, 67, 68, 349, , 350, 369, 399, 400, 484, 54, 60, 62, 369, 438, 528, 647, 648 439, 441, 484, 672 , 90, 91, 95, 157, 168, 169 SIGNAL, 85 Index 57 , 90 , tion>, 62, 71, 99, 102, 89, 90, 95, 146, 147, 114, 116, 167, 347, 377, 267 378, 399, 408, 425, 426, significant, 27, 28, 31, 431, 433, 434, 438, 442, 33, 34, 146, 149, 151, 443, 447, 451, 465, 480, 154, 158, 166, 169, 170, 657 171, 209, 238, 240, 241, , 141 242, 267, 363, 512, 518, simply contain, 11, 24, 36, 653 119, 124, 156, 158, 162, SIMILAR, 85 163, 165, 166, 167, 168, , 141, 142 169, 173, 174, 175, 191, , 22, 192, 193, 197, 201, 267, 79, 98 372, 375, 443, 444, 446, , 79, 81, 87, 88, simply underlying table, 135, 136, 640 38, 193, 200, 299, 372, , 79, 81, 87, , 135, 136, 619, 666 239, 240, 241, 242 , 196, 197, SIZE, 85, 399, 682 200, 201, 202, 632, 670 SMALLINT, 19, 27, 34, 85, , 434, 435, 358, 359, 361, 362, 425, 672 426, 429, 440, 500, 502, , 434, 435, 662 672 , 80, 157, 158, , 114, 116, 347, SOME, 85, 220 425, 426, 434, 435, 447, , 220, 221 479, 480, 482, 485 , 371 , 371, 1>, 438 372, 373, 530, 531, 675 , 2>, 438, 439 371 58 Database Language SQL , 320, 22, 28, 30, 32, 34, 35, 335 36, 38, 41, 47, 49, 50, SOURCE_CHARACTER_SET_ 62, 63, 65, 66, 67, 68, CATALOG, 556, 610, 611 72, 87, 94, 100, 108, SOURCE_CHARACTER_SET_NAME, 109, 110, 112, 115, 116, 556, 610, 611 126, 142, 145, 168, 169, SOURCE_CHARACTER_SET_SCHEMA 189, 192, 193, 197, 218, , 556, 610, 611 238, 240, 241, 242, 243, SPACE, 21, 35, 85, 249, 245, 246, 249, 263, 264, 250, 314, 315, 608, 609, 265, 268, 272, 273, 275, 660, 682 276, 277, 278, 279, 281, , 20, 35, 62, 71, 79, 80, 83, 86, 90, 91, 282, 284, 301, 302, 315, 136, 146, 147, 148, 149, 316, 321, 326, 329, 330, 151, 163, 208, 216, 232, 333, 342, 344, 347, 352, 234, 235, 268, 363, 364, 356, 357, 358, 359, 360, 365, 366, 367, 486, 487, 361, 362, 363, 364, 365, 488, 491, 512 366, 367, 371, 373, 376, spans, 72, 299 378, 379, 382, 388, 393, Specification of syntactic 395, 403, 408, 428, 429, elements, 9 446, 449, 452, 454, 464, Specification of the 482, 492, 493, 494, 495, Information Schema, 496, 497, 499, 501, 502, 10 506, 507, 510, 513, 514, 516, 518, 519, 522, 526, 531, 564, 619, 624, 625, 626, 630, 632, 638, 641, 644, 648, 659, 661, 668, 669, 685 SQL, 85, 489 Index 59 SQL-agent, 48, 66, 68, 70, SQL-data, 1, 10, 12, 31, 71, 72, 74, 96, 342, 35, 40, 43, 45, 46, 50, 343, 348, 349, 350, 352, 51, 52, 53, 55, 56, 57, 399, 400, 401, 403, 405, 58, 59, 60, 67, 68, 69, 408, 409, 410, 411, 412, 70, 231, 234, 281, 351, 413, 526, 527, 528, 646, 379, 382, 403, 404, 405, 654, 656, 661, 668, 669, 528, 655, 662, 668 670, 671, 672 SQL-agents, 66 , 368, 369 SQL-client, 70, 71, 74, , 350, 409, 656, 669 368 SQL-client unable to SQL descriptor area, 62, establish SQL-connection 64, 104, 431, 432, 433, , 409, 620 434, 435, 436, 438, 439, SQLCODE, 47, 48, 49, 85, 451, 453, 457, 458, 460, 346, 347, 352, 356, 357, 469, 470, 663, 667 358, 359, 360, 361, 482, , 479 500, 502, 507, 510, 514, 516, 519, 522, 624, 654, , 48, 74, 349, 351, 368, 661, 662, 664, 665, 666, 369, 647 668, 675 , 67, 350, , 16, 17 369, 655 SQL-connection, 52, 54, 55, , 57, 58, 60, 70, 71, 72, 104, 368, 369, 451, 635, 104, 407, 408, 409, 410, 647 411, 412, 413, 662, 672 SQL dynamic statements, 61 SQL-connections, 70 , 16, 17 , , 79 488, 525, 526, 527, 635, SQL-environment, 45, 46, 640 70, 71, 72, 74, 75, 344, 654, 655, 663 SQLERROR, 85, 497, 499 SQLEXCEPTION, 85 SQL Flagger, 76, 77, 626 60 Database Language SQL SQL-implementation, 1, 6, , 70, 71, 7, 16, 45, 46, 48, 71, 99, 103, 407, 408, 409, 74, 76, 77, 350, 352, 488, 655, 663 528, 563, 616, 625, 656, SQL-server rejected 662 establishment of SQL- , connection, 409, 620 20, 46, 79, 86, 92, 93, SQL-session, 7, 31, 38, 39, 100, 147, 148, 149, 150, 44, 45, 46, 51, 52, 54, 151, 344, 492, 658, 661 55, 56, 58, 60, 62, 63, , 65, 69, 71, 72, 73, 74, 98, 99, 100 93, 94, 96, 100, 101, , 98, 100 122, 139, 153, 167, 256, , 98, 100 350, 397, 398, 401, 408, , 16 409, 410, 411, 413, 415, , 489, 490, 491 417, 419, 420, 421, 422, , 47, 55, 56, 74, 346, 440, 487, 526, 527, 528, 347, 348, 368, 370, 489, 653, 654, 655, 656, 663, 494, 495, 496, 497, 499, 668, 669 526, 635, 647, 656, 673, SQL-sessions, 72 674 , , 16 368, 369, 442, 525, 635, SQL-schema, 44 639, 647, 651 , statement>, 368, 370 79, 83 , 368 84, 85, 253, 346, 347, SQL-schemas, 44 352, 353, 354, 355, 356, , 44, 357, 358, 359, 360, 361, 350, 368, 442, 525, 528, 481, 482, 485, 486, 487, 529, 533, 635, 639, 647, 488, 492, 494, 495, 496, 651 500, 502, 507, 510, 513, SQL-server, 70, 71, 72, 74, 514, 516, 519, 522, 619, 99, 103, 407, 408, 409, 624, 665, 668, 682 410, 411, 488, 655, 662, SQLSTATE class and subclass 663, 669 values, 619 Index 61 SQL-statement, 1, 10, 12, SQL-transaction, 7, 41, 45, 14, 41, 45, 48, 50, 51, 49, 50, 52, 54, 55, 56, 52, 55, 56, 57, 58, 59, 58, 60, 67, 68, 69, 70, 60, 61, 63, 64, 65, 66, 71, 75, 76, 349, 350, 67, 68, 69, 71, 72, 116, 384, 386, 389, 392, 394, 139, 140, 174, 192, 197, 399, 400, 401, 403, 404, 199, 200, 253, 256, 277, 405, 407, 410, 420, 448, 279, 280, 342, 349, 368, 527, 528, 654, 655, 662, 407, 410, 449, 482, 484, 668, 672, 677 485, 486, 492, 497, 526, SQL-transaction isolation 533, 654, 658, 667, 668, levels and the three 669, 673, 674 phenomena, 68 SQL-statement character SQL-transactions, 67 codes for use in the diagnostics area, 482 , 368, 369, 442, 525, , 14, 635, 639, 647 59, 99, 105, 442, 447, , 16 448, 449, 450, 459, 640 SQLWARNING, 85 SQL-statements, 51 SQL_IDENTIFIER, 536, 564, SQL-statements and 568, 569, 570, 573, 574, transaction states, 576, 578, 580, 583, 584, 59 585, 588, 590, 593, 595, SQL-statements classified 596, 598, 600, 602, 604, by function, 52 606, 608, 610 , SQL_IDENTIFIER domain, 564 14, 59, 442, 443, 462 SQL_LANGUAGES, 563, 612, , 640 79 SQL_LANGUAGES base table, , 489, 490, 612 491 SQL_LANGUAGES view, 563 SQL_LANGUAGES_SOURCE_NOT_ NULL, 612 SQL_LANGUAGES_STANDARD_ VALID_CHECK, 612 SQL_LANGUAGE_BINDING_STYLE, 563, 612, 613, 614 SQL_LANGUAGE_CONFORMANCE, 563, 612, 613, 614 62 Database Language SQL SQL_LANGUAGE_IMPLEMENTATION , 479, 480, 481 SQL_LANGUAGE_INTEGRITY, , 62, 99, 563, 612, 613, 614 103, 448, 449, 450, 459, SQL_LANGUAGE_PROGRAMMING_ 464, 467, 672 LANGUAGE, 563, 612, 613, , 614, 615 489 SQL_LANGUAGE_SOURCE, 563, Status codes, 619 612, 613, 614, 665 status parameter, 47 SQL_LANGUAGE_YEAR, 563, , 346, 612, 613 347 SQL_TEXT, 20, 30, 87, 100, Status parameters, 47 109, 115, 248, 267, 427, Store assignment, 234 428, 564, 607, 609, 658, string data, length 665 mismatch, 235, 620 , 248, truncation, 147, 148, 249, 311, 660 149, 150, 151, 152, 163, , 232, 234, 235, 621, 623 314, 315, 317, 661 , 132, 133, Standard programming 135, 137 languages, 49, 243 , 128, 130, 131, 135, 155, , 320, 321, 661 160, 533 , character form-of-use 132, 160, 161 name>, 248, 249, 660 STRUCTURE, 85 , 171, 238, structured collection, 14 239, 240, 241, 242 SUBCLASS_ORIGIN, 84, 479, , 132, 133, 481, 485, 663 135, 137 , 11, 102, 119, statement completion 124, 125, 156, 185, 189, unknown, 71, 622 190, 191, 192, 195, 203, , 204, 281, 282, 296, 386, 479 395, 631, 632, 633, 635, , 479, 480, 482 Index 63 SUBSTRING, 22, 85, 132, Syntax Rules, 9, 10, 12, 133, 149, 151, 353, 362, 13, 14, 15, 64, 77, 82, 363, 364, 366, 445, 682 89, 139, 162, 208, 237, substring error, 135, 137, 270, 284, 302, 342, 347, 621 371, 377, 382, 388, 392, successful completion, 47, 394, 407, 408, 415, 417, 351, 622, 624 419, 420, 431, 435, 439, SUM, 85, 124, 125, 126, 659 442, 443, 447, 456, 458, Syntactic containment, 11 459, 462, 465, 469, 475, syntactic element, 11, 12, 13, 72 476, 477, 495, 496, 497, Syntactic substitution, 13 500, 501, 504, 505, 506, syntax error or access rule 508, 509, 512, 513, 515, violation, 12, 13, 486, 517, 518, 520, 521, 525, 487, 622 526, 530, 625, 663, 665, syntax error or access rule 667, 677, 678 violation in direct SQL _SYSTEM, 66, 248, 261, 289, statement, 12, 486, 487, 290, 294, 298, 300, 302, 526, 622 310, 312, 313, 316, 318, syntax error or access rule 321, 323, 330, 331, 332, violation in dynamic SQL 334, 335, 336, 398 statement, 12, 443, 462, , 369 SYSTEM_USER, 85, 114, 115, 116, 117, 192, 266, 267, 268, 269, 282, 325, 375, 530, 641, 645, 658, 682 - T - table, 37 64 Database Language SQL TABLE, 85, 196, 197, 258,
, 119, 260, 283, 292, 294, 329, 122, 125, 177, 191, 192, 332, 338, 397, 398, 482, 193, 195, 203, 382, 383, 483, 484, 568, 569, 570, 631, 632, 635, 643, 677 573, 574, 576, 577, 578,
, 11, 44, 98, 580, 583, 584, 585, 588, 101, 103, 118, 119, 121, 590, 593, 595, 596, 598, 122, 179, 193, 196, 197, 600, 602, 604, 606, 608, 200, 245, 258, 260, 261, 610, 612, 646 263, 272, 274, 282, 283, table check constraint, 41, 289, 291, 292, 294, 296, 43 297, 298, 299, 300, 326, table constraint, 41, 42 329, 330, 331, 333, 334,
, 264, 335, 338, 384, 386, 388, 270, 271, 309, 487 389, 391, 392, 394, 395,
, 260, 263, 477, 485, 492, 631, 635, 264, 270, 291, 309, 310, 636, 638 586 table privilege descriptor, table constraint descriptor 66 , 40, 41, 42, 270, 271,
, 118, 275, 289, 291, 336, 338 119, 120, 121, 122, 125, Table constraints, 41 178, 179, 180, 192, 193,
, 37, 38, 197, 199, 200, 281, 296, 52, 255, 260, 261, 262, 298, 331, 630, 631, 641 263, 265, 272, 274, 281, Tables, 37 284, 368, 484, 566 TABLES, 542, 543, 576, 578, table descriptor, 15, 39, 580, 583, 585, 586, 595, 40, 44, 75, 260, 261, 600, 640 265, 273, 275, 283, 289, TABLES base table, 576 291, 292, 296, 309, 326,
, 118, 119, 375, 576, 581 203, 212, 220, 222, 223,
, 260, 261 224, 225, 446, 447
, 260, TABLES view, 542 397 TABLES_CHECK_NOT_VIEW, 576 TABLES_FOREIGN_KEY_SCHEMATA , 576 TABLES_PRIMARY_KEY, 576 TABLES_TYPE_CHECK, 576 Index 65
, TABLE_CONSTRAINTS_TABLE_ 175, 176, 196, 197, 200, SCHEMA_NOT_NULL, 585 202, 212, 390, 444, 446, TABLE_CONSTRAINTS_UNIQUE_ 631, 632, 642, 648 CHECK, 586
, 176 486, 487, 542, 543, 544, TABLE_CATALOG, 542, 543, 545, 546, 547, 549, 552, 544, 545, 546, 547, 549, 557, 558, 559, 561, 562, 552, 557, 558, 559, 561, 572, 576, 578, 580, 581, 562, 572, 576, 578, 580, 583, 584, 585, 586, 587, 581, 583, 584, 585, 586, 588, 589, 595, 596, 597, 587, 588, 589, 591, 595, 600, 601, 602, 603 596, 597, 600, 601, 602, TABLE_OR_DOMAIN_CATALOG, 603 539, 545, 570, 571, 572, TABLE_CONSTRAINTS, 549, 573, 581 559, 561, 585, 586, 588, TABLE_OR_DOMAIN_CHECK_ 590, 591, 593, 616, 618 COMBINATIONS, 570 TABLE_CONSTRAINTS base TABLE_OR_DOMAIN_DATA_TYPE_ table, 585 NOT_NULL, 570 TABLE_CONSTRAINTS view, 549 TABLE_OR_DOMAIN_NAME, 539, TABLE_CONSTRAINTS_CHECK_ 545, 570, 571, 572, 573, REFERENCES_TABLES, 585 581 TABLE_CONSTRAINTS_CHECK_ TABLE_OR_DOMAIN_SCHEMA, VIEWS, 586 539, 545, 570, 571, 572, TABLE_CONSTRAINTS_DEFERRED_ 573, 581 CHECK, 585 TABLE_PRIVILEGES, 542, 546, TABLE_CONSTRAINTS_ 600, 640 INITIALLY_DEFERRED_ TABLE_PRIVILEGES base table NOT_NULL, 585 , 600 TABLE_CONSTRAINTS_IS_ TABLE_PRIVILEGES view, 546 DEFERRABLE_NOT_NULL, TABLE_PRIVILEGES_FOREIGN_ 585 KEY_TABLES, 600 TABLE_CONSTRAINTS_PRIMARY_ TABLE_PRIVILEGES_GRANTABLE_ KEY, 585 CHECK, 600 TABLE_CONSTRAINTS_TABLE_ TABLE_PRIVILEGES_GRANTABLE_ CATALOG_NOT_NULL, 585 NOT_NULL, 600 TABLE_CONSTRAINTS_TABLE_ TABLE_PRIVILEGES_GRANTEE_ NAME_NOT_NULL, 585 FOREIGN_KEY_USERS, 600 66 Database Language SQL TABLE_PRIVILEGES_GRANTOR_ temporary table, 37, 38, FOREIGN_KEY_USERS, 600 39, 46, 53, 56, 57, 58, TABLE_PRIVILEGES_PRIMARY_ 60, 72, 73, 76, 101, KEY, 600 103, 245, 258, 260, 261, TABLE_SCHEMA, 542, 543, 262, 265, 275, 281, 283, 544, 545, 546, 547, 549, 294, 296, 325, 343, 384, 552, 557, 558, 559, 561, 386, 389, 392, 394, 397, 562, 572, 576, 578, 580, 398, 403, 420, 459, 486, 581, 583, 584, 585, 586, 487, 492, 494, 495, 577, 587, 588, 589, 595, 596, 633, 634, 636, 639, 652, 597, 600, 601, 602, 603 655, 668 TABLE_TYPE, 542, 576, 578, , 39, 46, TABLE_TYPE_NOT_NULL, 576 53, 56, 57, 58, 60, 72, , 320, 343, 397, 398, 489, 492, 335 494, 495, 525, 634, 636, , 10, 62, 114, 115, 281, 296, 639, 652 325, 347, 350, 375, 377, temporary view, 668 380, 382, 383, 436, 439, , 157, 168, 169 451, 456, 457, 458, 460, Terms denoting rule 469, 470, 647, 667 requirements, 12 TARGET_CHARACTER_SET_ TEST, 85 THEN, 85, 141, 142, 314, CATALOG, 556, 610, 611 316, 318, 543, 544, 682 TARGET_CHARACTER_SET_NAME, THERE, 85 556, 610, 611 TIME, 19, 29, 30, 31, 49, TARGET_CHARACTER_SET_SCHEMA 85, 90, 94, 108, 110, , 556, 610, 611 111, 112, 122, 123, 129, TEMPORARY, 37, 38, 85, 260, 139, 152, 153, 165, 166, 261, 397, 576, 577, 633, 167, 422, 429, 440, 446, 682 484, 571, 682