User Information in Oracle introduction.pptx

AzarHamid 16 views 65 slides May 18, 2024
Slide 1
Slide 1 of 65
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65

About This Presentation

helpfull


Slide Content

SELECT sid , osuser , username , status , TO_CHAR ( logon_time , 'DAY HH24:MI:SS') LOGON_TIME , FLOOR ( last_call_et /3600)||':'|| FLOOR ( MOD ( last_call_et ,3600)/60)||':'|| MOD ( MOD ( last_call_et ,3600),60) IDLE , program FROM v_$session WHERE username IS NOT NULL ORDER BY last_call_et ; USER Information

USER Information

Total Active USER Information SELECT COUNT (*) "ACTIVE USERS" FROM v_$session WHERE username IS NOT NULL ;

Active USER Information

USER Memory SELECT username , VALUE || 'bytes' "Current UGA memory" FROM v_$session sess , v_$ sesstat sstat , v_$ statname sname WHERE sess . sid = sstat . sid AND sstat . statistic # = sname . statistic # AND sname . name = 'session uga memory';

USER Memory

SCOTT User Open & Lock SELECT username, account_status FROM DBA_USERS WHERE username = 'SCOTT' ;

Total User Open & Lock SELECT username, lock_date , account_status , default_tablespace FROM dba_users ;

User Sample List HR - Human resources, basic topics, supports Oracle Internet Directory OE - Order entry, intermediate topics, various data types PM - Product media, used for multimedia data types QS - Queued shipping, shows advanced queuing ( renamed IX in Oracle 10g) SH - Sales history, large amount of data, analytic processing SCOTT- Demo User (Only Deptt , and Sale)

User List

User Sample 11 G

User Sample 12c

Check SYS Info How to get SID name select instance_name from v$instance ; OR select global_name from global_name ; OR select name from v$database ; use the v$database table, you must have a sysdba privilege

Change Oracle passwords, expire, and lock unnecessary users There are many users on a full installation of Oracle, most of which you probably won't need. To lock an Oracle user account, you can use the following command : alter user username account lock ; To unlock the user, simply replace 'lock' with 'unlock .‘ Oracle comes with a few default accounts that should never be locked or dropped. These include: SYS, SYSTEM, SYSMAN

you do want always to change the password for these users. The default password for SYS is change_on_install . It is important that you follow these directions. To change the password for a user: alter user username identified by new_password ; Change Oracle passwords, expire, and lock unnecessary users

Setting the Oracle database user password lifetime SQL> select * from dba_profiles s where s.profile ='DEFAULT' and resource_name =' PASSWORD_LIFE_TIME '; PROFILE RESOURCE_NAME RESOURCE LIMIT ----------------------------------------------------------- ---------------------------- DEFAULT PASSWORD_LIFE_TIME PASSWORD 180dys The output shows that the lifetime of the user is 180 days. Set the password lifetime to Unlimited. SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

User Lock and password expired ALTER USER user_name IDENTIFIED BY password ACCOUNT UNLOCK; alter user scott identified by tiger account lock password expire;

User Sample Scott

User Sample Scott ALTER USER scott ACCOUNT UNLOCK;

User Sample Scott alter user scott identified by tiger;

User Sample Scott

User Sample Scott

User Sample Scott Run this script: CREATE USER scott IDENTIFIED BY tiger ; scott is the user tiger is the password. Grant all access to user scott,run this script : GRANT ALL PRIVILEGES TO scott ; Extract the downloaded file in your system. Then Connect to Scott user as: CONNECT scott Password: tiger Then type this in your sql command prompt: @( extract file path)\ oracle.sql ; for example: @C:\Users\ABC\oracle\ oracle.sql ;

Show all table and table structure select * from tab ; SQL > DESC emp ;

view User privileges select * from SESSION_PRIVS

System User The SYSTEM account is one of a handful of predefined administrative accounts generated automatically when Oracle is installed. SYSTEM is capable of most administrative tasks, but the task we’re particularly interested in is account management.

System User no DBA

Create a new user

Create a new user

Create a new user

Create a new user

Create A New User CREATE USER zahid IDENTIFIED BY password123 DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON USERS ACCOUNT UNLOCK ; SELECT username, lock_date , account_status FROM dba_users where username='ZAHID'; QUOTA 100M on users

Check New User

Drop User The DROP USER statement is used to remove a user from the Oracle database and remove all objects owned by that user.

Drop User If zahid did own objects in its schema, you would need to run the following DROP USER statement instead : DROP USER zahid CASCADE ; This DROP USER statement would remove the user zahid , drop all objects ( ie : tables and views) owned by zahid , and all referential integrity constraints on zahid objects would also be dropped.

View User privileges desc dba_sys_privs ;

Grant P rivileges grant create session, resource to zahid ; Check Grant P rivileges SELECT grantee, PRIVILEGE FROM dba_sys_privs WHERE grantee = 'ZAHID' ORDER BY privilege;

Check Grant P rivileges

Check Grant P rivileges SELECT grantee, COUNT(privilege) FROM dba_sys_privs GROUP BY grantee;

DBA Grant P rivileges

Check User how many tables select table_name FROM user_tables ;

Create a Table CREATE TABLE suppliers ( supplier_id number(10) NOT NULL, supplier_name varchar2(50) NOT NULL, address varchar2(50), city varchar2(50), state varchar2(25), zip_code varchar2(10) );

Create a Table

Data Control Language Statements are used to grant privileges on tables, views, sequences, synonyms, procedures to other users or roles. Data Control Language

System Privileges System Privileges are normally granted by a DBA to users. Examples of system privileges are CREATE SESSION, CREATE TABLE, CREATE USER etc . Object privileges Object privileges means privileges on objects such as tables, views, synonyms, procedure. These are granted by owner of the object. Data Control Language

Syntax for tables GRANT privilegeType ON [ TABLE ] { tableName | viewName } TO grantees Grant Privileges

Grant Privileges on Table You can grant users various privileges to tables. These privileges can be any combination of SELECT, INSERT, UPDATE, DELETE, REFERENCES, ALTER, INDEX, or ALL. Syntax The syntax for granting privileges on a table in Oracle is: GRANT privileges ON object TO user; Grant Privileges

Grant Privileges Grant on Table You can grant users various privileges to tables. These privileges can be any combination of SELECT, INSERT, UPDATE, DELETE, REFERENCES, ALTER, INDEX, or ALL.

Grant Privileges For example, if you wanted to grant SELECT, INSERT, UPDATE, and DELETE privileges on a table called suppliers to a user name zahid , you would run the following GRANT statement: GRANT select, insert, update, delete ON suppliers TO zahid ;

Grant Privileges You can also use the ALL keyword to indicate that you wish ALL permissions to be granted for a user named Zahid . For example: GRANT ALL ON suppliers TO zahid ;

Grant Privileges If you wanted to grant only 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;

Grant Privileges If you wanted to grant only 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;

Grant Privileges Suppose you want to grant update and insert privilege on only certain columns not on all the columns then include the column names in grant statement. For example you want to grant update privilege on ename column only and insert privilege on empno and ename columns only. grant update ( ename ), insert ( empno , ename )  on emp to zahid ;

Grant Privileges To grant select statement on emp table to zahid and to make zahid be able further pass on this privilege you have to give WITH GRANT OPTION clause in GRANT statement like this. grant select on emp to zahid with grant option;

REVOKE Privileges Use to revoke privileges already granted to other users. For example to revoke select, update, insert privilege you have granted to zahid then give the following statement . revoke select, update, insert on emp from zahid ; REVOKE DELETE ON suppliers FROM anderson ; REVOKE ALL ON suppliers FROM anderson ; REVOKE ALL ON suppliers FROM public;

REVOKE Privileges

ROLES A role is a group of Privileges. A role is very handy in managing privileges, Particularly in such situation when number of users should have the same set of privileges.

ROLES

ROLES

ROLES

ROLES

ROLES

ROLES For example you have four users : zahid , Scott, khalid , Ali in the database. To these users you want to grant select ,update privilege on emp table, select , delete privilege on dept table. To do this first create a role by giving the following statement create role clerks; Check how many roles SELECT * FROM USER_ROLE_PRIVS;

ROLES Then grant privileges to this role. grant select , update on Scott.emp to clerks; grant select , delete on Scott. dept to clerks ; Now grant this clerks role to users like this grant clerks to zahid , scott , khalid , ali ;

ROLES Suppose after one month you want grant delete on privilege on emp table all these users then just grant this privilege to clerks role and automatically all the users will have the privilege. grant delete on emp to clerks; If you want to take back update privilege on emp table from these users just take it back from clerks role . revoke update on emp from clerks; To Drop a role Drop role clerks;
Tags