May 17, 2026, 11:40 PM

This commit is contained in:
Paweł Domański
2026-05-18 06:40:19 +00:00
commit 64944cf004
896 changed files with 310709 additions and 0 deletions
@@ -0,0 +1,28 @@
VIEW TABLESPACE INFO IN POSTGRES:
postgres=# select * from pg_tablespace;
(OR)
postgres=# \db+
(or)
-- For getting size of specific tablespace:
postgres=# select pg_size_pretty(pg_tablespace_size('ts_dbaclass'));
pg_size_pretty
----------------
96 bytes
(1 row)
Pre-configured tablespaces:( these are default tablespaces)
Pg_global - > PGDATA/global - > used for cluster wide table and system catalog
Pg_default - > PGDATA/base directory - > it stores databases and relations
@@ -0,0 +1,16 @@
CREATE TABLESPACE:
postgres=# create tablespace ts_postgres location '/Library/PostgreSQL/TEST/TS_POSTGRES';
CREATE TABLESPACE
RENAME TABLESPACE:
postgres=# alter tablespace ts_postgres rename to ts_dbaclass;
ALTER TABLESPACE
DROP TABLESPACE:
postgres=# drop tablespace ts_dbaclass;
DROP TABLESPACE
<<Before dropping tablespace make sure it is emptry>>
@@ -0,0 +1,36 @@
postgres=# show default_tablespace;
default_tablespace
--------------------
(1 row)
<<<< If output is blank means default is pg_default tablespace>>>>>
--To change the default tablespace at database level:
postgres=# alter system set default_tablespace=ts_postgres;
ALTER SYSTEM
postgres=# select pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
postgres=# show default_tablespace;
default_tablespace
--------------------
ts_postgres
(1 row)
postgres=# SELECT name, setting FROM pg_settings where name='default_tablespace';
name | setting
--------------------+-------------
default_tablespace | ts_postgres
(1 row)
Steps to change default tablespace at session level:
postgres=# set default_tablespace=ts_postgres;
SET
@@ -0,0 +1,74 @@
VIEW DEFAULT TEMP TABLESPACE:
dbaclass=# SELECT name, setting FROM pg_settings where name='temp_tablespaces';
name | setting
------------------+---------
temp_tablespaces |
(1 row)
dbaclass=# show temp_tablespaces
dbaclass-# ;
temp_tablespaces
------------------
(1 row)
CHANGE DEFAULT TEMP TABLESPACE
postgres=# alter system set temp_tablespaces=TS_TEMP;
ALTER SYSTEM
postgres=# select pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
postgres=# show temp_tablespaces;
temp_tablespaces
------------------
ts_temp
(1 row)
postgres=# SELECT name, setting FROM pg_settings where name='temp_tablespaces';
name | setting
------------------+---------
temp_tablespaces | ts_temp
(1 row)
VIEW DEFAULT TEMP TABLESPACE:
dbaclass=# SELECT name, setting FROM pg_settings where name='temp_tablespaces';
name | setting
------------------+---------
temp_tablespaces |
(1 row)
dbaclass=# show temp_tablespaces
dbaclass-# ;
temp_tablespaces
------------------
(1 row)
CHANGE DEFAULT TEMP TABLESPACE
postgres=# alter system set temp_tablespaces=TS_TEMP;
ALTER SYSTEM
postgres=# select pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
postgres=# show temp_tablespaces;
temp_tablespaces
------------------
ts_temp
(1 row)
postgres=# SELECT name, setting FROM pg_settings where name='temp_tablespaces';
name | setting
------------------+---------
temp_tablespaces | ts_temp
(1 row)