Recently I decided to do all of my new database development using PostgreSQL instead of MySQL since now that Oracle owns MySQL, I figure that it isn't long for this world. At least it isn't in any usuable fashion. The transition hasn't exactly been easy so I have created this page to help me and you with that transition.

Here are the subjects so far


Command Cheatsheet

I have created for myself (and for you) a cheatsheet of common MySQL commands which aren't the same on PostgreSQL. Please pardon the tables.

MySQL Command PostgreSQL Equivalent
DESCRIBE <table name> \d <table name>
SHOW TABLES \dt

Build PHP extension module

Additionally, my Linux distribution (Slackware, I know, don't tell me about it) comes with PHP, but not PostgreSQL. This means that even when I install PostgreSQL myself, my PHP won't support it. I don't want to completely rebuild PHP just for PostgreSQL support and break my distro's upgrade tools for PHP.

I've looked around and found out how to build just the pgsql.so extension. You will need to download the latest source distribution from the PHP website. The instructions to build it for your (and my) reference are as follows:

$ tar zxvf php-<version>.tar.gz
$ cd php-<version>/ext/pgsql
$ phpize
$ ./configure --with-pgsql=<path-to-pgsql>
$ make
$ su
# cp modules/pgsql.so <path-to-your-php-extensions-directory>

Now add the following line to your php.ini:

extension=pgsql.so
Restart your webserver to pick up the new php.ini. And now your PHP should support PostgreSQL. It should be noted that you should be able to build any of the PHP extensions using this method without having to rebuild all of PHP.

Copyright ©1997 - 2021, Bulent Yilmaz