Difference between revisions of "GRANT"
From Lianjapedia
Helen.george (Talk | contribs) |
Helen.george (Talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 17: | Line 17: | ||
The GRANT command is used to grant access privileges for users to tables. It can extend user privileges but cannot limit existing privileges. Later GRANT statements do affect privileges already granted to a user. Privileges can only be removed with the REVOKE statement. To grant privileges you must be the owner of the table or have already been granted ALTER privileges. | The GRANT command is used to grant access privileges for users to tables. It can extend user privileges but cannot limit existing privileges. Later GRANT statements do affect privileges already granted to a user. Privileges can only be removed with the REVOKE statement. To grant privileges you must be the owner of the table or have already been granted ALTER privileges. | ||
− | {| class="wikitable" | + | {| class="wikitable" width="100%" |
− | !Keywords||Description | + | !width="20%"|Keywords||Description |
|- | |- | ||
|ALL||All privileges are granted. | |ALL||All privileges are granted. | ||
|- | |- | ||
− | |SELECT||The ability to name any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. | + | |valign="top"|SELECT||The ability to name any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. |
|- | |- | ||
− | |UPDATE||The ability to name any column in an UPDATE statement. The privilege can be restricted to one or more columns by listing them. | + | |valign="top"|UPDATE||The ability to name any column in an UPDATE statement. The privilege can be restricted to one or more columns by listing them. |
|- | |- | ||
|INSERT||The ability to INSERT rows into the table. | |INSERT||The ability to INSERT rows into the table. | ||
Line 30: | Line 30: | ||
|DELETE||The ability to DELETE rows from the table. | |DELETE||The ability to DELETE rows from the table. | ||
|- | |- | ||
− | |ALTER||The data type to be stored in that column, and the applicable length or precision. | + | |valign="top"|ALTER||The data type to be stored in that column, and the applicable length or precision. |
|- | |- | ||
− | |READ ONLY||The ability to read from any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. | + | |valign="top"|READ ONLY||The ability to read from any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. |
|- | |- | ||
− | |database||The name of the database to which the table belongs | + | |valign="top"|database||The name of the database to which the table belongs. The '!' character must be included between the database name and the table name. |
|- | |- | ||
|table||The name of the table to which the privileges are granted. | |table||The name of the table to which the privileges are granted. | ||
|- | |- | ||
− | |user||The user access control string that will be granted the privilege. User access control strings are defined by the operating system. | + | |valign="top"|user||The user access control string that will be granted the privilege. User access control strings are defined by the operating system. |
|- | |- | ||
− | |group||The group access control string that will be granted the privilege. Group access control strings are defined by the operating system | + | |valign="top"|group||The group access control string that will be granted the privilege. Group access control strings are defined by the operating system |
|- | |- | ||
|PUBLIC||All users and groups will be granted the privilege. | |PUBLIC||All users and groups will be granted the privilege. | ||
Line 57: | Line 57: | ||
</code> | </code> | ||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
[[Category:Commands]] | [[Category:Commands]] |
Latest revision as of 11:27, 30 January 2013
Contents
Purpose
Grants access privileges for users to tables
Syntax
GRANT
ALL | [SELECT [(<column> [,...])]] [UPDATE [(<column> [,...])]]
[INSERT] [DELETE] [ALTER] [READ ONLY [(<column> [,...])]]
ON [<database>!] <table> TO '<user>,<group>' [,...] | PUBLIC
See Also
ALTER TABLE, CREATE TABLE, GETENV(), REVOKE
Description
The GRANT command is used to grant access privileges for users to tables. It can extend user privileges but cannot limit existing privileges. Later GRANT statements do affect privileges already granted to a user. Privileges can only be removed with the REVOKE statement. To grant privileges you must be the owner of the table or have already been granted ALTER privileges.
Keywords | Description |
---|---|
ALL | All privileges are granted. |
SELECT | The ability to name any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. |
UPDATE | The ability to name any column in an UPDATE statement. The privilege can be restricted to one or more columns by listing them. |
INSERT | The ability to INSERT rows into the table. |
DELETE | The ability to DELETE rows from the table. |
ALTER | The data type to be stored in that column, and the applicable length or precision. |
READ ONLY | The ability to read from any column in a SELECT statement. The privilege can be restricted to one or more columns by listing them. |
database | The name of the database to which the table belongs. The '!' character must be included between the database name and the table name. |
table | The name of the table to which the privileges are granted. |
user | The user access control string that will be granted the privilege. User access control strings are defined by the operating system. |
group | The group access control string that will be granted the privilege. Group access control strings are defined by the operating system |
PUBLIC | All users and groups will be granted the privilege. |
Example
// Grant update privilege for columns lastname and firstname and insert for the table GRANT UPDATE (lastname, firstname) INSERT; ON customer; TO '[20,100]' // Grant all privileges to all users GRANT ALL ON test TO PUBLIC