Keywords: collation, database attribute, TERRITORY_BASED, collation attribute

# collation=collation attribute

#### Function

The `collation` attribute is an optional attribute that specifies whether collation is based on the territory specified for the database or Unicode codepoint collation. The valid values for the `collation` attribute are: TERRITORY_BASED and UCS_BASIC. The default collation is Unicode codepoint collation (UCS_BASIC).

Restriction: The `collation` attribute can be specified only when you create a database. You cannot specify this attribute on an existing database or when you upgrade a database.

If you include the `collation` attribute with the value TERRITORY_BASED when you create the Derby database, the collation is based on the language and country codes that you specify with the `territory` attribute.

If you do not specify the `territory` attribute when you create the database, Derby uses the `java.util.Locale.getDefault` method to determine the current value of the default locale for this instance of the Java Virtual Machine (JVM).

Note: The `collation` attribute applies only to user-defined tables. The system tables use the Unicode codepoint collation.

#### Example

The following example shows the URL to create the `MexicanDB` database. The territory attribute specifies Spanish for the language code and Mexico for the country code. The `collation` attribute specifies that the collation for the database is territory based.

    jdbc:derby:MexicanDB;create=true;territory=es_MX;collation=TERRITORY_BASED

For information on how Derby handles collation, see "Character-based collation in Derby" in the Java DB Developer's Guide
Parent topic: Setting attributes for the database connection URL