Best practice to move from MySQL to PostgreSQL

Поиск
Список
Период
Сортировка
Искать

Best practice to move from MySQL to PostgreSQL

От:
Guenther Boelter <gboelter@gmail.com>
Дата:
I've decided to change my application from MySQL to PostgreSQL and I'm 
already sure, it's a good decision.

 From what I know, using PostgreSQL, all fieldnames should be written in 
lowercase to avoid problems.

Unfortunately in MySQL my fields are named like this:

> BelegNummer, BelegDatum ....

so a query looks like this

> SELECT BelegNummer, BelegDatum FROM rechnungen ORDER BY BelegDatum ASC;

This will not work with PostgreSQL, because PostgreSQL will change all 
fieldnames to lowercase, right?

Means, I've to change all fieldnames to lowercase like belegnummer, 
belegdatum ....

Ok, that;s not a big problem. But is there something else I should do to 
avoid other problems?

Should I change my queries to something like this:

> SELECT belegnummer, belegdatum FROM rechnungen ORDER BY belegdatum ASC;

or will Postgre do this automatically while executing the query?

I only would like to make sure, that I'm right until here and/or is 
there is better way to convert an application from MyQSL to PostgreSQL 
before I'll start to change everything.

Thanks in advance for your help.

Re: Best practice to move from MySQL to PostgreSQL

От:
Thomas Kellerer <spam_eater@gmx.net>
Дата:
Guenther Boelter, 02.12.2010 05:04:
> so a query looks like this
>
> SELECT BelegNummer, BelegDatum FROM rechnungen ORDER BY BelegDatum ASC;
>
> This will not work with PostgreSQL, because PostgreSQL will change all fieldnames to lowercase, right?
> Means, I've to change all fieldnames to lowercase like belegnummer, belegdatum ....

No you don't need to change the statements - at least not if they *don't* use doubles quotes.

As long as you don't use double quotes, the names are not case-sensitive (as required by the standard)
So just make sure you don't quote your table and column names and you should be fine.

The following statements are equivalent:

SELECT BELEGNUMMER FROM RECHNUNGEN
select belegnummer from rechnungen
SELECT belegnummer FROM rechnungen
SELECT BeLeGnUmMer FROM rechnungen
...


>  Should I change my queries to something like this:
>
>> SELECT belegnummer, belegdatum FROM rechnungen ORDER BY belegdatum ASC;
No need to do that.

Regards
Thomas
FAQ