Setting Default Schema
Syntax : Set search_path to < schema name >;
View the default Schema :
Show search_path;
Changing the schema :
postgres=# set search_path to s1;
SET
postgres=# show search_path;
search_path
-------------
s1
(1 row)
Now let us create multiple objects with same name in different schema :To list out the schemas :
postgres=# \dn;
List of schemas
Name | Owner
--------+----------
public | postgres
(1 row)
postgres=# show search_path;
search_path
-----------------
"$user", public
(1 row)
Step to list out tables :
postgres=# \dt;
Did not find any relations.
Creating table and insert values :
postgres=# create table vehicle(details varchar(50));
CREATE TABLE
postgres=# insert into vehicle values('this is a public car');
INSERT 0 1
postgres=# \dt;
List of relations
Schema | Name | Type | Owner
--------+---------+-------+----------
public | vehicle | table | postgres
(1 row)
postgres=# select * from vehicle;
details
----------------------
this is a public car
(1 row)
« Previous Next Topic » (Moving table across schema) |