I am trying to create a PG db in a specified location. According to the docs here, I must 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, the PG documentation on TABLESPACES does not show how it can be used to create a database in a specific directory. What is the required syntax to do this?
Open the Databases tree item and have a look at the available databases. The postgres database is the user database for the default postgres user and is not too interesting to us. Right-click on the Databases item and select New Database . Fill in the Create Database form as shown below and click OK.
Changing the Data folder Location on Postgresql Configuration Files. We can change the default data folder by editing the /etc/postgresql/9.5/main/postgresql. conf file and edit the data_directory. $ sudo vi /etc/postgresql/9.5/main/postgresql.
All the data needed for a database cluster is stored within the cluster's data directory, commonly referred to as PGDATA (after the name of the environment variable that can be used to define it). A common location for PGDATA is /var/lib/pgsql/data.
PostgreSQL provides two methods for creating a new database: the CREATE DATABASE SQL command, and the createdb command-line executable.
You would need to do this in 2 steps:
When you create tablespace you set it's location and then you can create multiple databases in the same tablespace if you choose to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With