alter_database 中文man頁面
NAME
ALTER DATABASE - 修改一個數(shù)據(jù)庫
SYNOPSIS
ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT } ALTER DATABASE name RESET parameter ALTER DATABASE name RENAME TO newname
DESCRIPTION 描述
ALTER DATABASE 用于改變一個數(shù)據(jù)庫的屬性。
頭兩種形式為 PostgreSQL 數(shù)據(jù)庫修改缺省的會話運(yùn)行時配置變量。 隨后在該數(shù)據(jù)庫上啟動一個新的會話的時候, 在啟動會話之前先有效地運(yùn)行 SET variable TO value。 數(shù)據(jù)庫相關(guān)的缺省值覆蓋任何在 postgresql.conf 里出現(xiàn)或者從 postmaster 命令行接收到的設(shè)置。 只有數(shù)據(jù)庫所有者或者超級用戶可以為一個數(shù)據(jù)庫修改會話缺省。
第三種形式修改該數(shù)據(jù)庫的名稱。只有數(shù)據(jù)庫所有者可以重命名一個數(shù)據(jù)庫,并且只有在他有 CREATEDB 權(quán)限的時候可以。 當(dāng)前的數(shù)據(jù)庫不能被重命名。(如果你需要這么做,那么連接另外一個數(shù)據(jù)庫。)
PARAMETERS 參數(shù)
- name
需要修改會話缺省的數(shù)據(jù)庫的名字。- parameter
- value
把指定的數(shù)據(jù)庫配置變量的會話缺省值設(shè)置為給出的數(shù)值。 如果 value 使用了 DEFAULT 或者是等效的 RESET, 那么與數(shù)據(jù)庫相關(guān)的變量設(shè)置將被刪除并且在新的會話中將繼承缺省設(shè)置。 用 RESET ALL 清除所有設(shè)置。
參閱 SET [set(7)] 和 Section 16.4 ``Run-time Configuration'' 獲取有關(guān)允許的變量名和數(shù)值的 更多信息。- newname
數(shù)據(jù)庫的新名字。
NOTES 注意
使用 ALTER USER [alter_user(7)], 我們也可以把一個會話缺省綁定到一個特定用戶,而不是某個數(shù)據(jù)庫上。 如果存在沖突,那么用戶聲明的設(shè)置覆蓋數(shù)據(jù)庫相關(guān)的設(shè)置。
EXAMPLES 例子
要關(guān)閉在數(shù)據(jù)庫 test 上缺省的索引使用∶
ALTER DATABASE test SET enable_indexscan TO off;
COMPATIBILITY 兼容性
ALTER DATABASE 語句是一個 PostgreSQL 擴(kuò)展。
SEE ALSO 參見
ALTER USER [alter_user(7)], CREATE DATABASE [create_database(l)], DROP DATABASE [drop_database(l)], SET [set(l)]
#p#
NAME
ALTER DATABASE - change a database
SYNOPSIS
ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT } ALTER DATABASE name RESET parameter ALTER DATABASE name RENAME TO newname
DESCRIPTION
ALTER DATABASE is used to change the attributes of a database.
The first two forms change the session default of a run-time configuration variable for a PostgreSQL database. Whenever a new session is subsequently started in that database, the specified value becomes the session default value. The database-specific default overrides whatever setting is present in postgresql.conf or has been received from the postmaster command line. Only the database owner or a superuser can change the session defaults for a database.
The third form changes the name of the database. Only the database owner can rename a database, and only if he has the CREATEDB privilege. The current database cannot be renamed. (Connect to a different database if you need to do that.)
PARAMETERS
- name
- The name of the database whose session defaults are to be altered.
- parameter
- value
- Set the session default for this database of the specified configuration parameter to the given value. If value is DEFAULT or, equivalently, RESET is used, the database-specific variable setting is removed and the system-wide default setting will be inherited in new sessions. Use RESET ALL to clear all settings.
See SET [set(7)] and the section called ``Run-time Configuration'' in the documentation for more information about allowed parameter names and values.
- newname
- The new name of the database.
NOTES
Using ALTER USER [alter_user(7)], it is also possible to tie a session default to a specific user rather than a database. User-specific settings override database-specific ones if there is a conflict.
EXAMPLES
To disable index scans by default in the database test:
ALTER DATABASE test SET enable_indexscan TO off;
COMPATIBILITY
The ALTER DATABASE statement is a PostgreSQL extension.
SEE ALSO
ALTER USER [alter_user(7)], CREATE DATABASE [create_database(l)], DROP DATABASE [drop_database(l)], SET [set(l)]