Creating table inside Schemapostgres=# create schema hr; CREATE SCHEMA postgres=# \dn; List of schemas Name | Owner --------+---------- hr | postgres public | postgres (2 rows) creating a table inside the schema “hr” (method 1) postgres=# create table hr.vehicle (details varchar(50)); CREATE TABLE postgres=# insert into hr.vehicle values('this is HR car'); INSERT 0 1 postgres=# set search_path to hr; SET postgres=# show search_path; search_path ------------- hr (1 row) postgres=# \dt; List of relations Schema | Name | Type | Owner --------+---------+-------+---------- hr | vehicle | table | postgres (1 row) postgres=# select * from vehicle; details ---------------- this is HR car (1 row) creating a table inside the schema (method 2) postgres=# set search_path to hr; SET postgres=# show search_path; search_path ------------- hr (1 row) postgres=# \dt; List of relations Schema | Name | Type | Owner --------+---------+-------+---------- hr | vehicle | table | postgres (1 row) postgres=# create table bike (details varchar(50)); CREATE TABLE postgres=# \dt; List of relations Schema | Name | Type | Owner --------+---------+-------+---------- hr | bike | table | postgres hr | vehicle | table | postgres (2 rows) postgres=# insert into bike values('this is my bike'); INSERT 0 1 postgres=# select * from bike; details ----------------- this is my bike (1 row) « Previous Next Topic » (Setting default schema) |