Creating SchemaSchema is a named space that contains named objects such as tables, datatypes, functions and operators. A schema can also contain views, indexes, sequences. One database can have multiple schema. A schema helps in separation of data between different application. Assume we have a production database which has different department such as HR,Finance, transport, manufacturing and all the departments are accessing the Production database. Here we can create a schema where we can include all the table belonging to HR dept, by that way when we need a backup we can take the particular schema backup alone rather than taking full DB backup. In one databse we can have multiple users accessing multiple schema without interfering with each other. There are several reasons why one might want to use schemas:
Syntax : create schema < schema name >;List out the schemas postgres=# \dn List of schemas Name | Owner --------+---------- public | postgres (1 row) postgres=# create schema s1; CREATE SCHEMA postgres=# \dn; List of schemas Name | Owner --------+---------- public | postgres s1 | postgres (2 rows) « Previous Next Topic » (Creating table inside schema) |