How to find the database creation date in PostgreSQL

In this article, we will see how to find the database creation date in PostgreSQL in windows and Linux.

There are two ways to check the database creation date in PostgreSQL. One is by running query against pg_database view and other is by checking PG_VERSION in base directory of specific database. Continue reading How to find the database creation date in PostgreSQL

Switch role after connecting to database in PostgreSQL

In this article, we will see how to Switch role after connecting to database in PostgreSQL with examples.

We can switch or change the current use/role as active using set command.
Continue reading Switch role after connecting to database in PostgreSQL

How to download and restore PostgreSQL sample database

In this article, we will see how to download and restore PostgreSQL sample database. We can restore sample database in PostgreSQL server using following methods.

1. Using psql tool on windows.
2. Using Terminal on Linux.

First we have to download PostgreSQL sample database. Go through Download PostgreSQL Sample database

Restore PostgreSQL sample database on windows by using psql utility

Continue reading How to download and restore PostgreSQL sample database

PostgreSQL sample database

In this article, we will see how to download and restore PostgreSQL sample database in PostgreSQL server. We can use PostgreSQL sample database for learning and practice PostgreSQL. We will use the DVD rental database for demonstrating the features of PostgreSQL.

The DVD rental database has many objects including tables, views, trigger, functions, sequences and domain.

Download the PostgreSQL Sample database

Continue reading PostgreSQL sample database

How to create database in Azure PostgreSQL Server

In this article, we will see how to create database in Azure PostgreSQL Server.

Database is collection objects like tables, views, indexes, schemas, ….etc.

We are going to create a database in Azure PostgreSQL server by using following two methods.

1. Using CREATE DATABASE command.
2. Using GUI method using pgadmin tool.
Continue reading How to create database in Azure PostgreSQL Server

How to do schema only backup and restore in PostgreSQL?

In this article, we will see how to do schema only backup and restore in PostgreSQL.
Schema only backup contains only objects definition like table definition.

To take a schema level backup in PostgreSQL database and restore on the another database, we use pg_dump utility with the option –schema-only or -s. If we gave –schema-only means, it dumps only the object definitions (schema), not data.
Continue reading How to do schema only backup and restore in PostgreSQL?

How to create copy of existing database in PostgreSQL

In this article, we will see how to create copy of existing database in PostgreSQL.

Postgres allows the use of any existing database on the server as a template when creating a new database.

Syntax to create copy of PostgreSQL Database:
Continue reading How to create copy of existing database in PostgreSQL

How to find list tables in a PostgreSQL schema

In this article, we will see how to find list tables in a PostgreSQL schema with examples.

We can find the list of tables in a PostgreSQL schema using meta-command or by using SQL statement by querying against table pg_tables.

Find list tables in a PostgreSQL schema using meta-command: Continue reading How to find list tables in a PostgreSQL schema

PostgreSQL Directory Layout

In this article, we will see PostgreSQL Directory Layout and their purpose.




PostgreSQL Database Directory Layout

 

Installation Directory Layout:

 

     
PostgreSQL is typically installed
to /usr/local/pgsql or /var/lib/pgsql on linux.

     
C:\Program
Files\PostgreSQL\<version number> on windows.

Continue reading PostgreSQL Directory Layout

How to find number of tables in PostgreSQL Database

In this article, we will see how to find number of tables in PostgreSQL Database.

The number of tables in a relational database is good measure of the complexity of a database, so it is a simple way to get know any database.
Continue reading How to find number of tables in PostgreSQL Database