postgresql migration tablespace

The storage space of postgresql is insufficient, and the table space needs to be migrated
1. Create a table space

create tablespace spacename location ‘/opt/data’;

2. Set the database to use the table space

alter database test set tablespace spacename;

3. When executing the above settings, it prompts that the database is in use.
This kind of sql that I disconnected from the Internet did not work.
I changed the configuration file port and restarted. At this time, the original database connection will be invalid. After executing it, change it back

4. Query tablespace
\db
or
select spcname from pg_tablespace;

Guess you like

Origin blog.csdn.net/TS_forever007/article/details/129859800