Professional Documents
Culture Documents
Database Languages
Stephen Cannan Convenor
2002-05-06
Agenda
Working Group changes ISO/IEC 9075 ISO/IEC 20606 Recap of recent changes Sketch of planned changes
S J Cannan
S J Cannan
ISO/IEC 9075
Multi-part standard
Part 1: SQL/Framework Part 2: SQL/Foundation Part 3: SQL/CLI Part 4: SQL/PSM Part 9: SQL/MED Part 10: SQL/OLB Part 11: SQL/Schemata Part 13: SQL/JRT Part 14: SQL/XML
S J Cannan
Part 1: SQL/Framework
Common definitions & concepts
Structure of multi-part standard Basic conformance structure & statement
About 85 pages
S J Cannan
Part 2: SQL/Foundation
The core of the standard Includes:
Traditional SQL Object-oriented SQL Module Language Host language bindings (except Java) Dynamic SQL Direct SQL
Excludes:
Information Schema & Definition Schema (in Part 11)
Part 3: SQL/CLI
Call-Level Interface Best-known implementation: ODBC About 400 pages
S J Cannan
Part 4: SQL/PSM
Persistent Stored Modules PSM-96 specified:
functions & procedures SQL-server modules computational completeness
Foundation (same in 2003) Analogous to PL/SQL, Transact-SQL, etc. About 170 pages
S J Cannan
Part 9: SQL/MED
Management of External Data Foreign Servers, Foreign-Data Wrappers,
Foreign Tables
SQL-aware vs non-SQL-aware
Datalinks Merge with 20606-2 Distribution Schema
S J Cannan
10
S J Cannan
11
S J Cannan
12
S J Cannan
13
S J Cannan
ISO/IEC 20206
20606-1 Authorization and Audit 20606-3 Encompassing Transaction
14
S J Cannan
No Working Draft available CD expected 2002-06-01 John Hadjioannou listed as Editor but not present
15 S J Cannan
16
S J Cannan
Consists of:
Many error corrections (TC stands at 376 pages and growing) A few new features Part 14 SQL/XML
17 S J Cannan
New Features
Data types
Predicates Semantics Security Active Database
18
S J Cannan
19
S J Cannan
20
S J Cannan
21
S J Cannan
INTEGER MULTISET(2, 3, 5, 7)
Integer multiset with first few primes
22
S J Cannan
SET (value1)
Type of value1 must be multiset Returns value1 with duplicate elements removed
ELEMENT (value1)
Type of value1 must be multiset
Cardinality of value1 must be 1 Returns the single element in value1
23 S J Cannan
3 5 7
24 S J Cannan
SELECT col1
MULTISET INTERSECT DISTINCT col2 FROM tbl1 WHERE CARDINALITY(col2) > 50 Close analogs to ordinary set operators
UNION, EXCEPT, and INTERSECT
26
S J Cannan
New Predicates
NORMALIZED
If character string argument is in Unicode Normalization Form C (NFC), returns true
MEMBER
If first argument is a member of multiset in second argument, returns true
SUBMULTISET
If first argument is a submultiset of second argument, returns true
SET
If argument is a set (no duplicate values), returns true
27
S J Cannan
NORMALIZED Predicate
string_value IS [ NOT ] NORMALIZED Character repertoire of string_value must
be UCS
28
S J Cannan
MEMBER Predicate
value [ NOT ] MEMBER [ OF ]
multiset
29
S J Cannan
SUBMULTISET Predicate
multiset1 [ NOT ] SUBMULTISET
[ OF ] multiset2
and their element types must be comparable If the cardinalities of multiset1 and
multiset2 are equal and if every value in multiset1 has a corresponding value in multiset2, then returns true
30 S J Cannan
SET Predicate
multiset IS [ NOT ] A SET multiset must be a multiset If there are no duplicate values in multiset,
returns true
31
S J Cannan
New Semantics
MERGE statement
OLAP: TABLESAMPLE Generated columns Identity columns and sequence generators
32
S J Cannan
34
S J Cannan
TABLESAMPLE
New feature in the OLAP capability Permits evaluation of aggregates on samples
derived from database data
Permits faster debugging when database is huge Two forms of sampling: BERNOULLI and
SYSTEM
35
S J Cannan
TABLESAMPLE
TABLESAMPLE method ( percentage )
Generated Columns
Ordinary columns of base tables: base columns Generated column: value computed from values of zero
or more base columns in same row CREATE TABLE EMPLOYEES ( EMP_ID INTEGER, SALARY DECIMAL(7,2), BONUS DECIMAL(7,2), TOTAL_COMP GENERATED ALWAYS AS ( SALARY + BONUS ), HR_CLERK GENERATED ALWAYS AS ( CURRENT_USER ) )
S J Cannan
37
Sequence generators
Sequence generators
Data type (exact numeric with scale zero) Starting value
Variations:
NO CYCLE NO MAXVALUE, MINVALUE, NO MINVALUE Order of clauses can vary
40 S J Cannan
Sequence generators
Every sequence generator has a current base
value initially set to the start value Generate next value of a sequence generator: NEXT VALUE FOR seqname some N 0
Sequence generators
INSERT INTO TBL ( COL1, COL2 )
VALUES ( 10, NEXT VALUE FOR seqgen )
CALL myproc ( NEXT VALUE FOR seqgen ) SET J = J + NEXT VALUE FOR seqgen
42
S J Cannan
Sequence generators
ALTER SEQUENCE seqname
RESTART WITH newbase resets start of computation Common sequence generator options change start value, maximum or minimum, increment, cycle option
43
S J Cannan
45
S J Cannan
To be added:
Inserting XML into an SQL database
Transform character string containing XML text into an
XML value INSERT INTO employees ( empxml ) VALUES XMLPARSE ( '<emp id="15339"> <name>Gurney Halleck</name> <hiredate>3998-04-25</hiredate> <dept>Security</dept></emp>' STRIP WHITESPACE )
48
S J Cannan
To be added:
Inserting XML into an SQL database
XMLPARSE does not validate But it does:
Syntax check all in-line DTDs
To be added:
Validating XML in an SQL context
Validate an XML value against an XML schema
(possibly a DTD) INSERT INTO employees ( empxml ) VALUES XMLVALIDATE ( XMLPARSE ( '<emp id="15339"><name>Gurney Halleck</name><hiredate>3998-04-25 </hiredate><dept>Security</dept> </emp>' STRIP WHITESPACE ) )
50
S J Cannan
To be added:
Validating XML in an SQL context
Many remaining problems:
How to reference DTDs and schemas Security problems of referencing arbitrary DTDs and schemas Namespace considerations
xsi:schemaLocation and
xsi:noNameSpaceSchemaLocation might identify schemas outside the database a solution might involve caching schemas inside the database
S J Cannan
51
To be added:
Retrieving XML from an SQL database
Transform an XML value into a character string
containing XML text SELECT XMLSERIALIZE ( e.empxml ) INTO :hostvar FROM emp AS e WHERE ...
52
S J Cannan
To be added:
Retrieving XML from an SQL database
Numerous problems not yet resolved:
Precise SQL type of the function result (CHARACTER, CHARACTER VARYING, CHARACTER LARGE OBJECT)
Actual character encoding (UTF8, UTF16, other) and SQLs specified character set
Specified character encoding in prologue
53
S J Cannan
Summary
ISO/IEC 9075
Consolidation of changes since 1999 Correction of errors New Part (SQL/XML)
ISO/IEC 20206
Area of concern Looking for:
National Body participation Editor(s)
54
S J Cannan
Questions?
55
S J Cannan