Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to script a check of the collations used on my tables in PostgreSQL, but googling for Postgresql detect collation is not working well for me, and the documentation is not making this an easy search.

Can anyone tell me how I would check this?

share|improve this question
add comment

1 Answer 1

up vote 10 down vote accepted

To check for non-default collations on columns, you can use the following query:

select table_schema, 
       table_name, 
       column_name,
       collation_name
from information_schema.columns
where collation_name is not null
order by table_schema,
         table_name,
         ordinal_position;

Edit: to find the collation of the database, you need to query `pg_database:

select datname, 
       datcollate
from pg_database;

Here is the link to the relevant parts of the manual

share|improve this answer
    
Hmm... and how can I tell what the default collation is? –  Jeremy Holovacs Dec 6 '12 at 21:52
    
@JeremyHolovacs: see my edit. –  a_horse_with_no_name Dec 6 '12 at 21:56
    
Thanks, that helped a lot. –  Jeremy Holovacs Dec 6 '12 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.