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.
Related
Working with PostgreSQL, DataGrip converts all names of created tables/columns to lowercase. How to disable it and keep original formatting? I prefer PascalCase.
It happens even if I run a SQL command manually in DataGrip console:
create table FooBar();
so the table foobar is created in db. I searched across the web and found nothing. I suppose it is not a PostgreSQL problem because pgAdmin3 doesn't change anything when it's doing the same things.
My environment:
Windows 7 Pro
DataGrip 2016.3.4
PostgreSQL 9.4
This is a Postgres feature, DataGrip has nothing to this issue.
If you want "PascalCaseIdentifiers" you have to use double quotes.
Identifiers without quotes are case-insensitive. They are automatically converted to lower case.
Read about details in the documentation.
pgAdmin3 doesn't change anything when it's doing the same things.
Quite the opposite, pgAdmin3 adds double quotes when e.g. an identifier contains capital letters (see the last tab SQL in New table... dialog).
In my (and not only my) honest opinion, using quoted identifiers is in general a very bad idea. It simply creates more problems then they are worth it.
i have two database cvtl and cvtl_db , i need to write a single query to retrieve data from table A in cvtl and table B in cvtl_db.
Postgres is throwing error: cross database reference are not implemented
Basically you have two ways:
Older tools.
If you need to support older versions of PostgreSQL, use dblink or DBI-link. These two provide robust support for cross-db queries across a number of PostgreSQL versions. pl/proxy is another possibility.
Newer tools.
The newer approach is to use foreign data wrappers. This has more functionality (such as better transaction handling) and probably has more eyes in terms of support than dblink etc do today.
Recently I came across a (maybe known problem) when Postgre's versions differ in major number (always upgrade, no downgrade), for example with field types.
In my case, there was very little conflicting data so I changed it by hand, but wanted to know more, in case I come across this problem again with more data.
In this concrete case (but can be extended to other possible problems in the future), I created the backup using only data inserts, as I had already the table structure saved.
The problem came when upgrading from 8.x to 9.x with the money type, I got errors because the inserts had a value something like
INSERT INTO foo(...) VALUES (...,'EUR300',...);
So postgres was refusing to insert that in 9.1
My idea, and what I tried is to convert that field to DECIMAL and redoing the dump, that worked, but in a future, is there another mechanism, like using newer pg_dump connecting to old database, instead of current one? (Did not tested this)
When going etween different versions, you should always use the new version of pg_dump. Meaning when you go from 8.x to 9.1, you should use pg_dump version 9.1. It should normally take care of any conversions necessary.
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.
We have a daily process that pulls all data out of a number of tables in an Oracle database and imports them into a Postgress (EnterpriseDB) database - Version 8.4.
We are currently using a java application to select * from each table, change the keywords (date, timestamp, etc) and then import them into the Postgres Database.
Are there any tools available in Postgres that would provide a more efficient manner of doing this? I should note that there are CLOBs that are being transported over.
There is Ora2Pg, which is intended as a one-time-migration tool, but it might work in your case as well. I think of it as an Oracle-to-PostgreSQL pg_dump.