Java DB

Apache Derby

Derby Reference Manual

Derby Getting Started
Derby Reference Manual
Derby Developer's Guide
Derby Performance Tuning
Derby Server and Admin Guide
Derby Tools and Utilities
Derby Reference Manual
-SQL language reference
-Capitalization and special characters
-SQL identifiers
-Rules for SQL92 identifiers
-SQL92Identifier
-column-Name
-correlation-Name
-new-table-Name
-schemaName
-Simple-column-Name
-synonym-Name
-table-Name
-view-Name
-index-Name
-constraint-Name
-cursor-Name
-TriggerName
-
-RoleName
-Interaction with the dependency system
-ALTER TABLE
-CALL (PROCEDURE)
-CREATE statements
-DECLARE GLOBAL TEMPORARY TABLE
-DELETE
-DROP statements
-GRANT
-INSERT
-LOCK TABLE
-RENAME statements
-REVOKE
-SET statements
-SELECT
-UPDATE
-SQL clauses
-SQL expressions
-JOIN operations
-SQL queries
-Built-in functions
-Standard built-in functions
-Aggregates (set functions)
-ABS or ABSVAL function
-ACOS function
-ASIN function
-ATAN function
-ATAN2 function
-AVG function
-BIGINT function
-CASE expressions
-CAST function
-CEIL or CEILING function
-CHAR function
-COALESCE function
-Concatenation operator
-COS function
-COSH function
-COT function
-COUNT function
-COUNT(*) function
-CURRENT DATE function
-CURRENT_DATE function
-CURRENT ISOLATION function
-CURRENT_ROLE function
-CURRENT SCHEMA function
-CURRENT TIME function
-CURRENT_TIME function
-CURRENT TIMESTAMP function
-CURRENT_TIMESTAMP function
-CURRENT_USER function
-DATE function
-DAY function
-DEGREES function
-DOUBLE function
-EXP function
-FLOOR function
-HOUR function
-IDENTITY_VAL_LOCAL function
-INTEGER function
-LCASE or LOWER function
-LENGTH function
-LN or LOG function
-LOG10 function
-LOCATE function
-LTRIM function
-MAX function
-MIN function
-MINUTE function
-MOD function
-MONTH function
-NULLIF expressions
-PI function
-RADIANS function
-RANDOM function
-RAND function
-ROW_NUMBER function
-RTRIM function
-SECOND function
-SESSION_USER function
-SIGN function
-SIN function
-SINH function
-SMALLINT function
-SQRT function
-SUBSTR function
-SUM function
-TAN function
-TANH function
-TIME function
-TIMESTAMP function
-TRIM function
-UCASE or UPPER function
-USER function
-VARCHAR function
-XMLEXISTS operator
-XMLPARSE operator
-XMLQUERY operator
-XMLSERIALIZE operator
-YEAR function
-Built-in system functions
-Built-in system procedures
-SYSCS_B ACKUP_D ATABASE
-SYSCS_BAC KUP_DATAB ASE_NOWAIT
-SYSCS_BACKUP_DAT ABASE_AND_ENABLE _LOG_ARCHIVE_MODE
-SYSCS_BACKUP_DATAB ASE_AND_ENABLE_LOG ARCHIVE_MODE_NOWAIT
-SYSCS_EMP TY_STATEM ENT_CACHE
-SYSCS_CH ECKPOINT _DATABASE
-SYSCS_COMPRESS_TABLE
-SYSCS_INP LACE_COMP RESS_TABLE
-SYSCS_DISA BLE_LOG_AR CHIVE_MODE
-SYSCS_EXPORT_TABLE
-SYSCS_EXPOR T_TABLE_LOB S_TO_EXTFILE
-SYSCS_EXPORT_QUERY
-SYSCS_EXPOR T_QUERY_LOB S_TO_EXTFILE
-SYSCS_IMPORT_DATA
-SYSCS_IMPOR T_DATA_LOBS FROM_EXTFILE
-SYSCS_IMPORT_TABLE
-SYSCS_IMPORT _TABLE_LOBS_ FROM_EXTFILE
-SYSCS_F REEZE_D ATABASE
-SYSCS_U NFREEZE DATABASE
-SYSCS_REL OAD_SECUR ITY_POLICY
-SYSCS_SET _DATABASE _PROPERTY
-SYSCS_SET _RUNTIMES TATISTICS
-SYSCS_SET _STATISTI CS_TIMING
-SYSCS_S ET_XPLA N_SCHEMA
-SYSCS_S ET_XPLA IN_MODE
-SYSCS_S ET_USER _ACCESS
-SYSCS_U PDATE_S ATISTICS
-SYSCS_DIAG diagnostic tables and functions
-Data types
-Argument matching
-SQL reserved words
-Derby support for SQL-92 features
-Derby system tables
-XPLAIN style tables
-Derby exception messages and SQL states
-JDBC reference
-java.sql.Driver interface
-java. sql. DriverManager. getConnection method
-java.sql.Connection interface
-java. sql. DatabaseMetaData interface
-java.sql.Statement interface
-java. sql. CallableStatement interface
-java. sql. PreparedStatement interface
-java.sql.ResultSet interface
-java. sql. ResultSetMetaData interface
-java.sql.SQLException class
-java.sql.SQLWarning class
-java.sql.Savepoint interface
-Mapping of java. sql. Types to SQL types
-JDBC Package for Connected Device Configuration/Foundation Profile (JSR 169)
-JDBC 4.0-only features
-Setting attributes for the database connection URL
-bootPassword= key attribute
-collation= collation attribute
-create= true attribute
-createFrom= path attribute
-databaseName= nameofDatabase attribute
-dataEncryption= true attribute
-drop= true attribute
-encryptionKey= key attribute
-encryptionProvider= providerName attribute
-encryptionAlgorithm= algorithm attribute
-failover= true attribute
-logDevice= logDirectoryPath attribute
-newEncryptionKey= key attribute
-newBootPassword= newPassword attribute
-password= userPassword attribute
-restoreFrom= path attribute
-rollForwardRecoveryFrom= path attribute
-securityMechanism= value attribute
-shutdown= true attribute
-slaveHost= hostname attribute
-slavePort= portValue attribute
-startMaster= true attribute
-startSlave= true attribute
-stopMaster= true attribute
-stopSlave= true attribute
-territory= ll_CC attribute
-traceDirectory= path attribute
-traceFile= path attribute
-traceFileAppend= true attribute
-traceLevel= value attribute
-upgrade= true attribute
-user= userName attribute
-ssl= sslMode attribute
-Creating a connection without specifying attributes
-Derby property reference
-Scope of Derby properties
-Dynamic and static properties
-Derby properties
-derby. authentication. builtin. algorithm
-derby. authentication. ldap. searchAuthDN
-derby. authentication. ldap. searchAuthPW
-derby. authentication. ldap. searchBase
-derby. authentication. ldap. searchFilter
-
-
-derby. connection. requireAuthentication
-derby. database. defaultConnectionMode
-derby. database. forceDatabaseLock
-
-
-
-derby. database. readOnlyAccessUsers
-derby. database. sqlAuthorization
-derby.infolog.append
-derby. jdbc. xaTransactionTimeout
-
-derby. language. logStatementText
-
-
-derby. locks. escalationThreshold
-derby.locks.monitor
-
-derby. replication. logBufferSize
-derby. replication. maxLogShippingInterval
-derby. replication. minLogShippingInterval
-
-
-derby. storage. minimumRecordSize
-
-derby. storage. pageReservedSpace
-
-
-
-
-
-
-derby. stream. error. logSeverityLevel
-derby.system.bootAll
-
-derby.system.home
-derby.user.UserName
-J2EE Compliance: Java Transaction API and javax. sql Interfaces
-Derby API
-Supported territories
-Derby limitations

 

CREATE INDEX statement

A CREATE INDEX statement creates an index on a table. Indexes can be on one or more columns in the table.

Syntax

CREATE [UNIQUE] INDEX index-Name
ON table-Name ( Simple-column-Name [ ASC | DESC ]
    [ , Simple-column-Name [ ASC | DESC ]] * )

The maximum number of columns for an index key in Derby is 16.

An index name cannot exceed 128 characters.

A column must not be named more than once in a single CREATE INDEX statement. Different indexes can name the same column, however.

Derby can use indexes to improve the performance of data manipulation statements (see Tuning Derby). In addition, UNIQUE indexes provide a form of data integrity checking.

Index names are unique within a schema. (Some database systems allow different tables in a single schema to have indexes of the same name, but Derby does not.) Both index and table are assumed to be in the same schema if a schema name is specified for one of the names, but not the other. If schema names are specified for both index and table, an exception will be thrown if the schema names are not the same. If no schema name is specified for either table or index, the current schema is used.

By default, Derby uses the ascending order of each column to create the index. Specifying ASC after the column name does not alter the default behavior. The DESC keyword after the column name causes Derby to use descending order for the column to create the index. Using the descending order for a column can help improve the performance of queries that require the results in mixed sort order or descending order and for queries that select the minimum or maximum value of an indexed column.

If a qualified index name is specified, the schema name cannot begin with SYS.

Indexes and constraints

Unique, primary key, and foreign key constraints generate indexes that enforce or "back" the constraint (and are thus sometimes called backing indexes). If a column or set of columns has a UNIQUE or PRIMARY KEY constraint on it, you can not create an index on those columns. Derby has already created it for you with a system-generated name. System-generated names for indexes that back up constraints are easy to find by querying the system tables if you name your constraint. Adding a PRIMARY KEY or UNIQUE constraint when an existing UNIQUE index exists on the same set of columns will result in two physical indexes on the table for the same set of columns. One index is the original UNIQUE index and one is the backing index for the new constraint.

To find out the name of the index that backs a constraint called FLIGHTS_PK:

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);

Page size and key size

Note: The size of the key columns in an index must be equal to or smaller than half the page size. If the length of the key columns in an existing row in a table is larger than half the page size of the index, creating an index on those key columns for the table will fail. This error only occurs when creating an index if an existing row in the table fails the criteria. After an index is created, inserts may fail if the size of their associated key exceeds the criteria.

Statement dependency system

Prepared statements that involve SELECT, INSERT, UPDATE, UPDATE WHERE CURRENT, DELETE, and DELETE WHERE CURRENT on the table referenced by the CREATE INDEX statement are invalidated when the index is created. Open cursors on the table are not affected.

 

javadb@jdbcurl.com