Is it safe to change Collation on Postgres (keeping encoding)? - postgresql

I have a Postgres 9.3 database which, by mistake, has been set to:
but I need it to be:
Since the Encoding doesn't change, it is safe to dump the DB and restore it later (see here) to a database with the new Collation / Character type?

Perfectly safe -- the collation is just telling Postgres which set of rules to apply when sorting text.
You can even set it dynamically on a query basis in the order by clause, and should be able to alter it without needing to dump the database.

Related

Alter TYPE RENAME VALUE works in Postgres 10 but not in Postgres 9.6?

I am using Postgres 10.3.
Based on this question, I use:
ALTER TYPE name RENAME VALUE attribute_name TO new_attribute_name
to rename an enum value.
But I need a solution that works with Postgres 9.6 that does not require updating pg_enum manually because it needs permissions that I don't have.
There is no supported way to rename an enum value in PostgreSQL 9.6.
Directly modifying pg_enum is something you should not only rule out because of permission issues, but also because directly messing with the system catalogs is dangerous and may destroy your data.
You should use enums with care. They are only good if they never need to be modified. If there is a chance that the enum values won't be immutable, use a lookup table instead.

how can i change the "character type" of a database in postgresql?

I'm using postgreSQL 9.1
I've set the Collation and the Character Type of the database to Greek_Greece.1253 and I want to change it to utf8
To change the collation I should use this, right?
But how can I change the character type?
Thanks
EDIT
I ment to wright C instead of utf8. I would like to change the Collation and the Character Type to C
You cannot change default collation of an existing database. You need to CREATE DATABASE with the collation you need and then dump/restore your schema and data into it.
If you do not want to recreate the database - you can specify collation for every text collumn in your db.
Here is detailed postgres manual on collations: Collation Support.
First line of this manual page states:
LC_COLLATE and LC_CTYPE settings of a database cannot be changed after
its creation.
CREATE DATABASE, pg_dump, pg_restore

Force Postgres shift to uppercase rather than lowercase before sorting case insensitive?

I try to migrate to postgres from pervasive. In pervasive there was something like 'upper.alt' - alternative collation. I don't really know how it works, but I have to make my new postgres database to behave like pervasive with this collation.
I use Postgres 9.2.4 and utf-8 encoding and LC_COLLATE='Polish_Poland.1250' .
You can try and order with COLLATE "C". That would get what you want in your example. It has side effects though! Effectively everything is ordered according to the byte values of the encoded character.
WITH x(col) AS (
VALUES
('ABC_AAAAA')
,('ABC_BBBBB')
,('ABC_ZZZZZ')
,('ABCAAAAA')
,('ABCBBBBB')
,('ABCZZZZZ')
)
SELECT *
FROM x
ORDER BY col COLLATE "C"
This option to change the collation for individual expressions (as opposed to using a collation defined at creation time of the db) was introduced with Postgres 9.1.
More about collation in the manual here.

How to add collations UNICODE_CI/_AI to an old database

I have an old database running on a Firebird 2.5 server, on which is missing the collations UNICODE_AI and UNICODE_CI. Direct selection on meta tables is indicating this.
select * from RDB$COLLATIONS where rdb$collation_name like 'U%'
returns UNICODE, UNICODE_FSS, UTF8 and UCS_BASIC.
How can I add these collation to my current database?
Doing a backup restore of the meta table solve the issue.

firebird set case insensitive collation

How can I set case insensitive collation for the whole database?
Do I have to recreate the tables and data?
Database is firebird 2.5
Quote from the release notes:
The character set and collation of existing columns are not affected by ALTER CHARACTER SET changes.
So yes, it seems that the best way would be to recreate the database with desired default character set and collation (and / or with explicit definitions in domains).