Postgresql 中文操作指南
23.4. Database Configuration #
从 Chapter 20 中回想一下,PostgreSQL 服务器提供了大量运行时配置变量。您可以为许多这些设置设置特定于数据库的默认值。
Recall from Chapter 20 that the PostgreSQL server provides a large number of run-time configuration variables. You can set database-specific default values for many of these settings.
例如,如果出于某种原因您希望为给定数据库禁用 GEQO 优化器,则通常必须为所有数据库禁用它,或者确保每个连接客户端都会谨慎地发布 SET geqo TO off。要在特定数据库内使此设置成为默认设置,您可以执行以下命令:
For example, if for some reason you want to disable the GEQO optimizer for a given database, you’d ordinarily have to either disable it for all databases or make sure that every connecting client is careful to issue SET geqo TO off. To make this setting the default within a particular database, you can execute the command:
ALTER DATABASE mydb SET geqo TO off;
这将保存该设置(但不立即设置它)。在随后的与此数据库的连接中,它将显示为在会话开始之前刚刚执行了 SET geqo TO off; 。注意,用户在会话期间仍可以更改此设置;它只能是默认设置。要撤销任何此类设置,请使用 ALTER DATABASE _dbname RESET varname_ 。
This will save the setting (but not set it immediately). In subsequent connections to this database it will appear as though SET geqo TO off; had been executed just before the session started. Note that users can still alter this setting during their sessions; it will only be the default. To undo any such setting, use ALTER DATABASE _dbname RESET varname_.