/****************************************************************************************************************
-- Title : [PGS9.2] Changing Tablespace Directory Path/Name
-- Reference : dbrang.tistory.com
-- Key word : 테이블스페이스 경로 변경 패스 수정 tablespace rename path
****************************************************************************************************************/
-- Confirming Tablespace
-- Title : [PGS9.2] Changing Tablespace Directory Path/Name
-- Reference : dbrang.tistory.com
-- Key word : 테이블스페이스 경로 변경 패스 수정 tablespace rename path
****************************************************************************************************************/
-- Confirming Tablespace
=# select tbs_nm, tbs_location from sp_tablespace0;
tbs_nm tbs_location
----------- ----------------------
"jp_trade" "/Databases/JP_Trade"
-- Confirming Symbolic link of Tablespace
$ cd /home/postgres/pgsql/data/pg_tblspc
$ ll
lrwxrwxrwx. 1 postgres postgres 19 2014-03-04 21:58 16391 -> /Databases/JP_Trade
-- Service Stop
$ pg_ctl stop -m immediate
-- Rename Tablespace Directory
$ mv JP_Trade ts_data1;
-- Change Symbolic Link
$ rm -f 16391
$ ln -s /Databases/ts_data1 16391
-- Service Start
$ pg_ctl start
-- Confirming Tablespace
=# select tbs_nm, tbs_location from sp_tablespace0;
tbs_nm tbs_location
----------- ----------------------
"jp_trade" "/Databases/ts_data1"
-- Confirming Tablespace of Table
=# select rel_nm, tbs_nm from sp_table0;
rel_nm tbs_nm
------- ---------
"gzt" "jp_trade"
"ttt" "jp_trade"
-- Rename Tablespace
=# alter tablespace jp_trade rename to ts_data1;
-- Confirming Tablespace of Table
=# select rel_nm, tbs_nm from sp_table0;
rel_nm tbs_nm
------- ---------
"gzt" "ts_data1"
"ttt" "ts_data1"