Category Archives: postgressql

DB Schema with their Sizes on Postgresql

To Know the list of database schema and their size Run below Sql Query SELECT schema_name,pg_size_pretty(sum(table_size)::bigint) as “disk space”,(sum(table_size) / pg_database_size(current_database())) * 100 as “percent” FROM (SELECT pg_catalog.pg_namespace.nspname as schema_name,pg_relation_size(pg_catalog.pg_class.oid) as table_size FROM pg_catalog.pg_class JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid) t GROUP BY schema_name ORDER BY schema_name asc

Dynamic Table Name In Postgresql Trigger

Dynamic table name in PostgreSQL trigger used as “TG_TABLE_NAME” “TG_TABLE_NAME” is a name of the table that caused the trigger invocation. Like If you want to copy data from one table to another on updating first table Then start using triggers Lets say you have table name “first_table” Create same table as log table to […]

Extracting Information Schema Using Postgres Sql

This Tutorial introduces how to extract Information Schema in PostgreSQL with simple Sql queries. Information schema provides information about tables, columns, views, trigger, functions and sequences in a database. We extract these information from simple SQL queries, lets we have a well maintained database and below are simple Sql statements to get various information in […]