Skip to main content

GRANT statement

GRANT statement

Use the GRANT statement to give privileges to a specific user or role, or to all users, to perform actions on database objects. You can also use the GRANT statement to grant a role to a user, to PUBLIC, or to another role.
The following types of privileges can be granted:
  • Delete data from a specific table.
  • Insert data into a specific table.
  • Create a foreign key reference to the named table or to a subset of columns from a table.
  • Select data from a table, view, or a subset of columns in a table.
  • Create a trigger on a table.
  • Update data in a table or in a subset of columns in a table.
  • Run a specified function or procedure.
  • Use a sequence generator or a user-defined type.
Before you issue a GRANT statement, check that the derby.database.sqlAuthorization property is set to true. The derby.database.sqlAuthorization property enables the SQL Authorization mode.
You can grant privileges on an object if you are the owner of the object or the database owner. See the CREATE statement for the database object that you want to grant privileges on for more information.
The syntax that you use for the GRANT statement depends on whether you are granting privileges to a schema object or granting a role.
For more information on using the GRANT statement, see "Using SQL standard authorization" in the Java DB Developer's Guide.

Syntax for tables

GRANT privilege-type ON [TABLE] { table-Name | view-Name } TO grantees

Syntax for routines

GRANT EXECUTE ON { FUNCTION | PROCEDURE } routine-designator TO grantees

Syntax for sequence generators

GRANT USAGE ON SEQUENCE [ schemaName. ] SQL92Identifier TO grantees
In order to use a sequence generator, you must have the USAGE privilege on it. This privilege can be granted to users and to roles. See CREATE SEQUENCE statement for more information.
The sequence name is composed of an optional schemaName and a SQL92Identifier. If a schemaName is not provided, the current schema is the default schema. If a qualified sequence name is specified, the schema name cannot begin with SYS.

Syntax for user-defined types

GRANT USAGE ON TYPE [ schemaName. ] SQL92Identifier TO grantees
In order to use a user-defined type, you must have the USAGE privilege on it. This privilege can be granted to users and to roles. See CREATE TYPE statement for more information.
The type name is composed of an optional schemaName and a SQL92Identifier. If a schemaName is not provided, the current schema is the default schema. If a qualified type name is specified, the schema name cannot begin with SYS.

Syntax for roles

GRANT roleName [ {, roleName }* ] TO grantees
Before you can grant a role to a user or to another role, you must create the role using the CREATE ROLE statement. Only the database owner can grant a role.
A role A contains another role B if role B is granted to role A, or is contained in a role C granted to role A. Privileges granted to a contained role are inherited by the containing roles. So the set of privileges identified by role A is the union of the privileges granted to role A and the privileges granted to any contained roles of role A.

privilege-types

  ALL PRIVILEGES |
  privilege-list

privilege-list

 table-privilege {, table-privilege }*

table-privilege

  DELETE |
  INSERT |
  REFERENCES [column list] |
  SELECT [column list] |
  TRIGGER |
  UPDATE [column list]

column list

  ( column-identifier {, column-identifier}* )
Use the ALL PRIVILEGES privilege type to grant all of the privileges to the user or role for the specified table. You can also grant one or more table privileges by specifying a privilege-list.
Use the DELETE privilege type to grant permission to delete rows from the specified table.
Use the INSERT privilege type to grant permission to insert rows into the specified table.
Use the REFERENCES privilege type to grant permission to create a foreign key reference to the specified table. If a column list is specified with the REFERENCES privilege, the permission is valid on only the foreign key reference to the specified columns.
Use the SELECT privilege type to grant permission to perform SELECT statements or SelectExpressions on a table or view. If a column list is specified with the SELECT privilege, the permission is valid on only those columns. If no column list is specified, then the privilege is valid on all of the columns in the table.
For queries that do not select a specific column from the tables involved in a SELECT statement or SelectExpression (for example, queries that use COUNT(*)), the user must have at least one column-level SELECT privilege or table-level SELECT privilege.
Use the TRIGGER privilege type to grant permission to create a trigger on the specified table.
Use the UPDATE privilege type to grant permission to use the UPDATE statement on the specified table. If a column list is specified, the permission applies only to the specified columns. To update a row using a statement that includes a WHERE clause, you must have the SELECT privilege on the columns in the row that you want to update.

grantees

{ AuthorizationIdentifier | roleName | PUBLIC } 
[, { AuthorizationIdentifier | roleName | PUBLIC } ] *
You can grant privileges or roles to specific users or roles or to all users. Use the keyword PUBLIC to specify all users. When PUBLIC is specified, the privileges or roles affect all current and future users. The privileges granted to PUBLIC and to individual users or roles are independent privileges. For example, a SELECT privilege on table t is granted to both PUBLIC and to the authorization ID harry. The SELECT privilege is later revoked from the authorization ID harry, but Harry can access the table t through the PUBLIC privilege.
Either the object owner or the database owner can grant privileges to a user or to a role. Only the database owner can grant a role to a user or to another role.

routine-designator

{
 function-name | procedure-name
}

http://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljgrant.html

Comments

Popular posts from this blog

Oracle SQL92_SECURITY parameter

The Oracle SQL92_SECURITY parameter must be set to TRUE. The configuration option SQL92_SECURITY specifies whether table-level SELECT privileges are required to execute an update or delete that references table column values. If this option is disabled (set to FALSE), the UPDATE privilege can be used to determine values that should require SELECT privileges. The SQL92_SECURITY setting of TRUE prevents the exploitation of user credentials with only DELETE or UPDATE privileges on a table from being able to derive column values in that table by performing a series of update/delete statements using a where clause, and rolling back the change.  In the following example, with SQL92_SECURITY set to FALSE, a user with only delete privilege on the scott.emp table is able to derive that there is one employee with a salary greater than 3000. With SQL92_SECURITY set to TRUE, that user is prevented from attempting to derive a value.  SQL92_SECURITY = FALSE SQL> delete from s...

Ofruesit e sistemeve të menaxhimit të bazës së të dhënave

Ofruesit e sistemeve të menaxhimit të bazës së të dhënave Cila është mënyra më e mirë për të përcaktuar se cili lloj i shërbimit të bazës së të dhënave ose bazës së të dhënave është më e mira për ndërmarrjen tuaj? E gjitha varet nga lloji i rastit të përdorimit që ju nevojitet. Zbuloni më shumë në këtë artikull , dhe artikujt vijues. Sistemi I menaxhimit të të dhenave Në thelb të gjitha informacionet digjitale që përdorim në baza ditore janë në një sistem të menaxhimit të bazës së të dhënave ose një grupi ruajtës diku në botë. Këto mund të shkojnë nga një pajisje e vogël e ruajtjes si një smartphone   ose a aq i madh sa një sistem ruajtje relativisht i pakufizuar i cloud. Më së miri është të zbuloni se cila DBMS është për ndërmarrjen tuaj? A duhet të abonoheni në një shërbim në AWS, Azure, Google ose ofrues tjetër cloud ose duhet të blini magazinimin e qendrës së të dhënave dhe serverat dhe ta ekzekutoni atë vetë? E gjitha varet nga lloji i rastit të përdorimit që ju ...

Autentifikimi, Autorizimi dhe Llogaritja (AAA)- Authentication, Authorization, and Accounting (AAA)

Autentifikimi, Autorizimi dhe Llogaritja (AAA)- Authentication, Authorization, and Accounting (AAA) Autentifikimi, autorizimi dhe llogaritja (AAA) është një term për një kornizë për kontrollin inteligjent të qasjes në burimet kompjuterike, zbatimin e politikave, përdorimin e auditimit dhe sigurimin e informacionit të nevojshëm për të faturuar shërbimet. Këto procese të kombinuara konsiderohen të rëndësishme për menaxhimin efektiv të rrjetit dhe sigurinë. Si proces i parë, autentifikimi siguron një mënyrë për identifikimin e një përdoruesi, zakonisht duke i dhënë përdoruesit një emër përdoruesi të vlefshëm dhe një fjalëkalim të vlefshëm përpara se qasja të jepet. Procesi i legalizimit bazohet në secilin përdorues që ka një grup të kritereve unike për të fituar akses. Serveri AAA krahason kredencialet e identifikimit të përdoruesit me kredencialet e tjera të përdoruesit të ruajtura në një bazë të dhënash. Nëse kredencialet përputhen, përdoruesit i jepet aksesi në rrjet. Nëse kre...