Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
• | SQL language reference Reference information
about Derby's SQL language,
including manual pages for statements, functions, and other syntax elements. | |
• | SQL reserved words SQL keywords beyond the standard SQL-92 keywords. | |
• | Derby support for SQL-92 features A list of
SQL-92 features that Derby does
and does not support. | |
• | Derby system tables Reference
information about the Derby system
catalogs. | |
• | Derby exception messages and SQL states Information
about Derby exception messages. | |
• | JDBC reference Information
about Derby's implementation
of the Java Database Connectivity (JDBC) API. | |
• | Setting attributes for the database connection URL Information
about the supported attributes to Derby's
JDBC database connection URL. | |
• | Derby property reference Information about Derby
properties. | |
• | J2EE Compliance: Java Transaction API and javax.sql Interfaces Information
about Derby's support for the
Java EE platform, in particular support for the Java Transaction API and the
JDBC API. | |
• | Derby API Notes
about proprietary APIs for Derby. | |
• | Supported territories Territories
supported by Derby. | |
• | Derby limitations Limitations
of Derby. |
• | Double quotation marks delimit special identifiers referred to in SQL-92
as delimited identifiers. | |
• | Single quotation marks delimit character strings. | |
• | Within a character string, to represent a single quotation mark or apostrophe,
use two single quotation marks. (In other words, a single quotation mark is
the escape character for a single quotation mark.) A double quotation
mark does not need an escape character. To represent a double quotation mark,
simply use a double quotation mark. However, note that in a Java
program, a double quotation mark requires the backslash escape character. Example:
| |
• | SQL keywords are case-insensitive. For example, you can type the keyword
SELECT as SELECT, Select, select, or sELECT. | |
• | SQL-92-style identifiers are case-insensitive (see SQL92Identifier),
unless they are delimited. | |
• | Java-style identifiers are always case-sensitive. | |
• | * is a wildcard within a SelectExpression. See The * wildcard. It
can also be the multiplication operator. In all other cases, it is a syntactical
metasymbol that flags items you can repeat 0 or more times. | |
• | % and _ are character wildcards when used within character strings following
a LIKE operator (except when escaped with an escape character). See Boolean expressions. | |
• | Comments can be either single- or multiline as per the SQL-92 standard. Singleline
comments start with two dashes (--) and end with the newline character. Multiline
comments are bracketed and start with forward slash star (/*), and end with star
forward slash (*/). Note that bracketed comments may be nested. Any text between
the starting and ending comment character sequence is ignored. |
"A.B"
"A"."B"
• | creating a table (CREATE TABLE statement) | |
• | specifying updatable columns in a cursor | |
• | in a column's correlation name in a SELECT expression (see SelectExpression) | |
• | in a column's correlation name in a TableExpression (see TableExpression) |
In this example, the correlation-Name col1 FOR c11 is not permitted because c11 is listed in the FOR UPDATE list of columns. You can use the correlation-Name FOR c12 because it is not in the FOR UPDATE list.SELECT c11 AS col1, c12 AS col2, c13 FROM t1 FOR UPDATE of c11,c13
-- C.Country is a column-Name qualified with a -- correlation-Name. SELECT C.Country FROM APP.Countries C
In this example, the correlation-Name col1 FOR c11 is not permitted because c11 is listed in the FOR UPDATE list of columns. You can use the correlation-Name FOR c12 because it is not in the FOR UPDATE list.SELECT c11 AS col1, c12 AS col2, c13 FROM t1 FOR UPDATE of c11,c13
ij> CREATE TABLE mytable (mycol INT); 0 rows inserted/updated/deleted ij> INSERT INTO mytable VALUES (1), (2), (3); 3 rows inserted/updated/deleted -- this example uses the ij command prepare, -- which prepares a statement ij> prepare p1 AS 'INSERT INTO MyTable VALUES (4)'; -- p1 depends on mytable; ij> execute p1; 1 row inserted/updated/deleted -- Derby executes it without recompiling ij> CREATE INDEX i1 ON mytable(mycol); 0 rows inserted/updated/deleted -- p1 is temporarily invalidated because of new index ij> execute p1; 1 row inserted/updated/deleted -- Derby automatically recompiles p1 and executes it ij> DROP TABLE mytable; 0 rows inserted/updated/deleted -- Derby permits you to drop table -- because result set of p1 is closed -- however, the statement p1 is temporarily invalidated ij> CREATE TABLE mytable (mycol INT); 0 rows inserted/updated/deleted ij> INSERT INTO mytable VALUES (1), (2), (3); 3 rows inserted/updated/deleted ij> execute p1; 1 row inserted/updated/deleted -- Because p1 is invalid, Derby tries to recompile it -- before executing. -- It is successful and executes. ij> DROP TABLE mytable; 0 rows inserted/updated/deleted -- statement p1 is now invalid, -- and this time the attempt to recompile it -- upon execution will fail ij> execute p1; ERROR 42X05: Table/View 'MYTABLE' does not exist.
• | add a column to a table | |
• | add a constraint to a table | |
• | drop a column from a table | |
• | drop an existing constraint from a table | |
• | increase the width of a VARCHAR or VARCHAR FOR BIT DATA column | |
• | override row-level locking for the table (or drop the override) | |
• | change the increment value and start value of the identity column | |
• | change the nullability constraint for a column | |
• | change the default value for a column |
ALTER TABLE table-Name { ADD COLUMN column-definition | ADD CONSTRAINT clause | DROP [ COLUMN ] column-name [ CASCADE | RESTRICT ] DROP { PRIMARY KEY | FOREIGN KEY constraint-name | UNIQUE constraint-name | CHECK constraint-name | CONSTRAINT constraint-name } ALTER [ COLUMN ] column-alteration | LOCKSIZE { ROW | TABLE } }
Simple-column-Name [ DataType ] [ Column-level-constraint ]* [ [ WITH ] DEFAULT DefaultConstantExpression | generation-clause ]
column-Name SET DATA TYPE VARCHAR(integer) | column-Name SET DATA TYPE VARCHAR FOR BIT DATA(integer) | column-name SET INCREMENT BY integer-constant | column-name RESTART WITH integer-constant | column-name [ NOT ] NULL | column-name [ WITH | SET ] DEFAULT default-value | column-name DROP DEFAULT
CREATE TABLE tauto(i INT GENERATED BY DEFAULT AS IDENTITY, k INT) CREATE UNIQUE INDEX tautoInd ON tauto(i) INSERT INTO tauto(k) values 1,2
INSERT INTO tauto VALUES (3,3) INSERT INTO tauto VALUES (4,4) INSERT INTO tauto VALUES (5,5)
ALTER TABLE tauto ALTER COLUMN i RESTART WITH 6
• | When adding a foreign key or check constraint to an existing table, Derby checks the table to make
sure existing rows satisfy the constraint. If any row is invalid, Derby throws
a statement exception and the constraint is not added. | |
• | All columns included in a primary key must contain non null data and be
unique. ALTER TABLE ADD UNIQUE or PRIMARY KEY provide a shorthand method
of defining a primary key composed of a single column. If PRIMARY KEY is specified
in the definition of column C, the effect is the same as if the PRIMARY KEY(C)
clause were specified as a separate clause. The column cannot contain null
values, so the NOT NULL attribute must also be specified. |
• | Increasing the width of an existing VARCHAR or VARCHAR FOR BIT DATA column. CHARACTER VARYING
or CHAR VARYING can be used as synonyms for the VARCHAR keyword. To increase
the width of a column of these types, specify the data type and new size after
the column name. You are not allowed to decrease the width or to change
the data type. You are not allowed to increase the width of a column that
is part of a primary or unique key referenced by a foreign key constraint
or that is part of a foreign key constraint. | |
• | Specifying the interval between consecutive values of the identity column. To
set an interval between consecutive values of the identity column, specify
the integer-constant. You must previously define the column with the IDENTITY
attribute (SQLSTATE 42837). If there are existing rows in the table, the values
in the column for which the SET INCREMENT default was added do not change. | |
• | Modifying the nullability constraint of a column.
You can add the NOT NULL constraint to an existing column. To do so
there must not be existing NULL values for the column in the table. You can remove the NOT NULL constraint from an existing column. To do
so the column must not be used in a PRIMARY KEY constraint. | |
• | Changing the default value for a column.
You can use DEFAULT default-value to change a column default. To disable a
previously set default, use DROP DEFAULT (alternatively, you can specify NULL as
the default-value). |
-- Add a new column with a column-level constraint -- to an existing table -- An exception will be thrown if the table -- contains any rows -- since the newcol will be initialized to NULL -- in all existing rows in the table ALTER TABLE CITIES ADD COLUMN REGION VARCHAR(26) CONSTRAINT NEW_CONSTRAINT CHECK (REGION IS NOT NULL); -- Add a new unique constraint to an existing table -- An exception will be thrown if duplicate keys are found ALTER TABLE SAMP.DEPARTMENT ADD CONSTRAINT NEW_UNIQUE UNIQUE (DEPTNO); -- add a new foreign key constraint to the -- Cities table. Each row in Cities is checked -- to make sure it satisfied the constraints. -- if any rows don't satisfy the constraint, the -- constraint is not added ALTER TABLE CITIES ADD CONSTRAINT COUNTRY_FK Foreign Key (COUNTRY) REFERENCES COUNTRIES (COUNTRY); -- Add a primary key constraint to a table -- First, create a new table CREATE TABLE ACTIVITIES (CITY_ID INT NOT NULL, SEASON CHAR(2), ACTIVITY VARCHAR(32) NOT NULL); -- You will not be able to add this constraint if the -- columns you are including in the primary key have -- null data or duplicate values. ALTER TABLE Activities ADD PRIMARY KEY (city_id, activity); -- Drop the city_id column if there are no dependent objects: ALTER TABLE Cities DROP COLUMN city_id RESTRICT; -- Drop the city_id column, also dropping all dependent objects: ALTER TABLE Cities DROP COLUMN city_id CASCADE; -- Drop a primary key constraint from the CITIES table ALTER TABLE Cities DROP CONSTRAINT Cities_PK; -- Drop a foreign key constraint from the CITIES table ALTER TABLE Cities DROP CONSTRAINT COUNTRIES_FK; -- add a DEPTNO column with a default value of 1 ALTER TABLE SAMP.EMP_ACT ADD COLUMN DEPTNO INT DEFAULT 1; -- increase the width of a VARCHAR column ALTER TABLE SAMP.EMP_PHOTO ALTER PHOTO_FORMAT SET DATA TYPE VARCHAR(30); -- change the lock granularity of a table ALTER TABLE SAMP.SALES LOCKSIZE TABLE; -- Remove the NOT NULL constraint from the MANAGER column ALTER TABLE Employees ALTER COLUMN Manager NULL; -- Add the NOT NULL constraint to the SSN column ALTER TABLE Employees ALTER COLUMN ssn NOT NULL; -- Change the default value for the SALARY column ALTER TABLE Employees ALTER COLUMN Salary DEFAULT 1000.0 ALTER TABLE Employees ALTER COLUMN Salary DROP DEFAULT
CREATE FUNCTION function-name ( [ FunctionParameter [, FunctionParameter] ] * ) RETURNS ReturnDataType [ FunctionElement ] *
{ | LANGUAGE { JAVA } | DeterministicCharacteristic | EXTERNAL NAME string | PARAMETER STYLE ParameterStyle | { NO SQL | CONTAINS SQL | READS SQL DATA } | { RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT } }
The External Name cannot have any extraneous spaces.class_name.method_name
DETERMINISTIC | NOT DETERMINISTIC
• | LANGUAGE | |
• | PARAMETER STYLE | |
• | EXTERNAL NAME |
CREATE [UNIQUE] INDEX index-Name ON table-Name ( Simple-column-Name [ ASC | DESC ] [ , Simple-column-Name [ ASC | DESC ]] * )
SELECT CONGLOMERATENAME FROM SYS.SYSCONGLOMERATES, SYS.SYSCONSTRAINTS WHERE SYS.SYSCONGLOMERATES.TABLEID = SYSCONSTRAINTS.TABLEID AND CONSTRAINTNAME = 'FLIGHTS_PK'
CREATE INDEX OrigIndex ON Flights(orig_airport); -- money is usually ordered from greatest to least, -- so create the index using the descending order CREATE INDEX PAY_DESC ON SAMP.EMPLOYEE (SALARY); -- use a larger page size for the index call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize','8192'); CREATE INDEX IXSALE ON SAMP.SALES (SALES); call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize',NULL);
CREATE PROCEDURE procedure-Name ( [ ProcedureParameter [, ProcedureParameter] ] * ) [ ProcedureElement ] *
{ | [ DYNAMIC ] RESULT SETS INTEGER | LANGUAGE { JAVA } | DeterministicCharacteristic | EXTERNAL NAME string | PARAMETER STYLE JAVA | { NO SQL | MODIFIES SQL DATA | CONTAINS SQL | READS SQL DATA } }
The External Name cannot have any extraneous spaces.class_name.method_name
DETERMINISTIC | NOT DETERMINISTIC
CREATE SCHEMA { [ schemaName AUTHORIZATION user-name ] | [ schemaName ] | [ AUTHORIZATION user-name ] }
with a user name other than the current user name. See "derby.database.sqlAuthorization" for information about the derby.database.sqlAuthorization property.AUTHORIZATION user-name
CREATE SCHEMA FLIGHTS AUTHORIZATION anita
CREATE SCHEMA EMP
CREATE SCHEMA AUTHORIZATION takumi
CREATE TABLE FLIGHTS.AVAILABILITY (FLIGHT_ID CHAR(6) NOT NULL, SEGMENT_NUMBER INT NOT NULL, FLIGHT_DATE DATE NOT NULL, ECONOMY_SEATS_TAKEN INT, BUSINESS_SEATS_TAKEN INT, FIRSTCLASS_SEATS_TAKEN INT, CONSTRAINT FLT_AVAIL_PK PRIMARY KEY (FLIGHT_ID, SEGMENT_NUMBER, FLIGHT_DATE))
CREATE TABLE EMP.AVAILABILITY (HOTEL_ID INT NOT NULL, BOOKING_DATE DATE NOT NULL, ROOMS_TAKEN INT, CONSTRAINT HOTELAVAIL_PK PRIMARY KEY (HOTEL_ID, BOOKING_DATE))
The synonym-Name in the statement represents the synonym name you are giving the target table or view, while the view-Name or table-Name represents the original name of the target table or view.CREATE SYNONYM synonym-Name FOR { view-Name | table-Name }
• | INSERT | |
• | SELECT | |
• | REFERENCES | |
• | TRIGGER | |
• | UPDATE |
CREATE TABLE table-Name { ( {column-definition | Table-level constraint} [ , {column-definition | Table-level constraint} ] * ) | [ ( column-name [ , column-name ] * ) ] AS query-expression WITH NO DATA }
CREATE TABLE HOTELAVAILABILITY (HOTEL_ID INT NOT NULL, BOOKING_DATE DATE NOT NULL, ROOMS_TAKEN INT DEFAULT 0, PRIMARY KEY (HOTEL_ID, BOOKING_DATE)); -- the table-level primary key definition allows you to -- include two columns in the primary key definition PRIMARY KEY (hotel_id, booking_date)) -- assign an identity column attribute to an INTEGER -- column, and also define a primary key constraint -- on the column CREATE TABLE PEOPLE (PERSON_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY CONSTRAINT PEOPLE_PK PRIMARY KEY, PERSON VARCHAR(26)); -- assign an identity column attribute to a SMALLINT -- column with an initial value of 5 and an increment value -- of 5. CREATE TABLE GROUPS (GROUP_ID SMALLINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 5, INCREMENT BY 5), ADDRESS VARCHAR(100), PHONE VARCHAR(15));
-- create a new table using all the columns and data types -- from an existing table: CREATE TABLE T3 AS SELECT * FROM T1 WITH NO DATA; -- create a new table, providing new names for the columns, but -- using the data types from the columns of an existing table: CREATE TABLE T3 (A,B,C,D,E) AS SELECT * FROM T1 WITH NO DATA; -- create a new table, providing new names for the columns, -- using the data types from the indicated columns of an existing table: CREATE TABLE T3 (A,B,C) AS SELECT V,DP,I FROM T1 WITH NO DATA; -- This example shows that the columns in the result of the -- query expression may be unnamed expressions, but their data -- types can still be used to provide the data types for the -- corresponding named columns in the newly-created table: CREATE TABLE T3 (X,Y) AS SELECT 2*I,2.0*F FROM T1 WITH NO DATA;
Simple-column-Name [ DataType ] [ Column-level-constraint ]* [ [ WITH ] DEFAULT DefaultConstantExpression | generated-column-spec | generation-clause ] [ Column-level-constraint ]*
DefaultConstantExpression: NULL | CURRENT { SCHEMA | SQLID } | USER | CURRENT_USER | SESSION_USER | CURRENT_ROLE | DATE | TIME | TIMESTAMP | CURRENT DATE | CURRENT_DATE | CURRENT TIME | CURRENT_TIME | CURRENT TIMESTAMP | CURRENT_TIMESTAMP | literal
• | If you specify USER, CURRENT_USER, SESSION_USER, or CURRENT_ROLE, the column must be a
character column whose length is at least 8. | |
• | If you specify CURRENT SCHEMA or CURRENT SQLID, the column must be a
character column whose length is at least 128. | |
• | If the column is an integer type, the default value must be an
integer literal. | |
• | If the column is a decimal type, the scale and precision of the default
value must be within those of the column. |
[ GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( START WITH IntegerConstant [ ,INCREMENT BY IntegerConstant] ) ] ] ]
• | SMALLINT | |
• | INT | |
• | BIGINT |
Automatically generated values in a GENERATED ALWAYS identity column are unique. Creating an identity column does not create an index on the column.create table greetings (i int generated always as identity, ch char(50)); insert into greetings values (DEFAULT, 'hello'); insert into greetings(ch) values ('bonjour');
Note that unlike a GENERATED ALWAYS column, a GENERATED BY DEFAULT column does not guarantee uniqueness. Thus, in the above example, the hi and salut rows will both have an identity value of "1", because the generated column starts at "1" and the user-specified value was also "1". To prevent duplication, especially when loading or importing data, create the table using the START WITH value which corresponds to the first identity value that the system should assign. To check for this condition and disallow it, you can use a primary key or unique constraint on the GENERATED BY DEFAULT identity column.create table greetings (i int generated by default as identity, ch char(50)); -- specify value "1": insert into greetings values (1, 'hi'); -- use generated default insert into greetings values (DEFAULT, 'salut'); -- use generated default insert into greetings(ch) values ('bonjour');
Data type | Maximum Value | Minimum Value |
SMALLINT | 32767 (java.lang.Short.MAX_VALUE) | -32768 (java.lang.Short.MIN_VALUE) |
INT | 2147483647 (java.lang.Integer.MAX_VALUE) | -2147483648 (java.lang.Integer.MIN_VALUE) |
BIGINT | 9223372036854775807 (java.lang.Long.MAX_VALUE) | -9223372036854775808 (java.lang.Long.MIN_VALUE) |
create table greetings (i int generated by default as identity (START WITH 2, INCREMENT BY 1), ch char(50)); -- specify value "1": insert into greetings values (1, 'hi'); -- use generated default insert into greetings values (DEFAULT, 'salut'); -- use generated default insert into greetings(ch) values ('bonjour');
GENERATED ALWAYS AS ( value-expression )
• | The functions must not read or write SQL data. | |||||||||||||||||||||||||
• | The functions must have been declared DETERMINISTIC. | |||||||||||||||||||||||||
• | The functions must not invoke any of the following possibly
non-deterministic system functions:
|
CREATE TRIGGER TriggerName { AFTER | NO CASCADE BEFORE } { INSERT | DELETE | UPDATE [ OF column-Name [, column-Name]* ] } ON table-Name [ ReferencingClause ] [ FOR EACH { ROW | STATEMENT } ] [ MODE DB2SQL ] Triggered-SQL-statement
• | Before triggers fire before the statement's changes are applied
and before any constraints have been applied. Before triggers can be either
row or statement triggers (see Statement versus row triggers). | |
• | After triggers fire after all constraints have been satisfied and
after the changes have been applied to the target table. After triggers
can be either row or statement triggers (see Statement versus row triggers). |
• | INSERT | |
• | UPDATE | |
• | DELETE |
REFERENCING OLD AS DELETEDROW
DELETE FROM HotelAvailability WHERE hotel_id = DELETEDROW.hotel_id
REFERENCING OLD_TABLE AS DeletedHotels
DELETE FROM HotelAvailability WHERE hotel_id IN (SELECT hotel_id FROM DeletedHotels)
• | statement triggers A statement trigger fires once per triggering
event and regardless of whether any rows are modified by the insert, update,
or delete event. | |
• | row triggers A row trigger fires once for each row affected
by the triggering event. If no rows are affected, the trigger does not fire. |
• | It must not contain any dynamic parameters (?). | |
• | It must not create, alter, or drop the table upon which the trigger is
defined. | |
• | It must not add an index to or remove an index from the table on which
the trigger is defined. | |
• | It must not add a trigger to or drop a trigger from the table upon which
the trigger is defined. | |
• | It must not commit or roll back the current transaction or change the
isolation level. | |
• | Before triggers cannot have INSERT, UPDATE or DELETE statements as their
action. | |
• | Before triggers cannot call procedures that modify SQL data as their action. | |
• | The NEW variable of a Before trigger cannot reference a generated column.
|
• | It fires No Cascade Before triggers. | |
• | It performs constraint checking (primary key, unique key, foreign key,
check). | |
• | It performs the insert, update, or delete. | |
• | It fires After triggers. |
-- Statements and triggers: CREATE TRIGGER t1 NO CASCADE BEFORE UPDATE ON x FOR EACH ROW MODE DB2SQL values app.notifyEmail('Jerry', 'Table x is about to be updated'); CREATE TRIGGER FLIGHTSDELETE AFTER DELETE ON FLIGHTS REFERENCING OLD_TABLE AS DELETEDFLIGHTS FOR EACH STATEMENT DELETE FROM FLIGHTAVAILABILITY WHERE FLIGHT_ID IN (SELECT FLIGHT_ID FROM DELETEDFLIGHTS); CREATE TRIGGER FLIGHTSDELETE3 AFTER DELETE ON FLIGHTS REFERENCING OLD AS OLD FOR EACH ROW DELETE FROM FLIGHTAVAILABILITY WHERE FLIGHT_ID = OLD.FLIGHT_ID;
REFERENCING { { OLD | NEW } [ ROW ] [ AS ] correlation-Name [ { OLD | NEW } [ ROW ] [ AS ] correlation-Name ] | { OLD TABLE | NEW TABLE } [ AS ] Identifier [ { OLD TABLE | NEW TABLE } [AS] Identifier ] | { OLD_TABLE | NEW_TABLE } [ AS ] Identifier [ { OLD_TABLE | NEW_TABLE } [AS] Identifier ] }
CREATE VIEW view-Name [ ( Simple-column-Name [, Simple-column-Name] * ) ] AS Query
CREATE VIEW SAMP.V1 (COL_SUM, COL_DIFF) AS SELECT COMM + BONUS, COMM - BONUS FROM SAMP.EMPLOYEE; CREATE VIEW SAMP.VEMP_RES (RESUME) AS VALUES 'Delores M. Quintana', 'Heather A. Nicholls', 'Bruce Adamson'; CREATE VIEW SAMP.PROJ_COMBO (PROJNO, PRENDATE, PRSTAFF, MAJPROJ) AS SELECT PROJNO, PRENDATE, PRSTAFF, MAJPROJ FROM SAMP.PROJECT UNION ALL SELECT PROJNO, EMSTDATE, EMPTIME, EMPNO FROM SAMP.EMP_ACT WHERE EMPNO IS NOT NULL;
CREATE TABLE T1 (C1 DOUBLE PRECISION); CREATE FUNCTION SIN (DATA DOUBLE) RETURNS DOUBLE EXTERNAL NAME 'java.lang.Math.sin' LANGUAGE JAVA PARAMETER STYLE JAVA; CREATE VIEW V1 (C1) AS SELECT SIN(C1) FROM T1;
SELECT * FROM V1
• | The table structure is not known before using an application. | |
• | Other users do not need the same table structure. | |
• | Data in the temporary table is needed while using the application. | |
• | The table can be declared and dropped without holding the locks on the
system catalog. |
DECLARE GLOBAL TEMPORARY TABLE table-Name { column-definition [ , column-definition ] * } [ ON COMMIT {DELETE | PRESERVE} ROWS ] NOT LOGGED [ON ROLLBACK DELETE ROWS]
• | BIGINT | |
• | CHAR | |
• | DATE | |
• | DECIMAL | |
• | DOUBLE | |
• | DOUBLE PRECISION | |
• | FLOAT | |
• | INTEGER | |
• | NUMERIC | |
• | REAL | |
• | SMALLINT | |
• | TIME | |
• | TIMESTAMP | |
• | VARCHAR |
set schema myapp; create table t1(c11 int, c12 date); declare global temporary table SESSION.t1(c11 int) not logged; -- The SESSION qualification is redundant here because temporary -- tables can only exist in the SESSION schema. declare global temporary table t2(c21 int) not logged; -- The temporary table is not qualified here with SESSION because temporary -- tables can only exist in the SESSION schema. insert into SESSION.t1 values (1); -- SESSION qualification is mandatory here if you want to use -- the temporary table, because the current schema is "myapp." select * from t1; -- This select statement is referencing the "myapp.t1" physical -- table since the table was not qualified by SESSION.
• | IDENTITY column-options | |
• | IDENTITY attribute in copy-options | |
• | AS (fullselect) DEFINITION ONLY | |
• | NOT LOGGED ON ROLLBACK PRESERVE ROWS | |
• | IN tablespace-name | |
• | PARTITIONING KEY | |
• | WITH REPLACE |
• | ALTER TABLE | |
• | CREATE INDEX | |
• | CREATE SYNONYM | |
• | CREATE TRIGGER | |
• | CREATE VIEW | |
• | GRANT | |
• | LOCK TABLE | |
• | RENAME | |
• | REVOKE |
• | Synonyms, triggers and views on SESSION schema tables (including physical
tables and temporary tables) | |
• | Caching statements that reference SESSION schema tables and views | |
• | Temporary tables cannot be specified in referential constraints and primary
keys | |
• | Temporary tables cannot be referenced in a triggered-SQL-statement | |
• | Check constraints on columns | |
• | Generated-column-spec | |
• | Importing into temporary tables |
• | BLOB | |
• | CHAR FOR BIT DATA | |
• | CLOB | |
• | LONG VARCHAR | |
• | LONG VARCHAR FOR BIT DATA | |
• | VARCHAR FOR BIT DATA | |
• | XML |
{ DELETE FROM table-Name [[AS] correlation-Name] [WHERE clause] | DELETE FROM table-Name WHERE CURRENT OF }
DELETE FROM SAMP.IN_TRAY stmt.executeUpdate("DELETE FROM SAMP.IN_TRAY WHERE CURRENT OF " + resultSet.getCursorName());
DROP FUNCTION function-name
• | If no function with the indicated name exists in the named or implied schema
(the error is SQLSTATE 42704) | |
• | If there is more than one specific instance of the function in the named or
implied schema | |
• | If you try to drop a user-defined function that is invoked in the
generation-clause of a generated column | |
• | If you try to drop a user-defined function that is invoked in a view |
DROP PROCEDURE procedure-Name
DROP SCHEMA schemaName RESTRICT
• | Delete data from a specific table. | |
• | Insert data into a specific table. | |
• | Create a foreign key reference to the named table or to a subset of columns
from a table. | |
• | Select data from a table, view, or a subset of columns in 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. |
DELETE | INSERT | REFERENCES [column list] | SELECT [column list] | TRIGGER | UPDATE [column list]
{ AuthorizationIdentifier | roleName | PUBLIC } [, { AuthorizationIdentifier | roleName | PUBLIC } ] *
GRANT SELECT ON TABLE t TO maria,harry
GRANT UPDATE, TRIGGER ON TABLE t TO anita,zhi
GRANT SELECT ON TABLE s.v to PUBLIC
GRANT EXECUTE ON PROCEDURE p TO george
GRANT purchases_reader_role TO george,maria
GRANT SELECT ON TABLE t TO purchases_reader_role
INSERT INTO table-Name [ (Simple-column-Name [ , Simple-column-Name]* ) ] Query
• | ||
• | a VALUES list | |
• | a multiple-row VALUES expression Single-row and multiple-row lists
can include the keyword DEFAULT. Specifying DEFAULT for a column inserts the
column's default value into the column. Another way to insert the default
value into the column is to omit the column from the column list and only
insert values into other columns in the table. For more information see VALUES Expression. The DEFAULT literal is the only value which you can directly
insert into a generated column. | |
• | UNION expressions |
INSERT INTO COUNTRIES VALUES ('Taiwan', 'TW', 'Asia') -- Insert a new department into the DEPARTMENT table, -- but do not assign a manager to the new department INSERT INTO DEPARTMENT (DEPTNO, DEPTNAME, ADMRDEPT) VALUES ('E31', 'ARCHITECTURE', 'E01') -- Insert two new departments using one statement -- into the DEPARTMENT table as in the previous example, -- but do not assign a manager to the new department. INSERT INTO DEPARTMENT (DEPTNO, DEPTNAME, ADMRDEPT) VALUES ('B11', 'PURCHASING', 'B01'), ('E41', 'DATABASE ADMINISTRATION', 'E01') -- Create a temporary table MA_EMP_ACT with the -- same columns as the EMP_ACT table. -- Load MA_EMP_ACT with the rows from the EMP_ACT -- table with a project number (PROJNO) -- starting with the letters 'MA'. CREATE TABLE MA_EMP_ACT ( EMPNO CHAR(6) NOT NULL, PROJNO CHAR(6) NOT NULL, ACTNO SMALLINT NOT NULL, EMPTIME DEC(5,2), EMSTDATE DATE, EMENDATE DATE ); INSERT INTO MA_EMP_ACT SELECT * FROM EMP_ACT WHERE SUBSTR(PROJNO, 1, 2) = 'MA'; -- Insert the DEFAULT value for the LOCATION column INSERT INTO DEPARTMENT VALUES ('E31', 'ARCHITECTURE', '00390', 'E01', DEFAULT)
• | Avoid the overhead of multiple row locks on a table (in other words, user-initiated
lock escalation) | |
• | Avoid deadlocks |
LOCK TABLE table-Name IN { SHARE | EXCLUSIVE } MODE
LOCK TABLE Flights IN SHARE MODE; SELECT * FROM Flights WHERE orig_airport > 'OOO';
LOCK TABLE FlightAvailability IN EXCLUSIVE MODE; UPDATE FlightAvailability SET economy_seats_taken = (economy_seats_taken + 2) WHERE flight_id = 'AA1265' AND flight_date = DATE('2004-03-31'); UPDATE FlightAvailability SET economy_seats_taken = (economy_seats_taken + 2) WHERE flight_id = 'AA1265' AND flight_date = DATE('2004-04-11'); UPDATE FlightAvailability SET economy_seats_taken = (economy_seats_taken + 2) WHERE flight_id = 'AA1265' AND flight_date = DATE('2004-04-12'); UPDATE FlightAvailability SET economy_seats_taken = (economy_seats_taken + 2) WHERE flight_id = 'AA1265' AND flight_date = DATE('2004-04-15');
LOCK TABLE Maps IN EXCLUSIVE MODE; SELECT MAX(map_id) + 1 FROM Maps; -- INSERT INTO Maps . . .
RENAME COLUMN EMPLOYEE.MANAGER TO SUPERVISOR
ALTER TABLE t ADD COLUMN c1_newtype NEWTYPE UPDATE t SET c1_newtype = c1 ALTER TABLE t DROP COLUMN c1 RENAME COLUMN t.c1_newtype TO c1
RENAME TABLE table-Name TO new-Table-Name
• | Delete data from a specific table. | |
• | Insert data into a specific table. | |
• | Create a foreign key reference to the named table or to a subset of columns
from a table. | |
• | Select data from a table, view, or a subset of columns in 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). |
REVOKE privilege-type ON [ TABLE ] { table-Name | view-Name } FROM grantees
REVOKE EXECUTE ON { FUNCTION | PROCEDURE } routine-designator FROM grantees RESTRICT
DELETE | INSERT | REFERENCES [column list] | SELECT [column list] | TRIGGER | UPDATE [column list]
{ AuthorizationIdentifier | roleName | PUBLIC } [,{ AuthorizationIdentifier | roleName | PUBLIC } ] *
REVOKE SELECT ON TABLE t FROM maria,harry
REVOKE UPDATE, TRIGGER ON TABLE t FROM anita,zhi
REVOKE SELECT ON TABLE s.v FROM PUBLIC
REVOKE UPDATE (c1,c2) ON TABLE s.v FROM PUBLIC
REVOKE EXECUTE ON PROCEDURE p FROM george RESTRICT
REVOKE purchases_reader_role FROM george,maria
REVOKE SELECT ON TABLE t FROM purchases_reader_role
• | The privileges granted to that role | |
• | The union of privileges of roles contained in that role (for a definition of
role containment, see "Syntax for roles" in GRANT statement)
|
• | The privileges granted to the current user | |
• | The privileges granted to PUBLIC | |
• | The privileges identified by the current role, if set |
SET ROLE reader;
// These examples show the use of SET ROLE in JDBC statements. // The case normal form is visible in the SYS.SYSROLES system table. stmt.execute("SET ROLE admin"); -- case normal form: ADMIN stmt.execute("SET ROLE \"admin\""); -- case normal form: admin stmt.execute("SET ROLE none"); -- special case PreparedStatement ps = conn.prepareStatement("SET ROLE ?"); ps.setString(1, " admin "); -- on execute: case normal form: ADMIN ps.setString(1, "\"admin\""); -- on execute: case normal form: admin ps.setString(1, "none"); -- on execute: syntax error ps.setString(1, "\"none\""); -- on execute: case normal form: none
SET [CURRENT] SCHEMA [=] { schemaName| USER | ? | '<string-constant>' } | SET CURRENT SQLID [=] { schemaName| USER | ? | '<string-constant>' }
-- the following are all equivalent and will work -- assuming a schema called HOTEL SET SCHEMA HOTEL SET SCHEMA hotel SET CURRENT SCHEMA hotel SET CURRENT SQLID hotel SET SCHEMA = hotel SET CURRENT SCHEMA = hotel SET CURRENT SQLID = hotel SET SCHEMA "HOTEL" -- quoted identifier SET SCHEMA 'HOTEL' -- quoted string--This example produces an error because --lower case hotel won't be found SET SCHEMA = 'hotel' --This example produces an error because SQLID is not --allowed without CURRENT SET SQLID hotel -- This sets the schema to the current user id SET CURRENT SCHEMA USER // Here's an example of using set schema in an Java program PreparedStatement ps = conn.PrepareStatement("set schema ?"); ps.setString(1,"HOTEL"); ps.executeUpdate(); ... do some work ps.setString(1,"APP"); ps.executeUpdate(); ps.setString(1,"app"); //error - string is case sensitive // no app will be found ps.setNull(1, Types.VARCHAR); //error - null is not allowed
Query [ORDER BY clause] [result offset clause] [fetch first clause] [FOR UPDATE clause] [WITH {RR|RS|CS|UR}]
-- lists the names of the expression -- SAL+BONUS+COMM as TOTAL_PAY and -- orders by the new name TOTAL_PAY SELECT FIRSTNME, SALARY+BONUS+COMM AS TOTAL_PAY FROM EMPLOYEE ORDER BY TOTAL_PAY -- creating an updatable cursor with a FOR UPDATE clause -- to update the start date (PRSTDATE) and the end date (PRENDATE) -- columns in the PROJECT table SELECT PROJNO, PRSTDATE, PRENDATE FROM PROJECT FOR UPDATE OF PRSTDATE, PRENDATE -- set the isolation level to RR for this statement only SELECT * FROM Flights WHERE flight_id BETWEEN 'AA1111' AND 'AA1112' WITH RR
• | The SELECT statement must not include an ORDER BY clause. | ||||||||||||||||
• | The underlying Query must be a SelectExpression. | ||||||||||||||||
• | The SelectExpression in
the underlying Query must not include:
| ||||||||||||||||
• | The FROM clause in the underlying Query must not have:
| ||||||||||||||||
• | If the underlying Query has a WHERE clause, the WHERE clause must not
have subqueries. |
{ UPDATE table-Name [[AS] correlation-Name] SET column-Name = Value [ , column-Name = Value} ]* [WHERE clause] | UPDATE table-Name SET column-Name = Value [ , column-Name = Value ]* WHERE CURRENT OF }
Expression | DEFAULT
-- All the employees except the manager of -- department (WORKDEPT) 'E21' have been temporarily reassigned. -- Indicate this by changing their job (JOB) to NULL and their pay -- (SALARY, BONUS, COMM) values to zero in the EMPLOYEE table. UPDATE EMPLOYEE SET JOB=NULL, SALARY=0, BONUS=0, COMM=0 WHERE WORKDEPT = 'E21' AND JOB <> 'MANAGER' -- PROMOTE the job (JOB) of employees without a specific job title to MANAGER UPDATE EMPLOYEE SET JOB = 'MANAGER' WHERE JOB IS NULL; // Increase the project staffing (PRSTAFF) by 1.5 for all projects stmt.executeUpdate("UPDATE PROJECT SET PRSTAFF = " "PRSTAFF + 1.5" + "WHERE CURRENT OF" + ResultSet.getCursorName()); -- Change the job (JOB) of employee number (EMPNO) '000290' in the EMPLOYEE table -- to its DEFAULT value which is NULL UPDATE EMPLOYEE SET JOB = DEFAULT WHERE EMPNO = '000290'
• | a
column-level constraint Column-level constraints refer to a single column
in the table and do not specify a column name (except check constraints).
They refer to the column that they follow. | |
• | a
table-level constraint Table-level constraints refer to one or more columns
in the table. Table-level constraints specify the names of the columns to
which they apply. Table-level CHECK constraints can refer to 0 or more columns
in the table. |
• | NOT NULL Specifies that this column cannot hold NULL values (constraints
of this type are not nameable). | |
• | PRIMARY KEY Specifies the column that uniquely identifies a row in the table. The
identified columns must be defined as NOT NULL. Note: If you attempt
to add a primary key using ALTER TABLE and any of the columns included in
the primary key contain null values, an error will be generated and the primary
key will not be added. See ALTER TABLE statement for
more information. | |
• | UNIQUE Specifies that values in the column must be unique. | |
• | FOREIGN KEY Specifies that the values in the column must correspond
to values in a referenced primary key or unique key column or that they are
NULL. | |
• | CHECK Specifies rules for values in the column. |
• | PRIMARY KEY Specifies
the column or columns that uniquely identify a row in the table. NULL values
are not allowed. | |
• | UNIQUE Specifies that values in the columns must be unique. | |
• | FOREIGN KEY Specifies that the values in the columns must correspond
to values in referenced primary key or unique columns or that they are NULL. Note: If
the foreign key consists of multiple columns, and any column is NULL,
the whole key is considered NULL. The insert is permitted no matter what is
on the non-null columns. | |
• | CHECK Specifies a wide range of rules for values in the table. |
• | Dynamic parameters (?) | |
• | Date/Time Functions (CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP) | |
• | Subqueries | |
• | User Functions (such as USER, SESSION_USER, CURRENT_USER) |
• | If the delete rule is RESTRICT or NO ACTION, a dependent table is involved
in the operation but is not affected by the operation. (That is, Derby checks
the values within the table, but does not delete any values.) | |
• | If the delete rule is SET NULL, a dependent table's rows can be updated
when a row of the parent table is the object of a delete or propagated delete
operation. | |
• | If the delete rule is CASCADE, a dependent table's rows can be deleted
when a parent table is the object of a delete. | |
• | If the dependent table is also a parent table, the actions described in
this list apply, in turn, to its dependents. |
-- column-level primary key constraint named OUT_TRAY_PK: CREATE TABLE SAMP.OUT_TRAY ( SENT TIMESTAMP, DESTINATION CHAR(8), SUBJECT CHAR(64) NOT NULL CONSTRAINT OUT_TRAY_PK PRIMARY KEY, NOTE_TEXT VARCHAR(3000) ); -- the table-level primary key definition allows you to -- include two columns in the primary key definition: CREATE TABLE SAMP.SCHED ( CLASS_CODE CHAR(7) NOT NULL, DAY SMALLINT NOT NULL, STARTING TIME, ENDING TIME, PRIMARY KEY (CLASS_CODE, DAY) ); -- Use a column-level constraint for an arithmetic check -- Use a table-level constraint -- to make sure that a employee's taxes does not -- exceed the bonus CREATE TABLE SAMP.EMP ( EMPNO CHAR(6) NOT NULL CONSTRAINT EMP_PK PRIMARY KEY, FIRSTNME CHAR(12) NOT NULL, MIDINIT vARCHAR(12) NOT NULL, LASTNAME VARCHAR(15) NOT NULL, SALARY DECIMAL(9,2) CONSTRAINT SAL_CK CHECK (SALARY >= 10000), BONUS DECIMAL(9,2), TAX DECIMAL(9,2), CONSTRAINT BONUS_CK CHECK (BONUS > TAX) ); -- use a check constraint to allow only appropriate -- abbreviations for the meals CREATE TABLE FLIGHTS ( FLIGHT_ID CHAR(6) NOT NULL , SEGMENT_NUMBER INTEGER NOT NULL , ORIG_AIRPORT CHAR(3), DEPART_TIME TIME, DEST_AIRPORT CHAR(3), ARRIVE_TIME TIME, MEAL CHAR(1) CONSTRAINT MEAL_CONSTRAINT CHECK (MEAL IN ('B', 'L', 'D', 'S')), PRIMARY KEY (FLIGHT_ID, SEGMENT_NUMBER) ); CREATE TABLE METROPOLITAN ( HOTEL_ID INT NOT NULL CONSTRAINT HOTELS_PK PRIMARY KEY, HOTEL_NAME VARCHAR(40) NOT NULL, CITY_ID INT CONSTRAINT METRO_FK REFERENCES CITIES ); -- create a table with a table-level primary key constraint -- and a table-level foreign key constraint CREATE TABLE FLTAVAIL ( FLIGHT_ID CHAR(6) NOT NULL, SEGMENT_NUMBER INT NOT NULL, FLIGHT_DATE DATE NOT NULL, ECONOMY_SEATS_TAKEN INT, BUSINESS_SEATS_TAKEN INT, FIRSTCLASS_SEATS_TAKEN INT, CONSTRAINT FLTAVAIL_PK PRIMARY KEY (FLIGHT_ID, SEGMENT_NUMBER), CONSTRAINT FLTS_FK FOREIGN KEY (FLIGHT_ID, SEGMENT_NUMBER) REFERENCES Flights (FLIGHT_ID, SEGMENT_NUMBER) ); -- add a unique constraint to a column ALTER TABLE SAMP.PROJECT ADD CONSTRAINT P_UC UNIQUE (PROJNAME); -- create a table whose city_id column references the -- primary key in the Cities table -- using a column-level foreign key constraint CREATE TABLE CONDOS ( CONDO_ID INT NOT NULL CONSTRAINT hotels_PK PRIMARY KEY, CONDO_NAME VARCHAR(40) NOT NULL, CITY_ID INT CONSTRAINT city_foreign_key REFERENCES Cities ON DELETE CASCADE ON UPDATE RESTRICT );
{ NOT NULL | [ [CONSTRAINT constraint-Name] { CHECK (searchCondition) | { PRIMARY KEY | UNIQUE | REFERENCES clause } } }
[CONSTRAINT constraint-Name] { CHECK (searchCondition) | { PRIMARY KEY ( Simple-column-Name [ , Simple-column-Name ]* ) | UNIQUE ( Simple-column-Name [ , Simple-column-Name ]* ) | FOREIGN KEY ( Simple-column-Name [ , Simple-column-Name ]* ) REFERENCES clause } }
REFERENCES table-Name [ ( Simple-column-Name [ , Simple-column-Name ]* ) ] [ ON DELETE {NO ACTION | RESTRICT | CASCADE | SET NULL}] [ ON UPDATE {NO ACTION | RESTRICT }] | [ ON UPDATE {NO ACTION | RESTRICT }] [ ON DELETE {NO ACTION | RESTRICT | CASCADE | SET NULL}]
FOR { READ ONLY | FETCH ONLY | UPDATE [ OF Simple-column-Name [ , Simple-column-Name]* ] }
SELECT Cities.city_id FROM Cities WHERE city_id < 5 -- other types of TableExpressions SELECT TABLENAME, ISINDEX FROM SYS.SYSTABLES T, SYS.SYSCONGLOMERATES C WHERE T.TABLEID = C.TABLEID ORDER BY TABLENAME, ISINDEX -- force the join order SELECT * FROM Flights, FlightAvailability WHERE FlightAvailability.flight_id = Flights.flight_id AND FlightAvailability.segment_number = Flights.segment_number AND Flights.flight_id < 'AA1115' -- a TableExpression can be a joinOperation. Therefore -- you can have multiple join operations in a FROM clause SELECT COUNTRIES.COUNTRY, CITIES.CITY_NAME, FLIGHTS.DEST_AIRPORT FROM COUNTRIES LEFT OUTER JOIN CITIES ON COUNTRIES.COUNTRY_ISO_CODE = CITIES.COUNTRY_ISO_CODE LEFT OUTER JOIN FLIGHTS ON Cities.AIRPORT = FLIGHTS.DEST_AIRPORT
GROUP BY column-Name [ , column-Name ] *
-- find the average flying_times of flights grouped by -- airport SELECT AVG (flying_time), orig_airport FROM Flights GROUP BY orig_airport SELECT MAX(city_name), region FROM Cities, Countries WHERE Cities.country_ISO_code = Countries.country_ISO_code GROUP BY region -- group by an a smallint SELECT ID, AVG(SALARY) FROM SAMP.STAFF GROUP BY ID -- Get the AVGSALARY and EMPCOUNT columns, and the DEPTNO column using the AS clause -- And group by the WORKDEPT column using the correlation name OTHERS SELECT OTHERS.WORKDEPT AS DEPTNO, AVG(OTHERS.SALARY) AS AVGSALARY, COUNT(*) AS EMPCOUNT FROM SAMP.EMPLOYEE OTHERS GROUP BY OTHERS.WORKDEPT
HAVING searchCondition
-- SELECT COUNT(*) -- FROM SAMP.STAFF -- GROUP BY ID -- HAVING SALARY > 15000
-- Find the total number of economy seats taken on a flight, -- grouped by airline, -- only when the group has at least 2 records. SELECT SUM(ECONOMY_SEATS_TAKEN), AIRLINE_FULL FROM FLIGHTAVAILABILITY, AIRLINES WHERE SUBSTR(FLIGHTAVAILABILITY.FLIGHT_ID, 1, 2) = AIRLINE GROUP BY AIRLINE_FULL HAVING COUNT(*) > 1
ORDER BY { column-Name | ColumnPosition | Expression } [ ASC | DESC ] [ , column-Name | ColumnPosition | Expression [ ASC | DESC ] ] *
• | If SELECT DISTINCT is specified or if the SELECT statement contains a
GROUP BY clause, the ORDER BY columns must be in the SELECT list. | |
• | An ORDER BY clause prevents a SELECT statement from being an updatable
cursor. For more information, see Requirements for updatable cursors and updatable ResultSets.
For example, if an INTEGER column contains integers, NULL is considered greater
than 1 for purposes of sorting. In other words, NULL values are sorted high. |
SELECT CITY_NAME, COUNTRY AS NATION FROM CITIES ORDER BY NATION
OFFSET integer-literal {ROW | ROWS}
FETCH { FIRST | NEXT } [integer-literal] {ROW | ROWS} ONLY
-- Fetch the first row of T SELECT * FROM T FETCH FIRST ROW ONLY -- Sort T using column I, then fetch rows 11 through 20 of the sorted -- rows (inclusive) SELECT * FROM T ORDER BY I OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY -- Skip the first 100 rows of T -- If the table has fewer than 101 records, an empty result set is -- returned SELECT * FROM T OFFSET 100 ROWS
WHERE Boolean expression
-- find the flights where no business-class seats have -- been booked SELECT * FROM FlightAvailability WHERE business_seats_taken IS NULL OR business_seats_taken = 0 -- Join the EMP_ACT and EMPLOYEE tables -- select all the columns from the EMP_ACT table and -- add the employee's surname (LASTNAME) from the EMPLOYEE table -- to each row of the result. SELECT SAMP.EMP_ACT.*, LASTNAME FROM SAMP.EMP_ACT, SAMP.EMPLOYEE WHERE EMP_ACT.EMPNO = EMPLOYEE.EMPNO -- Determine the employee number and salary of sales representatives -- along with the average salary and head count of their departments. -- This query must first create a new-column-name specified in the AS clause -- which is outside the fullselect (DINFO) -- in order to get the AVGSALARY and EMPCOUNT columns, -- as well as the DEPTNO column that is used in the WHERE clause SELECT THIS_EMP.EMPNO, THIS_EMP.SALARY, DINFO.AVGSALARY, DINFO.EMPCOUNT FROM EMPLOYEE THIS_EMP, (SELECT OTHERS.WORKDEPT AS DEPTNO, AVG(OTHERS.SALARY) AS AVGSALARY, COUNT(*) AS EMPCOUNT FROM EMPLOYEE OTHERS GROUP BY OTHERS.WORKDEPT )AS DINFO WHERE THIS_EMP.JOB = 'SALESREP' AND THIS_EMP.WORKDEPT = DINFO.DEPTNO
Statement s = conn.createStatement(); s.setCursorName("AirlinesResults"); ResultSet rs = conn.executeQuery( "SELECT Airline, basic_rate " + "FROM Airlines FOR UPDATE OF basic_rate"); Statement s2 = conn.createStatement(); s2.executeUpdate("UPDATE Airlines SET basic_rate = basic_rate " + "+ .25 WHERE CURRENT OF AirlinesResults");
• | ||
• | ||
• | UPDATE statement (SET
portion) | |
• | ||
• |
Expression Type | Explanation |
Column reference | A column-Name that
references the value of the column made visible to the expression containing
the Column reference. You must qualify the column-Name by
the table name or correlation name if it is ambiguous. The qualifier
of a column-Name must be the correlation name, if a correlation
name is given to a table that is in a FROM
clause. The table name is no longer visible as a column-Name qualifier
once it has been aliased by a correlation name. Allowed in SelectExpressions,
UPDATE statements, and the WHERE clauses of data manipulation statements. |
Constant | Most built-in data types typically have constants associated
with them (as shown in Data types). |
NULL | NULL is an untyped constant representing the unknown value. Allowed
in CAST expressions or in INSERT VALUES lists and UPDATE SET clauses. Using
it in a CAST expression gives it a specific data type. |
Dynamic parameter | A dynamic parameter is a parameter to an SQL statement
for which the value is not specified when the statement is created. Instead,
the statement has a question mark (?) as a placeholder for each dynamic parameter.
See Dynamic parameters. Dynamic parameters
are permitted only in prepared statements. You must specify values for them
before the prepared statement is executed. The values specified must match
the types expected. Allowed anywhere in an expression where the data
type can be easily deduced. See Dynamic parameters. |
CAST expression | Lets you specify the type of NULL or of a dynamic parameter
or convert a value to another type. See CAST function. |
Scalar subquery | Subquery that returns a single row with a single column.
See ScalarSubquery. |
Table subquery | Subquery that returns more than one column and more than
one row. See TableSubquery. Allowed
as a tableExpression in a FROM clause and with EXISTS, IN, and quantified
comparisons. |
Conditional expression | A conditional expression chooses an expression to evaluate
based on a boolean test. |
• | BIGINT | |
• | DECIMAL | |
• | DOUBLE PRECISION | |
• | INTEGER | |
• | REAL | |
• | SMALLINT |
Expression Type | Explanation |
+, -, *, /, unary + and - expressions | Evaluate the expected math operation on the operands. If
both operands are the same type, the result type is not promoted, so the division
operator on integers results in an integer that is the truncation of the actual
numeric result. When types are mixed, they are promoted as described in Data types. Unary + is a noop (i.e.,
+4 is the same as 4). Unary - is the same as multiplying the value by -1,
effectively changing its sign. |
AVG | Returns the average of a set of numeric values. AVG function |
SUM | Returns the sum of a set of numeric values. SUM function |
LENGTH | Returns the number of characters in a character or bit
string. See LENGTH function. |
LOWER | |
COUNT | Returns the count of a set of values. See COUNT function, COUNT(*) function. |
Expression Type | Explanation |
A CHAR or VARCHAR value that uses wildcards. | The wildcards % and _ make a character string a pattern
against which the LIKE operator can look for a match. |
Concatenation expression | In a concatenation expression, the concatenation operator,
"||", concatenates its right operand to the end of its left operand. Operates
on character and bit strings. See Concatenation operator. |
Built-in string functions | The built-in string functions act on a String and return
a string. See LTRIM function, LCASE or LOWER function, RTRIM function, TRIM function, SUBSTR function, and UCASE or UPPER function. |
USER functions | User functions return information about the current user
as a String. See CURRENT_USER function, SESSION_USER function, and . |
Expression type | Explanation |
CURRENT_DATE | Returns the current date. See CURRENT_DATE function. |
CURRENT_TIME | Returns the current time. See CURRENT_TIME function. |
CURRENT_TIMESTAMP | Returns the current timestamp. See CURRENT_TIMESTAMP function. |
SELECT [ DISTINCT | ALL ] SelectItem [ , SelectItem ]* FROM clause [ WHERE clause] [ GROUP BY clause ] [ HAVING clause ]
{ * | { table-Name | correlation-Name } .* | Expression [AS Simple-column-Name] }
-- List head count of each department, -- the department number (WORKDEPT), and the average departmental salary (SALARY) -- for all departments in the EMPLOYEE table. -- Arrange the result table in ascending order by average departmental salary. SELECT COUNT(*),WORK_DEPT,AVG(SALARY) FROM EMPLOYEE GROUP BY WORK_DEPT ORDER BY 3
• | FROM clause | |
• | WHERE clause | |
• | GROUP BY (or implicit GROUP BY) | |
• | HAVING clause | |
• | SELECT clause |
VALUES CURRENT_TIMESTAMP
• | They are made available on the JDBC ResultSetMetaData. | |
• | They are used as the names of the columns in the resulting table when
the SelectExpression is used as a table subquery in a FROM clause. | |
• | They are used in the ORDER BY clause as the column names available for
sorting. |
-- this example shows SELECT-FROM-WHERE -- with an ORDER BY clause -- and correlation-Names for the tables SELECT CONSTRAINTNAME, COLUMNNAME FROM SYS.SYSTABLES t, SYS.SYSCOLUMNS col, SYS.SYSCONSTRAINTS cons, SYS.SYSCHECKS checks WHERE t.TABLENAME = 'FLIGHTS' AND t.TABLEID = col. REFERENCEID AND t.TABLEID = cons.TABLEID AND cons.CONSTRAINTID = checks.CONSTRAINTID ORDER BY CONSTRAINTNAME -- This example shows the use of the DISTINCT clause SELECT DISTINCT ACTNO FROM EMP_ACT -- This example shows how to rename an expression -- Using the EMPLOYEE table, list the department number (WORKDEPT) and -- maximum departmental salary (SALARY) renamed as BOSS -- for all departments whose maximum salary is less than the -- average salary in all other departments. SELECT WORKDEPT AS DPT, MAX(SALARY) AS BOSS FROM EMPLOYEE EMP_COR GROUP BY WORKDEPT HAVING MAX(SALARY) < (SELECT AVG(SALARY) FROM EMPLOYEE WHERE NOT WORKDEPT = EMP_COR.WORKDEPT) ORDER BY BOSS
• | When a VALUES expression is used as a TableSubquery, since there is no other way to name
the columns of a VALUES expression. | |
• | When column names would otherwise be the same as those of columns in other
tables; renaming them means you don't have to qualify them. |
{table-Name |view-Name | TableFunctionInvocation} [ [ AS ] correlation-Name [ (Simple-column-Name [ , Simple-column-Name]* ) ] ] ]
• | As a statement that returns a ResultSet | |
• | Within expressions and statements wherever subqueries are permitted | |
• | As the source of values for an INSERT statement (in an INSERT statement,
you normally use a VALUES expression when you do not use a
SelectExpression) |
{ VALUES ( Value {, Value }* ) [ , ( Value {, Value }* ) ]* | VALUES Value [ , Value ]* }
Expression | DEFAULT
-- 3 rows of 1 column VALUES (1),(2),(3) -- 3 rows of 1 column VALUES 1, 2, 3 -- 1 row of 3 columns VALUES (1, 2, 3) -- 3 rows of 2 columns VALUES (1,21),(2,22),(3,23) -- constructing a derived table VALUES ('orange', 'orange'), ('apple', 'red'), ('banana', 'yellow') -- Insert two new departments using one statement into the DEPARTMENT table, -- but do not assign a manager to the new department. INSERT INTO DEPARTMENT (DEPTNO, DEPTNAME, ADMRDEPT) VALUES ('B11', 'PURCHASING', 'B01'), ('E41', 'DATABASE ADMINISTRATION', 'E01') -- insert a row with a DEFAULT value for the MAJPROJ column INSERT INTO PROJECT (PROJNO, PROJNAME, DEPTNO, RESPEMP, PRSTDATE, MAJPROJ) VALUES ('PL2101', 'ENSURE COMPAT PLAN', 'B01', '000020', CURRENT_DATE, DEFAULT) -- using a built-in function VALUES CURRENT_DATE -- getting the value of an arbitrary expression VALUES (3*29, 26.0E0/3) -- getting a value returned by a built-in function values char(1)
• | (), ?, Constant (including sign), NULL, ColumnReference, ScalarSubquery,
CAST | |
• | LENGTH, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, and other built-ins | |
• | unary + and - | |
• | *, /, || (concatenation) | |
• | binary + and - | |
• | comparisons, quantified comparisons, EXISTS, IN, IS NULL, LIKE, BETWEEN,
IS | |
• | NOT | |
• | AND | |
• | OR |
Operator | Explanation and Example | Syntax |
AND, OR, NOT | Evaluate any operand(s) that are boolean expressions
|
|
Comparisons | <, =, >, <=, >=, <> are applicable to
all of the built-in types.
|
|
IS NULL, IS NOT NULL | Test whether the result of an expression is null or not.
|
|
LIKE | Attempts to match a character expression to a character
pattern, which is a character string that includes one or more wildcards.
% matches any number (zero or more) of characters in the corresponding
position in first character expression. _ matches one character in
the corresponding position in the character expression. Any other
character matches only that character in the corresponding position in the
character expression.
To
treat % or _ as constant characters, escape the character with an optional
escape character, which you specify with the ESCAPE clause.
Note: When LIKE comparisons are used,Derby compares one character
at a time for non-metacharacters. This is different than the way Derby processes
= comparisons. The comparisons with the = operator compare the entire character
string on left side of the = operator with the entire character string on
the right side of the = operator. For more information, see Character-based
collation in Derby in
the Java DB Developer's Guide. |
|
BETWEEN | Tests whether the first operand is between the second and
third operands. The second operand must be less than the third operand. Applicable
only to types to which <= and >= can be applied.
|
|
IN | Operates on table subquery or list of values. Returns TRUE
if the left expression's value is in the result of the table subquery or in
the list of values. Table subquery can return multiple rows but must return
a single column.
|
|
EXISTS | Operates on a table subquery. Returns TRUE if the table
subquery returns any rows, and FALSE if it returns no rows. Table subquery
can return multiple columns (only if you use * to denote multiple columns)
and rows.
|
|
Quantified comparison | A quantified comparison is a comparison operator (<,
=, >, <=, >=, <>) with ALL or ANY or SOME applied. Operates
on table subqueries, which can return multiple rows but must return a single
column. If ALL is used, the comparison must be true for all values
returned by the table subquery. If ANY or SOME is used, the comparison must
be true for at least one value of the table subquery. ANY and SOME are equivalent.
|
|
PreparedStatement ps2 = conn.prepareStatement( "UPDATE HotelAvailability SET rooms_available = " + "(rooms_available - ?) WHERE hotel_id = ? " + "AND booking_date BETWEEN ? AND ?"); -- this sample code sets the values of dynamic parameters -- to be the values of program variables ps2.setInt(1, numberRooms); ps2.setInt(2, theHotel.hotelId); ps2.setDate(3, arrival); ps2.setDate(4, departure); updateCount = ps2.executeUpdate();
1.
| Use as the first operand of BETWEEN is allowed if one of the second and
third operands is not also a dynamic parameter. The type of the first operand
is assumed to be the type of the non-dynamic parameter, or the union result
of their types if both are not dynamic parameters.
| |
2.
| Use as the second or third operand of BETWEEN is allowed. Type is assumed
to be the type of the left operand.
| |
3.
| Use as the left operand of an IN list is allowed if at
least one item in the list is not itself a dynamic parameter. Type for the
left operand is assumed to be the union result of the types of the non-dynamic
parameters in the list.
| |
4.
| Use in the values list in an IN predicate is allowed if the first operand
is not a dynamic parameter or its type was determined in the previous rule.
Type of the dynamic parameters appearing in the values list is assumed to
be the type of the left operand.
| |
5.
| For the binary operators +, -, *, /, AND, OR, <, >,
=, <>, <=, and >=, use of a dynamic parameter as one operand but
not both is permitted. Its type is taken from the other side.
| |
6.
| Use in a CAST is always permitted. This gives the dynamic parameter a
type.
| |
7.
| Use on either or both sides of LIKE operator is permitted. When used on
the left, the type of the dynamic parameter is set to the type of the right
operand, but with the maximum allowed length for the type. When used on the
right, the type is assumed to be of the same length and type as the left operand.
(LIKE is permitted on CHAR and VARCHAR types; see Concatenation operator for
more information.)
| |
8.
| A ? parameter is allowed by itself on only one side of the || operator.
That is, "? || ?" is not allowed. The type of a ? parameter on one side of
a || operator is determined by the type of the expression on the other side
of the || operator. If the expression on the other side is a CHAR or VARCHAR,
the type of the parameter is VARCHAR with the maximum allowed length for the
type. If the expression on the other side is a CHAR FOR BIT DATA or VARCHAR
FOR BIT DATA type, the type of the parameter is VARCHAR FOR BIT DATA with
the maximum allowed length for the type.
| |
9.
| In
a conditional expression, which uses a ?, use of a dynamic parameter (which
is also represented as a ?) is allowed. The type of a dynamic parameter as
the first operand is assumed to be boolean. Only one of the second and third
operands can be a dynamic parameter, and its type will be assumed to be the
same as that of the other (that is, the third and second operand, respectively).
| |
10.
| A dynamic parameter is allowed as an item in the values list or select
list of an INSERT statement. The type of the dynamic parameter is assumed
to be the type of the target column.
| |
11.
| A ? parameter in a comparison with a subquery takes its type from the
expression being selected by the subquery. For example:
| |
12.
| A dynamic parameter is allowed as the value in an UPDATE statement. The
type of the dynamic parameter is assumed to be the type of the column in the
target table.
| |
13.
| Dynamic parameters are allowed as the operand of the unary operators -
or +. For example:
| |
14.
| LENGTH allow a dynamic parameter. The type is assumed to be a maximum
length VARCHAR type.
| |
15.
| Qualified comparisons.
| |
16.
| A dynamic parameter is allowed as the left operand of an IS expression
and is assumed to be a boolean. |
JOIN Operation
• | INNER JOIN operation Specifies a
join between two tables with an explicit join clause. See INNER JOIN operation. | |
• | LEFT OUTER JOIN operation Specifies a
join between two tables with an explicit join clause, preserving unmatched
rows from the first table. See LEFT OUTER JOIN operation. | |
• | RIGHT OUTER JOIN operation Specifies a
join between two tables with an explicit join clause, preserving unmatched
rows from the second table. See RIGHT OUTER JOIN operation. |
TableExpression [ INNER ] JOIN TableExpression { ON booleanExpression }
SELECT * FROM SAMP.EMPLOYEE INNER JOIN SAMP.STAFF ON EMPLOYEE.SALARY < STAFF.SALARY
-- Join the EMP_ACT and EMPLOYEE tables -- select all the columns from the EMP_ACT table and -- add the employee's surname (LASTNAME) from the EMPLOYEE table -- to each row of the result SELECT SAMP.EMP_ACT.*, LASTNAME FROM SAMP.EMP_ACT JOIN SAMP.EMPLOYEE ON EMP_ACT.EMPNO = EMPLOYEE.EMPNO -- Join the EMPLOYEE and DEPARTMENT tables, -- select the employee number (EMPNO), -- employee surname (LASTNAME), -- department number (WORKDEPT in the EMPLOYEE table and DEPTNO in the -- DEPARTMENT table) -- and department name (DEPTNAME) -- of all employees who were born (BIRTHDATE) earlier than 1930. SELECT EMPNO, LASTNAME, WORKDEPT, DEPTNAME FROM SAMP.EMPLOYEE JOIN SAMP.DEPARTMENT ON WORKDEPT = DEPTNO AND YEAR(BIRTHDATE) < 1930 -- Another example of "generating" new data values, -- using a query which selects from a VALUES clause (which is an -- alternate form of a fullselect). -- This query shows how a table can be derived called "X" -- having 2 columns "R1" and "R2" and 1 row of data SELECT * FROM (VALUES (3, 4), (1, 5), (2, 6)) AS VALUESTABLE1(C1, C2) JOIN (VALUES (3, 2), (1, 2), (0, 3)) AS VALUESTABLE2(c1, c2) ON VALUESTABLE1.c1 = VALUESTABLE2.c1 -- This results in: -- C1 |C2 |C1 |2 -- ----------------------------------------------- -- 3 |4 |3 |2 -- 1 |5 |1 |2 -- List every department with the employee number and -- last name of the manager SELECT DEPTNO, DEPTNAME, EMPNO, LASTNAME FROM DEPARTMENT INNER JOIN EMPLOYEE ON MGRNO = EMPNO -- List every employee number and last name -- with the employee number and last name of their manager SELECT E.EMPNO, E.LASTNAME, M.EMPNO, M.LASTNAME FROM EMPLOYEE E INNER JOIN DEPARTMENT INNER JOIN EMPLOYEE M ON MGRNO = M.EMPNO ON E.WORKDEPT = DEPTNO
TableExpression LEFT [ OUTER ] JOIN TableExpression { ON booleanExpression }
--match cities to countries in Asia SELECT CITIES.COUNTRY, CITIES.CITY_NAME, REGION FROM Countries LEFT OUTER JOIN Cities ON CITIES.COUNTRY_ISO_CODE = COUNTRIES.COUNTRY_ISO_CODE WHERE REGION = 'Asia' -- use the synonymous syntax, LEFT JOIN, to achieve exactly -- the same results as in the example above SELECT COUNTRIES.COUNTRY, CITIES.CITY_NAME,REGION FROM COUNTRIES LEFT JOIN CITIES ON CITIES.COUNTRY_ISO_CODE = COUNTRIES.COUNTRY_ISO_CODE WHERE REGION = 'Asia'
-- Join the EMPLOYEE and DEPARTMENT tables, -- select the employee number (EMPNO), -- employee surname (LASTNAME), -- department number (WORKDEPT in the EMPLOYEE table -- and DEPTNO in the DEPARTMENT table) -- and department name (DEPTNAME) -- of all employees who were born (BIRTHDATE) earlier than 1930 SELECT EMPNO, LASTNAME, WORKDEPT, DEPTNAME FROM SAMP.EMPLOYEE LEFT OUTER JOIN SAMP.DEPARTMENT ON WORKDEPT = DEPTNO AND YEAR(BIRTHDATE) < 1930 -- List every department with the employee number and -- last name of the manager, -- including departments without a manager SELECT DEPTNO, DEPTNAME, EMPNO, LASTNAME FROM DEPARTMENT LEFT OUTER JOIN EMPLOYEE ON MGRNO = EMPNO
TableExpression RIGHT [ OUTER ] JOIN TableExpression { ON booleanExpression }
-- get all countries and corresponding cities, including -- countries without any cities SELECT COUNTRIES.COUNTRY, CITIES.CITY_NAME FROM CITIES RIGHT OUTER JOIN COUNTRIES ON CITIES.COUNTRY_ISO_CODE = COUNTRIES.COUNTRY_ISO_CODE -- get all countries in Africa and corresponding cities, including -- countries without any cities SELECT COUNTRIES.COUNTRY, CITIES.CITY_NAME FROM CITIES RIGHT OUTER JOIN COUNTRIES ON CITIES.COUNTRY_ISO_CODE = COUNTRIES.COUNTRY_ISO_CODE WHERE Countries.region = 'Africa' -- use the synonymous syntax, RIGHT JOIN, to achieve exactly -- the same results as in the example above SELECT COUNTRIES.COUNTRY, CITIES.CITY_NAME FROM CITIES RIGHT JOIN COUNTRIES ON CITIES.COUNTRY_ISO_CODE = COUNTRIES.COUNTRY_ISO_CODE WHERE Countries.region = 'Africa'
-- a TableExpression can be a joinOperation. Therefore -- you can have multiple join operations in a FROM clause -- List every employee number and last name -- with the employee number and last name of their manager SELECT E.EMPNO, E.LASTNAME, M.EMPNO, M.LASTNAME FROM EMPLOYEE E RIGHT OUTER JOIN DEPARTMENT RIGHT OUTER JOIN EMPLOYEE M ON MGRNO = M.EMPNO ON E.WORKDEPT = DEPTNO
{ ( Query ) | Query INTERSECT [ ALL | DISTINCT ] Query | Query EXCEPT [ ALL | DISTINCT ] Query | Query UNION [ ALL | DISTINCT ] Query | SelectExpression | VALUES Expression }
• | UNION: ( L + R ). | |
• | EXCEPT: the maximum of ( L – R ) and 0 (zero). | |
• | INTERSECT: the minimum of L and R. |
-- a Select expression SELECT * FROM ORG -- a subquery SELECT * FROM (SELECT CLASS_CODE FROM CL_SCHED) AS CS -- a subquery SELECT * FROM (SELECT CLASS_CODE FROM CL_SCHED) AS CS (CLASS_CODE) -- a UNION -- returns all rows from columns DEPTNUMB and MANAGER -- in table ORG -- and (1,2) and (3,4) -- DEPTNUMB and MANAGER are smallint columns SELECT DEPTNUMB, MANAGER FROM ORG UNION ALL VALUES (1,2), (3,4) -- a values expression VALUES (1,2,3) -- List the employee numbers (EMPNO) of all employees in the EMPLOYEE table -- whose department number (WORKDEPT) either begins with 'E' or -- who are assigned to projects in the EMP_ACT table -- whose project number (PROJNO) equals 'MA2100', 'MA2110', or 'MA2112' SELECT EMPNO FROM EMPLOYEE WHERE WORKDEPT LIKE 'E%' UNION SELECT EMPNO FROM EMP_ACT WHERE PROJNO IN('MA2100', 'MA2110', 'MA2112') -- Make the same query as in the previous example -- and "tag" the rows from the EMPLOYEE table with 'emp' and -- the rows from the EMP_ACT table with 'emp_act'. -- Unlike the result from the previous example, -- this query may return the same EMPNO more than once, -- identifying which table it came from by the associated "tag" SELECT EMPNO, 'emp' FROM EMPLOYEE WHERE WORKDEPT LIKE 'E%' UNION SELECT EMPNO, 'emp_act' FROM EMP_ACT WHERE PROJNO IN('MA2100', 'MA2110', 'MA2112') -- Make the same query as in the previous example, -- only use UNION ALL so that no duplicate rows are eliminated SELECT EMPNO FROM EMPLOYEE WHERE WORKDEPT LIKE 'E%' UNION ALL SELECT EMPNO FROM EMP_ACT WHERE PROJNO IN('MA2100', 'MA2110', 'MA2112') -- Make the same query as in the previous example, -- only include an additional two employees currently not in any table and -- tag these rows as "new" SELECT EMPNO, 'emp' FROM EMPLOYEE WHERE WORKDEPT LIKE 'E%' UNION SELECT EMPNO, 'emp_act' FROM EMP_ACT WHERE PROJNO IN('MA2100', 'MA2110', 'MA2112') UNION VALUES ('NEWAAA', 'new'), ('NEWBBB', 'new')
-- avg always returns a single value, so the subquery is -- a ScalarSubquery SELECT NAME, COMM FROM STAFF WHERE EXISTS (SELECT AVG(BONUS + 800) FROM EMPLOYEE WHERE COMM < 5000 AND EMPLOYEE.LASTNAME = UPPER(STAFF.NAME) ) -- Introduce a way of "generating" new data values, -- using a query which selects from a VALUES clause (which is an -- alternate form of a fullselect). -- This query shows how a table can be derived called "X" having -- 2 columns "R1" and "R2" and 1 row of data. SELECT R1,R2 FROM (VALUES('GROUP 1','GROUP 2')) AS X(R1,R2)
• | as a TableExpression in
a FROM clause | |
• | with EXISTS, IN, or quantified comparisons. |
-- a subquery used as a TableExpression in a FROM clause SELECT VirtualFlightTable.flight_ID FROM (SELECT flight_ID, orig_airport, dest_airport FROM Flights WHERE (orig_airport = 'SFO' OR dest_airport = 'SCL') ) AS VirtualFlightTable -- a subquery (values expression) used as a TableExpression -- in a FROM clause SELECT mycol1 FROM (VALUES (1, 2), (3, 4)) AS mytable (mycol1, mycol2) -- a subquery used with EXISTS SELECT * FROM Flights WHERE EXISTS (SELECT * FROM Flights WHERE dest_airport = 'SFO' AND orig_airport = 'GRU') -- a subquery used with IN SELECT flight_id, segment_number FROM Flights WHERE flight_id IN (SELECT flight_ID FROM Flights WHERE orig_airport = 'SFO' OR dest_airport = 'SCL') -- a subquery used with a quantified comparison SELECT NAME, COMM FROM STAFF WHERE COMM > (SELECT AVG(BONUS + 800) FROM EMPLOYEE WHERE COMM < 5000)
Function Name | All Types | Numeric Built-in Data Types |
COUNT | X | X |
MIN | X | |
MAX | X | |
AVG | X | |
SUM | X |
• | A SelectItem in a SelectExpression. | |
• | ||
• | An ORDER BY clause (using an alias
name) if the aggregate appears in the result of the relevant query block.
That is, an alias for an aggregate is permitted in an ORDER BY clause if
and only if the aggregate appears in a SelectItem in a SelectExpression. |
-- not valid SELECT MIN(flying_time), flight_id FROM Flights
SELECT c1 FROM t1 GROUP BY c1 HAVING c2 > (SELECT t2.x FROM t2 WHERE t2.y = SUM(t1.c3))
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the absolute value of the specified number is greater than 1, an exception
is returned that indicates that the value is out of range (SQL state 22003). |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero
with the same sign as the specified number. | |
• | If the absolute value of the specified number is greater than 1, an exception
is returned that indicates that the value is out of range (SQL state 22003). |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero
with the same sign as the specified number. |
• | If either argument is NULL, the result of the function is NULL. | |
• | If the first argument is zero and the second argument is positive, the
result of the function is zero. | |
• | If the first argument is zero and the second argument is negative, the
result of the function is the double value closest to pi. | |
• | If the first argument is positive and the second argument is zero, the
result is the double value closest to pi/2. | |
• | If the first argument is negative and the second argument is zero, the
result is the double value closest to -pi/2. |
AVG ( [ DISTINCT | ALL ] Expression )
SELECT AVG (DISTINCT flying_time), SUM (DISTINCT miles) FROM Flights
SELECT AVG(c1) FROM (VALUES (1), (1), (1), (1), (2)) AS myTable (c1)
SELECT AVG(CAST (c1 AS DOUBLE PRECISION)) FROM (VALUES (1), (1), (1), (1), (2)) AS myTable (c1)
BIGINT (CharacterExpression | NumericExpression )
CASE WHEN booleanExpression THEN thenExpression [ WHEN booleanExpression THEN thenExpression ]... ELSE elseExpression END
-- returns 3 VALUES CASE WHEN 1=1 THEN 3 ELSE 4 END
-- returns 7 VALUES CASE WHEN 1 = 2 THEN 3 WHEN 4 = 5 THEN 6 ELSE 7 END
CAST ( [ Expression | NULL | ? ] AS Datatype)
Types |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SMALLINT | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - |
INTEGER | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - |
BIGINT | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - |
DECIMAL | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - |
REAL | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
DOUBLE | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
FLOAT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR | Y | Y | Y | Y | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - |
VARCHAR | Y | Y | Y | Y | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - |
LONG VARCHAR | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - |
CHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | Y | Y | - | - | - | - |
VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | Y | Y | - | - | - | - |
LONG VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | Y | Y | - | - | - | - |
CLOB | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - |
BLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y | - | - | - | - |
DATE | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | - | - | - |
TIME | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | Y | - | - |
TIMESTAMP | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | Y | Y | - |
XML | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y |
SELECT CAST (miles AS INT) FROM Flights -- convert timestamps to text INSERT INTO mytable (text_column) VALUES (CAST (CURRENT_TIMESTAMP AS VARCHAR(100))) -- you must cast NULL as a data type to use it SELECT airline FROM Airlines UNION ALL VALUES (CAST (NULL AS CHAR(2))) -- cast a double as a decimal SELECT CAST (FLYING_TIME AS DECIMAL(5,2)) FROM FLIGHTS -- cast a SMALLINT to a BIGINT VALUES CAST (CAST (12 as SMALLINT) as BIGINT)
• | If the specified number is NULL, the result of these functions is NULL. | |
• | If the specified number is equal to a mathematical integer, the result
of these functions is the same as the specified number. | |
• | If the specified number is zero (0), the result of these functions is
zero. | |
• | If the specified number is less than zero but greater than -1.0, then
the result of these functions is zero. |
• | A character string, if the first argument is any type of character string. | |
• | A datetime value, if the first argument is a date, time, or timestamp. | |
• | A decimal number, if the first argument is a decimal number. | |
• | A double-precision floating-point number, if the first argument is a DOUBLE
or REAL. | |
• | An integer number, if the first argument is a SMALLINT, INTEGER, or BIGINT. |
CHAR (CharacterExpression [, integer] )
CHAR (IntegerExpression )
• | If the first argument is a small integer: The length of the result is
6. If the number of characters in the result is less than 6, then the result
is padded on the right with blanks to length 6. | |
• | If the first argument is a large integer: The length of the result is
11. If the number of characters in the result is less than 11, then the result
is padded on the right with blanks to length 11. | |
• | If the first argument is a big integer: The length of the result is 20.
If the number of characters in the result is less than 20, then the result
is padded on the right with blanks to length 20. |
CHAR (DatetimeExpression )
• | date: The result is the character representation of the date. The
length of the result is 10. | |
• | time: The result is the character representation of the time. The
length of the result is 8. | |
• | timestamp: The result is the character string representation of
the timestamp. The length of the result is 26. |
CHAR (DecimalExpression )
{ { CharacterExpression || CharacterExpression } | { BitExpression || BitExpression } }
• | If the specified number is NULL, the result of this function is NULL. |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is one (1.0). |
• | If the specified number is NULL, the result of this function is NULL. |
COUNT ( [ DISTINCT | ALL ] Expression )
-- query not allowed SELECT COUNT (DISTINCT flying_time), SUM (DISTINCT miles) FROM Flights
-- Set the name column default to the current schema: CREATE TABLE mytable (id int, name VARCHAR(128) DEFAULT CURRENT SQLID) -- Inserts default value of current schema value into the table: INSERT INTO mytable(id) VALUES (1) -- Returns the rows with the same name as the current schema: SELECT name FROM mytable WHERE name = CURRENT SCHEMA
• | If the argument is a date, timestamp, or valid string representation of
a date or timestamp: The result is the date part of the value. | |
• | If the argument is a number: The result is the date that is n-1 days after
January 1, 0001, where n is the integral part of the number. | |
• | If the argument is a string with a length of 7: The result is the date
represented by the string. |
• | number if the argument is a numeric expression. | |
• | character string representation of a number if the argument is a string
expression. |
DOUBLE [PRECISION] (NumericExpression )
DOUBLE (StringExpression )
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is equal to a mathematical integer, the result
of this function is the same as the specified number. | |
• | If the specified number is zero (0), the result of this function is zero. |
• | A single row INSERT statement with a VALUES clause for a table without
an identity column | |
• | A multiple row INSERT statement with a VALUES clause | |
• | An INSERT statement with a fullselect |
ij> create table t1(c1 int generated always as identity, c2 int); 0 rows inserted/updated/deleted ij> insert into t1(c2) values (8); 1 row inserted/updated/deleted ij> values IDENTITY_VAL_LOCAL(); 1 ------------------------------- 1 1 row selected ij> select IDENTITY_VAL_LOCAL()+1, IDENTITY_VAL_LOCAL()-1 from t1; 1 |2 ------------------------------------------------------------------- 2 |0 1 row selected ij> insert into t1(c2) values (IDENTITY_VAL_LOCAL()); 1 row inserted/updated/deleted ij> select * from t1; C1 |C2 ------------------------------- 1 |8 2 |1 2 rows selected ij> values IDENTITY_VAL_LOCAL(); 1 ------------------------------- 2 1 row selected ij> insert into t1(c2) values (8), (9); 2 rows inserted/updated/deleted ij> -- multi-values insert, return value of the function should not change values IDENTITY_VAL_LOCAL(); 1 ------------------------------- 2 1 row selected ij> select * from t1; C1 |C2 ------------------------------- 1 |8 2 |1 3 |8 4 |9 4 rows selected ij> insert into t1(c2) select c1 from t1; 4 rows inserted/updated/deleted -- insert with sub-select, return value should not change ij> values IDENTITY_VAL_LOCAL(); 1 ------------------------------- 2 1 row selected ij> select * from t1; C1 |C2 ------------------------------- 1 |8 2 |1 3 |8 4 |9 5 |1 6 |2 7 |3 8 |4 8 rows selected
INT[EGER] (NumericExpression | CharacterExpression )
SELECT INTEGER (SALARY / EDLEVEL), SALARY, EDLEVEL, EMPNO FROM EMPLOYEE ORDER BY 1 DESC
LCASE or LOWER ( CharacterExpression )
• | If the specified number is NULL, the result of these functions is NULL. | |
• | If the specified number is zero or a negative number, an exception is
returned that indicates that the value is out of range (SQL state 22003). |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero or a negative number, an exception is
returned that indicates that the value is out of range (SQL state 22003). |
• | The first CharacterExpression specifies the string to
search for. | |
• | The second CharacterExpression specifies
the string in which to search. | |
• | The third argument is the startPosition, and specifies
the position in the second argument at which the search is
to start. If the third argument is not provided, the LOCATE
function starts its search at the beginning of the second
argument. |
-- returns 2, since 'love' is found at index position 2: VALUES LOCATE('love', 'clover')
-- returns 0, since 'stove' is not found in 'clover': VALUES LOCATE('stove', 'clover')
-- returns 5 (note the start position is 4): VALUES LOCATE('iss', 'Mississippi', 4)
-- returns 1, because the empty string is a special case: VALUES LOCATE('', 'ABC')
-- returns 0, because 'AAA' is not found in '': VALUES LOCATE('AAA', '')
-- returns 3 VALUES LOCATE('', '', 3)
MAX ( [ DISTINCT | ALL ] Expression )
SELECT COUNT (DISTINCT flying_time), MAX (DISTINCT miles) FROM Flights
-- find the latest date in the FlightAvailability table SELECT MAX (flight_date) FROM FlightAvailability -- find the longest flight originating from each airport, -- but only when the longest flight is over 10 hours SELECT MAX(flying_time), orig_airport FROM Flights GROUP BY orig_airport HAVING MAX(flying_time) > 10
MIN ( [ DISTINCT | ALL ] Expression )
SELECT COUNT (DISTINCT flying_time), MIN (DISTINCT miles) FROM Flights
mod(integer_type, integer_type)
• | SMALLINT if both arguments are SMALLINT. | |
• | INTEGER if one argument is INTEGER and the other is INTEGER or SMALLINT. | |
• | BIGINT if one integer is BIGINT and the other argument is BIGINT, INTEGER,
or SMALLINT. |
• | Derby does not currently allow the named or unnamed window specification to be specified in the OVER() clause, but requires an empty parenthesis. This means the function is evaluated over the entire result set. | |
• | The ROW_NUMBER function cannot currently be used in a WHERE clause. | |
• | Derby does not currently support ORDER BY in subqueries, so there is currently no way to guarantee the order of rows in the SELECT subquery. An optimizer override can be used to force the optimizer to use an index ordered on the desired column(s) if ordering is a firm requirement. |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero (0). | |
• | If the specified number is greater than zero (0), the result of this function is plus one (+1). | |
• | If the specified number is less than zero (0), the result of this function is minus one (-1). |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero. |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero. |
SMALLINT ( NumericExpression | CharacterExpression )
SUBSTR({ CharacterExpression }, StartPosition [, LengthOfString ] )
The result is 'ello'.VALUES SUBSTR('hello', 2)
The result is 'he'.VALUES SUBSTR('hello',1,2)
SUM ( [ DISTINCT | ALL ] Expression )
SELECT AVG (DISTINCT flying_time), SUM (DISTINCT miles) FROM Flights
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero. |
• | If the specified number is NULL, the result of this function is NULL. | |
• | If the specified number is zero (0), the result of this function is zero. |
• | If the argument is a time: The result is that time. | |
• | If the argument is a timestamp: The result is the time part of the timestamp. | |
• | If the argument is a string: The result is the time represented by the
string. |
• | If only one argument is specified: It must be a timestamp, a valid string
representation of a timestamp, or a string of length 14 that is not a CLOB,
LONG VARCHAR, or XML value. A string of length 14 must be a string of digits
that represents a valid date and time in the form yyyyxxddhhmmss, where yyyy is
the year, xx is the month, dd is the day, hh is the hour, mm is
the minute, and ss is the seconds. | |
• | If both arguments are specified: The first argument must be a date or
a valid string representation of a date and the second argument must be a
time or a valid string representation of a time. |
• | If both arguments are specified: The result is a timestamp with the date
specified by the first argument and the time specified by the second argument.
The microsecond part of the timestamp is zero. | |
• | If only one argument is specified and it is a timestamp: The result is
that timestamp. | |
• | If only one argument is specified and it is a string: The result is the
timestamp represented by that string. If the argument is a string of length
14, the timestamp has a microsecond part of zero. |
SELECT TIMESTAMP(col2, col3) FROM records_table
VALUES TIMESTAMP('1998-12-25', '17.12.30'); 1 -------------------------- 1998-12-25 17:12:30.0
TRIM( [ trimOperands ] trimSource)
trimOperands ::= { trimType [ trimCharacter ] FROM | trimCharacter FROM } trimType ::= { LEADING | TRAILING | BOTH } trimCharacter ::= CharacterExpression trimSource ::= CharacterExpression
• | a character string whose length is exactly one, or. | |
• | NULL |
• | If trimType is LEADING, the result will be the trimSource value with all leading occurrences of trimChar removed. | |
• | If trimType is TRAILING, the result will be the trimSource value with all trailing occurrences of trimChar removed. | |
• | If trimType is BOTH, the result will be the trimSource value with all leading *and* trailing occurrences of trimChar removed. |
-- returns 'derby' (no spaces) VALUES TRIM(' derby ')
-- returns 'derby' (no spaces) VALUES TRIM(BOTH ' ' FROM ' derby ')
-- returns 'derby ' (with a space at the end) VALUES TRIM(LEADING ' ' FROM ' derby ')
-- returns ' derby' (with two spaces at the beginning) VALUES TRIM(TRAILING ' ' FROM ' derby ')
-- returns NULL VALUES TRIM(cast (null as char(1)) FROM ' derby ')
-- returns NULL VALUES TRIM(' ' FROM cast(null as varchar(30)))
-- returns ' derb' (with a space at the beginning) VALUES TRIM('y' FROM ' derby')
-- results in an error because trimCharacter can only be 1 character VALUES TRIM('by' FROM ' derby')
UCASE or UPPER ( CharacterExpression )
VARCHAR (CharacterStringExpression )
XMLEXISTS ( xquery-string-literal PASSING BY REF xml-value-expression [ BY REF ] )
SELECT id, XMLEXISTS('//student[@age=20]' PASSING BY REF xcol) FROM x_table
SELECT id FROM x_table WHERE XMLEXISTS('/roster/student' PASSING BY REF xcol)
CREATE TABLE x_table ( id INT, xcol XML CHECK (XMLEXISTS ('//student[@age < 25]' PASSING BY REF xcol)) )
XMLPARSE (DOCUMENT string-value-expression PRESERVE WHITESPACE)
INSERT INTO x_table VALUES (1, XMLPARSE(DOCUMENT ' <roster> <student age="18">AB</student> <student age="23">BC</student> <student>NOAGE</student> </roster>' PRESERVE WHITESPACE) )
You should bind into the statement using the setCharacterStream() method, or any other JDBC setXXX method that works for the CAST target type.INSERT INTO x_table VALUES (2, XMLPARSE (DOCUMENT CAST (? AS CLOB) PRESERVE WHITESPACE) )
XMLQUERY ( xquery-string-literal PASSING BY REF xml-value-expression [ RETURNING SEQUENCE [ BY REF ] ] EMPTY ON EMPTY )
The result set for this query contains a row for every row in x_table, regardless of whether or not the XMLQUERY operator actually returns results.SELECT ID, XMLSERIALIZE( XMLQUERY('//student[@age>20]' PASSING BY REF xcol EMPTY ON EMPTY) AS VARCHAR(50)) FROM x_table
The result set for this query contains a row for only the rows in x_table that have a student whose name is BC.SELECT ID, XMLSERIALIZE( XMLQUERY('string(//student[text() = "BC"]/@age)' PASSING BY REF xcol EMPTY ON EMPTY) AS VARCHAR(50)) FROM x_table WHERE XMLEXISTS('//student[text() = "BC"]' PASSING BY REF xcol)
INSERT INTO x_table (id, xcol) VALUES (3, XMLPARSE(DOCUMENT '[xString]' PRESERVE WHITESPACE)); SELECT id, XMLSERIALIZE(xcol AS VARCHAR(100)) FROM x_table WHERE id = 3;
XMLSERIALIZE ( xml-value-expression AS string-data-type )
To retrieve the results from JDBC, you can use the JDBC getCharacterStream() or getString() method.SELECT ID, XMLSERIALIZE( xcol AS CLOB) FROM x_table
SELECT ID, XMLSERIALIZE( XMLQUERY('//student[@age>20]' PASSING BY REF xcol EMPTY ON EMPTY) AS VARCHAR(50)) FROM x_table
SYSCS_UTIL.SYSCS_GET_USER_ACCESS (USERNAME VARCHAR(128)) RETURNS VARCHAR(128)
SYSCS_UTIL.SYSCS_BACKUP_DATABASE(IN BACKUPDIR VARCHAR())
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT(IN BACKUPDIR VARCHAR())
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE (IN BACKUPDIR VARCHAR(32672), IN SMALLINT DELETE_ARCHIVED_LOG_FILES)
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(?, ?)"); cs.setString(1, "c:/backupdir"); cs.setInt(2, 0); cs.execute();
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE('c:/backupdir', 0)
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE('c:/backupdir', 1)
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT (IN BACKUPDIR VARCHAR(32672), IN SMALLINT DELETE_ARCHIVED_LOG_FILES)
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(?, ?)"); cs.setString(1, "c:/backupdir"); cs.setInt(2, 0); cs.execute();
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT('c:/backupdir', 0)
SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT('c:/backupdir', 1)
SYSCS_UTIL.SYSCS_COMPRESS_TABLE (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN SEQUENTIAL SMALLINT)
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('US', 'CUSTOMER', 1)
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_COMPRESS_TABLE(?, ?, ?)"); cs.setString(1, "US"); cs.setString(2, "CUSTOMER"); cs.setShort(3, (short) 1); cs.execute();
SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN PURGE_ROWS SMALLINT, IN DEFRAGMENT_ROWS SMALLINT, IN TRUNCATE_END SMALLINT )
call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE('US', 'CUSTOMER', 1, 1, 1);
call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE('US', 'CUSTOMER', 0, 0, 1);
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(?, ?, ?, ?, ?)"); cs.setString(1, "US"); cs.setString(2, "CUSTOMER"); cs.setShort(3, (short) 1); cs.setShort(4, (short) 1); cs.setShort(5, (short) 1); cs.execute();
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(?, ?, ?, ?, ?)"); cs.setString(1, "US"); cs.setString(2, "CUSTOMER"); cs.setShort(3, (short) 0); cs.setShort(4, (short) 0); cs.setShort(5, (short) 1); cs.execute();
SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(IN SMALLINT DELETE_ARCHIVED_LOG_FILES)
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(?)"); cs.setInt(1, 1); cs.execute(); cs.close();
CALL SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE DELETE_ARCHIVED_LOG_FILES(0);
CALL SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE DELETE_ARCHIVED_LOG_FILES(1);
SYSCS_UTIL.SYSCS_EXPORT_TABLE (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128))
SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE ( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128) IN LOBSFILENAME VARCHAR(32672) )
CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE( 'APP', 'STAFF', 'c:\data\staff.del', ',' ,'"', 'UTF-8', 'c:\data\pictures.dat');
SYSCS_UTIL.SYSCS_EXPORT_QUERY(IN SELECTSTATEMENT VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128))
SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE ( IN SELECTSTATEMENT VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128) IN LOBSFILENAME VARCHAR(32672) )
CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE( 'SELECT * FROM STAFF WHERE dept=20', 'c:\data\staff.del', ',' ,'"', 'UTF-8','c:\data\pictures.dat');
SYSCS_UTIL.SYSCS_IMPORT_DATA (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INSERTCOLUMNS VARCHAR(32672), IN COLUMNINDEXES VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
SYSCS_UTIL.SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE ( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INSERTCOLUMNS VARCHAR(32672), IN COLUMNINDEXES VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT) )
• | Offset is position in the external file in bytes | |
• | length is the size of the LOB column data in bytes |
CALL SYSCS_UTIL.SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE (null, 'STAFF', 'NAME,DEPT,SALARY,PICTURE', '2,3,4,6', 'c:\data\staff.del', ',','"','UTF-8', 0);
SYSCS_UTIL.SYSCS_IMPORT_TABLE (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'STAFF', 'c:/output/myfile.del', ';', '%', null,0);
SYSCS_UTIL.SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE ( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT) )
• | Offset is position in the external file in bytes | |
• | length is the size of the LOB column data in bytes |
CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE( 'APP','STAFF','c:\data\staff.del',',','"','UTF-8',0);
String backupdirectory = "c:/mybackups/" + JCalendar.getToday(); CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()"); cs.execute(); cs.close(); // user supplied code to take full backup of "backupdirectory" // now unfreeze the database once backup has completed: CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()"); cs.execute(); cs.close();
String backupdirectory = "c:/mybackups/" + JCalendar.getToday(); CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()"); cs.execute(); cs.close(); // user supplied code to take full backup of "backupdirectory" // now unfreeze the database once backup has completed: CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()"); cs.execute(); cs.close();
SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(IN KEY VARCHAR(128), IN VALUE VARCHAR(32672))
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)"); cs.setString(1, "derby.locks.deadlockTimeout"); cs.setString(2, "10"); cs.execute(); cs.close();
SYSCS_UTIL.SYSCS_SET_USER_ACCESS (USERNAME VARCHAR(128), CONNECTION_PERMISSION VARCHAR(128))
SYSCS_UTIL.SYSCS_UPDATE_STATISTICS(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INDEXNAME VARCHAR(128)))
CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('SAMP','EMPLOYEE','PAY_DESC');
CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('SAMP', 'EMPLOYEE', null);
Diagnostic table expression | Type of expression |
SYSCS_DIAG.CONTAINED_ROLES | Table function |
SYSCS_DIAG.ERROR_LOG_READER | Table function |
SYSCS_DIAG.ERROR_MESSAGES | Table |
SYSCS_DIAG.LOCK_TABLE | Table |
SYSCS_DIAG.SPACE_TABLE | Table function |
SYSCS_DIAG.STATEMENT_CACHE | Table |
SYSCS_DIAG.STATEMENT_DURATION | Table function |
SYSCS_DIAG.TRANSACTION_TABLE | Table |
SELECT * FROM TABLE (SYSCS_DIAG.CONTAINED_ROLES(reader))
where T1 is a user-specified table name that is any valid identifier.SELECT * FROM TABLE (SYSCS_DIAG.ERROR_LOG_READER()) AS T1
SELECT * FROM TABLE (SYSCS_DIAG.ERROR_LOG_READER('myderbyerrors.log')) AS T1
SELECT * FROM SYSCS_DIAG.ERROR_MESSAGES
SELECT * FROM SYSCS_DIAG.LOCK_TABLE
where T2 is a user-specified table name that is any valid identifier.SELECT T2.* FROM SYS.SYSTABLES systabs, TABLE (SYSCS_DIAG.SPACE_TABLE(systabs.tablename)) AS T2 WHERE systabs.tabletype = 'T'
SELECT * FROM TABLE (SYSCS_DIAG.SPACE_TABLE('MYSCHEMA', 'MYTABLE')) AS T2
SELECT * FROM SYSCS_DIAG.STATEMENT_CACHE
where T1 is a user-specified table name that is any valid identifier.SELECT * FROM TABLE (SYSCS_DIAG.STATEMENT_DURATION()) AS T1
SELECT * FROM TABLE (SYSCS_DIAG.STATEMENT_DURATION('somederby.log')) AS T1
SELECT * FROM SYSCS_DIAG.TRANSACTION_TABLE
Largest Type That Appears
in Expression | Resulting Type of Expression |
DOUBLE PRECISION | DOUBLE PRECISION |
REAL | DOUBLE PRECISION |
DECIMAL | DECIMAL |
BIGINT | BIGINT |
INTEGER | INTEGER |
SMALLINT | INTEGER |
create table mytable (r REAL, d DOUBLE PRECISION); 0 rows inserted/updated/deleted INSERT INTO mytable (r, d) values (3.4028236E38, 3.4028235E38); ERROR X0X41: The number '3.4028236E38' is outside the range for the data type REAL.
INSERT INTO mytable(integer_column) values (1.09e0); 1 row inserted/updated/deleted SELECT integer_column FROM mytable; I --------------- 1
ij> insert into mytable (decimal_column) VALUES (55555555556666666666); ERROR X0Y21: The number '55555555556666666666' is outside the range of the target DECIMAL/NUMERIC(5,2) datatype.
INSERT INTO mytable (int_column) values 2147483648; ERROR 22003: The resulting value is outside the range for the data type INTEGER.
• | lp stands for the precision of the left operand | |
• | rp stands for the precision of the right operand | |
• | ls stands for the scale of the left operand | |
• | rs stands for the scale of the right operand |
• | multiplication ls + rs | |
• | division 31 - lp + ls - rs | |
• | AVG() max(max(ls, rs), 4) | |
• | all others max(ls, rs) |
Types |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SMALL INT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
INTEGER | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
BIGINT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
DECIMAL | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
REAL | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
DOUBLE | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
FLOAT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - |
VARCHAR | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - |
LONG VARCHAR | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - |
CHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - |
VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - |
LONG VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - |
CLOB | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - |
BLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y | - | - | - | - |
DATE | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | - | - | - |
TIME | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | Y | - | - |
TIME STAMP | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - | Y | - |
XML | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y |
Types |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SMALL INT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
INTEGER | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
BIGINT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
DECIMAL | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
REAL | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
DOUBLE | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
FLOAT | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | Y | Y | - |
VARCHAR | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | Y | Y | - |
LONG VARCHAR | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - |
VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - |
LONG VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
CLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
BLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
DATE | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | - | - | - |
TIME | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | Y | - | - |
TIME STAMP | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - | Y | - |
XML | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
create table pictures(name varchar(32) not null primary key, pic blob(16M)); --find all logotype pictures select length(pic), name from pictures where name like '%logo%'; --find all image doubles (blob comparsions) select a.name as double_one, b.name as double_two from pictures as a, pictures as b where a.name < b.name and a.pic = b.pic order by 1,2;
CHAR[ACTER] [(length)]
-- within a string constant use two single quotation marks -- to represent a single quotation mark or apostrophe VALUES 'hello this is Joe''s string'
-- create a table with a CHAR field CREATE TABLE STATUS ( STATUSCODE CHAR(2) NOT NULL CONSTRAINT PK_STATUS PRIMARY KEY, STATUSDESC VARCHAR(40) NOT NULL );
{ CHAR | CHARACTER }[(length)] FOR BIT DATA
import java.sql.*; public class clob { public static void main(String[] args) { try { String url = "jdbc:derby:clobberyclob;create=true"; // Load the driver. This code is not needed if you are using // JDK 6, because in that environment the driver is loaded // automatically when the application requests a connection. Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); Connection conn = DriverManager.getConnection(url); Statement s = conn.createStatement(); s.executeUpdate( "CREATE TABLE documents (id INT, text CLOB(64 K))"); conn.commit(); // --- add a file java.io.File file = new java.io.File("asciifile.txt"); int fileLength = (int) file.length(); // - first, create an input stream java.io.InputStream fin = new java.io.FileInputStream(file); PreparedStatement ps = conn.prepareStatement("INSERT INTO documents VALUES (?, ?)"); ps.setInt(1, 1477); // - set the value of the input parameter to the input stream ps.setAsciiStream(2, fin, fileLength); ps.execute(); conn.commit(); // --- reading the columns ResultSet rs = s.executeQuery( "SELECT text FROM documents WHERE id = 1477"); while (rs.next()) { java.sql.Clob aclob = rs.getClob(1); java.io.InputStream ip = rs.getAsciiStream(1); int c = ip.read(); while (c > 0) { System.out.print((char)c); c = ip.read(); } System.out.print("\n"); // ... } } catch (Exception e) { System.out.println("Error! "+e); } } }
The first of the three formats above is the java.sql.Date format.yyyy-mm-dd mm/dd/yyyy dd.mm.yyyy
{ DECIMAL | DEC } [(precision [, scale ])]
-- this cast loses only fractional precision values cast (1.798765 AS decimal(5,2)); 1 -------- 1.79 -- this cast does not fit values cast (1798765 AS decimal(5,2)); 1 -------- ERROR 22003: The resulting value is outside the range for the data type DECIMAL/NUMERIC(5,2).
• | Smallest DOUBLE value: -1.79769E+308 | |
• | Largest DOUBLE value: 1.79769E+308 | |
• | Smallest positive DOUBLE value: 2.225E-307 | |
• | Largest negative DOUBLE value: -2.225E-307 |
-- this example will fail because the constant is too long: values 01234567890123456789012345678901e0;
FLOAT [ (precision) ]
• | Smallest REAL value: -3.402E+38 | |
• | Largest REAL value: 3.402E+38 | |
• | Smallest positive REAL value: 1.175E-37 | |
• | Largest negative REAL value: -1.175E-37 |
-- this example will fail because the constant is too long: values 01234567890123456789012345678901e0;
The first of the three formats above is the java.sql.Time format.hh:mm[:ss] hh.mm[.ss] hh[:mm] {AM | PM}
The first of the two formats above is the java.sql.Timestamp format.yyyy-mm-dd hh:mm:ss[.nnnnnn] yyyy-mm-dd-hh.mm.ss[.nnnnnn]
{ VARCHAR | CHAR VARYING | CHARACTER VARYING }(length)
{ VARCHAR | CHAR VARYING | CHARACTER VARYING } (length) FOR BIT DATA
• | To store XML documents that conform to the SQL/XML definition of a well-formed
XML(DOCUMENT(ANY)) value. | |
• | Transiently for XML(SEQUENCE) values, that might not be well-formed XML(DOCUMENT(ANY))
values. |
Then retrieve the XML value by using the getXXX method that corresponds to the target serialization type, in this example CLOB data types.SELECT XMLSERIALIZE (xcol as CLOB) FROM myXmlTable
Then use any of the setXXX methods that are compatible with String types, in this example use the PreparedStatement.setString or PreparedStatement.setCharacterStream method calls to bind the operator.INSERT INTO myXmlTable(xcol) VALUES XMLPARSE( DOCUMENT CAST (? AS CLOB) PRESERVE WHITESPACE)
• | 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. |
• | 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
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
of type java.sql.ResultSet[]. |
• | Function - Derby 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
whose argument types match as follows:
|
CREATE FUNCTION TO_DEGREES ( RADIANS DOUBLE ) RETURNS DOUBLE PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME 'acme.MathUtils.toDegrees'
public static double toDegrees( double arg ) {...} public static Double toDegrees( double arg ) {...} public static double toDegrees( Double arg ) {...} public static Double toDegrees( Double arg ) {...}
SQL type | Primitive match | Wrapper match |
SMALLINT | short | java.lang.Integer |
INTEGER | int | java.lang.Integer |
BIGINT | long | java.lang.Long |
DECIMAL | - | java.math.BigDecimal |
NUMERIC | - | java.math.BigDecimal |
REAL | float | java.lang.Float |
DOUBLE | double | java.lang.Double |
FLOAT | double | java.lang.Double |
CHAR | - | java.lang.String |
VARCHAR | - | java.lang.String |
LONG VARCHAR | - | java.lang.String |
CHAR FOR BIT DATA | byte[] | - |
VARCHAR FOR BIT DATA | byte[] | - |
LONG VARCHAR FOR BIT DATA | byte[] | - |
CLOB | - | java.sql.Clob |
BLOB | - | java.sql.Blob |
DATE | - | java.sql.Date |
TIME | - | java.sql.Time |
TIMESTAMP | - | java.sql.Timestamp |
XML | - | - |
ADD | ||
ALL | ||
ALLOCATE | ||
ALTER | ||
AND | ||
ANY | ||
ARE | ||
AS | ||
ASC | ||
ASSERTION | ||
AT | ||
AUTHORIZATION | ||
AVG | ||
BEGIN | ||
BETWEEN | ||
BIGINT | ||
BIT | ||
BOOLEAN | ||
BOTH | ||
BY | ||
CALL | ||
CASCADE | ||
CASCADED | ||
CASE | ||
CAST | ||
CHAR | ||
CHARACTER | ||
CHECK | ||
CLOSE | ||
COALESCE | ||
COLLATE | ||
COLLATION | ||
COLUMN | ||
COMMIT | ||
CONNECT | ||
CONNECTION | ||
CONSTRAINT | ||
CONSTRAINTS | ||
CONTINUE | ||
CONVERT | ||
CORRESPONDING | ||
CREATE | ||
CURRENT | ||
CURRENT_DATE | ||
CURRENT_ROLE | ||
CURRENT_TIME | ||
CURRENT_TIMESTAMP | ||
CURRENT_USER | ||
CURSOR | ||
DEALLOCATE | ||
DEC | ||
DECIMAL | ||
DECLARE | ||
DEFAULT | ||
DEFERRABLE | ||
DEFERRED | ||
DELETE | ||
DESC | ||
DESCRIBE | ||
DIAGNOSTICS | ||
DISCONNECT | ||
DISTINCT | ||
DOUBLE | ||
DROP | ||
ELSE | ||
END | ||
END-EXEC | ||
ESCAPE | ||
EXCEPT | ||
EXCEPTION | ||
EXEC | ||
EXECUTE | ||
EXISTS | ||
EXPLAIN | ||
EXTERNAL | ||
FALSE | ||
FETCH | ||
FIRST | ||
FLOAT | ||
FOR | ||
FOREIGN | ||
FOUND | ||
FROM | ||
FULL | ||
FUNCTION | ||
GET | ||
GETCURRENTCONNECTION | ||
GLOBAL | ||
GO | ||
GOTO | ||
GRANT | ||
GROUP | ||
HAVING | ||
HOUR | ||
IDENTITY | ||
IMMEDIATE | ||
IN | ||
INDICATOR | ||
INITIALLY | ||
INNER | ||
INOUT | ||
INPUT | ||
INSENSITIVE | ||
INSERT | ||
INT | ||
INTEGER | ||
INTERSECT | ||
INTO | ||
IS | ||
ISOLATION | ||
JOIN | ||
KEY | ||
LAST | ||
LEFT | ||
LIKE | ||
LOWER | ||
LTRIM | ||
MATCH | ||
MAX | ||
MIN | ||
MINUTE | ||
NATIONAL | ||
NATURAL | ||
NCHAR | ||
NVARCHAR | ||
NEXT | ||
NO | ||
NONE | ||
NOT | ||
NULL | ||
NULLIF | ||
NUMERIC | ||
OF | ||
ON | ||
ONLY | ||
OPEN | ||
OPTION | ||
OR | ||
ORDER | ||
OUTER | ||
OUTPUT | ||
OVER | ||
OVERLAPS | ||
PAD | ||
PARTIAL | ||
PREPARE | ||
PRESERVE | ||
PRIMARY | ||
PRIOR | ||
PRIVILEGES | ||
PROCEDURE | ||
PUBLIC | ||
READ | ||
REAL | ||
REFERENCES | ||
RELATIVE | ||
RESTRICT | ||
REVOKE | ||
RIGHT | ||
ROLLBACK | ||
ROWS | ||
ROW_NUMBER | ||
RTRIM | ||
SCHEMA | ||
SCROLL | ||
SECOND | ||
SELECT | ||
SESSION_USER | ||
SET | ||
SMALLINT | ||
SOME | ||
SPACE | ||
SQL | ||
SQLCODE | ||
SQLERROR | ||
SQLSTATE | ||
SUBSTR | ||
SUBSTRING | ||
SUM | ||
SYSTEM_USER | ||
TABLE | ||
TEMPORARY | ||
TIMEZONE_HOUR | ||
TIMEZONE_MINUTE | ||
TO | ||
TRANSACTION | ||
TRANSLATE | ||
TRANSLATION | ||
TRIM | ||
TRUE | ||
UNION | ||
UNIQUE | ||
UNKNOWN | ||
UPDATE | ||
UPPER | ||
USER | ||
USING | ||
VALUES | ||
VARCHAR | ||
VARYING | ||
VIEW | ||
WHENEVER | ||
WHERE | ||
WITH | ||
WORK | ||
WRITE | ||
XML | ||
XMLEXISTS | ||
XMLPARSE | ||
XMLQUERY | ||
XMLSERIALIZE | ||
YEAR |
• | SQL92E Entry | |
• | SQL92T Transitional, a level defined by NIST in a publication called
FIPS 127-2 | |
• | SQL92I Intermediate | |
• | SQL92F Full |
Feature | Source | Derby |
SMALLINT | SQL92E | Yes |
INTEGER | SQL92E | Yes |
DECIMAL(p,s) | SQL92E | Yes |
NUMERIC(p,s) | SQL92E | Yes |
REAL | SQL92E | Yes |
FLOAT(p) | SQL92E | Yes |
DOUBLE PRECISION | SQL92E | Yes |
CHAR(n) | SQL92E | Yes |
Feature | Source | Derby |
+, *, -, /, unary +, unary - | SQL92E | Yes |
Feature | Source | Derby |
<, >, <= ,>=, <>, = | SQL92E | Yes |
Feature | Source | Derby |
BETWEEN, LIKE, NULL | SQL92E | Yes |
Feature | Source | Derby |
IN, ALL/SOME, EXISTS | SQL92E | Yes |
Feature | Source | Derby |
Tables | SQL92E | Yes |
Views | SQL92E | Yes |
Privileges | SQL92E | Yes |
Feature | Source | Derby |
Default values | SQL92E | Yes |
Nullability | SQL92E | Yes |
Feature | Source | Derby |
NOT NULL | SQL92E | Yes (not stored in SYSCONSTRAINTS) |
UNIQUE/PRIMARY KEY | SQL92E | Yes |
FOREIGN KEY | SQL92E | Yes |
CHECK | SQL92E | Yes |
View WITH CHECK OPTION | SQL92E | No, views cannot be updated |
Feature | Source | Derby |
DECLARE, OPEN, FETCH, CLOSE | SQL92E | Yes, by using JDBC method calls |
UPDATE, DELETE CURRENT | SQL92E | Yes |
Feature | Source | Derby |
ALLOCATE / DEALLOCATE / GET / SET DESCRIPTOR | SQL92T | Yes, by using JDBC method calls |
PREPARE / EXECUTE / EXECUTE IMMEDIATE | SQL92T | Yes, by using JDBC method calls |
DECLARE, OPEN, FETCH, CLOSE, UPDATE, DELETE dynamic
cursor | SQL92T | Yes, by using JDBC method calls |
DESCRIBE output | SQL92T | Yes, by using JDBC method calls |
Feature | Source | Derby |
TABLES | SQL92T | SYS.SYSTABLES, SYS.SYSVIEWS, SYS.SYSCOLUMNS |
VIEWS | SQL92T | SYS.SYSTABLES, SYS.SYSVIEWS, SYS.SYSCOLUMNS |
COLUMNS | SQL92T | SYS.SYSTABLES, SYS.SYSVIEWS, SYS.SYSCOLUMNS |
Feature | Source | Derby |
CREATE / DROP TABLE | SQL92T | Yes |
CREATE / DROP VIEW | SQL92T | Yes |
GRANT / REVOKE | SQL92T | Yes |
ALTER TABLE ADD COLUMN | SQL92T | Yes |
ALTER TABLE DROP COLUMN | SQL92T | Yes |
Feature | Source | Derby |
INNER JOIN | SQL92T | Yes |
natural join | SQL92T | No |
LEFT, RIGHT OUTER JOIN | SQL92T | Yes |
join condition | SQL92T | Yes |
named columns join | SQL92T | Yes |
Feature | Source | Derby |
simple DATE, TIME, TIMESTAMP, INTERVAL | SQL92T | Yes, not INTERVAL |
datetime constants | SQL92T | Yes |
datetime math | SQL92T | Yes, with Java methods |
datetime comparisons | SQL92T | Yes |
predicates: OVERLAPS | SQL92T | Yes, with Java methods |
Feature | Source | Derby |
LENGTH | SQL92T | Yes |
concatenation (||) | SQL92T | Yes |
Feature | Source | Derby |
READ WRITE / READ ONLY | SQL92T | By using JDBC, database properties, and storage media |
RU, RC, RR, SER | SQL92T | Yes |
Feature | Source | Derby |
SCHEMATA view | SQL92T | SYS.SYSSCHEMAS |
Feature | Source | Derby |
TABLE_PRIVILEGES | SQL92T | No |
COLUMNS_PRIVILEGES | SQL92T | No |
USAGE_PRIVILEGES | SQL92T | No |
Feature | Source | Derby |
UNION relaxations | SQL92I | Yes |
EXCEPT | SQL92I | Yes |
INTERSECT | SQL92I | Yes |
CORRESPONDING | SQL92I | No |
Feature | Source | Derby |
CREATE SCHEMA | SQL92I | Partial support |
Feature | Source | Derby |
SET SESSION AUTHORIZATION | SQL92I | Use SET SCHEMA |
CURRENT_USER | SQL92I | Yes |
SESSION_USER | SQL92I | Yes |
SYSTEM_USER | SQL92I | No |
Feature | Source | Derby |
TABLE CONSTRAINTS | SQL92I | SYS.SYSCONSTRAINTS |
REFERENTIAL CONSTRAINTS | SQL92I | SYS.SYSFOREIGNKEYS |
CHECK CONSTRAINTS | SQL92I | SYS.SYSCHECKS |
Feature | Source | Derby |
SQL_FEATURES | SQL92I/FIPS 127-2 | Use JDBC DatabaseMetaData |
SQL_SIZING | SQL92I/FIPS 127-2 | Use JDBC DatabaseMetaData |
Feature | Source | Derby |
precision for TIME and TIMESTAMP | SQL92F | Yes |
Feature | Source | Derby |
POSITION expression | SQL92F | Use Java methods or LOCATE |
UPPER/LOWER functions | SQL92F | Yes |
Feature | Source | Derby |
Delimited identifiers | SQL92E | Yes |
Correlated subqueries | SQL92E | Yes |
Insert, Update, Delete statements | SQL92E | Yes |
Joins | SQL92E | Yes |
Where qualifications | SQL92E | Yes |
Group by | SQL92E | Yes |
Having | SQL92E | Yes |
Aggregate functions | SQL92E | Yes |
Order by | SQL92E | Yes |
Select expressions | SQL92E | Yes |
Select * | SQL92E | Yes |
SQLCODE | SQL92E | No, deprecated in SQL-92 |
SQLSTATE | SQL92E | Yes |
UNION, INTERSECT, and EXCEPT in views | SQL92T | Yes |
Implicit numeric casting | SQL92T | Yes |
Implicit character casting | SQL92T | Yes |
Get diagnostics | SQL92T | Use JDBC SQLExceptions |
Grouped operations | SQL92T | Yes |
Qualified * in select list | SQL92T | Yes |
Lowercase identifiers | SQL92T | Yes |
nullable PRIMARY KEYs | SQL92T | No |
Multiple module support | SQL92T | No (not required and not part of JDBC) |
Referential delete actions | SQL92T | CASCADE, SET NULL, RESTRICT, and NO ACTION |
CAST functions | SQL92T | Yes |
INSERT expressions | SQL92T | Yes |
Explicit defaults | SQL92T | Yes |
Keyword relaxations | SQL92T | Yes |
Domain definition | SQL92I | No |
CASE expression | SQL92I | Partial support |
Compound character string constants | SQL92I | Use concatenation |
LIKE enhancements | SQL92I | Yes |
UNIQUE predicate | SQL92I | No |
Usage tables | SQL92I | SYS.SYSDEPENDS |
Intermediate information schema | SQL92I | Use JDBC DatabaseMetaData and Derby system
tables |
Subprogram support | SQL92I | Not relevant to JDBC, which is much richer |
Intermediate SQL Flagging | SQL92I | No |
Schema manipulation | SQL92I | Yes |
Long identifiers | SQL92I | Yes |
Full outer join | SQL92I | No |
Time zone specification | SQL92I | No |
Scrolled cursors | SQL92I | Partial support (scrollable insensitive result sets
through JDBC 2.0) |
Intermediate set function support | SQL92I | Partial support |
Character set definition | SQL92I | Support for Java locales |
Named character sets | SQL92I | Support for Java locales |
Scalar subquery values | SQL92I | Yes |
Expanded null predicate | SQL92I | Yes |
Constraint management | SQL92I | Yes (ADD/DROP CONSTRAINT) |
FOR BIT DATA types | SQL92F | Yes |
Assertion constraints | SQL92F | No |
Temporary tables | SQL92F | Partial support, with DECLARE GLOBAL TEMPORARY TABLE |
Full dynamic SQL | SQL92F | No |
Full value expressions | SQL92F | Yes |
Truth value tests | SQL92F | Yes |
Derived tables in FROM | SQL92F | Yes |
Trailing underscore | SQL92F | Yes |
Indicator data types | SQL92F | Not relevant to JDBC |
Referential name order | SQL92F | No |
Full SQL Flagging | SQL92F | No |
Row and table constructors | SQL92F | Yes |
Catalog name qualifiers | SQL92F | No |
Simple tables | SQL92F | No |
Subqueries in CHECK | SQL92F | No, but can with Java methods |
Union join | SQL92F | No |
Collation and translation | SQL92F | Java locales supported |
Referential update actions | SQL92F | RESTRICT and NO ACTION. Can do others with triggers. |
ALTER domain | SQL92F | nNo |
INSERT column privileges | SQL92F | No |
Referential MATCH types | SQL92F | No |
View CHECK enhancements | SQL92F | No, views cannot be updated |
Session management | SQL92F | Use JDBC |
Connection management | SQL92F | Use JDBC |
Self-referencing operations | SQL92F | Yes |
Insensitive cursors | SQL92F | Yes through JDBC 2.0 |
Full set function | SQL92F | Partial support |
Catalog flagging | SQL92F | No |
Local table references | SQL92F | No |
Full cursor update | SQL92F | No |
Column Name | Type | Length | Nullability | Contents |
ALIASID | CHAR | 36 | false | unique identifier for the alias |
ALIAS | VARCHAR | 128 | false | alias |
SCHEMAID | CHAR | 36 | true | reserved for future use |
JAVACLASSNAME | LONGVARCHAR | 255 | false | the Java class name |
ALIASTYPE | CHAR | 1 | false | 'F' (function)'P' (procedure) |
NAMESPACE | CHAR | 1 | false | 'F' (function)'P' (procedure) |
SYSTEMALIAS | BOOLEAN | ' | false | true (system supplied or built-in alias) false (alias
created by a user) |
ALIASINFO |
This class is not part of the public API | ' | true | A Java interface that encapsulates the additional information
that is specific to an alias |
SPECIFICNAME | VARCHAR | 128 | false | system-generated identifier |
Column Name | Type | Length | Nullability | Contents |
CONSTRAINTID | CHAR | 36 | false | unique identifier for the constraint |
CHECKDEFINITION | LONG VARCHAR | ' | false | text of check constraint definition |
REFERENCEDCOLUMNS | org.apache.derby.catalog. ReferencedColumns: This class
is not part of the public API. | ' | false | description of the columns referenced by the check constraint |
• | Primary key (GRANTEE, TABLEID, TYPE, GRANTOR) | |
• | Unique key (COLPERMSID) | |
• | Foreign key (TABLEID references SYS.SYSTABLES) |
Column Name | Type | Length | Nullability | Contents |
COLPERMSID | CHAR | 36 | False | Used by the dependency manager to track the dependency
of a view, trigger, or constraint on the column level permissions. |
GRANTEE | VARCHAR | 128 | False | The authorization ID of the user or role to which the privilege
was granted. |
GRANTOR | VARCHAR | 128 | False | The authorization ID of the user who granted the privilege.
Privileges can be granted only by the object owner. |
TABLEID | CHAR | 36 | False | The unique identifier for the table on which the permissions
have been granted. |
TYPE | CHAR | 1 | False | If the privilege is non-grantable, the valid values are: If the privilege is grantable, the valid values are:
|
COLUMNS | org.apache.derby.iapi.services.io.FormatableBitSet | ' | False | A list of columns to which the privilege applies. This
class is not part of the public API. |
Column Name | Type | Length | Nullable | Contents |
REFERENCEID | CHAR | 36 | false | Identifier for table (join with SYSTABLES.TABLEID) |
COLUMNNAME | CHAR | 128 | false | column or parameter name |
COLUMNNUMBER | INT | 4 | false | the position of the column within the table |
COLUMNDATATYPE | org.apache.derby.catalog. TypeDescriptor This class
is not part of the public API. | ' | false | system type that describes precision, length, scale, nullability,
type name, and storage type of data |
COLUMNDEFAULT | java.io.Serializable | ' | true | for tables, describes default value of the column. The toString() method
on the object stored in the table returns the text of the default value as
specified in the CREATE TABLE or ALTER TABLE statement. |
COLUMNDEFAULTID | CHAR | 36 | true | unique identifier for the default value |
AUTOINCREMENT COLUMNVALUE | BIGINT | ' | true | what the next value for column will be, if the column is
an identity column |
AUTOINCREMENT COLUMNSTART | BIGINT | ' | true | initial value of column (if specified), if it is an identity
column |
AUTOINCREMENT COLUMNINC | BIGINT | ' | true | amount column value is automatically incremented (if specified),
if the column is an identity column |
Column Name | Type | Length | Nullable | Contents |
SCHEMAID | CHAR | 36 | false | schema id for the conglomerate |
TABLEID | CHAR | 36 | false | identifier for table (join with SYSTABLES.TABLEID) |
CONGLOMERATENUMBER | BIGINT | 8 | false | conglomerate id for the conglomerate (heap or index) |
CONGLOMERATENAME | VARCHAR | 128 | true | index name, if conglomerate is an index, otherwise the
table ID |
ISINDEX | BOOLEAN | 1 | false | whether or not conglomerate is an index |
DESCRIPTOR | This class is not part of the public API. | ' | true | system type describing the index |
ISCONSTRAINT | BOOLEAN | 1 | true | whether or not conglomerate is a system-generated index
enforcing a constraint |
CONGLOMERATEID | CHAR | 36 | false | unique identifier for the conglomerate |
Column Name | Type | Length | Nullable | Contents |
CONSTRAINTID | CHAR | 36 | false | unique identifier for constraint |
TABLEID | CHAR | 36 | false | identifier for table (join with SYSTABLES.TABLEID) |
CONSTRAINTNAME | VARCHAR | 128 | false | constraint name (internally generated if not specified
by user) |
TYPE | CHAR | 1 | false | P (primary key), U (unique), C (check),
or F (foreign key) |
SCHEMAID | CHAR | 36 | false | identifier for schema that the constraint belongs to (join
with SYSSCHEMAS.SCHEMAID) |
STATE | CHAR | 1 | false | E for enabled, D for disabled |
REFERENCECOUNT | INTEGER | 1 | false | the count of the number of foreign key constraints that
reference this constraint; this number can be greater than zero only for PRIMARY
KEY and UNIQUE constraints |
• | Dependents are views, constraints, or triggers. | |
• | Providers are tables, conglomerates, constraints, or privileges. |
Column Name | Type | Length | Nullable | Contents |
DEPENDENTID | CHAR | 36 | false | A unique identifier for the dependent. |
DEPENDENTFINDER | org.apache.derby.catalog. DependableFinder: This class
is not part of the public API. | 1 | false | A system type that describes the view, constraint, or trigger
that is the dependent. |
PROVIDERID | CHAR | 36 | false | A unique identifier for the provider. |
PROVIDERFINDER | org.apache.derby.catalog. DependableFinder This class is
not part of the public API. | 1 | false | A system type that describes the table, conglomerate, constraint,
and privilege that is the provider |
Column Name | Type | Length | Nullability | Contents |
FILEID | CHAR | 36 | false | unique identifier for the jar file |
SCHEMAID | CHAR | 36 | false | ID of the jar file's schema (join with SYSSCHEMAS. SCHEMAID) |
FILENAME | VARCHAR | 128 | false | SQL name of the jar file |
GENERATIONID | BIGINT | ' | false | Generation number for the file. When jar files are replaced,
their generation identifiers are changed. |
Column Name | Type | Length | Nullability | Contents |
CONSTRAINTID | CHAR | 36 | false | unique identifier for the foreign key constraint (join
with SYSCONSTRAINTS. CONSTRAINTID) |
CONGLOMERATEID | CHAR | 36 | false | unique identifier for index backing up the foreign key
constraint (join with SYSCONGLOMERATES. CONGLOMERATEID) |
KEYCONSTRAINTID | CHAR | 36 | false | unique identifier for the primary key or unique constraint
referenced by this foreign key (SYSKEYS.CONSTRAINTID or SYSCONSTRAINTS.
CONSTRAINTID) |
DELETERULE | CHAR | 1 | false | R for NO ACTION (default), S for RESTRICT, C for
CASCADE, U for SET NULL |
UPDATERULE | CHAR | 1 | false | R for NO ACTION(default), S for restrict |
Column Name | Type | Length | Nullable | Contents |
CONSTRAINTID | CHAR | 36 | false | unique identifier for constraint |
CONGLOMERATEID | CHAR | 36 | false | unique identifier for backing index |
• | A role definition (the result of a CREATE ROLE statement) | |
• | A role grant |
• | Primary key (GRANTEE, ROLEID, GRANTOR) | |
• | Unique key (UUID) |
Column Name | Type | Length | Nullability | Contents |
UUID | CHAR | 36 | False | A unique identifier for this role. |
ROLEID | VARCHAR | 128 | False | The role name, after conversion to case normal form. |
GRANTEE | VARCHAR | 128 | False | If the row represents a role grant, this is the authorization
identifier of a user or role to which this role is granted. If the row
represents a role definition, this is the database owner's user name. |
GRANTOR | VARCHAR | 128 | False | This is the authorization identifier of the user that granted
this role. If the row represents a role definition, this is the authorization
identifier _SYSTEM. If the row represents a role grant, this is the database
owner's user name (since only the database owner can create and grant roles).
|
WITHADMINOPTION | CHAR | 1 | False | A role definition is modelled as a grant from _SYSTEM to the
database owner, so if the row represents a role definition, the value is always
'Y'. This means that the creator (the database owner) is always allowed to grant
the newly created role. Currently roles cannot be granted WITH ADMIN OPTION, so
if the row represents a role grant, the value is always 'N'. |
ISDEF | CHAR | 1 | False | If the row represents a role definition, this value is
'Y'. If the row represents a role grant, the value is 'N'. |
• | Primary key (GRANTEE, ALIASID, GRANTOR) | |
• | Unique key (ROUTINEPERMSID) | |
• | Foreign key (ALIASID references SYS.SYSALIASES) |
Column Name | Type | Length | Nullability | Contents |
ROUTINEPERMSID | CHAR | 36 | false | Used by the dependency manager to track the dependency
of a view, trigger, or constraint on the routine level permissions. |
GRANTEE | VARCHAR | 128 | false | The authorization ID of the user or role to which the privilege
is granted. |
GRANTOR | VARCHAR | 128 | false | The authorization ID of the user who granted the privilege.
Privileges can be granted only by the object owner. |
ALIASID | CHAR | 36 | false | The ID of the object of the required permission. If PERMTYPE='E'
the ALIASID is a reference to the SYS.SYSALIASES table. Otherwise the ALIASID
is a reference to the SYS.SYSTABLES table. |
GRANTOPTION | CHAR | 1 | false | Specifies if the GRANTEE is the owner of the routine. Valid
values are Y and N. |
Column Name | Type | Length | Nullability | Contents |
STATID | CHAR | 36 | false | unique identifier for the statistic |
REFERENCEID | CHAR | 36 | false | the conglomerate for which the statistic was created (join
with SYSCONGLOMERATES. CONGLOMERATEID) |
TABLEID | CHAR | 36 | false | the table for which the information is collected |
CREATIONTIMESTAMP | TIMESTAMP | ' | false | time when this statistic was created or updated |
TYPE | CHAR | 1 | false | type of statistics |
VALID | BOOLEAN | ' | false | whether the statistic is still valid |
COLCOUNT | INTEGER | ' | false | number of columns in the statistic |
STATISTICS | This class is not part of the public API. | ' | true | statistics information |
Column Name | Type | Length | Nullability | Contents |
STMTID | CHAR | 36 | false | unique identifier for the statement |
STMTNAME | VARCHAR | 128 | false | name of the statement |
SCHEMAID | CHAR | 36 | false | the schema in which the statement resides |
TYPE | CHAR | 1 | false | always 'S' |
VALID | BOOLEAN | ' | false | TRUE if valid, FALSE if invalid |
TEXT | LONG VARCHAR | ' | false | text of the statement |
LASTCOMPILED | TIMESTAMP | ' | true | time that the statement was compiled |
COMPILATION SCHEMAID | CHAR | 36 | false | id of the schema containing the statement |
USINGTEXT | LONG VARCHAR | ' | true | text of the USING clause of the CREATE STATEMENT and ALTER
STATEMENT statements |
• | Primary key (GRANTEE, TABLEID, GRANTOR) | |
• | Unique key (TABLEPERMSID) | |
• | Foreign key (TABLEID references SYS.SYSTABLES) |
Column Name | Type | Length | Nullability | Contents |
TABLEPERMSID | CHAR | 36 | False | Used by the dependency manager to track the dependency
of a view, trigger, or constraint on the table level permissions. |
GRANTEE | VARCHAR | 128 | False | The authorization ID of the user or role to which the privilege
is granted. |
GRANTOR | VARCHAR | 128 | False | The authorization ID of the user who granted the privilege.
Privileges can be granted only by the object owner. |
TABLEID | CHAR | 36 | False | The unique identifier for the table on which the permissions
have been granted. |
SELECTPRIV | CHAR | 1 | False | Specifies if the SELECT permission is granted. The valid
values are:
|
DELETEPRIV | CHAR | 1 | False | Specifies if the DELETE permission is granted. The valid
values are:
|
INSERTPRIV | CHAR | 1 | False | Specifies if the INSERT permission is granted.
|
UPDATEPRIV | CHAR | 1 | False | Specifies if the UPDATE permission is granted. The valid
values are:
|
REFERENCEPRIV | CHAR | 1 | False | Specifies if the REFERENCE permission is granted. The valid
values are:
|
TRIGGERPRIV | CHAR | 1 | False | Specifies if the TRIGGER permission is granted. The valid
values are:
|
Column Name | Type | Length | Nullable | Contents |
TABLEID | CHAR | 36 | false | unique identifier for table or view |
TABLENAME | VARCHAR | 128 | false | table or view name |
TABLETYPE | CHAR | 1 | false | 'S' (system table), 'T' (user table), 'A' (synonym), or
'V' (view) |
SCHEMAID | CHAR | 36 | false | schema id for the table or view |
LOCK GRANULARITY | CHAR | 1 | false | Indicates the lock granularity for the table 'T' (table level locking) 'R' (row level locking, the default) |
Column Name | Type | Length | Nullability | Contents |
TRIGGERID | CHAR | 36 | false | unique identifier for the trigger |
TRIGGERNAME | VARCHAR | 128 | false | name of the trigger |
SCHEMAID | CHAR | 36 | false | id of the trigger's schema (join with SYSSCHEMAS. SCHEMAID) |
CREATIONTIMESTAMP | TIMESTAMP | ' | false | time the trigger was created |
EVENT | CHAR | 1 | false | 'U' for update, 'D' for delete, 'I' for insert |
FIRINGTIME | CHAR | 1 | false | 'B' for before 'A' for after |
TYPE | CHAR | 1 | false | 'R' for row, 'S' for statement |
STATE | CHAR | 1 | false | 'E' for enabled, 'D' for disabled |
TABLEID | CHAR | 36 | false | id of the table on which the trigger is defined |
WHENSTMTID | CHAR | 36 | true | used only if there is a WHEN clause (not yet supported) |
ACTIONSTMTID | CHAR | 36 | true | id of the stored prepared statement for the triggered-SQL-statement
(join with SYSSTATEMENTS. STMTID) |
REFERENCEDCOLUMNS | org.apache.derby.catalog. ReferencedColumns: This class
is not part of the public API. | ' | true | descriptor of the columns referenced by UPDATE triggers |
TRIGGERDEFINITION | LONG VARCHAR | ' | true | text of the action SQL statement |
REFERENCINGOLD | BOOLEAN | ' | true | whether or not the OLDREFERENCINGNAME, if non-null, refers
to the OLD row or table |
REFERENCINGNEW | BOOLEAN | ' | true | whether or not the NEWREFERENCINGNAME, if non-null, refers
to the NEW row or table |
OLDREFERENCINGNAME | VARCHAR | 128 | true | pseudoname as set using the REFERENCING OLD AS clause |
NEWREFERENCINGNAME | VARCHAR | 128 | true | pseudoname as set using the REFERENCING NEW AS clause |
Column Name | Type | Length | Nullability | Contents |
TABLEID | CHAR | 36 | false | unique identifier for the view (called TABLEID since it
is joined with column of that name in SYSTABLES) |
VIEWDEFINITION | LONG VARCHAR | ' | false | text of view definition |
CHECKOPTION | CHAR | 1 | false | 'N' (check option not supported yet) |
COMPILATION SCHEMAID | CHAR | 36 | false | id of the schema containing the view |
SQLSTATE | Message Text |
01001 | An attempt to update or delete an already deleted row was made: No row was updated or deleted. |
01003 | Null values were eliminated from the argument of a column function. |
01006 | Privilege not revoked from user <authorizationID>. |
01007 | Role <authorizationID> not revoked from authentication id <authorizationID>. |
01008 | WITH ADMIN OPTION of role <authorizationID> not revoked from authentication id <authorizationID>. |
01009 | Generated column <columnName> dropped from table <tableName>. |
0100E | XX Attempt to return too many result sets. |
01500 | The constraint <constraintName> on table <tableName> has been dropped. |
01501 | The view <viewName> has been dropped. |
01502 | The trigger <triggerName> on table <tableName> has been dropped. |
01503 | The column <columnName> on table <tableName> has been modified by adding a not null constraint. |
01504 | The new index is a duplicate of an existing index: <indexName>. |
01505 | The value <valueName> may be truncated. |
01522 | The newly defined synonym '<synonymName>' resolved to the object '<objectName>' which is currently undefined. |
01J01 | Database '<databaseName>' not created, connection made to existing database instead. |
01J02 | Scroll sensitive cursors are not currently implemented. |
01J04 | The class '<className>' for column '<columnName>' does not implement java.io.Serializable or java.sql.SQLData. Instances must implement one of these interfaces to allow them to be stored. |
01J05 | Database upgrade succeeded. The upgraded database is now ready for use. Revalidating stored prepared statements failed. See next exception for details of failure. |
01J06 | ResultSet not updatable. Query does not qualify to generate an updatable ResultSet. |
01J07 | ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction. |
01J08 | Unable to open resultSet type <resultSetType>. ResultSet type <resultSetType> opened. |
01J10 | Scroll sensitive result sets are not supported by server; remapping to forward-only cursor |
01J12 | Unable to obtain message text from server. See the next exception. The stored procedure SYSIBM.SQLCAMESSAGE is not installed on the server. Please contact your database administrator. |
01J13 | Number of rows returned (<number>) is too large to fit in an integer; the value returned will be truncated. |
01J14 | SQL authorization is being used without first enabling authentication. |
SQLSTATE | Message Text |
07000 | At least one parameter to the current statement is uninitialized. |
07004 | Parameter <parameterName> is an <procedureName> procedure parameter and must be registered with CallableStatement.registerOutParameter before execution. |
07009 | No input parameters. |
SQLSTATE | Message Text |
08000 | Connection closed by unknown interrupt. |
08001 | A connection could not be established because the security token is larger than the maximum allowed by the network protocol. |
08001 | A connection could not be established because the user id has a length of zero or is larger than the maximum allowed by the network protocol. |
08001 | A connection could not be established because the password has a length of zero or is larger than the maximum allowed by the network protocol. |
08001 | Required Derby DataSource property <propertyName> not set. |
08001 | <error> : Error connecting to server <serverName> on port <portNumber> with message <messageText>. |
08001 | SocketException: '<error>' |
08001 | Unable to open stream on socket: '<error>'. |
08001 | User id length (<number>) is outside the range of 1 to <number>. |
08001 | Password length (<value>) is outside the range of 1 to <number>. |
08001 | User id can not be null. |
08001 | Password can not be null. |
08001 | A connection could not be established because the database name '<databaseName>' is larger than the maximum length allowed by the network protocol. |
08003 | No current connection. |
08003 | getConnection() is not valid on a closed PooledConnection. |
08003 | Lob method called after connection was closed |
08003 | The underlying physical connection is stale or closed. |
08004 | Connection refused : <connectionName> |
08004 | Connection authentication failure occurred. Reason: <reasonText>. |
08004 | The connection was refused because the database <databaseName> was not found. |
08004 | Database connection refused. |
08004 | User '<authorizationID>' cannot shut down database '<databaseName>'. Only the database owner can perform this operation. |
08004 | User '<authorizationID>' cannot (re)encrypt database '<databaseName>'. Only the database owner can perform this operation. |
08004 | User '<authorizationID>' cannot hard upgrade database '<databaseName>'. Only the database owner can perform this operation. |
08004 | Connection refused to database '<databaseName>' because it is in replication slave mode. |
08004 | User '<authorizationID>' cannot issue a replication operation on database '<databaseName>'. Only the database owner can perform this operation. |
08004 | Missing permission for user '<authorizationID>' to shutdown system [<exceptionMsg>]. |
08004 | Cannot check system permission to create database '<databaseName>' [<exceptionMsg>]. |
08004 | Missing permission for user '<authorizationID>' to create database '<databaseName>' [<exceptionMsg>]. |
08006 | A network protocol error was encountered and the connection has been terminated: <error> |
08006 | An error occurred during connect reset and the connection has been terminated. See chained exceptions for details. |
08006 | SocketException: '<error>' |
08006 | A communications error has been detected: <error>. |
08006 | An error occurred during a deferred connect reset and the connection has been terminated. See chained exceptions for details. |
08006 | Insufficient data while reading from the network - expected a minimum of <number> bytes and received only <number> bytes. The connection has been terminated. |
08006 | Attempt to fully materialize lob data that is too large for the JVM. The connection has been terminated. |
08006 | Database '<databaseName>' shutdown. |
SQLSTATE | Message Text |
0A000 | Feature not implemented: <featureName>. |
0A000 | The DRDA command <commandName> is not currently implemented. The connection has been terminated. |
0A000 | JDBC method is not yet implemented. |
0A000 | JDBC method <methodName> is not supported by the server. Please upgrade the server. |
0A000 | resultSetHoldability property <propertyName> not supported |
0A000 | cancel() not supported by the server. |
0A000 | Security mechanism '<mechanismName>' is not supported. |
0A000 | The data type '<datatypeName>' is not supported. |
SQLSTATE | Message Text |
0P000 | Invalid role specification, role does not exist: '<roleName>'. |
0P000 | Invalid role specification, role not granted to current user or PUBLIC: '<roleName>'. |
SQLSTATE | Message Text |
21000 | Scalar subquery is only allowed to return a single row. |
SQLSTATE | Message Text |
22001 | A truncation error was encountered trying to shrink <value> '<value>' to length <value>. |
22003 | The resulting value is outside the range for the data type <datatypeName>. |
22003 | Year (<value>) exceeds the maximum '<value>'. |
22003 | Decimal may only be up to 31 digits. |
22003 | Overflow occurred during numeric data type conversion of '<datatypeName>' to <datatypeName>. |
22003 | The length (<number>) exceeds the maximum length for the data type (<datatypeName>). |
22005 | Unable to convert a value of type '<typeName>' to type '<typeName>' : the encoding is not supported. |
22005 | The required character converter is not available. |
22005 | Unicode string cannot convert to Ebcdic string |
22005 | Unrecognized JDBC type. Type: <typeName>, columnCount: <value>, columnIndex: <value>. |
22005 | Invalid JDBC type for parameter <parameterName>. |
22005 | Unrecognized Java SQL type <datatypeName>. |
22005 | An attempt was made to get a data value of type '<datatypeName>' from a data value of type '<datatypeName>'. |
22007 | The string representation of a datetime value is out of range. |
22007 | The syntax of the string representation of a datetime value is incorrect. |
22008 | '<argument>' is an invalid argument to the <functionName> function. |
2200L | Values assigned to XML columns must be well-formed DOCUMENT nodes. |
2200M | Invalid XML DOCUMENT: <parserError> |
2200V | Invalid context item for <operatorName> operator; context items must be well-formed DOCUMENT nodes. |
2200W | XQuery serialization error: Attempted to serialize one or more top-level Attribute nodes. |
22011 | The second or third argument of the SUBSTR function is out of range. |
22011 | The range specified for the substring with offset <offset> and len <len> is out of range for the String: <str>. |
22012 | Attempt to divide by zero. |
22013 | Attempt to take the square root of a negative number, '<value>'. |
22014 | The start position for LOCATE is invalid; it must be a positive integer. The index to start the search from is '<fromString>'. The string to search for is '<startIndex>'. The string to search from is '<searchString>'. |
22015 | Invalid data conversion: requested conversion would result in a loss of precision of <value> |
22015 | The '<functionName>' function is not allowed on the following set of types. First operand is of type '<typeName>'. Second operand is of type '<typeName>'. Third operand (start position) is of type '<typeName>'. |
22018 | Invalid character string format for type <typeName>. |
22019 | Invalid escape sequence, '<sequenceName>'. The escape string must be exactly one character. It cannot be a null or more than one character. |
22020 | Invalid trim string, '<string>'. The trim string must be exactly one character or NULL. It cannot be more than one character. |
22025 | Escape character must be followed by escape character, '_', or '%'. It cannot be followed by any other character or be at the end of the pattern. |
22027 | The built-in TRIM() function only supports a single trim character. The LTRIM() and RTRIM() built-in functions support multiple trim characters. |
22028 | The string exceeds the maximum length of <number>. |
22501 | An ESCAPE clause of NULL returns undefined results and is not allowed. |
2201X | Invalid row count for OFFSET, must be >= 0. |
2201W | Invalid row count for FIRST/NEXT, must be >= 1. |
SQLSTATE | Message Text |
23502 | Column '<columnName>' cannot accept a NULL value. |
23503 | <constraintName> on table '<tableName>' caused a violation of foreign key constraint '<value>' for key <keyName>. The statement has been rolled back. |
23505 | The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by '<value>' defined on '<value>'. |
23513 | The check constraint '<tableName>' was violated while performing an INSERT or UPDATE on table '<constraintName>'. |
SQLSTATE | Message Text |
24000 | Invalid cursor state - no current row. |
24501 | The identified cursor is not open. |
SQLSTATE | Message Text |
25001 | Cannot close a connection while a transaction is still active. |
25001 | Invalid transaction state: active SQL transaction. |
25501 | Unable to set the connection read-only property in an active transaction. |
25502 | An SQL data change is not permitted for a read-only connection, user or database. |
25503 | DDL is not permitted for a read-only connection, user or database. |
25505 | A read-only user or a user in a read-only database is not permitted to disable read-only mode on a connection. |
SQLSTATE | Message Text |
28502 | The user name '<authorizationID>' is not valid. |
SQLSTATE | Message Text |
2D521 | setAutoCommit(true) invalid during global transaction. |
2D521 | COMMIT or ROLLBACK invalid for application execution environment. |
SQLSTATE | Message Text |
38000 | The exception '<exception>' was thrown while evaluating an expression. |
38001 | The external routine is not allowed to execute SQL statements. |
38002 | The routine attempted to modify data, but the routine was not defined as MODIFIES SQL DATA. |
38004 | The routine attempted to read data, but the routine was not defined as READS SQL DATA. |
SQLSTATE | Message Text |
39004 | A NULL value cannot be passed to a method which takes a parameter of primitive type '<type>'. |
SQLSTATE | Message Text |
3B001 | SAVEPOINT, <savepointName> does not exist or is not active in the current transaction. |
3B002 | The maximum number of savepoints has been reached. |
3B501 | A SAVEPOINT with the passed name already exists in the current transaction. |
3B502 | A RELEASE or ROLLBACK TO SAVEPOINT was specified, but the savepoint does not exist. |
SQLSTATE | Message Text |
40001 | A lock could not be obtained due to a deadlock, cycle of locks and waiters is:
<lockCycle>. The selected victim is XID : <transactionID>. |
40XC0 | Dead statement. This may be caused by catching a transaction severity error inside this statement. |
40XD0 | Container has been closed. |
40XD1 | Container was opened in read-only mode. |
40XD2 | Container <containerName> cannot be opened; it either has been dropped or does not exist. |
40XL1 | A lock could not be obtained within the time requested |
40XL2 | A lock could not be obtained within the time requested. The lockTable dump is: <tableDump> |
40XT0 | An internal error was identified by RawStore module. |
40XT1 | An exception was thrown during transaction commit. |
40XT2 | An exception was thrown during rollback of a SAVEPOINT. |
40XT4 | An attempt was made to close a transaction that was still active. The transaction has been aborted. |
40XT5 | Exception thrown during an internal transaction. |
40XT6 | Database is in quiescent state, cannot activate transaction. Please wait for a moment till it exits the quiescent state. |
40XT7 | Operation is not supported in an internal transaction. |
SQLSTATE | Message Text |
42000 | Syntax error or access rule violation; see additional errors for details. |
42500 | User '<authorizationID>' does not have <permissionType> permission on table '<schemaNamet>'.'<tableName>'. |
42501 | User '<authorizationID>' does not have <permissionType> permission on table '<schemaNamet>'.'<tableName>' for grant. |
42502 | User '<authorizationID>' does not have <permissionType> permission on column '<columnName>' of table '<schemaName>'.'<tableName>'. |
42503 | User '<authorizationID>' does not have <permissionType> permission on column '<columnName>' of table '<schemaName>'.'<tableName>' for grant. |
42504 | User '<authorizationID>' does not have execute permission on <objectName> '<schemaName>'.'<tableName>'. |
42505 | User '<authorizationID>' does not have execute permission on <objectName> '<schemaName>'.'<tableName>' for grant. |
42506 | User '<authorizationID>' is not the owner of <objectName> '<schemaName>'.'<tableName>'. |
42507 | User '<authorizationID>' can not perform the operation in schema '<schemaName>'. |
42508 | User '<authorizationID>' can not create schema '<schemaName>'. Only database owner could issue this statement. |
42509 | Specified grant or revoke operation is not allowed on object '<objectName>'. |
4250A | User '<authorizationID>' does not have <permissionName> permission on object '<schemaName>'.'<objectName>'. |
4250B | Invalid database authorization property '<value>=<value>'. |
4250C | User(s) '<authorizationID>' must not be in both read-only and full-access authorization lists. |
4250D | Repeated user(s) '<listName>' in access list '<authorizationID>'; |
4250E | Internal Error: invalid <authorizationID> id in statement permission list. |
4251A | Statement <value> can only be issued by database owner. |
4251B | PUBLIC is reserved and cannot be used as a user identifier or role name. |
4251C | Role <authorizationID> cannot be granted to <authorizationID> because this would create a circularity. |
42601 | In an ALTER TABLE statement, the column '<columnName>' has been specified as NOT NULL and either the DEFAULT clause was not specified or was specified as DEFAULT NULL. |
42601 | ALTER TABLE statement cannot add an IDENTITY column to a table. |
42605 | The number of arguments for function '<functionName>' is incorrect. |
42606 | An invalid hexadecimal constant starting with '<number>' has been detected. |
42610 | All the arguments to the COALESCE/VALUE function cannot be parameters. The function needs at least one argument that is not a parameter. |
42611 | The length, precision, or scale attribute for column, or type mapping '<value>' is not valid. |
42613 | Multiple or conflicting keywords involving the '<clause>' clause are present. |
42621 | A check constraint or generated column that is defined with '<value>' is invalid. |
42622 | The name '<name>' is too long. The maximum length is '<number>'. |
42734 | Name '<name>' specified in context '<context>' is not unique. |
42802 | The number of values assigned is not the same as the number of specified or implied columns. |
42803 | An expression containing the column '<columnName>' appears in the SELECT list and is not part of a GROUP BY clause. |
42815 | The replacement value for '<value>' is invalid. |
42815 | The data type, length or value of arguments '<value>' and '<value>' is incompatible. |
42818 | Comparisons between '<type>' and '<type>' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1') |
42820 | The floating point literal '<string>' contains more than 30 characters. |
42821 | Columns of type '<type>' cannot hold values of type '<type>'. |
42824 | An operand of LIKE is not a string, or the first operand is not a column. |
42831 | '<columnName>' cannot be a column of a primary key or unique key because it can contain null values. |
42831 | '<columnName>' cannot be a column of a primary key because it can contain null values. |
42834 | SET NULL cannot be specified because FOREIGN KEY '<key>' cannot contain null values. |
42837 | ALTER TABLE '<tableName>' specified attributes for column '<columnName>' that are not compatible with the existing column. |
42846 | Cannot convert types '<type>' to '<type>'. |
42877 | A qualified column name '<columnName>' is not allowed in the ORDER BY clause. |
42878 | The ORDER BY clause of a SELECT UNION statement only supports unqualified column references and column position numbers. Other expressions are not currently supported. |
42879 | The ORDER BY clause may not contain column '<columnName>', since the query specifies DISTINCT and that column does not appear in the query result. |
4287A | The ORDER BY clause may not specify an expression, since the query specifies DISTINCT. |
42884 | No authorized routine named '<routineName>' of type '<type>' having compatible arguments was found. |
42886 | '<value>' parameter '<value>' requires a parameter marker '?'. |
42894 | DEFAULT value or IDENTITY attribute value is not valid for column '<columnName>'. |
428C1 | Only one identity column is allowed in a table. |
428EK | The qualifier for a declared global temporary table name must be SESSION. |
42903 | Invalid use of an aggregate function. |
42908 | The CREATE VIEW statement does not include a column list. |
42909 | The CREATE TABLE statement does not include a column list. |
42915 | Foreign Key '<key>' is invalid because '<value>'. |
42916 | Synonym '<synonym2>' cannot be created for '<synonym1>' as it would result in a circular synonym chain. |
42939 | An object cannot be created with the schema name '<schemaNamet>'. |
4293A | A role cannot be created with the name '<authorizationID>', the SYS prefix is reserved. |
42962 | Long column type column or parameter '<columnName>' not permitted in declared global temporary tables or procedure definitions. |
42972 | An ON clause associated with a JOIN operator is not valid. |
42995 | The requested function does not apply to global temporary tables. |
42X01 | Syntax error: <error>. |
42X02 | <value>. |
42X03 | Column name '<columnName>' is in more than one table in the FROM list. |
42X04 | Column '<columnName>' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then '<columnName>' is not a column in the target table. |
42X05 | Table/View '<objectName>' does not exist. |
42X06 | Too many result columns specified for table '<tableName>'. |
42X07 | Null is only allowed in a VALUES clause within an INSERT statement. |
42X08 | The constructor for class '<className>' cannot be used as an external virtual table because the class does not implement '<constructorName>'. |
42X09 | The table or alias name '<tableName>' is used more than once in the FROM list. |
42X10 | '<tableName>' is not an exposed table name in the scope in which it appears. |
42X12 | Column name '<columnName>' appears more than once in the CREATE TABLE statement. |
42X13 | Column name '<columnName>' appears more than once times in the column list of an INSERT statement. |
42X14 | '<columnName>' is not a column in table or VTI '<value>'. |
42X15 | Column name '<columnName>' appears in a statement without a FROM list. |
42X16 | Column name '<columnName>' appears multiple times in the SET clause of an UPDATE statement. |
42X17 | In the Properties list of a FROM clause, the value '<value>' is not valid as a joinOrder specification. Only the values FIXED and UNFIXED are valid. |
42X19 | The WHERE or HAVING clause or CHECK CONSTRAINT definition is a '<value>' expression. It must be a BOOLEAN expression. |
42X20 | Syntax error; integer literal expected. |
42X23 | Cursor <cursorName> is not updatable. |
42X24 | Column <columnName> is referenced in the HAVING clause but is not in the GROUP BY list. |
42X25 | The '<functionName>' function is not allowed on the '<1>' type. |
42X26 | The class '<className>' for column '<columnName>' does not exist or is inaccessible. This can happen if the class is not public. |
42X28 | Delete table '<tableName>' is not target of cursor '<cursorName>'. |
42X29 | Update table '<tableName>' is not the target of cursor '<cursorName>'. |
42X30 | Cursor '<cursorName>' not found. Verify that autocommit is OFF. |
42X31 | Column '<columnName>' is not in the FOR UPDATE list of cursor '<cursorName>'. |
42X32 | The number of columns in the derived column list must match the number of columns in table '<tableName>'. |
42X33 | The derived column list contains a duplicate column name '<columnName>'. |
42X34 | There is a ? parameter in the select list. This is not allowed. |
42X35 | It is not allowed for both operands of '<value>' to be ? parameters. |
42X36 | The '<operator>' operator is not allowed to take a ? parameter as an operand. |
42X37 | The unary '<operator>' operator is not allowed on the '<type>' type. |
42X38 | 'SELECT *' only allowed in EXISTS and NOT EXISTS subqueries. |
42X39 | Subquery is only allowed to return a single column. |
42X40 | A NOT statement has an operand that is not boolean . The operand of NOT must evaluate to TRUE, FALSE, or UNKNOWN. |
42X41 | In the Properties clause of a FROM list, the property '<propertyName>' is not valid (the property was being set to '<value>'). |
42X42 | Correlation name not allowed for column '<columnName>' because it is part of the FOR UPDATE list. |
42X43 | The ResultSetMetaData returned for the class/object '<className>' was null. In order to use this class as an external virtual table, the ResultSetMetaData cannot be null. |
42X44 | Invalid length '<number>' in column specification. |
42X45 | <type> is an invalid type for argument number <value> of <value>. |
42X46 | There are multiple functions named '<functionName>'. Use the full signature or the specific name. |
42X47 | There are multiple procedures named '<procedureName>'. Use the full signature or the specific name. |
42X48 | Value '<value>' is not a valid precision for <value>. |
42X49 | Value '<value>' is not a valid integer literal. |
42X50 | No method was found that matched the method call <methodName>.<value>(<value>), tried all combinations of object and primitive types and any possible type conversion for any parameters the method call may have. The method might exist but it is not public and/or static, or the parameter types are not method invocation convertible. |
42X51 | The class '<className>' does not exist or is inaccessible. This can happen if the class is not public. |
42X52 | Calling method ('<methodName>') using a receiver of the Java primitive type '<type>' is not allowed. |
42X53 | The LIKE predicate can only have 'CHAR' or 'VARCHAR' operands. Type '<type>' is not permitted. |
42X54 | The Java method '<methodName>' has a ? as a receiver. This is not allowed. |
42X55 | Table name '<value>' should be the same as '<tableName>'. |
42X56 | The number of columns in the view column list does not match the number of columns in the underlying query expression in the view definition for '<value>'. |
42X57 | The getColumnCount() for external virtual table '<tableName>' returned an invalid value '<value>'. Valid values are greater than or equal to 1. |
42X58 | The number of columns on the left and right sides of the <tableName> must be the same. |
42X59 | The number of columns in each VALUES constructor must be the same. |
42X60 | Invalid value '<value>' for insertMode property specified for table '<tableName>'. |
42X61 | Types '<type>' and '<type>' are not <value> compatible. |
42X62 | '<value>' is not allowed in the '<schemaNamet>' schema. |
42X63 | The USING clause did not return any results. No parameters can be set. |
42X64 | In the Properties list, the invalid value '<value>' was specified for the useStatistics property. The only valid values are TRUE or FALSE. |
42X65 | Index '<index>' does not exist. |
42X66 | Column name '<columnName>' appears more than once in the CREATE INDEX statement. |
42X68 | No field '<fieldName>' was found belonging to class '<className>'. It may be that the field exists, but it is not public, or that the class does not exist or is not public. |
42X69 | It is not allowed to reference a field ('<fieldName>') using a referencing expression of the Java primitive type '<type>'. |
42X70 | The number of columns in the table column list does not match the number of columns in the underlying query expression in the table definition for '<value>'. |
42X71 | Invalid data type '<datatypeName>' for column '<columnName>'. |
42X72 | No static field '<fieldName>' was found belonging to class '<className>'. The field might exist, but it is not public and/or static, or the class does not exist or the class is not public. |
42X73 | Method resolution for signature <value>.<value>(<value>) was ambiguous. (No single maximally specific method.) |
42X74 | Invalid CALL statement syntax. |
42X75 | No constructor was found with the signature <value>(<value>). It may be that the parameter types are not method invocation convertible. |
42X76 | At least one column, '<columnName>', in the primary key being added is nullable. All columns in a primary key must be non-nullable. |
42X77 | Column position '<columnPosition>' is out of range for the query expression. |
42X78 | Column '<columnName>' is not in the result of the query expression. |
42X79 | Column name '<columnName>' appears more than once in the result of the query expression. |
42X80 | VALUES clause must contain at least one element. Empty elements are not allowed. |
42X82 | The USING clause returned more than one row. Only single-row ResultSets are permissible. |
42X83 | The constraints on column '<columnName>' require that it be both nullable and not nullable. |
42X84 | Index '<index>' was created to enforce constraint '<constraintName>'. It can only be dropped by dropping the constraint. |
42X85 | Constraint '<constraintName>'is required to be in the same schema as table '<tableName>'. |
42X86 | ALTER TABLE failed. There is no constraint '<constraintName>' on table '<tableName>'. |
42X87 | At least one result expression (THEN or ELSE) of the '<expression>' expression must not be a '?'. |
42X88 | A conditional has a non-Boolean operand. The operand of a conditional must evaluate to TRUE, FALSE, or UNKNOWN. |
42X89 | Types '<type>' and '<type>' are not type compatible. Neither type is assignable to the other type. |
42X90 | More than one primary key constraint specified for table '<tableName>'. |
42X91 | Constraint name '<constraintName>' appears more than once in the CREATE TABLE statement. |
42X92 | Column name '<columnName>' appears more than once in a constraint's column list. |
42X93 | Table '<tableName>' contains a constraint definition with column '<columnName>' which is not in the table. |
42X94 | <value> '<value>' does not exist. |
42X96 | The database class path contains an unknown jar file '<fileName>'. |
42X98 | Parameters are not allowed in a VIEW definition. |
42X99 | Parameters are not allowed in a TABLE definition. |
42XA0 | The generation clause for column '<columnName>' has data type '<datatypeName>', which cannot be assigned to the column's declared data type. |
42XA1 | The generation clause for column '<columnName>' contains an aggregate. This is not allowed. |
42XA2 | '<value>' cannot appear in a GENERATION CLAUSE because it may return unreliable results. |
42XA3 | You may not override the value of generated column '<columnName>'. |
42XA4 | The generation clause for column '<columnName>' references other generated columns. This is not allowed. |
42XA5 | Routine '<routineName>' may issue SQL and therefore cannot appear in a GENERATION CLAUSE. |
42XA6 | '<columnName>' is a generated column. It cannot be part of a foreign key whose referential action for DELETE is SET NULL or SET DEFAULT, or whose referential action for UPDATE is CASCADE. |
42XA7 | '<columnName>' is a generated column. You cannot change its default value. |
42XA8 | You cannot rename '<columnName>' because it is referenced by the generation clause of column '<columnName>'. |
42XA9 | Column '<columnName>' needs an explicit datatype. The datatype can be omitted only for columns with generation clauses. |
42XAA | The NEW value of generated column '<columnName>' is mentioned in the BEFORE action of a trigger. This is not allowed. |
42XAB | NOT NULL is allowed only if you explicitly declare a datatype. |
42Y00 | Class '<className>' does not implement org.apache.derby.iapi.db.AggregateDefinition and thus cannot be used as an aggregate expression. |
42Y01 | Constraint '<constraintName>' is invalid. |
42Y03 | '<statement>' is not recognized as a function or procedure. |
42Y03 | '<statement>' is not recognized as a procedure. |
42Y03 | '<statement>' is not recognized as a function. |
42Y04 | Cannot create a procedure or function with EXTERNAL NAME '<name>' because it is not a list separated by periods. The expected format is <full java path>.<method name>. |
42Y05 | There is no Foreign Key named '<key>'. |
42Y07 | Schema '<schemaNamet>' does not exist |
42Y08 | Foreign key constraints are not allowed on system tables. |
42Y09 | Void methods are only allowed within a CALL statement. |
42Y10 | A table constructor that is not in an INSERT statement has all ? parameters in one of its columns. For each column, at least one of the rows must have a non-parameter. |
42Y11 | A join specification is required with the '<clauseName>' clause. |
42Y12 | The ON clause of a JOIN is a '<expressionType>' expression. It must be a BOOLEAN expression. |
42Y13 | Column name '<columnName>' appears more than once in the CREATE VIEW statement. |
42Y16 | No public static method '<methodName>' was found in class '<className>'. The method might exist, but it is not public, or it is not static. |
42Y22 | Aggregate <aggregateType> cannot operate on type <type>. |
42Y23 | Incorrect JDBC type info returned for column <colunmName>. |
42Y24 | View '<viewName>' is not updatable. (Views are currently not updatable.) |
42Y25 | '<tableName>' is a system table. Users are not allowed to modify the contents of this table. |
42Y26 | Aggregates are not allowed in the GROUP BY list. |
42Y27 | Parameters are not allowed in the trigger action. |
42Y29 | The SELECT list of a non-grouped query contains at least one invalid expression. When the SELECT list contains at least one aggregate then all entries must be valid aggregate expressions. |
42Y30 | The SELECT list of a grouped query contains at least one invalid expression. If a SELECT list has a GROUP BY, the list may only contain valid grouping expressions and valid aggregate expressions. |
42Y32 | Aggregator class '<className>' for aggregate '<aggregateName>' on type <type> does not implement org.apache.derby.iapi.sql.execute.ExecAggregator. |
42Y33 | Aggregate <aggregateName> contains one or more aggregates. |
42Y34 | Column name '<columnName>' matches more than one result column in table '<tableName>'. |
42Y35 | Column reference '<reference>' is invalid. When the SELECT list contains at least one aggregate then all entries must be valid aggregate expressions. |
42Y36 | Column reference '<reference>' is invalid, or is part of an invalid expression. For a SELECT list with a GROUP BY, the columns and expressions being selected may only contain valid grouping expressions and valid aggregate expressions. |
42Y37 | '<value>' is a Java primitive and cannot be used with this operator. |
42Y38 | insertMode = replace is not permitted on an insert where the target table, '<tableName>', is referenced in the SELECT. |
42Y39 | '<value>' may not appear in a CHECK CONSTRAINT definition because it may return non-deterministic results. |
42Y40 | '<value>' appears multiple times in the UPDATE OF column list for trigger '<triggerName>'. |
42Y41 | '<value>' cannot be directly invoked via EXECUTE STATEMENT because it is part of a trigger. |
42Y42 | Scale '<value>' is not a valid scale for a <scaleValue>. |
42Y43 | Scale '<scaleValue>' is not a valid scale with precision of '<precision>'. |
42Y44 | Invalid key '<key>' specified in the Properties list of a FROM list. The case-sensitive keys that are currently supported are '<key>'. |
42Y45 | VTI '<value>' cannot be bound because it is a special trigger VTI and this statement is not part of a trigger action or WHEN clause. |
42Y46 | Invalid Properties list in FROM list. There is no index '<index>' on table '<tableName>'. |
42Y48 | Invalid Properties list in FROM list. Either there is no named constraint '<constraintName>' on table '<tableName>' or the constraint does not have a backing index. |
42Y49 | Multiple values specified for property key '<key>'. |
42Y50 | Properties list for table '<tableName>' may contain values for index or for constraint but not both. |
42Y55 | '<value>' cannot be performed on '<value>' because it does not exist. |
42Y56 | Invalid join strategy '<strategyValue>' specified in Properties list on table '<tableName>'. The currently supported values for a join strategy are: 'hash' and 'nestedloop'. |
42Y58 | NumberFormatException occurred when converting value '<value>' for optimizer override '<value>'. |
42Y59 | Invalid value, '<value>', specified for hashInitialCapacity override. Value must be greater than 0. |
42Y60 | Invalid value, '<value>', specified for hashLoadFactor override. Value must be greater than 0.0 and less than or equal to 1.0. |
42Y61 | Invalid value, '<value>', specified for hashMaxCapacity override. Value must be greater than 0. |
42Y62 | '<statement>' is not allowed on '<viewName>' because it is a view. |
42Y63 | Hash join requires an optimizable equijoin predicate on a column in the selected index or heap. An optimizable equijoin predicate does not exist on any column in table or index '<index>'. Use the 'index' optimizer override to specify such an index or the heap on table '<tableName>'. |
42Y64 | bulkFetch value of '<value>' is invalid. The minimum value for bulkFetch is 1. |
42Y65 | bulkFetch is not permitted on '<joinType>' joins. |
42Y66 | bulkFetch is not permitted on updatable cursors. |
42Y67 | Schema '<schemaNamet>' cannot be dropped. |
42Y69 | No valid execution plan was found for this statement. This may have one of two causes: either you specified a hash join strategy when hash join is not allowed (no optimizable equijoin) or you are attempting to join two external virtual tables, each of which references the other, and so the statement cannot be evaluated. |
42Y70 | The user specified an illegal join order. This could be caused by a join column from an inner table being passed as a parameter to an external virtual table. |
42Y71 | System function or procedure '<procedureName>' cannot be dropped. |
42Y82 | System generated stored prepared statement '<statement>' that cannot be dropped using DROP STATEMENT. It is part of a trigger. |
42Y83 | An untyped null is not permitted as an argument to aggregate <aggregateName>. Please cast the null to a suitable type. |
42Y84 | '<value>' may not appear in a DEFAULT definition. |
42Y85 | The DEFAULT keyword is only allowed in a VALUES clause when the VALUES clause appears within an INSERT statement. |
42Y90 | FOR UPDATE is not permitted in this type of statement. |
42Y91 | The USING clause is not permitted in an EXECUTE STATEMENT for a trigger action. |
42Y92 | <triggerName> triggers may only reference <value> transition variables/tables. |
42Y93 | Illegal REFERENCING clause: only one name is permitted for each type of transition variable/table. |
42Y94 | An AND or OR has a non-boolean operand. The operands of AND and OR must evaluate to TRUE, FALSE, or UNKNOWN. |
42Y95 | The '<operatorName>' operator with a left operand type of '<operandType>' and a right operand type of '<operandType>' is not supported. |
42Y97 | Invalid escape character at line '<lineNumber>', column '<columnName>'. |
42Z02 | Multiple DISTINCT aggregates are not supported at this time. |
42Z07 | Aggregates are not permitted in the ON clause. |
42Z08 | Bulk insert replace is not permitted on '<value>' because it has an enabled trigger (<value>). |
42Z15 | Invalid type specified for column '<columnName>'. The type of a column may not be changed. |
42Z16 | Only columns of type VARCHAR may have their length altered. |
42Z17 | Invalid length specified for column '<columnName>'. Length must be greater than the current column length. |
42Z18 | Column '<columnName>' is part of a foreign key constraint '<constraintName>'. To alter the length of this column, you should drop the constraint first, perform the ALTER TABLE, and then recreate the constraint. |
42Z19 | Column '<columnName>' is being referenced by at least one foreign key constraint '<constraintName>'. To alter the length of this column, you should drop referencing constraints, perform the ALTER TABLE and then recreate the constraints. |
42Z20 | Column '<columnName>' cannot be made nullable. It is part of a primary key or unique constraint, which cannot have any nullable columns. |
42Z20 | Column '<columnName>' cannot be made nullable. It is part of a primary key, which cannot have any nullable columns. |
42Z21 | Invalid increment specified for identity for column '<columnName>'. Increment cannot be zero. |
42Z22 | Invalid type specified for identity column '<columnName>'. The only valid types for identity columns are BIGINT, INT and SMALLINT. |
42Z23 | Attempt to modify an identity column '<columnName>'. |
42Z24 | Overflow occurred in identity value for column '<tableName>' in table '<columnName>'. |
42Z25 | INTERNAL ERROR identity counter. Update was called without arguments with current value \= NULL. |
42Z26 | A column, '<columnName>', with an identity default cannot be made nullable. |
42Z27 | A nullable column, '<columnName>', cannot be modified to have identity default. |
42Z50 | INTERNAL ERROR: Unable to generate code for <value>. |
42Z53 | INTERNAL ERROR: Type of activation to generate for node choice <value> is unknown. |
42Z60 | <value> not allowed unless database property <propertyName> has value '<value>'. |
42Z70 | Binding directly to an XML value is not allowed; try using XMLPARSE. |
42Z71 | XML values are not allowed in top-level result sets; try using XMLSERIALIZE. |
42Z72 | Missing SQL/XML keyword(s) '<keywords>' at line <lineNumber>, column <columnNumber>. |
42Z73 | Invalid target type for XMLSERIALIZE: '<typeName>'. |
42Z74 | XML feature not supported: '<featureName>'. |
42Z75 | XML query expression must be a string literal. |
42Z76 | Multiple XML context items are not allowed. |
42Z77 | Context item must have type 'XML'; '<value>' is not allowed. |
42Z79 | Unable to determine the parameter type for XMLPARSE; try using a CAST. |
42Z90 | Class '<className>' does not return an updatable ResultSet. |
42Z91 | subquery |
42Z92 | repeatable read |
42Z93 | Constraints '<constraintName>' and '<constraintName>' have the same set of columns, which is not allowed. |
42Z97 | Renaming column '<columnName>' will cause check constraint '<constraintName>' to break. |
42Z99 | String or Hex literal cannot exceed 64K. |
42Z9A | read uncommitted |
42Z9B | The external virtual table interface does not support BLOB or CLOB columns. '<value>' column '<value>'. |
42Z9D | Procedures that modify SQL data are not allowed in BEFORE triggers. |
42Z9D | '<statement>' statements are not allowed in '<triggerName>' triggers. |
42Z9E | Constraint '<constraintName>' is not a <value> constraint. |
42Z9F | Too many indexes (<index>) on the table <tableName>. The limit is <number>. |
42ZA0 | Statement too complex. Try rewriting the query to remove complexity. Eliminating many duplicate expressions or breaking up the query and storing interim results in a temporary table can often help resolve this error. |
42ZA1 | Invalid SQL in Batch: '<batch>'. |
42ZA2 | Operand of LIKE predicate with type <type> and collation <value> is not compatable with LIKE pattern operand with type <type> and collation <value>. |
42ZA3 | The table will have collation type <type> which is different than the collation of the schema <type> hence this operation is not supported . |
42ZB1 | Parameter style DERBY_JDBC_RESULT_SET is only allowed for table functions. |
42ZB2 | Table functions can only have parameter style DERBY_JDBC_RESULT_SET. |
42ZB3 | XML is not allowed as the datatype of a column returned by a table function. |
42ZB4 | '<schemaName>'.<functionName>' does not identify a table function. |
42ZB5 | Class '<className>' implements VTICosting but does not provide a public, no-arg constructor. |
SQLSTATE | Message Text |
57017 | There is no available conversion for the source code page, <codePage>, to the target code page, <codePage>. The connection has been terminated. |
SQLSTATE | Message Text |
58009 | Network protocol exception: only one of the VCM, VCS length can be greater than 0. The connection has been terminated. |
58009 | The connection was terminated because the encoding is not supported. |
58009 | Network protocol exception: actual code point, <value>, does not match expected code point, <value>. The connection has been terminated. |
58009 | Network protocol exception: DDM collection contains less than 4 bytes of data. The connection has been terminated. |
58009 | Network protocol exception: collection stack not empty at end of same id chain parse. The connection has been terminated. |
58009 | Network protocol exception: DSS length not 0 at end of same id chain parse. The connection has been terminated. |
58009 | Network protocol exception: DSS chained with same id at end of same id chain parse. The connection has been terminated. |
58009 | Network protocol exception: end of stream prematurely reached while reading InputStream, parameter #<value>. The connection has been terminated. |
58009 | Network protocol exception: invalid FDOCA LID. The connection has been terminated. |
58009 | Network protocol exception: SECTKN was not returned. The connection has been terminated. |
58009 | Network protocol exception: only one of NVCM, NVCS can be non-null. The connection has been terminated. |
58009 | Network protocol exception: SCLDTA length, <length>, is invalid for RDBNAM. The connection has been terminated. |
58009 | Network protocol exception: SCLDTA length, <length>, is invalid for RDBCOLID. The connection has been terminated. |
58009 | Network protocol exception: SCLDTA length, <length>, is invalid for PKGID. The connection has been terminated. |
58009 | Network protocol exception: PKGNAMCSN length, <length>, is invalid at SQLAM <value>. The connection has been terminated. |
58010 | A network protocol error was encountered. A connection could not be established because the manager <value> at level <value> is not supported by the server. |
58014 | The DDM command 0x<value> is not supported. The connection has been terminated. |
58015 | The DDM object 0x<value> is not supported. The connection has been terminated. |
58016 | The DDM parameter 0x<value> is not supported. The connection has been terminated. |
58017 | The DDM parameter value 0x<value> is not supported. An input host variable may not be within the range the server supports. The connection has been terminated. |
SQLSTATE | Message Text |
X0A00 | The select list mentions column '<columnName>' twice. This is not allowed in queries with GROUP BY or HAVING clauses. Try aliasing one of the conflicting columns to a unique name. |
X0X02 | Table '<tableName>' cannot be locked in '<mode>' mode. |
X0X03 | Invalid transaction state - held cursor requires same isolation level |
X0X05 | Table/View '<tableName>' does not exist. |
X0X07 | Cannot remove jar file '<fileName>' because it is on your derby.database.classpath '<fileName>'. |
X0X0D | Invalid column array length '<columnArrayLength>'. To return generated keys, column array must be of length 1 and contain only the identity column. |
X0X0E | Table '<tableName>' does not have an auto-generated column at column position '<columnPosition>'. |
X0X0F | Table '<tableName>' does not have an auto-generated column named '<columnName>'. |
X0X10 | The USING clause returned more than one row; only single-row ResultSets are permissible. |
X0X11 | The USING clause did not return any results so no parameters can be set. |
X0X13 | Jar file '<fileName>' does not exist in schema '<schemaNamet>'. |
X0X57 | An attempt was made to put a Java value of type '<type>' into a SQL value, but there is no corresponding SQL type. The Java value is probably the result of a method call or field access. |
X0X60 | A cursor with name '<cursorName>' already exists. |
X0X61 | The values for column '<location>' in index '<columnName>' and table '<indexName>.<schemaNamet>' do not match for row location <tableName>. The value in the index is '<value>', while the value in the base table is '<value>'. The full index key, including the row location, is '<indexKey>'. The suggested corrective action is to recreate the index. |
X0X62 | Inconsistency found between table '<tableName>' and index '<indexName>'. Error when trying to retrieve row location '<rowLocation>' from the table. The full index key, including the row location, is '<indexKey>'. The suggested corrective action is to recreate the index. |
X0X63 | Got IOException '<value>'. |
X0X67 | Columns of type '<type>' may not be used in CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT or DISTINCT statements because comparisons are not supported for that type. |
X0X81 | <value> '<value>' does not exist. |
X0X85 | Index '<indexName>' was not created because '<indexType>' is not a valid index type. |
X0X86 | 0 is an invalid parameter value for ResultSet.absolute(int row). |
X0X87 | ResultSet.relative(int row) cannot be called when the cursor is not positioned on a row. |
X0X95 | Operation '<operationName>' cannot be performed on object '<objectName>' because there is an open ResultSet dependent on that object. |
X0X99 | Index '<indexName>' does not exist. |
X0Y16 | '<value>' is not a view. If it is a table, then use DROP TABLE instead. |
X0Y23 | Operation '<operationName>' cannot be performed on object '<objectName>' because VIEW '<viewName>' is dependent on that object. |
X0Y24 | Operation '<operationName>' cannot be performed on object '<objectName>' because STATEMENT '<statement>' is dependent on that object. |
X0Y25 | Operation '<operationName>' cannot be performed on object '<objectName>' because <value> '<value>' is dependent on that object. |
X0Y26 | Index '<indexName>' is required to be in the same schema as table '<tableName>'. |
X0Y28 | Index '<indexName>' cannot be created on system table '<tableName>'. Users cannot create indexes on system tables. |
X0Y32 | <value> '<value>' already exists in <value> '<value>'. |
X0Y38 | Cannot create index '<indexName>' because table '<tableName>' does not exist. |
X0Y41 | Constraint '<constraintName>' is invalid because the referenced table <tableName> has no primary key. Either add a primary key to <tableName> or explicitly specify the columns of a unique constraint that this foreign key references. |
X0Y42 | Constraint '<constraintName>' is invalid: the types of the foreign key columns do not match the types of the referenced columns. |
X0Y43 | Constraint '<constraintName>' is invalid: the number of columns in <constraintName> (<value>) does not match the number of columns in the referenced key (<value>). |
X0Y44 | Constraint '<constraintName>' is invalid: there is no unique or primary key constraint on table '<tableName>' that matches the number and types of the columns in the foreign key. |
X0Y45 | Foreign key constraint '<constraintName>' cannot be added to or enabled on table <tableName> because one or more foreign keys do not have matching referenced keys. |
X0Y46 | Constraint '<constraintName>' is invalid: referenced table <tableName> does not exist. |
X0Y54 | Schema '<schemaNamet>' cannot be dropped because it is not empty. |
X0Y55 | The number of rows in the base table does not match the number of rows in at least 1 of the indexes on the table. Index '<indexName>' on table '<schemaNamet>.<tableName>' has <number> rows, but the base table has <number> rows. The suggested corrective action is to recreate the index. |
X0Y56 | '<value>' is not allowed on the System table '<tableName>'. |
X0Y57 | A non-nullable column cannot be added to table '<tableName>' because the table contains at least one row. Non-nullable columns can only be added to empty tables. |
X0Y58 | Attempt to add a primary key constraint to table '<tableName>' failed because the table already has a constraint of that type. A table can only have a single primary key constraint. |
X0Y59 | Attempt to add or enable constraint(s) on table '<rowName>' failed because the table contains <constraintName> row(s) that violate the following check constraint(s): <tableName>. |
X0Y63 | The command on table '<tableName>' failed because null data was found in the primary key or unique constraint/index column(s). All columns in a primary or unique index key must not be null. |
X0Y63 | The command on table '<tableName>' failed because null data was found in the primary key/index column(s). All columns in a primary key must not be null. |
X0Y66 | Cannot issue commit in a nested connection when there is a pending operation in the parent connection. |
X0Y67 | Cannot issue rollback in a nested connection when there is a pending operation in the parent connection. |
X0Y68 | <value> '<value>' already exists. |
X0Y69 | <triggerName> is not supported in trigger <value>. |
X0Y70 | INSERT, UPDATE and DELETE are not permitted on table <triggerName> because trigger <tableName> is active. |
X0Y71 | Transaction manipulation such as SET ISOLATION is not permitted because trigger <triggerName> is active. |
X0Y72 | Bulk insert replace is not permitted on '<value>' because it has an enabled trigger (<value>). |
X0Y77 | Cannot issue set transaction isolation statement on a global transaction that is in progress because it would have implicitly committed the global transaction. |
X0Y78 | Statement.executeQuery() cannot be called with a statement that returns a row count. |
X0Y78 | <value>.executeQuery() cannot be called because multiple result sets were returned. Use <value>.execute() to obtain multiple results. |
X0Y78 | <value>.executeQuery() was called but no result set was returned. Use <value>.executeUpdate() for non-queries. |
X0Y79 | Statement.executeUpdate() cannot be called with a statement that returns a ResultSet. |
X0Y80 | ALTER table '<tableName>' failed. Null data found in column '<columnName>'. |
X0Y83 | WARNING: While deleting a row from a table the index row for base table row <rowName> was not found in index with conglomerate id <id>. This problem has automatically been corrected as part of the delete operation. |
SQLSTATE | Message Text |
XBCA0 | Cannot create new object with key <cache> in <key> cache. The object already exists in the cache. |
SQLSTATE | Message Text |
XBCM1 | Java linkage error thrown during load of generated class <className>. |
XBCM2 | Cannot create an instance of generated class <className>. |
XBCM3 | Method <className>() does not exist in generated class <methodName>. |
XBCM4 | Java class file format limit(s) exceeded: <className> in generated class <value>. |
SQLSTATE | Message Text |
XBCX0 | Exception from Cryptography provider. See next exception for details. |
XBCX1 | Initializing cipher with illegal mode, must be either ENCRYPT or DECRYPT. |
XBCX2 | Initializing cipher with a boot password that is too short. The password must be at least <number> characters long. |
XBCX5 | Cannot change boot password to null. |
XBCX6 | Cannot change boot password to a non-string serializable type. |
XBCX7 | Wrong format for changing boot password. Format must be : old_boot_password, new_boot_password. |
XBCX8 | Cannot change boot password for a non-encrypted database. |
XBCX9 | Cannot change boot password for a read-only database. |
XBCXA | Wrong boot password. |
XBCXB | Bad encryption padding '<value>' or padding not specified. 'NoPadding' must be used. |
XBCXC | Encryption algorithm '<algorithmName>' does not exist. Please check that the chosen provider '<providerName>' supports this algorithm. |
XBCXD | The encryption algorithm cannot be changed after the database is created. |
XBCXE | The encryption provider cannot be changed after the database is created. |
XBCXF | The class '<className>' representing the encryption provider cannot be found. |
XBCXG | The encryption provider '<providerName>' does not exist. |
XBCXH | The encryptionAlgorithm '<algorithmName>' is not in the correct format. The correct format is algorithm/feedbackMode/NoPadding. |
XBCXI | The feedback mode '<mode>' is not supported. Supported feedback modes are CBC, CFB, OFB and ECB. |
XBCXJ | The application is using a version of the Java Cryptography Extension (JCE) earlier than 1.2.1. Please upgrade to JCE 1.2.1 and try the operation again. |
XBCXK | The given encryption key does not match the encryption key used when creating the database. Please ensure that you are using the correct encryption key and try again. |
XBCXL | The verification process for the encryption key was not successful. This could have been caused by an error when accessing the appropriate file to do the verification process. See next exception for details. |
XBCXM | The length of the external encryption key must be an even number. |
XBCXN | The external encryption key contains one or more illegal characters. Allowed characters for a hexadecimal number are 0-9, a-f and A-F. |
XBCXO | Cannot encrypt the database when there is a global transaction in the prepared state. |
XBCXP | Cannot re-encrypt the database with a new boot password or an external encryption key when there is a global transaction in the prepared state. |
XBCXQ | Cannot configure a read-only database for encryption. |
XBCXR | Cannot re-encrypt a read-only database with a new boot password or an external encryption key . |
XBCXS | Cannot configure a database for encryption, when database is in the log archive mode. |
XBCXT | Cannot re-encrypt a database with a new boot password or an external encryption key, when database is in the log archive mode. |
XBCXU | Encryption of an un-encrypted database failed: <failureMessage> |
XBCXV | Encryption of an encrypted database with a new key or a new password failed: <failureMessage> |
SQLSTATE | Message Text |
XBM01 | Startup failed due to an exception. See next exception for details. |
XBM02 | Startup failed due to missing functionality for <value>. Please ensure your classpath includes the correct Derby software. |
XBM05 | Startup failed due to missing product version information for <value>. |
XBM06 | Startup failed. An encrypted database cannot be accessed without the correct boot password. |
XBM07 | Startup failed. Boot password must be at least 8 bytes long. |
XBM08 | Could not instantiate <value> StorageFactory class <value>. |
XBM0G | Failed to start encryption engine. Please make sure you are running Java 2 and have downloaded an encryption provider such as jce and put it in your class path. |
XBM0H | Directory <directoryName> cannot be created. |
XBM0I | Directory <directoryName> cannot be removed. |
XBM0J | Directory <directoryName> already exists. |
XBM0K | Unknown sub-protocol for database name <databaseName>. |
XBM0L | Specified authentication scheme class <className> does implement the authentication interface <interfaceName>. |
XBM0M | Error creating instance of authentication scheme class <className>. |
XBM0N | JDBC Driver registration with java.sql.DriverManager failed. See next exception for details. |
XBM0P | Service provider is read-only. Operation not permitted. |
XBM0Q | File <fileName> not found. Please make sure that backup copy is the correct one and it is not corrupted. |
XBM0R | Unable to remove File <fileName>. |
XBM0S | Unable to rename file '<fileName>' to '<fileName>' |
XBM0T | Ambiguous sub-protocol for database name <databaseName>. |
XBM0U | No class was registered for identifier <identifierName>. |
XBM0V | An exception was thrown while loading class <identifierName> registered for identifier <className>. |
XBM0W | An exception was thrown while creating an instance of class <identifierName> registered for identifier <className>. |
XBM0X | Supplied territory description '<value>' is invalid, expecting ln[_CO[_variant]]
ln=lower-case two-letter ISO-639 language code, CO=upper-case two-letter ISO-3166 country codes, see java.util.Locale. |
XBM03 | Supplied value '<value>' for collation attribute is invalid, expecting UCS_BASIC or TERRITORY_BASED. |
XBM04 | Collator support not available from the JVM for the database's locale '<value>'. |
XBM0Y | Backup database directory <directoryName> not found. Please make sure that the specified backup path is right. |
XBM0Z | Unable to copy file '<fileName>' to '<fileName>'. Please make sure that there is enough space and permissions are correct. |
SQLSTATE | Message Text |
XCL01 | Result set does not return rows. Operation <operationName> not permitted. |
XCL05 | Activation closed, operation <operationName> not permitted. |
XCL07 | Cursor '<cursorName>' is closed. Verify that autocommit is OFF. |
XCL08 | Cursor '<cursorName>' is not on a row. |
XCL09 | An Activation was passed to the '<methodName>' method that does not match the PreparedStatement. |
XCL10 | A PreparedStatement has been recompiled and the parameters have changed. If you are using JDBC you must prepare the statement again. |
XCL12 | An attempt was made to put a data value of type '<datatypeName>' into a data value of type '<datatypeName>'. |
XCL13 | The parameter position '<parameterPosition>' is out of range. The number of parameters for this prepared statement is '<number>'. |
XCL14 | The column position '<columnPosition>' is out of range. The number of columns for this ResultSet is '<number>'. |
XCL15 | A ClassCastException occurred when calling the compareTo() method on an object '<object>'. The parameter to compareTo() is of class '<className>'. |
XCL16 | ResultSet not open. Operation '<operation>' not permitted. Verify that autocommit is OFF. |
XCL16 | ResultSet not open. Verify that autocommit is OFF. |
XCL18 | Stream of column value in result cannot be retrieved twice |
XCL19 | Missing row in table '<tableName>' for key '<key>'. |
XCL20 | Catalogs at version level '<versionNumber>' cannot be upgraded to version level '<versionNumber>'. |
XCL21 | You are trying to execute a Data Definition statement (CREATE, DROP, or ALTER) while preparing a different statement. This is not allowed. It can happen if you execute a Data Definition statement from within a static initializer of a Java class that is being used from within a SQL statement. |
XCL22 | Parameter <parameterName> cannot be registered as an OUT parameter because it is an IN parameter. |
XCL23 | SQL type number '<type>' is not a supported type by registerOutParameter(). |
XCL24 | Parameter <parameterName> appears to be an output parameter, but it has not been so designated by registerOutParameter(). If it is not an output parameter, then it has to be set to type <type>. |
XCL25 | Parameter <parameterName> cannot be registered to be of type <type> because it maps to type <type> and they are incompatible. |
XCL26 | Parameter <parameterName> is not an output parameter. |
XCL27 | Return output parameters cannot be set. |
XCL30 | An IOException was thrown when reading a '<value>' from an InputStream. |
XCL31 | Statement closed. |
XCL33 | The table cannot be defined as a dependent of table <tableName> because of delete rule restrictions. (The relationship is self-referencing and a self-referencing relationship already exists with the SET NULL delete rule.) |
XCL34 | The table cannot be defined as a dependent of table <tableName> because of delete rule restrictions. (The relationship forms a cycle of two or more tables that cause the table to be delete-connected to itself (all other delete rules in the cycle would be CASCADE)). |
XCL35 | The table cannot be defined as a dependent of table <tableName> because of delete rule restrictions. (The relationship causes the table to be delete-connected to the indicated table through multiple relationships and the delete rule of the existing relationship is SET NULL.). |
XCL36 | The delete rule of foreign key must be <value>. (The referential constraint is self-referencing and an existing self-referencing constraint has the indicated delete rule (NO ACTION, RESTRICT or CASCADE).) |
XCL37 | The delete rule of foreign key must be <value>. (The referential constraint is self-referencing and the table is dependent in a relationship with a delete rule of CASCADE.) |
XCL38 | the delete rule of foreign key must be <ruleName>. (The relationship would cause the table to be delete-connected to the same table through multiple relationships and such relationships must have the same delete rule (NO ACTION, RESTRICT or CASCADE).) |
XCL39 | The delete rule of foreign key cannot be CASCADE. (A self-referencing constraint exists with a delete rule of SET NULL, NO ACTION or RESTRICT.) |
XCL40 | The delete rule of foreign key cannot be CASCADE. (The relationship would form a cycle that would cause a table to be delete-connected to itself. One of the existing delete rules in the cycle is not CASCADE, so this relationship may be definable if the delete rule is not CASCADE.) |
XCL41 | the delete rule of foreign key can not be CASCADE. (The relationship would cause another table to be delete-connected to the same table through multiple paths with different delete rules or with delete rule equal to SET NULL.) |
XCL42 | CASCADE |
XCL43 | SET NULL |
XCL44 | RESTRICT |
XCL45 | NO ACTION |
XCL46 | SET DEFAULT |
XCL47 | Use of '<value>' requires database to be upgraded from version <versionNumber> to version <versionNumber> or later. |
XCL48 | TRUNCATE TABLE is not permitted on '<value>' because unique/primary key constraints on this table are referenced by enabled foreign key constraints from other tables. |
XCL49 | TRUNCATE TABLE is not permitted on '<value>' because it has an enabled DELETE trigger (<value>). |
XCL50 | Upgrading the database from a previous version is not supported. The database being accessed is at version level '<versionNumber>', this software is at version level '<versionNumber>'. |
XCL51 | The requested function can not reference tables in SESSION schema. |
XCL52 | The statement has been cancelled or timed out. |
XCL53 | Stream is closed |
SQLSTATE | Message Text |
XCW00 | Unsupported upgrade from '<value>' to '<value>'. |
SQLSTATE | Message Text |
XCXA0 | Invalid identifier. |
XCXB0 | Invalid database classpath: '<classpath>'. |
XCXC0 | Invalid id list. |
XCXE0 | You are trying to do an operation that uses the territory of the database, but the database does not have a territory. |
SQLSTATE | Message Text |
XCY00 | Invalid value for property '<value>'='<value>'. |
XCY02 | The requested property change is not supported '<value>'='<value>'. |
XCY03 | Required property '<propertyName>' has not been set. |
XCY04 | Invalid syntax for optimizer overrides. The syntax should be -- DERBY-PROPERTIES propertyName = value [, propertyName = value]* |
SQLSTATE | Message Text |
XCZ00 | Unknown permission '<permissionName>'. |
XCZ01 | Unknown user '<authorizationID>'. |
XCZ02 | Invalid parameter '<value>'='<value>'. |
SQLSTATE | Message Text |
XD003 | Unable to restore dependency from disk. DependableFinder = '<value>'. Further information: '<value>'. |
XD004 | Unable to store dependencies. |
SQLSTATE | Message Text |
XIE01 | Connection was null. |
XIE03 | Data found on line <lineNumber> for column <columnName> after the stop delimiter. |
XIE04 | Data file not found: <fileName> |
XIE05 | Data file cannot be null. |
XIE06 | Entity name was null. |
XIE07 | Field and record separators cannot be substrings of each other. |
XIE08 | There is no column named: <columnName>. |
XIE09 | The total number of columns in the row is: <number>. |
XIE0B | Column '<columnName>' in the table is of type <type>, it is not supported by the import/export feature. |
XIE0D | Cannot find the record separator on line <lineNumber>. |
XIE0E | Read endOfFile at unexpected place on line <lineNumber>. |
XIE0I | An IOException occurred while writing data to the file. |
XIE0J | A delimiter is not valid or is used more than once. |
XIE0K | The period was specified as a character string delimiter. |
XIE0M | Table '<tableName>' does not exist. |
XIE0N | An invalid hexadecimal string '<hexString>' detected in the import file. |
XIE0P | Lob data file <fileName> referenced in the import file not found. |
XIE0Q | Lob data file name cannot be null. |
XIE0R | Import error on line <lineNumber> of file <fileName>: <details> |
XIE0S | The export operation was not performed, because the specified output file (<fileName>) already exists. Export processing will not overwrite an existing file, even if the process has permissions to write to that file, due to security concerns, and to avoid accidental file damage. Please either change the output file name in the export procedure arguments to specify a file which does not exist, or delete the existing file, then retry the export operation. |
XIE0T | The export operation was not performed, because the specified large object auxiliary file (<fileName>) already exists. Export processing will not overwrite an existing file, even if the process has permissions to write to that file, due to security concerns, and to avoid accidental file damage. Please either change the large object auxiliary file name in the export procedure arguments to specify a file which does not exist, or delete the existing file, then retry the export operation. |
SQLSTATE | Message Text |
XJ004 | Database '<databaseName>' not found. |
XJ008 | Cannot rollback or release a savepoint when in auto-commit mode. |
XJ009 | Use of CallableStatement required for stored procedure call or use of output parameters: <value> |
XJ010 | Cannot issue savepoint when autoCommit is on. |
XJ011 | Cannot pass null for savepoint name. |
XJ012 | '<value>' already closed. |
XJ013 | No ID for named savepoints. |
XJ014 | No name for un-named savepoints. |
XJ015 | Derby system shutdown. |
XJ016 | Method '<methodName>' not allowed on prepared statement. |
XJ017 | No savepoint command allowed inside the trigger code. |
XJ018 | Column name cannot be null. |
XJ020 | Object type not convertible to TYPE '<typeName>', invalid java.sql.Types value, or object was null. |
XJ021 | Type is not supported. |
XJ022 | Unable to set stream: '<name>'. |
XJ023 | Input stream did not have exact amount of data as the requested length. |
XJ025 | Input stream cannot have negative length. |
XJ028 | The URL '<urlValue>' is not properly formed. |
XJ030 | Cannot set AUTOCOMMIT ON when in a nested connection. |
XJ040 | Failed to start database '<databaseName>', see the next exception for details. |
XJ041 | Failed to create database '<databaseName>', see the next exception for details. |
XJ042 | '<value>' is not a valid value for property '<propertyName>'. |
XJ044 | '<value>' is an invalid scale. |
XJ045 | Invalid or (currently) unsupported isolation level, '<levelName>', passed to Connection.setTransactionIsolation(). The currently supported values are java.sql.Connection.TRANSACTION_SERIALIZABLE, java.sql.Connection.TRANSACTION_REPEATABLE_READ, java.sql.Connection.TRANSACTION_READ_COMMITTED, and java.sql.Connection.TRANSACTION_READ_UNCOMMITTED. |
XJ049 | Conflicting create attributes specified. |
XJ04B | Batch cannot contain a command that attempts to return a result set. |
XJ04C | CallableStatement batch cannot contain output parameters. |
XJ056 | Cannot set AUTOCOMMIT ON when in an XA connection. |
XJ057 | Cannot commit a global transaction using the Connection, commit processing must go thru XAResource interface. |
XJ058 | Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface. |
XJ059 | Cannot close a connection while a global transaction is still active. |
XJ05B | JDBC attribute '<attributeName>' has an invalid value '<value>', valid values are '<value>'. |
XJ05C | Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction. |
XJ061 | The '<methodName>' method is only allowed on scroll cursors. |
XJ062 | Invalid parameter value '<value>' for ResultSet.setFetchSize(int rows). |
XJ063 | Invalid parameter value '<value>' for Statement.setMaxRows(int maxRows). Parameter value must be >= 0. |
XJ064 | Invalid parameter value '<value>' for setFetchDirection(int direction). |
XJ065 | Invalid parameter value '<value>' for Statement.setFetchSize(int rows). |
XJ066 | Invalid parameter value '<value>' for Statement.setMaxFieldSize(int max). |
XJ067 | SQL text pointer is null. |
XJ068 | Only executeBatch and clearBatch allowed in the middle of a batch. |
XJ069 | No SetXXX methods allowed in case of USING execute statement. |
XJ070 | Negative or zero position argument '<argument>' passed in a Blob or Clob method. |
XJ071 | Negative length argument '<argument>' passed in a BLOB or CLOB method. |
XJ072 | Null pattern or searchStr passed in to a BLOB or CLOB position method. |
XJ073 | The data in this BLOB or CLOB is no longer available. The BLOB/CLOB's transaction may be committed, its connection closed or it has been freed. |
XJ074 | Invalid parameter value '<value>' for Statement.setQueryTimeout(int seconds). |
XJ076 | The position argument '<positionArgument>' exceeds the size of the BLOB/CLOB. |
XJ077 | Got an exception when trying to read the first byte/character of the BLOB/CLOB pattern using getBytes/getSubString. |
XJ078 | Offset '<value>' is either less than zero or is too large for the current BLOB/CLOB. |
XJ079 | The length specified '<number>' exceeds the size of the BLOB/CLOB. |
XJ080 | USING execute statement passed <number> parameters rather than <number>. |
XJ081 | Conflicting create/restore/recovery attributes specified. |
XJ081 | Invalid value '<value>' passed as parameter '<parameterName>' to method '<methodName>' |
XJ085 | Stream has already been read and end-of-file reached and cannot be re-used. |
XJ086 | This method cannot be invoked while the cursor is not on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY. |
XJ087 | Sum of position('<pos>') and length('<length>') is greater than the size of the LOB plus one. |
XJ088 | Invalid operation: wasNull() called with no data retrieved. |
XJ090 | Invalid parameter: calendar is null. |
XJ091 | Invalid argument: parameter index <indexNumber> is not an OUT or INOUT parameter. |
XJ093 | Length of BLOB/CLOB, <number>, is too large. The length cannot exceed <number>. |
XJ094 | This object is already closed. |
XJ095 | An attempt to execute a privileged action failed. |
XJ096 | A resource bundle could not be found in the <packageName> package for <value> |
XJ097 | Cannot rollback or release a savepoint that was not created by this connection. |
XJ098 | The auto-generated keys value <value> is invalid |
XJ099 | The Reader/Stream object does not contain length characters |
XJ100 | The scale supplied by the registerOutParameter method does not match with the setter method. Possible loss of precision! |
XJ103 | Table name can not be null |
XJ104 | Shared key length is invalid: <value>. |
XJ105 | DES key has the wrong length, expected length <number>, got length <number>. |
XJ106 | No such padding |
XJ107 | Bad Padding |
XJ108 | Illegal Block Size |
XJ110 | Primary table name can not be null |
XJ111 | Foreign table name can not be null |
XJ112 | Security exception encountered, see next exception for details. |
XJ113 | Unable to open file <fileName> : <error> |
XJ114 | Invalid cursor name '<cursorName>' |
XJ115 | Unable to open resultSet with requested holdability <value>. |
XJ116 | No more than <number> commands may be added to a single batch. |
XJ117 | Batching of queries not allowed by J2EE compliance. |
XJ118 | Query batch requested on a non-query statement. |
XJ121 | Invalid operation at current cursor position. |
XJ122 | No updateXXX methods were called on this row. |
XJ123 | This method must be called to update values in the current row or the insert row. |
XJ124 | Column not updatable. |
XJ125 | This method should only be called on ResultSet objects that are scrollable (type TYPE_SCROLL_INSENSITIVE). |
XJ126 | This method should not be called on sensitive dynamic cursors. |
XJ128 | Unable to unwrap for '<value>' |
XJ200 | Exceeded maximum number of sections <value> |
XJ202 | Invalid cursor name '<cursorName>'. |
XJ203 | Cursor name '<cursorName>' is already in use |
XJ204 | Unable to open result set with requested holdability <holdValue>. |
XJ206 | SQL text '<value>' has no tokens. |
XJ207 | executeQuery method can not be used for update. |
XJ208 | Non-atomic batch failure. The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements. |
XJ209 | The required stored procedure is not installed on the server. |
XJ210 | The load module name for the stored procedure on the server is not found. |
XJ211 | Non-recoverable chain-breaking exception occurred during batch processing. The batch is terminated non-atomically. |
XJ212 | Invalid attribute syntax: <attributeSyntax> |
XJ213 | The traceLevel connection property does not have a valid format for a number. |
XJ214 | An IO Error occurred when calling free() on a CLOB or BLOB. |
XJ215 | You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back. |
XJ216 | The length of this BLOB/CLOB is not available yet. When a BLOB or CLOB is accessed as a stream, the length is not available until the entire stream has been processed. |
XJ217 | The locator that was supplied for this CLOB/BLOB is invalid |
SQLSTATE | Message Text |
XK000 | The security policy could not be reloaded: <reason> |
SQLSTATE | Message Text |
XN001 | Connection reset is not allowed when inside a unit of work. |
XN008 | Query processing has been terminated due to an error on the server. |
XN009 | Error obtaining length of BLOB/CLOB object, exception follows. |
XN010 | Procedure name can not be null. |
XN011 | Procedure name length <number> is not within the valid range of 1 to <number>. |
XN012 | On <operatingSystemName> platforms, XA supports version <versionNumber> and above, this is version <versionNumber> |
XN013 | Invalid scroll orientation. |
XN014 | Network protocol error: encountered an IOException, parameter #<value>. Remaining data has been padded with 0x0. Message: <messageText>. |
XN015 | Network protocol error: the specified size of the InputStream, parameter #<value>, is less than the actual InputStream length. |
XN016 | Network protocol error: encountered error in stream length verification, parameter #<value>. Message: <messageText>. |
XN017 | Network protocol error: end of stream prematurely reached, parameter #<value>. Remaining data has been padded with 0x0. |
XN018 | Network protocol error: the specified size of the Reader, parameter #<value>, is less than the actual InputStream length. |
XN019 | Error executing a <value>, server returned <value>. |
SQLSTATE | Message Text |
XRE00 | This LogFactory module does not support replicatiosn. |
XRE01 | The log received from the master is corrupted. |
XRE02 | Master and Slave at different versions. Unable to proceed with Replication. |
XRE03 | Unexpected replication error. See derby.log for details. |
XRE04 | Could not establish a connection to the peer of the replicated database '<dbname>' on address '<hostname>:<portname>'. |
XRE04 | Connection lost for replicated database '<dbname>'. |
XRE05 | The log files on the master and slave are not in synch for replicated database '<dbname>'. The master log instant is <masterfile>:<masteroffset>, whereas the slave log instant is <slavefile>:<slaveoffset>. This is FATAL for replication - replication will be stopped. |
XRE06 | The connection attempts to the replication slave for the database <dbname> exceeded the specified timeout period. |
XRE07 | Could not perform operation because the database is not in replication master mode. |
XRE08 | Replication slave mode started successfully for database '<dbname>'. Connection refused because the database is in replication slave mode. |
XRE09 | Cannot start replication slave mode for database '<dbname>'. The database has already been booted. |
XRE10 | Conflicting attributes specified. See reference manual for attributes allowed in combination with replication attribute '<attribute>'. |
XRE11 | Could not perform operation '<command>' because the database '<dbname>' has not been booted. |
XRE12 | Replication network protocol error for database '<dbname>'. Expected message type '<expectedtype>', but received type '<receivedtype>'. |
XRE20 | Failover performed successfully for database '<dbname>', the database has been shutdown. |
XRE21 | Error occurred while performing failover for database '<dbname>', Failover attempt was aborted. |
XRE22 | Replication master has already been booted for database '<dbname>' |
XRE23 | Replication master cannot be started since unlogged operations are in progress, unfreeze to allow unlogged operations to complete and restart replication |
XRE40 | Could not perform operation because the database is not in replication slave mode. |
XRE41 | Replication operation 'failover' or 'stopSlave' refused on the slave database because the connection with the master is working. Issue the 'failover' or 'stopMaster' operation on the master database instead. |
XRE42 | Replicated database '<dbname>' shutdown. |
XRE43 | Unexpected error when trying to stop replication slave mode. To stop repliation slave mode, use operation 'stopSlave' or 'failover'. |
SQLSTATE | Message Text |
XSAI2 | The conglomerate (<value>) requested does not exist. |
XSAI3 | Feature not implemented. |
SQLSTATE | Message Text |
XSAM0 | Exception encountered while trying to boot module for '<value>'. |
XSAM2 | There is no index or conglomerate with conglom id '<conglomID>' to drop. |
XSAM3 | There is no index or conglomerate with conglom id '<conglomID>'. |
XSAM4 | There is no sort called '<sortName>'. |
XSAM5 | Scan must be opened and positioned by calling next() before making other calls. |
XSAM6 | Record <containerName> on page <pageNumber> in container <recordNumber> not found. |
SQLSTATE | Message Text |
XSAS0 | A scan controller interface method was called which is not appropriate for a scan on a sort. |
XSAS1 | An attempt was made to fetch a row before the beginning of a sort or after the end of a sort. |
XSAS3 | The type of a row inserted into a sort does not match the sort's template. |
XSAS6 | Could not acquire resources for sort. |
SQLSTATE | Message Text |
XSAX0 | XA protocol violation. |
XSAX1 | An attempt was made to start a global transaction with an Xid of an existing global transaction. |
SQLSTATE | Message Text |
XSCB0 | Could not create container. |
XSCB1 | Container <containerName> not found. |
XSCB2 | The required property <propertyName> not found in the property list given to createConglomerate() for a btree secondary index. |
XSCB3 | Unimplemented feature. |
XSCB4 | A method on a btree open scan has been called prior to positioning the scan on the first row (i.e. no next() call has been made yet). The current state of the scan is (<value>). |
XSCB5 | During logical undo of a btree insert or delete the row could not be found in the tree. |
XSCB6 | Limitation: Record of a btree secondary index cannot be updated or inserted due to lack of space on the page. Use the parameters derby.storage.pageSize and/or derby.storage.pageReservedSpace to work around this limitation. |
XSCB7 | An internal error was encountered during a btree scan - current_rh is null = <value>, position key is null = <value>. |
XSCB8 | The btree conglomerate <value> is closed. |
XSCB9 | Reserved for testing. |
SQLSTATE | Message Text |
XSCG0 | Could not create a template. |
SQLSTATE | Message Text |
XSCH0 | Could not create container. |
XSCH1 | Container <containerName> not found. |
XSCH4 | Conglomerate could not be created. |
XSCH5 | In a base table there was a mismatch between the requested column number <number> and the maximum number of columns <number>. |
XSCH6 | The heap container with container id <containerID> is closed. |
XSCH7 | The scan is not positioned. |
XSCH8 | The feature is not implemented. |
SQLSTATE | Message Text |
XSDA1 | An attempt was made to access an out of range slot on a page |
XSDA2 | An attempt was made to update a deleted record |
XSDA3 | Limitation: Record cannot be updated or inserted due to lack of space on the page. Use the parameters derby.storage.pageSize and/or derby.storage.pageReservedSpace to work around this limitation. |
XSDA4 | An unexpected exception was thrown |
XSDA5 | An attempt was made to undelete a record that is not deleted |
XSDA6 | Column <columnName> of row is null, it needs to be set to point to an object. |
XSDA7 | Restore of a serializable or SQLData object of class <className>, attempted to read more data than was originally stored |
XSDA8 | Exception during restore of a serializable or SQLData object of class <className> |
XSDA9 | Class not found during restore of a serializable or SQLData object of class <className> |
XSDAA | Illegal time stamp <value>, either time stamp is from a different page or of incompatible implementation |
XSDAB | cannot set a null time stamp |
XSDAC | Attempt to move either rows or pages from one container to another. |
XSDAD | Attempt to move zero rows from one page to another. |
XSDAE | Can only make a record handle for special record handle id. |
XSDAF | Using special record handle as if it were a normal record handle. |
XSDAG | The allocation nested top transaction cannot open the container. |
XSDAI | Page <page> being removed is already locked for deallocation. |
XSDAJ | Exception during write of a serializable or SQLData object |
XSDAK | Wrong page is gotten for record handle <value>. |
XSDAL | Record handle <value> unexpectedly points to overflow page. |
XSDAM | Exception during restore of a SQLData object of class <className>. The specified class cannot be instantiated. |
XSDAN | Exception during restore of a SQLData object of class <className>. The specified class encountered an illegal access exception. |
SQLSTATE | Message Text |
XSDB0 | Unexpected exception on in-memory page <page> |
XSDB1 | Unknown page format at page <page> |
XSDB2 | Unknown container format at container <containerName> : <value> |
XSDB3 | Container information cannot change once written: was <value>, now <value> |
XSDB4 | Page <page> is at version <versionNumber>, the log file contains change version <versionNumber>, either there are log records of this page missing, or this page did not get written out to disk properly. |
XSDB5 | Log has change record on page <page>, which is beyond the end of the container. |
XSDB6 | Another instance of Derby may have already booted the database <databaseName>. |
XSDB7 | WARNING: Derby (instance <value>) is attempting to boot the database <databaseName> even though Derby (instance <value>) may still be active. Only one instance of Derby should boot a database at a time. Severe and non-recoverable corruption can result and may have already occurred. |
XSDB8 | WARNING: Derby (instance <value>) is attempting to boot the database <databaseName> even though Derby (instance <value>) may still be active. Only one instance of Derby should boot a database at a time. Severe and non-recoverable corruption can result if 2 instances of Derby boot on the same database at the same time. The db2j.database.forceDatabaseLock=true property has been set, so the database will not boot until the db.lck is no longer present. Normally this file is removed when the first instance of Derby to boot on the database exits, but it may be left behind in some shutdowns. It will be necessary to remove the file by hand in that case. It is important to verify that no other VM is accessing the database before deleting the db.lck file by hand. |
XSDB9 | Stream container <containerName> is corrupt. |
XSDBA | Attempt to allocate object <object> failed. |
XSDBB | Unknown page format at page <page>, page dump follows: <value> |
SQLSTATE | Message Text |
XSDF0 | Could not create file <fileName> as it already exists. |
XSDF1 | Exception during creation of file <fileName> for container |
XSDF2 | Exception during creation of file <fileName> for container, file could not be removed. The exception was: <value>. |
XSDF3 | Cannot create segment <segmentName>. |
XSDF4 | Exception during remove of file <fileName> for dropped container, file could not be removed <value>. |
XSDF6 | Cannot find the allocation page <page>. |
XSDF7 | Newly created page failed to be latched <value> |
XSDF8 | Cannot find page <page> to reuse. |
XSDFB | Operation not supported by a read only database |
XSDFD | Different page image read on 2 I/Os on Page <page>, first image has incorrect checksum, second image has correct checksum. Page images follows: <value><value> |
XSDFF | The requested operation failed due to an unexpected exception. |
XSDFH | Cannot backup the database, got an I/O Exception while writing to the backup container file <fileName>. |
XSDFI | Error encountered while trying to write data to disk during database recovery. Check that the database disk is not full. If it is then delete unnecessary files, and retry connecting to the database. It is also possible that the file system is read only, or the disk has failed, or some other problem with the media. System encountered error while processing page <page>. |
SQLSTATE | Message Text |
XSDG0 | Page <page> could not be read from disk. |
XSDG1 | Page <page> could not be written to disk, please check if disk is full. |
XSDG2 | Invalid checksum on Page <page>, expected=<value>, on-disk version=<value>, page dump follows: <value> |
XSDG3 | Meta-data for Container <containerName> could not be accessed |
XSDG5 | Database is not in create mode when createFinished is called. |
XSDG6 | Data segment directory not found in <value> backup during restore. Please make sure that backup copy is the right one and it is not corrupted. |
XSDG7 | Directory <directoryName> could not be removed during restore. Please make sure that permissions are correct. |
XSDG8 | Unable to copy directory '<directoryName>' to '<value>' during restore. Please make sure that there is enough space and permissions are correct. |
SQLSTATE | Message Text |
XSLA0 | Cannot flush the log file to disk <value>. |
XSLA1 | Log Record has been sent to the stream, but it cannot be applied to the store (Object <object>). This may cause recovery problems also. |
XSLA2 | System will shutdown, got I/O Exception while accessing log file. |
XSLA3 | Log Corrupted, has invalid data in the log stream. |
XSLA4 | Cannot write to the log, most likely the log is full. Please delete unnecessary files. It is also possible that the file system is read only, or the disk has failed, or some other problems with the media. |
XSLA5 | Cannot read log stream for some reason to rollback transaction <transactionID>. |
XSLA6 | Cannot recover the database. |
XSLA7 | Cannot redo operation <operation> in the log. |
XSLA8 | Cannot rollback transaction <value>, trying to compensate <value> operation with <value> |
XSLAA | The store has been marked for shutdown by an earlier exception. |
XSLAB | Cannot find log file <logfileName>, please make sure your logDevice property is properly set with the correct path separator for your platform. |
XSLAC | Database at <value> have incompatible format with the current version of software, it may have been created by or upgraded by a later version. |
XSLAD | log Record at instant <value> in log file <value> corrupted. Expected log record length <value>, real length <logfileName>. |
XSLAE | Control file at <value> cannot be written or updated. |
XSLAF | A Read Only database was created with dirty data buffers. |
XSLAH | A Read Only database is being updated. |
XSLAI | Cannot log the checkpoint log record |
XSLAJ | The logging system has been marked to shut down due to an earlier problem and will not allow any more operations until the system shuts down and restarts. |
XSLAK | Database has exceeded largest log file number <value>. |
XSLAL | log record size <logfileName> exceeded the maximum allowable log file size <value>. Error encountered in log file <value>, position <number>. |
XSLAM | Cannot verify database format at {1} due to IOException. |
XSLAN | Database at <value> has an incompatible format with the current version of the software. The database was created by or upgraded by version <versionNumber>. |
XSLAO | Recovery failed unexpected problem <value>. |
XSLAP | Database at <value> is at version <versionNumber>. Beta databases cannot be upgraded, |
XSLAQ | cannot create log file at directory <directoryName>. |
XSLAR | Unable to copy log file '<logfileName>' to '<value>' during restore. Please make sure that there is enough space and permissions are correct. |
XSLAS | Log directory <directoryName> not found in backup during restore. Please make sure that backup copy is the correct one and it is not corrupted. |
XSLAT | The log directory '<directoryName>' exists. The directory might belong to another database. Check that the location specified for the logDevice attribute is correct. |
SQLSTATE | Message Text |
XSLB1 | Log operation <logOperation> encounters error writing itself out to the log stream, this could be caused by an errant log operation or internal log buffer full due to excessively large log operation. |
XSLB2 | Log operation <logOperation> logging excessive data, it filled up the internal log buffer. |
XSLB4 | Cannot find truncationLWM <value>. |
XSLB5 | Illegal truncationLWM instant <value> for truncation point <value>. Legal range is from <value> to <value>. |
XSLB6 | Trying to log a 0 or -ve length log Record. |
XSLB8 | Trying to reset a scan to <value>, beyond its limit of <value>. |
XSLB9 | Cannot issue any more change, log factory has been stopped. |
SQLSTATE | Message Text |
XSRS0 | Cannot freeze the database after it is already frozen. |
XSRS1 | Cannot backup the database to <value>, which is not a directory. |
XSRS4 | Error renaming file (during backup) from <value> to <value>. |
XSRS5 | Error copying file (during backup) from <path> to <path>. |
XSRS6 | Cannot create backup directory <directoryName>. |
XSRS7 | Backup caught unexpected exception. |
XSRS8 | Log Device can only be set during database creation time, it cannot be changed on the fly. |
XSRS9 | Record <recordName> no longer exists |
XSRSA | Cannot backup the database when unlogged operations are uncommitted. Please commit the transactions with backup blocking operations. |
XSRSB | Backup cannot be performed in a transaction with uncommitted unlogged operations. |
XSRSC | Cannot backup the database to <directoryLocation>, it is a database directory. |
SQLSTATE | Message Text |
XSTA2 | A transaction was already active, when attempt was made to make another transaction active. |
SQLSTATE | Message Text |
XSTB0 | An exception was thrown during transaction abort. |
XSTB2 | Cannot log transaction changes, maybe trying to write to a read only database. |
XSTB3 | Cannot abort transaction because the log manager is null, probably due to an earlier error. |
XSTB5 | Creating database with logging disabled encountered unexpected problem. |
XSTB6 | Cannot substitute a transaction table with another while one is already in use. |
SQLSTATE | Message Text |
XXXXX | Normal database session close. |
• |
The recommended way to load the driver class. With the embedded driver, if your application shuts down Derby or calls the
DriverManager.unload method, and you then want to reload the driver, call
the Class.forName().newInstance() method to do so:
| |
• |
Same as using
Class.forName(), except
that it requires the class to be found when the code is compiled. | |
• |
This
is also the same as using Class.forName(), except
that it requires the class to be found when the code is compiled. The pseudo-static
field class evaluates to the class that is named. | |
• | Setting the system property jdbc.drivers To set a system property, you alter the invocation command line or the
system properties within your application. It is not possible to alter system
properties within an applet.
|
jdbc:derby: [subsubprotocol:][databasename][;attributes]*
• | |||||||||||
• | subsubprotocol: subsubprotocol,
which is not typically specified, specifies where Derby looks
for a database: in a directory, in a classpath, or in a jar file. It is used
only in rare instances, usually for read-only databases. subsubprotocol is
one of the following:
jar: requires an additional element immediately before the databaseName:
pathToArchive is
the path to the jar or zip file that holds the database and includes the name
of the jar or zip file. See the Java DB Developer's Guide for
examples of database connection URLs for read-only databases. | ||||||||||
• | databaseName Specify the databaseName to connect to
an existing database or a new one. You can specify the database name
alone, or with a relative or absolute path. See "Standard Connections-Connecting
to Databases in the File System" in Chapter 1 of the Java DB Developer's Guide. | ||||||||||
• | attributes Specify 0 or more database connection URL attributes
as detailed in Attributes of the Derby database connection URL. |
jdbc:default:connection
import java.util.Properties; Connection conn = DriverManager.getConnection( "jdbc:derby:sampleDB;create=true"); /* setting an attribute in a Properties object */ Properties myProps = new Properties(); myProps.put("create", "true"); Connection conn = DriverManager.getConnection( "jdbc:derby:sampleDB", myProps); /* passing user name and password */ Connection conn = DriverManager.getConnection( "jdbc:derby:sampleDB", "dba", "password");
Returns | Signature | Implementation Notes |
PreparedStatement | prepareStatement(String sql, int [] columnIndexes) | Every column index in the array must correlate to an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
PreparedStatement | prepareStatement(String sql, String [] columnNames) | Every column name in the array must designate an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
• | createArrayOf( java.lang.String, java.lang.Object[] ) | |
• | createNClob( ) | |
• | createSQLXML( ) | |
• | createStruct( java.lang.String, java.lang.Object[] ) | |
• | getTypeMap( ) | |
• | prepareStatement( java.lang.String, int[] ) | |
• | prepareStatement( java.lang.String, java.lang.String[] ) | |
• | setTypeMap( java.util.Map ) |
• | PROCEDURE_CAT always "null" in Derby | |
• | PROCEDURE_SCHEM schema for a Java procedure | |
• | PROCEDURE_NAME the name of the procedure | |
• | COLUMN_NAME the name of the parameter (see column-Name-Pattern) | |
• | COLUMN_TYPE short indicating what the row describes. Always is DatabaseMetaData.procedureColumnIn for
method parameters, unless the parameter is an array. If so, it is DatabaseMetaData.procedureColumnInOut.
It always returns DatabaseMetaData.procedureColumnReturn for return
values. | |
• | TYPE_NAME Derby-specific
name for the type. | |
• | NULLABLE always returns DatabaseMetaData.procedureNoNulls for
primitive parameters and DatabaseMetaData.procedureNullable for object
parameters | |
• | REMARKS a String describing the java type of the method parameter | |
• | COLUMN_DEF a String describing the default value for the
column (may be null) | |
• | SQL_DATA_TYPE reserved by JDBC spec for future use | |
• | SQL_DATETIME_SUB reserved by JDBC spec for future use | |
• | CHAR_OCTET_LENGTH the maximum length of binary and character
based columns (or any other datatype the returned value is a NULL) | |
• | ORDINAL_POSITION the ordinal position, starting from 1, for the input and output parameters for a procedure. | |
• | IS_NULLABLE a String describing the parameter's nullability
(YES means parameter can include NULLs, NO means it can't) | |
• | SPECIFIC_NAME the name which uniquely identifies this procedure within its schema | |
• | METHOD_ID a Derby-specific
column. | |
• | PARAMETER_ID a Derby-specific
column. |
• | A primary key on the table | |
• | A unique constraint or unique index on the table | |
• | All of the columns in the table |
Returns | Signature | Implementation Notes |
ResultSet | getGeneratedKeys() | If the user has indicated that auto-generated keys
should be made available, this method returns the same results as a call to the
IDENTITY_VAL_LOCAL
function. Otherwise this method returns null. |
boolean | execute(String sql, int [] columnIndexes) | Every column index in the array must correlate to an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
boolean | execute(String sql, String [] columnNames) | Every column name in the array must designate an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
int | executeUpdate(String sql, int [] columnIndexes) | Every column index in the array must correlate to an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
int | executeUpdate(String sql, String [] columnNames) | Every column name in the array must designate an
auto-increment
column within the target table of the INSERT. Supported in embedded mode only. |
• | A constant indicating that auto-generated keys should be made available.
The specific constant to use is Statement.RETURN_GENERATED_KEYS. | |
• | An array of the names of the columns in the inserted row that should be
made available. If any column name in the array does not designate
an auto-increment column, Derby
will throw an error with the Derby embedded
driver. With the client driver, the one element column name is ignored currently and the value returned corresponds to the identity column. To ensure compatibility with future changes an application should ensure the column described is the identity column. If the column name corresponds to another column or a non-existent column then future changes may result in a value for a different column being returned or an exception being thrown. | |
• | An array of the positions of the columns in the inserted row that should
be made available. If any column position in the array does not correlate
to an auto-increment column, Derby will
throw an error with the Derby embedded
driver. With the client driver, the one element position array is ignored currently and the value returned corresponds to the identity column. To ensure compatibility with future changes an application should ensure the column described is the identity column. If the position corresponds to another column or a non-existent column then future changes may result in a value for a different column being returned or an exception being thrown. |
CREATE TABLE TABLE1 (C11 int, C12 int GENERATED ALWAYS AS IDENTITY)
Statement stmt = conn.createStatement(); stmt.execute( "INSERT INTO TABLE1 (C11) VALUES (1)", Statement.RETURN_GENERATED_KEYS); ResultSet rs = stmt.getGeneratedKeys();
Statement stmt = conn.createStatement(); String [] colNames = new String [] { "C12" }; stmt.execute( "INSERT INTO TABLE1 (C11) VALUES (1)", colNames); ResultSet rs = stmt.getGeneratedKeys();
Statement stmt = conn.createStatement(); int [] colIndexes = new int [] { 2 }; stmt.execute( "INSERT INTO TABLE1 (C11) VALUES (1)", colIndexes); ResultSet rs = stmt.getGeneratedKeys();
CallableStatement cs = conn.prepareCall( "? = CALL getDriverType(cast (? as INT))" cs.registerOutParameter(1, Types.INTEGER); cs.setInt(2, 35); cs.executeUpdate();
CallableStatement call = conn.prepareCall( "{CALL doubleMyInt(?)}"); // for inout parameters, it is good practice to // register the outparameter before setting the input value call.registerOutParameter(1, Types.INTEGER); call.setInt(1,10); call.execute(); int retval = call.getInt(1);
public static void doubleMyInt(int[] i) { i[0] *=2; /* Derby returns the first element of the array.*/ }
JDBC Type | Array Type for Method Parameter | Value and Return Type |
BIGINT | long[] | long |
BINARY | byte[][] | byte[] |
BIT | boolean[] | boolean |
DATE | java.sql.Date[] | java.sql.Date |
DOUBLE | double[] | double |
FLOAT | double[] | double |
INTEGER | int[] | int |
LONGVARBINARY | byte[][] | byte[] |
REAL | float[] | float |
SMALLINT | short[] | short |
TIME | java.sql.Time[] | java.sql.Time |
TIMESTAMP | java.sql.Timestamp[] | java.sql.Timestamp |
VARBINARY | byte[][] | byte[] |
OTHER | yourType[] | yourType |
JAVA_OBJECT (only valid in Java2/JDBC 2.0 environments) | yourType[] | yourType |
• | setBinaryStream Use for streams that contain uninterpreted bytes | |
• | setAsciiStream Use for streams that contain ASCII characters | |
• | setCharacterStream Use for streams that contain characters |
Column Data Type | Corresponding Java Type | AsciiStream | CharacterStream | BinaryStream |
CLOB | java.sql.Clob | x | x | |
CHAR | x | x | ||
VARCHAR | x | x | ||
LONGVARCHAR | X | X | ||
BINARY | x | x | x | |
BLOB | java.sql.Blob | x | x | x |
VARBINARY | x | x | x | |
LONGVARBINARY | x | x | X |
• | A large X indicates the preferred target data type for the type of stream.
See Mapping of java.sql.Types to SQL Types. | |
• | For applications using the client driver, if the stream is stored in a column of a type other than LONG VARCHAR
or LONG VARCHAR FOR BIT DATA, the entire stream must be able to fit into memory
at one time. Streams stored in LONG VARCHAR and LONG VARCHAR FOR BIT DATA
columns do not have this limitation. | |
• | Streams cannot be stored in columns of the other built-in data types or
columns of user-defined data types. |
Statement s = conn.createStatement(); s.executeUpdate("CREATE TABLE atable (a INT, b LONG VARCHAR)"); conn.commit(); java.io.File file = new java.io.File("derby.txt"); int fileLength = (int) file.length(); // create an input stream java.io.InputStream fin = new java.io.FileInputStream(file); PreparedStatement ps = conn.prepareStatement( "INSERT INTO atable VALUES (?, ?)"); ps.setInt(1, 1); // set the value of the input parameter to the input stream ps.setAsciiStream(2, fin, fileLength); ps.execute(); conn.commit();
Returns | Signature | Implementation Notes |
void | deleteRow() | After the row is deleted, the ResultSet object will
be positioned before the next row. Before issuing any methods other
than close on the ResultSet object, the program will need to
reposition the ResultSet object. |
int | getConcurrency() | If the Statement object has CONCUR_READ_ONLY concurrency,
then this method will return ResultSet.CONCUR_READ_ONLY. But if the
Statement object has CONCUR_UPDATABLE concurrency, then the return
value will depend on whether the underlying language ResultSet is updatable
or not. If the language ResultSet is updatable, then getConcurrency() will
return ResultSet.CONCUR_UPDATABLE. If the language ResultSet is not
updatable, then getConcurrency() will return ResultSet.CONCUR_READ_ONLY. |
boolean | rowDeleted() | For forward-only result sets this method always returns false, for
scrollable result sets it returns true if the row has been deleted, via result set or positioned delete. |
boolean | rowInserted() | Always returns false. |
boolean | rowUpdated() | For forward-only result sets this method always returns false, for
scrollable result sets it returns true if the row has been updated, via result set or positioned update. |
void | updateRow() | After the row is updated, the ResultSet object will be
positioned before the next row. Before issuing any methods other than close
on the ResultSet object, the program will need to reposition the ResultSet
object. |
// retrieve data as a stream ResultSet rs = s.executeQuery("SELECT b FROM atable"); while (rs.next()) { // use a java.io.Reader to get the data java.io.Reader ip = rs.getCharacterStream(1); // process the stream--this is just a generic way to // print the data char[] buff = new char[128]; int size; while ((size = ip.read(buff)) != -1) { String chunk = new String(buff, 0, size); System.out.print(chunk); } } rs.close(); s.close(); conn.commit();
java.sql.Types | SQL Types |
BIGINT | BIGINT |
BINARY | CHAR FOR BIT DATA |
BIT1 | CHAR FOR BIT DATA |
BLOB | BLOB (JDBC 2.0 and up) |
CHAR | CHAR |
CLOB | CLOB (JDBC 2.0 and up) |
DATE | DATE |
DECIMAL | DECIMAL |
DOUBLE | DOUBLE PRECISION |
FLOAT | DOUBLE PRECISION2 |
INTEGER | INTEGER |
LONGVARBINARY | LONG VARCHAR FOR BIT DATA |
LONGVARCHAR | LONG VARCHAR |
NULL | Not a data type; always a value of a particular type |
NUMERIC | DECIMAL |
REAL | REAL |
SMALLINT | SMALLINT |
SQLXML3 | XML |
TIME | TIME |
TIMESTAMP | TIMESTAMP |
VARBINARY | VARCHAR FOR BIT DATA |
VARCHAR | VARCHAR |
1.
| BIT is only valid in JDBC 2.0 and earlier environments. | |
2.
| Values can be passed in using the FLOAT type code; however,
these are stored as DOUBLE PRECISION values, and so always have the type code
DOUBLE when retrieved. | |
3.
| SQLXML is only valid in JDBC 4.0 and later environments. SQLXML
corresponds to the SQL type XML in Derby.
However, Derby does not
recognize the java.sql.Types.SQLXML data type and does not support any JDBC-side
operations for the XML data type. Support for XML and the related operators
is implemented only at the SQL layer. See XML
data types for more. |
• | Use the SQL BLOB type for columns which hold very large binary values. | |
• | Use the SQL CLOB type for columns which hold very large string values. | |
• | Use the getBlob and getClob methods of the
java.sql.ResultSet interface to retrieve a LOB using its locator.
You can then materialize all or part of the LOB by calling Blob and
Clob methods. Alternatively, you can call the ResultSet.getBytes
method to materialize a BLOB, and you can call the ResultSet.getString
method to materialize a CLOB. |
• | LOB-types cannot be compared for equality (=) and non-equality (!=, <>). | |
• | LOB-typed values are not orderable, so <, <=, >, >= tests
are not supported. | |
• | LOB-types cannot be used in indices or as primary key columns. | |
• | DISTINCT, GROUP BY, and ORDER BY clauses are also prohibited on LOB-types. | |
• | LOB-types cannot be involved in implicit casting as other base-types. |
Returns | Signature | Implementation Notes |
byte[] | getBytes(long pos, int length) | Exceptions are raised if pos < 1, if pos is
larger than the length of the , or if length <= 0. |
long | position(byte[] pattern, long start) | Exceptions are raised if pattern == null, if start <
1, or if pattern is an array of length 0. |
long | position(Blob pattern, long start) | Exceptions are raised if pattern == null, if start <
1, if pattern has length 0, or if an exception is thrown when trying
to read the first byte of pattern. |
Returns | Signature | Implementation Notes |
String | getSubString(long pos, int length) | Exceptions are raised if pos < 1, if pos is
larger than the length of the Clob, or if length <= 0. |
long | position(Clob searchstr, long start) | Exceptions are raised if searchStr == null or start <
1, if searchStr has length 0, or if an exception is thrown when trying
to read the first char of searchStr. |
long | position(String searchstr, long start) | Exceptions are raised if searchStr == null or start <
1, or if the pattern is an empty string. |
• | getBlob | |
• | getClob | |
• | getAsciiStream | |
• | getBinaryStream | |
• | getCharacterStream |
ResultSet rs = s.executeQuery("SELECT text FROM CLOBS WHERE i = 1"); while (rs.next()) { aclob = rs.getClob(1); ip = rs.getAsciiStream(1); }
• | Applications must get and set DECIMAL values using alternate
JDBC getXXX and setXXX methods, such as getString() and setString().
Any alternate method that works against a DECIMAL type with JDBC 3.0
will work in JSR 169. | |
• | The XML data type is not supported, but an application can retrieve, update,
query, or otherwise access an XML data value if it has classes for a JAXP parser
and for Xalan in the classpath.
Derby issues an error if
either the parser or Xalan is not found. In some situations, you may need to
take steps to place the parser and Xalan in your classpath. See
"XML data types and operators" in the
Java DB Developer's Guide for details. |
• | Java functions and procedures that use server-side JDBC, that is, routines
declared with CONTAINS SQL, READS SQL DATA,
or MODIFIES SQL DATA clauses | |
• | The DriverManager interface (this means that you cannot use
the DriverManager.getConnection method to obtain
a connection but must use the
org.apache.derby.jdbc.EmbeddedSimpleDataSource class instead)
| |
• | The standard URL used to obtain a connection,
jdbc:default:connection (a runtime error may occur if the
routine tries to obtain a connection using
jdbc:default:connection) | |
• | Diagnostic tables | |
• | Triggers | |
• | Encrypted databases | |
• | Non-blocking I/O | |
• | Java EE resource manager support, including distributed transactions | |
• | Principal-based security | |
• | LDAP-based authentication | |
• | SSL/TLS encryption | |
• | Replication |
• | DataSources. To support the JDBC 4.0 ease of development,
Derby
introduces new implementations of javax.sql.DataSource. See
javax.sql.DataSource interface: JDBC 4.0 features.
| |
• | Autoloading of JDBC drivers. In earlier versions of JDBC,
applications had to manually register drivers before requesting
Connections. With JDBC 4.0, applications no longer need to issue a
Class.forName() on the driver name; instead, the DriverManager will
find an appropriate JDBC driver when the application requests a Connection.
| |
• | SQLExceptions. JDBC 4.0 introduces refined subclasses of SQLException. See Refined subclasses of SQLException. | |
• | Wrappers. JDBC 4.0 introduces the concept of wrapped JDBC
objects. This is a formal mechanism by which application servers can
look for vendor-specific extensions inside standard JDBC objects like
Connections, Statements, and ResultSets. For
Derby,
this is a vacuous exercise because
Derby
does not expose any of these extensions. | |
• | Statement events. With JDBC 4.0, Connection pools can listen for Statement closing and Statement error events. New methods were added to javax.sql.PooledConnection: addStatementEventListener and removeStatementEventListener. | |
• | Streaming APIs. JDBC 4.0 adds new overloads of the streaming methods in CallableStatement, PreparedStatement, and ResultSet. These are the setXXX and updateXXX methods which take java.io.InputStream and java.io.Reader arguments. The new overloads allow you to omit the length arguments or to specify long lengths. | |
• | New methods. New methods were added to the following interfaces:
javax.sql.Connection,
javax.sql.DatabaseMetaData,
and javax.sql.Statement.
See java.sql.Connection interface: JDBC 4.0 features,
java.sql.DatabaseMetaData interface: JDBC 4.0 features,
java.sql.Statement interface: JDBC 4.0 features. |
• | java.sql.SQLClientInfoException | |
• | java.sql.SQLDataException | |
• | java.sql.SQLFeatureNotSupportedException | |
• | java.sql.SQLIntegrityConstraintViolationException | |
• | java.sql.SQLInvalidAuthorizationSpecException | |
• | java.sql.SQLSyntaxErrorException | |
• | java.sql.SQLTransactionRollbackException | |
• | java.sql.SQLTransientConnectionException |
• | Capability reports - JDBC 4.0 adds new methods for
querying the capabilities of a database. These include
autoCommitFailureClosesAllResultSets,
providesQueryObjectGenerator,
getClientInfoProperties,
and supportsStoredFunctionsUsingCallSyntax.
| |
• | Column metadata - The getColumns method
reports IS_AUTOINCREMENT = YES if a column is generated. | |
• | Function metadata - JDBC 4.0 adds new methods for
inspecting the arguments and return types of functions, including
user-defined functions.
These new methods are getFunctions and
getFunctionColumns. These methods behave similarly to getProcedures and
getProcedureColumns. | |
• | Procedure metadata - The getProcedureColumns method
reports additional information about procedure arguments. For more
information, see the javadoc for this method. The new columns in the
ResultSet returned by getProcedureColumns are:
COLUMN_DEF,
SQL_DATA_TYPE,
SQL_DATETIME_SUB,
CHAR_OCTET_LENGTH,
ORDINAL_POSITION,
IS_NULLABLE,
and SPECIFIC_NAME. | |
• | Schema metadata - JDBC 4.0 adds a new getSchemas
overload, which lets you look up schemas based on a name
pattern. |
• | Pooling support - JDBC 4.0 adds new methods
to help application servers manage pooled Statements:
isPoolable
and setPoolable.
| |
• | Validity tracking - JDBC 4.0 lets you track the validity of
a Statement through the new
isClosed method.
|
• | org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40 | |
• | org.apache.derby.jdbc.EmbeddedDataSource40 | |
• | org.apache.derby.jdbc.EmbeddedXADataSource40 | |
• | org.apache.derby.jdbc.ClientConnectionPoolDataSource40 | |
• | org.apache.derby.jdbc.ClientDataSource40 | |
• | org.apache.derby.jdbc.ClientXADataSource40 |
• | JDBC escape keyword for call statements The escape keyword
for use in CallableStatements. | |
• | JDBC escape syntax The escape keyword
for date formats. | |
• | JDBC escape syntax for LIKE clauses The keyword
for specifying escape characters for LIKE clauses. | |
• | JDBC escape syntax for fn keyword The escape keyword
for scalar functions. | |
• | JDBC escape syntax for outer joins The escape keyword
for outer joins. | |
• | JDBC escape syntax for time formats The escape keyword
for time formats. | |
• | JDBC escape syntax for timestamp formats The escape keyword
for timestamp formats. |
WHERE CharacterExpression [ NOT ] LIKE CharacterExpressionWithWildCard { ESCAPE 'escapeCharacter' }
-- find all rows in which a begins with the character "%" SELECT a FROM tabA WHERE a LIKE '$%%' {escape '$'} -- find all rows in which a ends with the character "_" SELECT a FROM tabA WHERE a LIKE '%=_' {escape '='}
{fn functionCall}
• | Numeric functions | |
• | String functions | |
• | Date and time functions | |
• | System function |
abs(NumericExpression)
acos(number)
asin(number)
atan(number)
atan2(y, x)
ceiling(number)
cos(number)
cot(number)
degrees(number)
exp(number)
floor(number)
log(number)
log10(number)
mod(integer_type, integer_type)
pi()
radians(number)
rand(seed)
sign(number)
sin(number)
sqrt(FloatingPointExpression)
tan(number)
concat(CharacterExpression, CharacterExpression)
lcase(CharacterExpression)
length(CharacterExpression)
locate(CharacterExpression,CharacterExpression [, startIndex] )
ltrim(CharacterExpression)
rtrim(CharacterExpression)
substring(CharacterExpression, startIndex, length)
ucase(CharacterExpression)
curdate()
curtime()
hour(expression)
minute(expression)
month(expression)
second(expression)
TIMESTAMPADD( interval, integerExpression, timestampExpression )
TIMESTAMPDIFF( interval, timestampExpression1, timestampExpression2 )
year(expression)
• | SQL_TSI_DAY | |
• | SQL_TSI_FRAC_SECOND | |
• | SQL_TSI_HOUR | |
• | SQL_TSI_MINUTE | |
• | SQL_TSI_MONTH | |
• | SQL_TSI_QUARTER | |
• | SQL_TSI_SECOND | |
• | SQL_TSI_WEEK | |
• | SQL_TSI_YEAR |
{fn TIMESTAMPADD( SQL_TSI_MONTH, 1, CURRENT_TIMESTAMP)}
{fn TIMESTAMPDIFF(SQL_TSI_WEEK, CURRENT_TIMESTAMP, timestamp('2008-01-01-12.00.00.000000'))}
user()
-- outer join SELECT * FROM {oj Countries LEFT OUTER JOIN Cities ON (Countries.country_ISO_code=Cities.country_ISO_code)} -- another join operation SELECT * FROM {oj Countries JOIN Cities ON (Countries.country_ISO_code=Cities.country_ISO_code)} -- a TableExpression can be a joinOperation. Therefore -- you can have multiple join operations in a FROM clause SELECT E.EMPNO, E.LASTNAME, M.EMPNO, M.LASTNAME FROM {oj EMPLOYEE E INNER JOIN DEPARTMENT INNER JOIN EMPLOYEE M ON MGRNO = M.EMPNO ON E.WORKDEPT = DEPTNO};
• | Encrypt a new database | |
• | Configure an existing unencrypted database for encryption | |
• | Boot an existing encrypted database |
-- create a new, encrypted database jdbc:derby:newDB;create=true;dataEncryption=true; bootPassword=cseveryPlace -- configure an existing unencrypted database for encryption jdbc:derby:salesdb;dataEncryption=true;bootPassword=cseveryPlace -- boot an existing encrypted database jdbc:derby:encryptedDB;bootPassword=cseveryPlace
jdbc:derby:MexicanDB;create=true;territory=es_MX;collation=TERRITORY_BASED
• | jdbc:derby:toursDB | |
• | jdbc:derby:;databaseName=toursDB | |
• | jdbc:derby:(with a property databaseName and its value set
to toursDB in the Properties object passed into a connection
request) |
jdbc:derby:toursDB;databaseName=flightsDB
• | Encrypt a new database | |
• | Configure an existing unencrypted database for encryption | |
• | Boot an existing encrypted database |
jdbc:derby:newDB;create=true;dataEncryption=true; encryptionAlgorithm=DES/CBC/NoPadding;encryptionKey=6162636465666768
jdbc:derby:salesdb;dataEncryption=true;encryptionKey=6162636465666768
jdbc:derby:encryptedDB;encryptionKey=6162636465666768
-- create a new, encrypted database jdbc:derby:encryptedDB;create=true;dataEncryption=true; encryptionProvider=com.sun.crypto.provider.SunJCE; encryptionAlgorithm=DESede/CBC/NoPadding; bootPassword=cLo4u922sc23aPe -- configure an existing database for encryption jdbc:derby:salesdb;dataEncryption=true; encryptionProvider=com.sun.crypto.provider.SunJCE; encryptionAlgorithm=DESede/CBC/NoPadding; bootPassword=cLo4u922sc23aPe
algorithmName/feedbackMode/padding
-- encrypt a new database jdbc:derby:encryptedDB;create=true;dataEncryption=true; encryptionProvider=com.sun.crypto.provider.SunJCE; encryptionAlgorithm=DESede/CBC/NoPadding; bootPassword=cLo4u922sc23aPe -- configure an existing database for encryption jdbc:derby:salesdb;dataEncryption=true; encryptionProvider=com.sun.crypto.provider.SunJCE; encryptionAlgorithm=DESede/CBC/NoPadding; bootPassword=cLo4u922sc23aPe
• | 8, which specifies Strong Password Substitute security. If
you specify this mechanism, a strong password substitute is generated and used
to authenticate the user with the network server. The original password is
never sent in any form across the network. | |
• | 9, which specifies Encrypted UserID and Encrypted Password
security. If you specify this mechanism, both the user ID and the password are
encrypted. See "Enabling the encrypted user ID and password security mechanism"
in the Java DB Server and Administration Guide for additional
requirements for the use of this security mechanism. | |
• | 3, which specifies Clear Text Password security. Clear
Text Password security is the default if you do not specify the
securityMechanism attribute and you specify both the
user=userName
and
password=userPassword
attributes. | |
• | 4, which specifies User Only security. User Only security
is the default if you do not specify the securityMechanism attribute and
you specify the
user=userName
attribute but not the
password=userPassword
attribute. |
-- start master using database name in subprotocol, default slave -- port, authorization jdbc:derby:myDB;startMaster=true;slaveHost=elsewhere;user=mary; password=little88lamb
-- start master using databaseName attribute, non-default slave -- port, no security jdbc:derby:;databaseName=myDB;startMaster=true;slaveHost=elsewhere; slavePort=4852
1.
| Partially boots the specified database | |
2.
| Starts to listen on the specified port and accepts a connection from the
master | |
3.
| Hangs until the master has connected to it | |
4.
| Reports the startup status to the caller (whether it has started, and if
not, why not) | |
5.
| Continually receives chunks of the transaction log from the master and
applies the operations in the transaction log to the slave database |
-- start slave using database name in subprotocol, default slave host -- and port, authorization jdbc:derby:myDB;startslave=true;user=mary;password=little88lamb
-- start slave using databaseName attribute, non-default slave host -- and port, no security jdbc:derby:;databaseName=myDB;startSlave=true;slaveHost=localhost; slavePort=4852
Language Code | Description |
de | German |
en | English |
es | Spanish |
ja | Japanese |
Country Code | Description |
DE | Germany |
US | United States |
ES | Spain |
MX | Mexico |
JP | Japan |
jdbc:derby:MexicanDB;create=true;territory=es_MX
-- enable tracing on an existing database that will have multiple connections jdbc:derby://localhost:1527/mydb;traceDirectory=/home/mydir/mydbtracedir -- specify a trace file name within the directory jdbc:derby://localhost:1527/mydb;traceDirectory=/home/mydir/mydbtracedir;traceFile=trace.out -- append to the default trace file jdbc:derby://localhost:1527/mydb;traceDirectory=/home/mydir/mydbtracedir;traceFileAppend=true
-- enable tracing on an existing database, appending to the -- specified file jdbc:derby://localhost:1527/mydb;traceFile=trace.out;traceFileAppend=true -- enable tracing on an existing database, appending to the default file -- within the specified directory, relative to the Derby home directory jdbc:derby://localhost:1527/mydb;traceDirectory=mytracedir;traceFileAppend=true
Trace level | Hex value | Decimal value |
org.apache.derby.jdbc.ClientDataSource.TRACE_NONE | 0x0 | 0 |
org.apache.derby.jdbc.ClientDataSource.TRACE_CONNECTION_CALLS | 0x1 | 1 |
org.apache.derby.jdbc.ClientDataSource.TRACE_STATEMENT_CALLS | 0x2 | 2 |
org.apache.derby.jdbc.ClientDataSource.TRACE_RESULT_SET_CALLS | 0x4 | 4 |
org.apache.derby.jdbc.ClientDataSource.TRACE_DRIVER_CONFIGURATION | 0x10 | 16 |
org.apache.derby.jdbc.ClientDataSource.TRACE_CONNECTS | 0x20 | 32 |
org.apache.derby.jdbc.ClientDataSource.TRACE_PROTOCOL_FLOWS | 0x40 | 64 |
org.apache.derby.jdbc.ClientDataSource.TRACE_RESULT_SET_META_DATA | 0x80 | 128 |
org.apache.derby.jdbc.ClientDataSource.TRACE_PARAMETER_META_DATA | 0x100 | 256 |
org.apache.derby.jdbc.ClientDataSource.TRACE_DIAGNOSTICS | 0x200 | 512 |
org.apache.derby.jdbc.ClientDataSource.TRACE_XA_CALLS | 0x800 | 2048 |
org.apache.derby.jdbc.ClientDataSource.TRACE_ALL | 0xFFFFFFFF | -1 |
• | If you are using the ij tool, add the decimal values
together and specify the sum. For example, to trace both PROTOCOL flows and
connection calls, add the values for TRACE_PROTOCOL_FLOWS (64) and
TRACE_CONNECTION_CALLS (1). Specify the sum, the value 65. | |||||||
• | If you are running a JDBC program, do one of the following:
|
• | system-wide System-wide properties apply
to an entire system, including all its databases and tables if applicable.
| |||||||
• | database-wide A database-wide property
is stored in a database and is valid for that specific database only. |
• | As database-wide properties | |
• | As system-wide properties via a Properties object in the application
in which the Derby engine is
embedded |
1.
| [*] System-wide properties set programmatically (as a command-line option
to the JVM when starting the application or within application code) | |
2.
| Database-wide properties | |
3.
| [*] System-wide properties set in the derby.properties file |
Statement s = conn.createStatement(); s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" + "'derby.database.fullAccessUsers', null)");
ou=people,o=ExampleSite.com
(&(objectClass=inetOrgPerson)(uid=userName))
-- system-wide properties derby.authentication.ldap.searchFilter=objectClass=person ## people in the marketing department ## Derby automatically adds (uid=<userName>) derby.authentication.ldap.searchFilter=(&(ou=Marketing) (objectClass=person)) ## all people but those in marketing ## Derby automatically adds (uid=<userName>) derby.authentication.ldap.searchFilter=(&(!(ou=Marketing) (objectClass=person)) ## map %USERNAME% to user, not uid derby.authentication.ldap.searchFilter=(&((ou=People) (user=%USERNAME%)) ## cache user DNs locally and use the default for others derby.authentication.ldap.searchFilter=derby.user -- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.authentication.ldap.searchFilter', 'objectClass=person')
• | LDAP An external LDAP directory service. | |
• | BUILTIN Derby's
simple internal user authentication repository. | |
• | A complete Java class name A user-defined class that provides user
authentication. |
• | ||
• | ||
• | ||
• |
derby.authentication.server= [{ ldap: | ldaps: | nisplus: }] [//] { hostname [ :portnumber ] | nisServerName/nisDomain }
-- system-wide property ##LDAP example derby.authentication.server=godfrey:9090 ##LDAP example derby.authentication.server=ldap://godfrey:9090 ##LDAP example derby.authentication.server=//godfrey:9090 ##LDAP over SSL example derby.authentication.server=ldaps://godfrey:636/ -- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.authentication.server', 'godfrey:9090')
• | noAccess Disallows connections. | |
• | readOnlyAccess Grants read-only connections. | |
• | fullAccess Grants full access. |
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.defaultConnectionMode', '{ noAccess | readOnlyAccess | fullAccess}')
-- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.defaultConnectionMode', 'noAccess') -- system-wide property derby.database.defaultConnectionMode=noAccess
-- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.fullAccessUsers', 'commaSeparatedlistOfUsers')
-- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.fullAccessUsers', 'dba,fred,peter') --system-level property derby.database.fullAccessUsers=dba,fred,peter
-- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.readOnlyAccessUsers', 'commaSeparatedListOfUsers')
-- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.database.readOnlyAccessUsers', 'ralph,guest') -- system-level property derby.database.readOnlyAccessUsers=ralph,guest
• | TRUE SQL authorization for the database or system is enabled,
which allows the use of GRANT and REVOKE statements. | |
• | FALSE SQL authorization for the database or system is disabled.
After this property is set to TRUE, the property cannot be set back to
FALSE. |
-- system-wide property derby.jdbc.xaTransactionTimeout=120
-- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.jdbc.xaTransactionTimeout', '120')
derby.locks.deadlockTimeout=30 -- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.locks.deadlockTimeout', '30')
-- system property derby.locks.deadlockTrace=true CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.locks.deadlockTrace', 'true')
-- system-wide property derby.locks.escalationThreshold=1000 -- database-wide property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.locks.escalationThreshold', '1000')
-- system property derby.locks.monitor=true CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.locks.monitor', 'true')
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.locks.waitTimeout', '15') derby.locks.waitTimeout=60
(1 + derby.storage.initialPages) * derby.storage.pageSize
-- changing the default for the system derby.storage.minimumRecordSize=128 -- changing the default for the database CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.storage.minimumRecordSize', '128')
• | The size of the cache, configured with the
derby.storage.pageCacheSize property. | |
• | The size of the pages, configured with the
derby.storage.pageSize
property. Derby automatically
tunes for the database page size. If you have long columns, the default page
size for the table is set to 32768 bytes. Otherwise, the default is 4096
bytes. | |
• | Overhead, which varies with JVMs. |
-- modifying the default for the system derby.storage.pageReservedSpace=40 -- modifying the default for the database CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.storage.pageReservedSpace', '40')
-- changing the default for the system derby.storage.pageSize=8192 -- changing the default for the database CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.storage.pageSize', '8192')
ERROR XSDF1: Exception during creation of file c:\databases\db\tmp\T887256591756.tmp for container ERROR XJ001: Java exception: 'a:\databases\db\tmp\T887256591756.tmp: java.io.IOException'.
derby.storage.tempDirectory=C:/Temp/dbtemp
• | 20000 Errors that cause the statement to be rolled back, for example syntax errors
and constraint violations. | |
• | 30000 Errors that cause the transaction to be rolled back, for example
deadlocks. | |
• | 40000 Errors that cause the connection to be closed. | |
• | 50000 Errors that shut down the
Derby system. |
• | The log file at each commit | |
• | The log file before a data page is forced to disk | |
• | Page allocation when a file is grown | |
• | Data writes during checkpoints |
WARNING: The database is booted with derby.system.durability=test. In this mode, it is possible that database may not be able to recover, committed transactions may be lost, and the database may be in an inconsistent state. Please use this mode only when these consequences are acceptable.
• | Creates users and passwords when
derby.authentication.provider
is set to BUILTIN. | |
• | Caches user DNs locally when derby.authentication.provider is set to
LDAP and
derby.authentication.ldap.searchFilter
is set to derby.user. |
• | Database-Level Properties When you create users with
database-level properties, those users are available to the specified database
only. You set the property once for each user. To delete a user, set that user's
password to null. | |
• | System-Level Properties When you create users with system-level
properties, those users are available to all databases in the system. You set the value of this system-wide property once for each user, so you can
set it several times. To delete a user, remove that user from the file. You can define this property in the usual ways -- typically in the
derby.properties file. |
derby.user.{UserName=Password} | UserName=userDN }
-- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.user.UserName', 'Password | userDN')
-- system-level property derby.user.guest=java5w
derby.user.sa=Derby3x9 derby.user."!Amber"=java5w -- database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.user.sa', 'Derby3x9') -- cache a userDN locally, database-level property CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( 'derby.user.richard', 'uid=richard, ou=People, o=ExampleSite.com')
• | JNDI support Allows calling applications to register names for databases
and access them through those names instead of through database connection
URLs. Implementation of one of the JDBC interfaces, javax.sql.DataSource, provides
this support. | |
• | Connection pooling A mechanism by which a connection pool server keeps
a set of open connections to a resource manager (Derby).
A user requesting a connection can get one of the available connections from
the pool. Such a connection pool is useful in client/server environments because
establishing a connection is relatively expensive. In an embedded environment,
connections are much cheaper, making the performance advantage of a connection
pool negligible. Implementation of two of the JDBC interfaces, javax.sql.ConnectionPoolDataSource
and javax.sql.PooledConnection, provide this support. | |
• | XA support XA is one of several standards for distributed transaction
management. It is based on two-phase commit. The javax.sql.XAxxx interfaces,
along with java.transaction.xa package, are an abstract implementation
of XA. For more information about XA, see X/Open CAE Specification-Distributed
Transaction Processing: The XA Specification, X/Open Document No. XO/CAE/91/300
or ISBN 1 872630 24 3. Implementation of the JTA API, the interfaces of the
java.transaction.xa package (javax.sql.XAConnection,javax.sql.XADataSource,javax.transaction.xa.XAResource,javax.transaction.xa.Xid, and javax.transaction.xa.XAException),
provides this support. |
• | setCreateDatabase(String create) Sets a property
to create a database at the next connection. The string argument must be "create". | |
• | setShutdownDatabase(String shutdown) Sets a property to shut
down a database. Shuts down the database at the next connection. The string
argument must be "shutdown". |
• | org.apache.derby.tools.ij An SQL scripting tool that can run
as an embedded or a remote client/server application. See the Java DB Tools and Utilities Guide. | |
• | org.apache.derby.tools.sysinfo A command-line, server-side utility that displays information about your
JVM and Derby product.
See the Java DB Tools and Utilities Guide. | |
• | org.apache.derby.tools.dblook A utility to view all or parts
of the Data Definition Language (DDL) for a given database. See the Java DB Tools and Utilities Guide. |
• | org.apache.derby.jdbc.EmbeddedDataSource and org.apache.derby.jdbc.EmbeddedDataSource40 | |
• | org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource and org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40 | |
• | org.apache.derby.jdbc.EmbeddedXADataSource and org.apache.derby.jdbc.EmbeddedXADataSource40 |
• | org.apache.derby.jdbc.ClientDataSource and org.apache.derby.jdbc.ClientDataSource40 | |
• | org.apache.derby.jdbc.ClientConnectionPoolDataSource and org.apache.derby.jdbc.ClientConnectionPoolDataSource40 | |
• | org.apache.derby.jdbc.ClientXADataSource and org.apache.derby.jdbc.ClientXADataSource40 |
Value | Limit |
Maximum columns in a table | 1,012 |
Maximum columns in a view | 5,000 |
Maximum number of parameters in a stored procedure | 90 |
Maximum indexes on a table | 32,767 or storage capacity |
Maximum tables referenced in an SQL statement or a
view | storage capacity |
Maximum elements in a select list | 1,012 |
Maximum predicates in a WHERE or HAVING clause | storage capacity |
Maximum number of columns in a GROUP BY clause | 32,677 |
Maximum number of columns in an ORDER BY clause | 1,012 |
Maximum number of prepared statements | storage capacity |
Maximum declared cursors in a program | storage capacity |
Maximum number of cursors opened at one time | storage capacity |
Maximum number of constraints on a table | storage capacity |
Maximum level of subquery nesting | storage capacity |
Maximum number of subqueries in a single statement | storage capacity |
Maximum number of rows changed in a unit of work | storage capacity |
Maximum constants in a statement | storage capacity |
Maximum depth of cascaded triggers | 16 |
Value | Limit |
Smallest DATE value | 0001-01-01 |
Largest DATE value | 9999-12-31 |
Smallest TIME value | 00:00:00 |
Largest TIME value | 24:00:00 |
Smallest TIMESTAMP value | 0001-01-01-00.00.00.000000 |
Largest TIMESTAMP value | 9999-12-31-23.59.59.999999 |
Identifier | Maximum number of characters
allowed |
constraint name | 128 |
correlation name | 128 |
cursor name | 128 |
data source column name | 128 |
data source index name | 128 |
data source name | 128 |
savepoint name | 128 |
schema name | 128 |
unqualified column name | 128 |
unqualified function name | 128 |
unqualified index name | 128 |
unqualified procedure name | 128 |
parameter name | 128 |
unqualified trigger name | 128 |
unqualified table name, view name, stored procedure
name | 128 |
Value | Limit |
Smallest INTEGER | -2,147,483,648 |
Largest INTEGER | 2,147,483,647 |
Smallest BIGINT | -9,223,372,036,854,775,808 |
Largest BIGINT | 9,223,372,036,854,775,807 |
Smallest SMALLINT | -32,768 |
Largest SMALLINT | 32,767 |
Largest decimal precision | 31 |
Smallest DOUBLE | -1.79769E+308 |
Largest DOUBLE | 1.79769E+308 |
Smallest positive DOUBLE | 2.225E-307 |
Largest negative DOUBLE | -2.225E-307 |
Smallest REAL | -3.402E+38 |
Largest REAL | 3.402E+38 |
Smallest positive REAL | 1.175E-37 |
Largest negative REAL | -1.175E-37 |
Value | Maximum Limit |
Length of CHAR | 254 characters |
Length of VARCHAR | 32,672 characters |
Length of LONG VARCHAR | 32,700 characters |
Length of CLOB | 2,147,483,647 characters |
Length of BLOB | 2,147,483,647 characters |
Length of character constant | 32,672 |
Length of concatenated character string | 2,147,483,647 |
Length of concatenated binary string | 2,147,483,647 |
Number of hex constant digits | 16,336 |
Length of DOUBLE value constant | 30 characters |
Issue | Limitation |
Length of XML | 2,147,483,647 characters |
Use of XML operators | Requires that the JAXP parser classes (such as Apache
Xerces) and the Apache Xalan classes are in the classpath. Attempts to use
XML operators without these classes in the classpath result in an error. In
some situations, you may need to take steps to place the parser and Xalan in
your classpath. See "XML data types and operators" in the
Java DB Developer's Guide for details. |