Postgresql: creating a database at a specified location

I am trying to create a PG database at the specified location. According to the docs here , I have to use the LOCATION flag. However, when I run CREATE DATABASE (from the pgsql CLI) , I get the following warning:

 WARNING: LOCATION is not supported anymore HINT: Consider using tablespaces instead. 

However, PG's TABLESPACES documentation does not show how it can be used to create a database in a specific directory. What is the required syntax for this?

+7
source share
2 answers

You need to do it in 2 steps:

When you create a tablespace, you set its location, and then you can create multiple databases in the same tablespace if you want.

+10
source

CREATE TABLESPACE fastspace LOCATION '/ mnt / sda1 / postgresql / data';

See the tablespaces chapter in the manual.

+1
source

All Articles