Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

SQL Commands

The document discusses how to lock and unlock Oracle database user accounts using the ALTER USER statement, and how to grant and revoke various privileges on database objects like tables, functions, and procedures using the GRANT and REVOKE statements. Privileges that can be granted include CREATE, SELECT, INSERT, UPDATE, DELETE, EXECUTE and more, and these privileges can be granted to specific users or to the group PUBLIC to grant access to all users. Syntax examples are provided for each type of GRANT and REVOKE statement.

Uploaded by

hemanthvak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

SQL Commands

The document discusses how to lock and unlock Oracle database user accounts using the ALTER USER statement, and how to grant and revoke various privileges on database objects like tables, functions, and procedures using the GRANT and REVOKE statements. Privileges that can be granted include CREATE, SELECT, INSERT, UPDATE, DELETE, EXECUTE and more, and these privileges can be granted to specific users or to the group PUBLIC to grant access to all users. Syntax examples are provided for each type of GRANT and REVOKE statement.

Uploaded by

hemanthvak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

how to lock or unlock Oracle database user accounts.

SQL> ALTER USER username ACCOUNT LOCK;

SQL> ALTER USER username ACCOUNT UNLOCK;

GRANT CREATE ANY INDEX, SELECT ANY TABLE TO Robert;

GRANT CREATE ANY INDEX TO Robert;

gRANT CREATE ANY INDEX TO Robert WITH ADMIN OPTION;

he syntax for granting privileges on a table is:

grant privileges on object to user;

For example, if you wanted to grant select, insert, update, and delete privileges on a table called suppliers to a user
name smithj, you would execute the following statement:

grant select, insert, update, delete on suppliers to smithj;

You can also use the all keyword to indicate that you wish all permissions to be granted. For example:

grant all on suppliers to smithj;

If you wanted to grant select access on your table to all users, you could grant the privileges to the public keyword.
For example:

grant select on suppliers to public;

Revoke Privileges on Tables


Once you have granted privileges, you may need to revoke some or all of these privileges. To do this, you can
execute a revoke command. You can revoke any combination of select, insert, update, delete, references, alter, and
index.

The syntax for revoking privileges on a table is:

revoke privileges on object from user;

For example, if you wanted to revoke delete privileges on a table called suppliers from a user named anderson, you
would execute the following statement:

revoke delete on suppliers from anderson;

If you wanted to revoke all privileges on a table, you could use the all keyword. For example:

revoke all on suppliers from anderson;

If you had granted privileges to public (all users) and you wanted to revoke these privileges, you could execute the
following statement:

revoke all on suppliers from public;

Grant Privileges on Functions/Procedures

When dealing with functions and procedures, you can grant users the ability to execute these functions and
procedures. The Execute privilege is explained below:

Privilege Description

Execute Ability to compile the function/procedure.


Ability to execute the function/procedure directly.

The syntax for granting execute privileges on a function/procedure is:

grant execute on object to user;

For example, if you had a function called Find_Value and you wanted to grant execute access to the user named
smithj, you would execute the following statement:

grant execute on Find_Value to smithj;

If you wanted to grant all users the ability to execute this function, you would execute the following:

grant execute on Find_Value to public;

Revoke Privileges on Functions/Procedures


Once you have granted execute privileges on a function or procedure, you may need to revoke these privileges from
a user. To do this, you can execute a revoke command.

The syntax for the revoking privileges on a function or procedure is:

revoke execute on object from user;

If you wanted to revoke execute privileges on a function called Find_Value from a user named anderson, you would
execute the following statement:

revoke execute on Find_Value from anderson;

If you had granted privileges to public (all users) and you wanted to revoke these privileges, you could execute the
following statement:

revoke execute on Find_Value from public;

insert into emp_tab select * from emp


where

You might also like