Book Contents

Book Index

Next Topic

Home

GRANT (Table)

Grants privileges on a table to a user.

In a database with trust authentication, the GRANT and REVOKE statements appear to work as expected but have no actual effect on the security of the database.

Syntax

GRANT { { SELECT | INSERT | UPDATE | DELETE | REFERENCES } [,...]

| ALL [ PRIVILEGES ]

}

ON [ TABLE ] tablename [, ...]

TO { username | PUBLIC } [, ...]

[ WITH GRANT OPTION ]

Semantics

 

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.

ALL

is synonomous with SELECT, INSERT, UPDATE, DELETE, REFERENCES.

PRIVILEGES

is for SQL standard compatibility and is ignored.

tablename

specifies the table on which to grant the privileges.

username

specifies the user to whom to grant the privileges.

PUBLIC

grants the privilege to all users.

WITH GRANT

OPTION

allows the user to grant the same privileges to other users.

Notes