Comparisons allowed by DerbyThis table displays
valid comparisons between data types in .
A "Y" indicates that the comparison is allowed.
@@ -636,7 +698,7 @@ colwidth="83*"/>
+colwidth="89*"/>
Types
@@ -796,6 +858,23 @@ P
X
M
L
+ U
+s
+e
+r
+-
+d
+e
+f
+i
+n
+e
+d
+
+t
+y
+p
+e
@@ -864,6 +943,7 @@ L
-
-
-
+-
DECIMAL
@@ -886,6 +966,7 @@ L
-
-
-
+-
REAL
@@ -908,6 +989,7 @@ L
-
-
-
+-
DOUBLE
@@ -930,6 +1012,7 @@ L
-
-
-
+-
FLOAT
@@ -952,6 +1035,7 @@ L
-
-
-
+-
CHAR
@@ -974,6 +1058,7 @@ L
Y
Y
-
+-
VARCHAR
@@ -996,6 +1081,7 @@ L
Y
Y
-
+-
LONG VARCHAR
@@ -1018,6 +1104,7 @@ L
-
-
-
+-
CHAR FOR BIT DATA
@@ -1040,6 +1127,7 @@ L
-
-
-
+-
VARCHAR FOR BIT DATA
@@ -1062,6 +1150,7 @@ L
-
-
-
+-
LONG VARCHAR FOR BIT DATA
@@ -1084,6 +1173,7 @@ L
-
-
-
+-
CLOB
@@ -1106,6 +1196,7 @@ L
-
-
-
+-
BLOB
@@ -1128,6 +1219,7 @@ L
-
-
-
+-
DATE
@@ -1150,6 +1242,7 @@ L
-
-
-
+-
TIME
@@ -1172,9 +1265,10 @@ L
Y
-
-
+-
-TIME STAMP
+TIMESTAMP
-
-
-
@@ -1194,6 +1288,7 @@ L
-
Y
-
+-
XML
@@ -1216,6 +1311,30 @@ L
-
-
-
+-
+
+
+User-defined type
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
Modified: db/derby/docs/trunk/src/ref/rrefsqljargmatching.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljargmatching.dita?rev=935706&r1=935705&r2=935706&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljargmatching.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqljargmatching.dita Mon Apr 19 18:58:48 2010
@@ -28,9 +28,12 @@ limitations under the License.
When you declare a function or procedure using CREATE
-FUNCTION/PROCEDURE, Derby does not verify whether a matching Java
-method exists. Instead, Derby looks for a matching method only when you invoke the
-function or procedure in a later SQL statement. At that time, Derby
+FUNCTION/PROCEDURE,
+does not verify whether a matching Java
+method exists. Instead,
+looks for a matching method only when you invoke the
+function or procedure in a later SQL statement. At that time,
+
searches for a public, static method having the class and method name
declared in the EXTERNAL NAME clause of the earlier
CREATE FUNCTION/PROCEDURE statement. Furthermore, the Java types of
@@ -40,41 +43,55 @@ following may happen:
-- Success - If exactly one Java method matches, then Derby
-invokes it.
-- Ambiguity - Derby raises an error if more than one method matches.
-- Failure - Derby also raises an error if no method matches.
+- Success - If exactly one Java method matches, then
+ invokes it.
+- Ambiguity -
+raises an error if more than one method matches.
+- Failure -
+also raises an error if no method matches.
-In mapping SQL data types to Java data types, Derby considers the following
+In mapping SQL data types to Java data types,
+ considers the following
kinds of matches:
-- Primitive match - Derby looks for a primitive Java type
-corresponding to the SQL type. For instance, SQL INTEGER matches Java int.
-- Wrapper match - Derby looks for a wrapper class
-in the java.lang or java.sql packages corresponding to the SQL type. For instance, SQL
-INTEGER matches java.lang.Integer.
-- Array match - For OUT and INOUT procedure arguments, Derby
+
- Primitive match -
+ looks for a primitive
+Java type corresponding to the SQL type. For instance, SQL INTEGER matches Java
+int.
+- Wrapper match -
+ looks for a wrapper
+class in the java.lang or java.sql packages corresponding to the
+SQL type. For instance, SQL INTEGER matches java.lang.Integer. For a
+user-defined type (UDT),
+ looks for the UDT's
+external name class.
+- Array match - For OUT and INOUT procedure arguments,
+
looks for an array of the corresponding primitive or wrapper type. For
instance, an OUT procedure argument of type SQL INTEGER matches
int[] and Integer[].
- ResultSet match - If a procedure is declared to return n
-RESULT SETS, then Derby looks for a method whose last n arguments are
+RESULT SETS, looks for
+a method whose last n arguments are
of type java.sql.ResultSet[].
-Derby resolves function and procedure invocations as follows:
+ resolves function and
+procedure invocations as follows:
-- Function - Derby looks for a method whose argument and
+
- Function -
+looks for a method whose argument and
return types are primitive matches or wrapper matches for
the function's SQL arguments and return value.
-- Procedure - Derby looks for a method which returns void and
+
- Procedure -
+looks for a method which returns void and
whose argument types match as follows:
- IN - Method arguments are
@@ -122,7 +139,8 @@ public static Double toDegrees( Double a
-Note that Derby would raise an exception if Derby found more than one matching method.
+Note that would raise
+an exception if it found more than one matching method.
@@ -131,8 +149,9 @@ Note that Derby would raise an exception
Mapping SQL data types to Java data types
-The following table shows how Derby maps specific SQL data types to Java
-data types:
+The following table shows how
+ maps specific SQL data
+types to Java data types:
@@ -273,6 +292,12 @@ data types:
-
+
+ User-defined type
+ -
+ Underlying Java class
+
+
Modified: db/derby/docs/trunk/src/ref/rrefsqljcreatesequence.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljcreatesequence.dita?rev=935706&r1=935705&r2=935706&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljcreatesequence.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqljcreatesequence.dita Mon Apr 19 18:58:48 2010
@@ -39,15 +39,14 @@ privilege cannot be revoked from the sch
for more information.
Syntax
-CREATE SEQUENCE sequenceName [ sequenceElement ]*
-
-sequenceName
-[ CREATE SEQUENCE [ schemaName. ] SQL92Identifier
-If schemaName is not provided, the current schema is the default
-schema. If a qualified sequence name is specified, the schema name cannot
-begin with SYS.
+href="crefsqlj34834.dita#crefsqlj34834">SQL92Identifier [ sequenceElement ]*
+The sequence name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified sequence name is specified, the
+schema name cannot begin with SYS.
sequenceElement
{
AS dataType
Added: db/derby/docs/trunk/src/ref/rrefsqljcreatetype.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljcreatetype.dita?rev=935706&view=auto
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljcreatetype.dita (added)
+++ db/derby/docs/trunk/src/ref/rrefsqljcreatetype.dita Mon Apr 19 18:58:48 2010
@@ -0,0 +1,108 @@
+
+
+
+
+
+CREATE TYPE statement
+
+CREATE TYPE statement
+SQL statementsCREATE TYPE
+user-defined typescreating
+data typesuser-defined
+
+
+
+
+The CREATE TYPE statement creates a user-defined type (UDT). A UDT is a
+serializable Java class whose instances are stored in columns. The class must
+implement the java.io.Serializable interface.
+Syntax
+CREATE TYPE [ schemaName. ] SQL92Identifier
+EXTERNAL NAME singleQuotedJavaClassName
+LANGUAGE JAVA
+The type name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified type name is specified, the schema
+name cannot begin with SYS.
+If the Java class does not implement java.io.Serializable, or if it is
+not public and visible on the classpath,
+ raises an exception
+when preparing statements which refer to the UDT.
+A UDT cannot be cast explicitly to any other type, and no other type can be
+cast to a UDT.
+A UDT has no ordering. This means that you cannot compare and sort UDTs. You
+cannot use them in expressions involving the <,
+=, >, IN, BETWEEN, and LIKE operators. You
+cannot use UDTs in aggregates, DISTINCT expressions, and GROUP/ORDER BY clauses.
+You cannot build indexes on them.
+You can use subtypes in UDTs. That is, if you use the CREATE TYPE statement
+to bind a class named C to a UDT, you can populate that UDT value with an
+instance of any subclass of C.
+
+Example
+CREATE TYPE price
+EXTERNAL NAME 'com.acme.types.Price'
+LANGUAGE JAVA
+
+Using user-defined types
+You can create tables and views with columns that have UDTs. For example:
+CREATE TABLE order
+(
+ orderID INT GENERATED ALWAYS AS IDENTITY,
+ customerID INT REFERENCES customer( customerID ),
+ totalPrice typeSchema.price
+);
+Although UDTs have no natural order, you can use generated columns to provide
+useful sort orders:
+ALTER TABLE order
+ ADD COLUMN normalizedValue DECIMAL( 31, 5 ) GENERATED ALWAYS AS
+ ( convert( 'EUR', TIMESTAMP('2005-01-01 09:00:00'), totalPrice ) );
+CREATE INDEX normalizedOrderPrice ON order( normalizedValue );
+You can use factory functions to construct UDTs. For example:
+
+INSERT INTO order( customerID, totalPrice )
+ VALUES ( 12345,
+ makePrice( 'USD',
+ CAST( 9.99 AS DECIMAL( 31, 5 ) ),
+ TIMESTAMP('2009-10-16 14:24:43') ) );
+Once a UDT column has been populated, you can use it in other INSERT and
+UPDATE statements. For example:
+INSERT INTO backOrder SELECT * from order;
+
+UPDATE order SET totalPrice = ( SELECT todaysDiscount FROM discount );
+UPDATE order SET totalPrice = adjustForInflation( totalPrice );
+Using functions, you can access fields inside UDTs in a SELECT statement:
+SELECT getCurrencyCode( totalPrice ) from order;
+You can use JDBC API setObject() and getObject() methods to
+store and retrieve values of UDTs. For example:
+PreparedStatement ps = conn.prepareStatement( "SELECT * from order" );
+ResultSet rs = ps.executeQuery();
+
+while( rs.next() )
+{
+ int orderID = rs.getInt( 1 );
+ int customerID = rs.getInt( 2 );
+ Price totalPrice = (Price) rs.getObject( 3 );
+ ...
+}
+
+
+
Propchange: db/derby/docs/trunk/src/ref/rrefsqljcreatetype.dita
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/docs/trunk/src/ref/rrefsqljdropsequence.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljdropsequence.dita?rev=935706&r1=935705&r2=935706&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljdropsequence.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqljdropsequence.dita Mon Apr 19 18:58:48 2010
@@ -30,21 +30,20 @@ limitations under the License.
The DROP SEQUENCE statement removes a sequence generator that was
created using a .
Syntax
-DROP SEQUENCE sequenceName RESTRICT
+DROP SEQUENCE [ schemaName. ] SQL92Identifier RESTRICT
+The sequence name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified sequence name is specified, the
+schema name cannot begin with SYS.
The RESTRICT keyword is required. If a trigger or view references the
sequence generator,
throws an exception.
Dropping a sequence generator implicitly drops all USAGE privileges that
reference it.
-sequenceName
-[ schemaName. ] SQL92Identifier
-If schemaName is not provided, the current schema is the default
-schema. If a qualified sequence name is specified, the schema name cannot
-begin with SYS.
Example
DROP SEQUENCE order_id RESTRICT;
Added: db/derby/docs/trunk/src/ref/rrefsqljdroptype.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljdroptype.dita?rev=935706&view=auto
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljdroptype.dita (added)
+++ db/derby/docs/trunk/src/ref/rrefsqljdroptype.dita Mon Apr 19 18:58:48 2010
@@ -0,0 +1,65 @@
+
+
+
+
+
+DROP TYPE statement
+
+DROP TYPE statement
+SQL statementsDROP TYPE
+user-defined typesdropping
+data typesuser-defined
+
+
+
+The DROP TYPE statement removes a user-defined type (UDT) that was
+created using a
+.
+
+Syntax
+DROP TYPE [ schemaName. ] SQL92Identifier RESTRICT
+The type name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified type name is specified, the schema
+name cannot begin with SYS.
+The RESTRICT keyword is required. CASCADE semantics are not supported. That
+is, will not track down
+and drop orphaned objects.
+Dropping a UDT implicitly drops all USAGE privileges that reference it.
+You cannot drop a type if it would make another SQL object unusable. This
+includes the following restrictions:
+
+- Table columns: No table columns have this UDT.
+- Views: No view definition involves expressions which have this UDT.
+- Constraints: No constraints reference expressions of this UDT.
+- Generated columns: No generated columns reference expressions of this
+UDT.
+- Routines: No functions or procedures have arguments or return values of this
+UDT.
+- Table Functions: No table functions return tables with columns of this
+UDT.
+
+
+Example
+DROP TYPE price RESTRICT;
+
+
+
Propchange: db/derby/docs/trunk/src/ref/rrefsqljdroptype.dita
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/docs/trunk/src/ref/rrefsqljgrant.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljgrant.dita?rev=935706&r1=935705&r2=935706&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljgrant.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqljgrant.dita Mon Apr 19 18:58:48 2010
@@ -40,7 +40,7 @@ from a table.
- Create a trigger on a table.
- Update data in a table or in a subset of columns in a table.
- Run a specified function or procedure.
-- Use a sequence generator.
+- Use a sequence generator or a user-defined type.
Before you issue a GRANT statement, check that the
derby.database.sqlAuthorization property
is set to true. The derby.database.sqlAuthorization property
@@ -50,7 +50,7 @@ object if you are the owner of the objec
CREATE statement for the database object that you want to grant privileges on
for more information.
The
syntax that you use for the GRANT statement depends on whether you are granting
-privileges to a table, a routine, or a sequence generator, or granting a role.
+privileges to a schema object or granting a role.
For more information on using the GRANT statement, see "Using SQL standard
authorization" in the .
@@ -62,11 +62,29 @@ href="rrefviewname.dita#rrefviewname">
href="rrefsqljgrant.dita#rrefsqljgrant/grantroutinename">routine-designator TO grantees
Syntax for sequence generators
-GRANT USAGE ON SEQUENCE sequenceName TO grantees
+GRANT USAGE ON SEQUENCE [ schemaName. ] SQL92Identifier TO grantees
In order to use a sequence generator, you must have the USAGE privilege on
it. This privilege can be granted to users and to roles. See
for more
-information.
+information.
+The sequence name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified sequence name is specified, the
+schema name cannot begin with SYS.
+Syntax for user-defined types
+GRANT USAGE ON TYPE [ schemaName. ] SQL92Identifier TO grantees
+In order to use a user-defined type, you must have the USAGE privilege on
+it. This privilege can be granted to users and to roles. See
+ for more
+information.
+The type name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified type name is specified, the schema
+name cannot begin with SYS.
Syntax for roles
GRANT roleName [ {, roleName }* ] TO
routine-designator{
function-name | procedure-name
}
-sequenceName
-[ schemaName. ] SQL92Identifier
-If schemaName is not provided, the current schema is the default
-schema. If a qualified sequence name is specified, the schema name cannot
-begin with SYS.
ExamplesTo grant the SELECT
privilege on table t to the authorization IDs maria and harry,
use the following syntax:GRANT SELECT ON TABLE t TO maria,harry
To
@@ -166,6 +177,10 @@ syntax:
order_id to the role sales_role, use the
following syntax:
GRANT USAGE ON SEQUENCE order_id TO sales_role;
+To grant the USAGE privilege on the user-defined type
+price to the role finance_role, use the
+following syntax:
+GRANT USAGE ON TYPE price TO finance_role;
Modified: db/derby/docs/trunk/src/ref/rrefsqljrevoke.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljrevoke.dita?rev=935706&r1=935705&r2=935706&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljrevoke.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqljrevoke.dita Mon Apr 19 18:58:48 2010
@@ -39,7 +39,7 @@ from a table.
- Create a trigger on a table.
- Update data in a table or in a subset of columns in a table.
- Run a specified routine (function or procedure).
-- Use a sequence generator.
+- Use a sequence generator or a user-defined type.
The
derby.database.sqlAuthorization
property must be set to true before you can use the GRANT
@@ -48,8 +48,8 @@ statement or the REVOKE statement. The
enables SQL Authorization mode.
You can revoke privileges for an
object if you are the owner of the object or the database
owner.
The syntax that you use for the REVOKE statement depends
-on whether you are revoking privileges to a table, a routine, or a sequence
-generator, or whether you are revoking a role.
+on whether you are revoking privileges to a schema object or revoking a
+role.
For more information on using the REVOKE statement, see "Using SQL standard
authorization" in the .
@@ -66,14 +66,35 @@ clause specifies that the EXECUTE privil
routine is used in a view, trigger, or constraint, and the privilege is being
revoked from the owner of the view, trigger, or constraint.
Syntax for sequence generators
-REVOKE USAGE ON SEQUENCE sequenceName FROM grantees RESTRICT
+REVOKE USAGE ON SEQUENCE [ schemaName. ] SQL92Identifier FROM grantees RESTRICT
In order to use a sequence generator, you must have the USAGE privilege on
it. This privilege can be revoked from users and roles. Only RESTRICTed revokes
are allowed. This means that the REVOKE statement cannot make a view, trigger,
or constraint unusable by its owner. The USAGE privilege cannot be revoked from
the schema owner. See
for more
-information.
+information.
+The sequence name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified sequence name is specified, the
+schema name cannot begin with SYS.
+Syntax for user-defined types
+REVOKE USAGE ON TYPE [ schemaName. ] SQL92Identifier FROM grantees RESTRICT
+In order to use a user-defined type, you must have the USAGE privilege on
+it. This privilege can be revoked from users and roles. Only RESTRICTed revokes
+are allowed. This means that the REVOKE statement cannot make a view, trigger,
+or constraint unusable by its owner. The USAGE privilege cannot be revoked from
+the schema owner. See
+ for more
+information.
+The type name is composed of an optional schemaName and a
+SQL92Identifier. If a schemaName is not provided, the current
+schema is the default schema. If a qualified type name is specified, the schema
+name cannot begin with SYS.
Syntax for roles
REVOKE roleName [ {, roleName }* ] FROM
order_id from the role sales_role, use the
following syntax:
REVOKE USAGE ON SEQUENCE order_id FROM sales_role;
+To revoke the USAGE privilege on the user-defined type
+price from the role finance_role, use the
+following syntax:
+REVOKE USAGE ON TYPE price FROM finance_role;
Added: db/derby/docs/trunk/src/ref/rrefsqljudt.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqljudt.dita?rev=935706&view=auto
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqljudt.dita (added)
+++ db/derby/docs/trunk/src/ref/rrefsqljudt.dita Mon Apr 19 18:58:48 2010
@@ -0,0 +1,43 @@
+
+
+
+
+
+User-defined types
+
+user-defined types
+data typesuser-defined
+
+
+ allows
+you to create user-defined types. A user-defined type is a serializable Java
+class whose instances are stored in columns. The class must implement the
+java.io.Serializable interface.
+For information on creating and removing types, see
+ and
+. See
+ and
+ for information on usage
+privileges for types.
+For information on writing the Java classes that implement user-defined
+types, see "Programming user-defined types" in the
+.
+
+
+
Propchange: db/derby/docs/trunk/src/ref/rrefsqljudt.dita
------------------------------------------------------------------------------
svn:eol-style = native