# Creating a database with locale-based collation

By default, Derby uses Unicode codepoint collation. However, you can specify locale-based collation when you create the database.

You can use the collation=collation and territory=ll_CC connection URL attributes to specify locale-based collation (see the Derby Reference Manual for details on these attributes). This type of collation applies only to user-defined tables. The system tables use the Unicode codepoint collation.

Restriction: The collation=collation and territory=ll_CC attributes can be specified only when you create a database. You cannot specify these attributes on an existing database or when you upgrade a database.

To create a database with locale-based collation, specify the language and country codes for the territory=ll_CC attribute, and the TERRITORY_BASED value for the collation=collation attribute, when you create the database.

For example, you could use the following connection URL:

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

See the documentation of the territory=ll_CC and collation=collation attributes in the Derby Reference Manual for details on these attributes. See Creating a case-insensitive database for information on making the database use case-insensensitive searches.

Parent topic: Working with the database connection URL attributes
Related concepts
Character-based collation in Derby
How collation works in Derby
Locale-based collation
Database connection URL attributes that control collation
Examples of case-sensitive and case-insensitive string sorting
Differences between LIKE and equal (=) comparisons
Related tasks
Creating a case-insensitive database
Creating a customized collator