How to retrieve data from Firebird DB with missing user collation? - firebird

I've got a Firebird DB (FDB file) that I can connect to just fine. However, one of the tables uses a user-defined collation, which apparently was defined via an fbintl_xyz.dll extension. That extension is not available to me.
Accessing that table consequently results in
COLLATION UTF8_XYZ for CHARACTER SET UTF8 is not installed
Is there any way around this?
I only need read access, and I don't care about collation support (ordering, upper case/lower case).

Related

Postgres - could not determine which collation to use for string comparison

I read up several web pages, all spoke about upgrading from Postgres pre-9.0 edition to post-9.1 edition.
www.peterbe.com/plog/postgres-collation-citext-9.1
servoytipsfromsovan.wordpress.com/2014/08/20/migrating-postgres-sql-from-v9-0-to-latest-version/
nandovieira.com/using-insensitive-case-columns-in-postgresql-with-citext
stackoverflow.com/questions/15981197/postgresql-error-type-citext-does-not-exist
databasecm.blogspot.sg/2015/03/where-do-you-find-citext-module-in.html
dba.stackexchange.com/questions/17609/how-do-i-resolve-postgresql-error-no-collation-was-derived-for-column-foo-w
In my case, I upgraded from 9.4 to 9.5. The issue for me is, some database threw the error (as stated on the title) whenever I run a SELECT query yet some don't. I setup a separate test server with 9.4, the query runs well.
I do not need to compare case insensitive. In postgres 9.4, I did not load citext too. In fact all my string comparisons are to be case sensitive unless I use "ILIKE". I also loaded citext individually to ALL the databases in the server.
What information do I need to provide to you so that I can find out why some database works, some don't. And how do I solve the problem I encountered.

In PostgreSQL on Windows what effect does the locale have on a database itself

I have a database that has been created on a database server that was installed with "Default Locale" selected where asked for "Select the locale to be used by the new database cluster". It should have been set to a specific locale. Can I just change that afterwards, or do I have to create the database from scratch?
It affects the text encoding ("code page") chosen for the DB, as well as the collation (sort order) used for text.
Changing either requires that you dump the database, drop it, re-create it and restore a dump.
When creating the database you can specify a specific ENCODING, LC_CTYPE, LC_COLLATE etc to override the DB-system-wide defaults. You must use TEMPLATE template0 if you want to change the encoding when creating a DB.
The locale used when creating the cluster sets the locale of the template databases. This in turn affects the locale of any further databases you create in the cluster since they are initialized by copying a template database (if you don't specify another locale when creating the database - see below).
The locale affects aspects such as the collation and the encoding. Encoding is the way in which characters are encoded into bytes in the database.
You can specify a collation or encoding when creating a database, but only if creating the database from template0. See CREATE DATABASE
You cannot change the encoding of an existing database. You would have to dump and reload the database to get a different encoding.

Postgres.pgadmin. How to configure encoding?

I have installed postgreSQL.
I use pgAdminIII as admin panel.
I am trying to watch tables content and see following:
How to avoid encoding problem?
For a UTF8 database, pgAdmin should always display strings correctly. The most likely explanation is that the data itself is incorrect.
This generally happens when a client application sends data in a format which doesn't match its client_encoding setting. If this is the case, setting client_encoding correctly would prevent this from happening (provided the client application's code page is supported by Postgres). This wouldn't fix the existing data, but it might be possible to repair it with the convert function.

How do I change the collation for a CRM 2011 SQL database?

I have a collection of CRM 2011 databases, all of which are installed on the same SQL server running SQL 2008 R2. One of those databases has a collation of Modern_Spanish_Cl_Al, while all of the others are set to Latin1_General_Cl_Al. I want all of them to be set to Latin1, so I would like to go back and fix the Spanish database to be like the others.
How do I change the database collation from Modern_Spanish_Cl_Al to Latin1_General_Cl_Al?
I tried doing it at the database level using the UI, but I received a million errors like:
The statistics 'TeamBase.fndx_Sync_VersionNumber' is dependent on database collation. The database collation cannot be changed if a schema-bound object depends on it. Remove the dependencies on the database collation and then retry the operation.
I tried going to the column level while also using the UI, but received a different error message:
Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created...
I am dealing with this issue in a test environment, so I am willing to experiment, and I realize that what I am trying to do might not be possible without breaking CRM.
Did you try creating a new DB with the correct collation
CREATE DATABASE DatabaseName COLLATE Latin1_General_Cl_Al;
And then Backup-Restore your DB with incorrect collation into the new one?
Should this work, you'll have to import a new organization based on your new database, using the Import Organization Wizard in the Deployment Manager.
edit
After looking into this, it seems quite hard to change collation, even when doing backup/restore.
Your only option if you want to change the collation on the database level seems to be an
ALTER DATABASE ... COLLATE
but that will only affect new objects. You would then have to use ALTER TABLE to change your existing tables.
In addition, because the collation specifies how data is sorted and stored, you need to export all your data and bring it in again (using BCP and BULK INSERT for instance).
To add to this, certain properties of a column prevents its collation from being changed (such as certain constraints and schema bound function references). If you do want to change the collation of the entire database, the easiest way is probably to script the database and create a new with the right collation and then shuffle the data into the new database.

PostgreSQL Field Name

The project which I am working now is upgrading the database from mysql to postgreSQL in Zend framework. I had migrated the database to PostgreSQL through "ESF Database Migration Toolkit". How ever the field names like "Emp_FirstName", "Emp_LastName" etc are stored in PostgreSQL as "emp_firstname" and "emp_lastname". This caused Errors in code. However when I updated the filed in PostgreSQL to Emp_FirstName it showing error
********** Error **********
ERROR: column "Emp_FirstName" does not exist
SQL state: 42703
Character: 8
Is it possible to give filed name exactly like in MYSQL?
The migration tool isn't "double quoting" identifiers, so their case is being flattened to lower-case by PostgreSQL. Your code must be quoting the identifiers so they're case-preserved. PostgreSQL is case sensitive and case-flattens unquoted identifiers, wheras MySQL is case-insensitive on Windows and Mac and case-sensitive on *nix.
See the PostgreSQL manual section on identifiers and keywords for details on PostgreSQL's behaviour. You should probably read that anyway, so you understand how string quoting works among other things.
You need to pick one of these options:
Change your code not to quote identifiers;
Change your migration tool to quote identifiers when creating the schema;
Hand migrate the schema instead of using a migration tool;
Fix the quoting of identifers in the tool-generated SQL by hand; or
lower-case all identifiers so it doesn't matter for Pg
The last option won't help you when you add Oracle support and discover that Oracle upper-cases all identifiers, so I'd recommend picking one of the first four options. I didn't find a way to get the migration tool to quote identifiers in a quick 30second Google search, but didn't spend much time on it. I'd look for options to control quoting mode in the migration tool first.
PostgreSQL does not have a configuration option to always treat identifiers as quoted or to use case-insensitive identifier comparisons.
This is far from the only incompatibility you will encounter, so be prepared to change queries and application code. In some cases you might even need one query for MySQL and another for PostgreSQL if you plan to continue to support MySQL.
If you weren't using sql_mode = ANSI and using STRICT mode in MySQL you'll have a lot more trouble with porting than if you were using those options, since both options bring MySQL closer to SQL standard behaviour.