HAS_TABLE_PRIVILEGE
HAS_TABLE_PRIVILEGE returns a true/false value indicating whether or not a user can access a table in a particular way.
Syntax
HAS_TABLE_PRIVILEGE ( [ user, ] table, privilege )
Semantics
user
|
specifies the name of a database user. The default is the CURRENT_USER.
CURRENT_USER returns a VARCHAR containing the name of the user who initiated the current database connection.
Syntax
CURRENT_USER
Notes
- This function must be called without trailing parentheses.
- CURRENT_USER is useful for permission checking
- CURRENT_USER is equivalent to SESSION_USER and USER.
Examples
=> SELECT CURRENT_USER;
current_user
--------------
dbadmin
(1 row)
|
table
|
specifies the name of a table in the logical schema.
|
privilege
|
SELECT
|
Allows the user to SELECT from any column of the specified table.
|
INSERT
|
Allows the user to INSERT tuples into the specified table and to use the COPY command to load the table.
|
UPDATE
|
Allows the user to UPDATE tuples in the specified table.
|
DELETE
|
Allows DELETE of a row from the specified table.
|
REFERENCES
|
To create a foreign key constraint, it is necessary to have this privilege on both the referencing and referenced tables.
|
|
|
Notes
Examples
SELECT HAS_TABLE_PRIVILEGE('mytable', 'SELECT');