Oracle User Management

Keywords: sqlplus Session Database SQL

Example:
  

#sqlplus /nolog
  SQL> conn / as sysdba;
  create user username identified by password;
  grant connect,resource to username;
  grant select,insert,update,delete on Table name to username;
  //Let this user create views
  grant CREATE VIEW to username;
  //Let this user create tables
  grant create table to username; 
  //Create synonym permissions. If the user's level is not enough to create a public synonym, it can be authorized under system:
    grant create any synonym to username;
    grant create public synonym to username;
     //View user permissions on tables
    SELECT * FROM user_tab_privs t where t.TABLE_NAME=upper('Table name');

    //Subuser login, validation
   conn username/password;
   
   select * from user_sys_privs;
  //Query whether authorization is successful and whether synonyms can be defined
        select * from session_privs where privilege like '%SYNONYM%';
  //Create synonym statements
        create  synonym emp for scott.emp;
    //Creating Common Synonym Statements
        create public synonym emp for scott.emp;
    //Look at all synonyms:
  select * from dba_synonyms 
//drop synonym
//Use DROP SYNONYM statement to delete synonyms that are no longer needed. To delete private synonyms, omit PUBLIC keywords. To delete // public synonyms, include PUBLIC keywords.
//DROP SYNONYM emp; -- Delete a private synonym named EMP
//DROP PUBLIC SYNONYM public_emp; -- Delete a public synonym named public_emp

SELECT * FROM user_tab_privs t where t.TABLE_NAME=upper('Table name');

select * from Table name where rownum<=2

I. User Classification
sys; // System Administrator, with the highest privileges
system; // Local Administrator, sub-high privilege
scott; // Ordinary user, password default tiger, default unlock

Two. Landing
sqlplus / as sysdba; // login to sys account
sqlplus sys as sysdba; //ibid.
sqlplus scott/tiger; // login to ordinary user scott

III. Managing Users
create user zhangsan; // create user zhangsan under the administrator account
alert user scott identified by tiger; //change password

   //Permission to create session session session, otherwise unable to log in
   grant create session to facc_fields_sel;

Command: grant XXX permission on TableA to USERA
grant select,insert,update,delete on table name to user name
For example, give solidwang the user the query privilege of the test table
grant select on test to solidwang;
Four: Authority
Next, look at system permissions.
DBA: With all privileges, it is the highest privilege of the system. Only DBA can create database structure.
RESOURCE: Users with Resource privileges can only create entities, not database structures.
CONNECT: Users with Connect privileges can only login to Oracle, not create entities, not create database structures.
For ordinary users: grant connect, resource permissions.
For DBA management users: grant connect, resource, dba permissions.
And system privileges can only be granted by DBA users: sys, system (initially only two users). Ordinary users can have the same user rights as system through authorization.
But it can never achieve the same privileges as system users, and the privileges of system users can also be reclaimed.
V. Withdrawal of authority

The basic grammar is the same as grant, and the key word is revoke.
Cancellation of authorization:
revoke create any synoym from scott;
revoke create public synoym from scott;
Cancel synonyms:
drop public synonym abc;
Authorization to cancel synonyms:
grant dorp public synonym to scott;
Cancellation of authorization:
revoke drop public synonym to scott;

6. View permissions

select * from user_sys_privs; // View all current user rights

select * from user_tab_privs; // View the permissions of the user to the table used

7. User's table of operation table
  select * from zhangsan.tablename

Posted by syntaxerror on Tue, 21 May 2019 18:05:50 -0700