postgresql:在指定位置创建数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9876132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
postgresql: creating database in a specified location
提问by Homunculus Reticulli
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:
我正在尝试在指定位置创建一个 PG db。根据此处的文档,我必须使用 LOCATION 标志。但是,当我运行时CREATE DATABASE (from the pgsql CLI)
,我收到以下警告:
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?
但是,关于 TABLESPACES 的 PG 文档没有显示如何使用它在特定目录中创建数据库。执行此操作所需的语法是什么?
回答by Karlson
You would need to do this in 2 steps:
您需要分两步执行此操作:
- Create Tablespaceexamples for which you can see in the link
- Create Database
When you create tablespace you set it's location and then you can create multiple databases in the same tablespace if you choose to.
创建表空间时,您可以设置它的位置,然后您可以选择在同一个表空间中创建多个数据库。
回答by johnshen64
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
See the chapter about tablespacesin the manual.
请参阅手册中有关表空间的章节。