Postgresql 中文操作指南
Synopsis
dropuser [ connection-option …] [ option …] [ username ]
dropuser [connection-option…] [option…] [username]
Description
dropuser 删除现有 PostgreSQL 用户。超级用户可以使用此命令删除任何角色;否则,只能删除非超级用户角色,并且只能由拥有 CREATEROLE 权限且已授予 ADMIN OPTION 至目标角色的用户删除。
dropuser removes an existing PostgreSQL user. Superusers can use this command to remove any role; otherwise, only non-superuser roles can be removed, and only by a user who possesses the CREATEROLE privilege and has been granted ADMIN OPTION on the target role.
dropuser 是围绕 SQL 命令 DROP ROLE 的包装器。通过此实用程序或通过其他访问服务器方法删除用户之间没有实际差异。
dropuser is a wrapper around the SQL command DROP ROLE. There is no effective difference between dropping users via this utility and via other methods for accessing the server.
Options
dropuser 接受以下命令行参数:
dropuser accepts the following command-line arguments:
-
username
-
Specifies the name of the PostgreSQL user to be removed. You will be prompted for a name if none is specified on the command line and the -i/—interactive option is used.
-
-
-e_—echo_
-
Echo the commands that dropuser generates and sends to the server.
-
-
-i_—interactive_
-
Prompt for confirmation before actually removing the user, and prompt for the user name if none is specified on the command line.
-
-
-V_—version_
-
Print the dropuser version and exit.
-
-
—if-exists
-
Do not throw an error if the user does not exist. A notice is issued in this case.
-
-
-?_—help_
-
Show help about dropuser command line arguments, and exit.
-
dropuser 还接受以下命令行参数作为连接参数:
dropuser also accepts the following command-line arguments for connection parameters:
-
-h _host—host=_host
-
Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket.
-
-
-p _port—port=_port
-
Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.
-
-
-U _username—username=_username
-
User name to connect as (not the user name to drop).
-
-
-w_—no-password_
-
Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.
-
-
-W_—password_
-
Force dropuser to prompt for a password before connecting to a database.
-
This option is never essential, since dropuser will automatically prompt for a password if the server demands password authentication. However, dropuser will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.
-
Environment
-
PGHOST_PGPORT_PGUSER
-
Default connection parameters
-
-
PG_COLOR
-
Specifies whether to use color in diagnostic messages. Possible values are always, auto and never.
-
此实用程序与大多数其他 PostgreSQL 实用程序一样,还使用 libpq 支持的环境变量(请参阅 Section 34.15 )。
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15).
Examples
若要从默认数据库服务器中删除用户 joe :
To remove user joe from the default database server:
$ dropuser joe
若要使用主机 eden 上的服务器、端口 5000、通过验证并窥视底层命令来删除用户 joe :
To remove user joe using the server on host eden, port 5000, with verification and a peek at the underlying command:
$ dropuser -p 5000 -h eden -i -e joe
Role "joe" will be permanently removed.
Are you sure? (y/n) y
DROP ROLE joe;