PostgreSQL – String Sorting Sequence (LC_COLLATE and LC_CTYPE)

Obviously, since version 8.4, PostgreSQL allows each database to use a different locale.
So I went to the document to read about the locale (http://www. postgresql .org/docs/8.4/static/locale.html).

The string sort order is of particular interest to me (I want the string sort to be’A abc D d’instead of ‘ ABC… Z ab c’).

Question 1: Do I only need to set LC_COLLATE (string sort order) when creating a database?

I also read about LC_CTYPE (character classification (what is a letter? Its capital equivalent?))

Question 2: Can someone explain what this means?

The sort order you describe is the standard in most locales.
Try it :

SELECT regexp_split_to_table('D da A c b', '') ORDER BY 1;

When using initdb to initialize the database cluster, You can use –locale=some_locale to select the locale. In my case, it is –locale=de_AT.UTF-8. If no locale is specified to inherit from the environment-your current system locale will be used.

< p>The cluster’s template database will be set to this locale. When you create a new database, it will inherit the settings from the template. Normally you don’t have to worry about anything, it all works.

Read the CREATE DATABASE chapter to learn more More information.
If you want to speed up the indexed text search speed, please be sure to read the content about operator classes.
All links to version 8.4, as you specifically requested.

In In PostgreSQL 9.1 or later, there is collation support to allow more flexible use of classification:

The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation. This alleviates the restriction that the LC_COLLATE and LC_CTYPE settings of a database cannot be changed after its creation.

Obviously , Since version 8.4, PostgreSQL allows each database to use a different locale.
So I went to the document to read about the locale (http://www.postgresql.org/docs/8.4/static/locale.html ).

Characters The string sort order is of particular interest to me (I want the string sort to be’A abc D d’instead of’ABC… Z ab c’).

Question 1: Do you only need to set up when creating a database? LC_COLLATE (string sort order)?

I also read about LC_CTYPE (character classification (what is a letter? Its capital equivalent?))

Question 2: Can someone explain what this means?

The sort order you describe is the standard in most locales.
Try it:

< /p>

SELECT regexp_split_to_table('D da A c b', '') ORDER BY 1;

When using initdb to initialize the database cluster, you can use –locale = some_locale to select the locale. Just me In terms, it is –locale=de_AT.UTF-8. If no locale is specified to inherit from the environment-your current system locale will be used.

The cluster’s template database will be set to that locale When you create a new database, it inherits settings from the template. Normally you don’t have to worry about anything, it all works.

Read the CREATE DATABASE chapter for more information.
If you want to speed up indexing For text search speed, please be sure to read about operator classes.
All links to version 8.4, as you have specifically requested.

In PostgreSQL 9.1 or later, collation support is allowed More flexible use of classification:

The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation. This alleviates the restriction that the LC_COLLATE and LC_CTYPE settings of a database cannot be changed after its creation.

Leave a Comment

Your email address will not be published.