Date Published:
Last Modified:


To change the position of a column:

ALTER TABLE tbl_name MODIFY COLUMN col_name column_definition AFTER col_name;

More info at


PostgreSQL is a object-orientated database. The main feature of a object-orientated database is that tables can inherit from other tables, which means they automatically get all the data columns of the table they inherit from (similar to object inheritance in object-orientated programming languages).

Inheritance is defined when creating tables with the INHERITS clause with the CREATE TABLE statement:

    name            text,
    age             int

CREATE TABLE student (
    student_id      text,
) INHERITS (people);

If a table already exists, you can inheritance via the INHERIT variant of the ALTER TABLE statement.

Working With PostgreSQL In Python

One of the most popular PostgreSQL libraries for Python is psycopg2. To install it on Ubuntu you will also need the libpg-dev package on your system:

sudo apt install libpq-dev
pip install psycopg2

Related Content:


comments powered by Disqus
Page contents: