简体   繁体   中英

postgres databases on different partitions

Is it possible to work with different postgresql databases on different partitions? What I mean is that I'd like to keep one database on my SSD drive (in the default pgsql data folder on system partition C:) and I'd like to keep another DB on an external USB HDD, and I would like to being able to work with both databases when I connect to the postgresql server. I'm on Windows 7 Ultimate x64 with postgresql-x64-9.0. If it's possible to do I'd deeply appreciate some guidance about the steps needed to make.

you need to create tablespaces

like this:

first create desired directory in your partitions (Ex. D:\\\\DB_ONE_SPACE , G:\\\\DB_TWO_SPACE ) then create tablespace for each

 CREATE TABLESPACE space_one
      OWNER postgres
      LOCATION 'D:\\DB_ONE_SPACE';

 CREATE TABLESPACE space_two
      OWNER postgres
      LOCATION 'E:\\DB_TWO_SPACE';

and create DB by assigning tablespace for each

CREATE DATABASE "DB1"
  WITH OWNER = postgres
       ENCODING = 'UTF8'
       TABLESPACE = space_one

  CREATE DATABASE "DB2"
  WITH OWNER = postgres
       ENCODING = 'UTF8'
       TABLESPACE = space_two

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM