Category Archives: PostgreSQL

Malko ERP basic database

Let’s start with the product management. I’ll try to keep it simple for the time being. My weapon of choice, when designing the database schema is the almost great WWW SQL Designer.
Right now the schema looks like this:

And the XML file is located here.

Move table in postgres to different schema

To move table to different schema in PostgreSQL use:
ALTER TABLE table_name SET SCHEMA schema_name;

Enable PL/SQL for Database in Postgres

To enable PL/SQL in PostgreSQL use:
 
CREATE LANGUAGE ‘plpgsql’ HANDLER plpgsql_call_handler
LANCOMPILER ‘PL/pgSQL’;
 

Alter Columns Position in Postgres

Some workarounds to alter columns position in Postgres

SQL_CALC_FOUND_ROWS (kind of) for postgres

When I switched from MySQL to PostgreSQL, one of the things I missed the most was the ease of paging using SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS() afterwards. One of the places I use it heavily is in my Table class, which generates, sortable, filterable and paged HTML table based on an SQL Query. The tough spot [...]