USER MANAGEMENT
we have 3 types of users.
>end users
>developers
>DBA's
End users are the real users who access the business.
developers develop the project.
DBA's ae administrative the entire database.
SQL>select username from dba_users;
how many users are there in the database will display
when we create a database oracle automatically create default users inside a database.
outof all users sys user is sysdba and remaining users are developers.
syntax to create non default users;
SQL>create user username identified by password;
SQL>select username,password from dba_users;
NOTE:oracle always store the password in encrypted format.
SQL>selectuser_id,account_status,default_tablespace,temporary_tablespace from dba_users where username='username';
even though user exist in the database he require CREATE SESSION privilege to connect to the database.
SQL>grnat create session to username;
when user account locked the ora -28000 error will came that time you can unlock the account
SQL>alter user username account unlock;
we can also lock the account
SQL>alter user username account lock;
Particular user to assign a tablespace
SQL>alter user username default tablesapce tablesapcename;
this is for creating any tables,indexes any other objects will create in the tablespace only.
SQL>alter user username temporary tablespace tablespacename;
SQL>grant create table to username;
this previlige to create table to user
particular user want to some quota in the tablespace.
SQL>alter user username quota 5m on tablespacename;
SQL> select username,tablespace_name,bytes/(1024*1024)"MB",max_bytes/(1024*1024)"maxbytes" from dba_ts_quotas where username =username;
QUOTA MANAGEMENT
---------------------
Using this quotas concept we can resrict a user upto some maximum memory inside a tablespace.
SQL>alter user username quota 10m on tablespacename;
SQL>alter user username quota unlimited on tablespace;
Single user can have quotas on multiple tablespaces
PROFILE MANAGEMENT
Every user inside a database will have it's own profile.
when we create a database oracle will autimatically create a profile is DEFAULT.
This profile is assigned to every user by default if there is no profile explicitly assign.
SQL>select username,profile from dba_users;
SQL>select distinct(profile) from dba_proifiles;
PROFILE
------------------------------
MONITORING_PROFILE
DEFAULT
syntax to create user defined profile
SQL>create profile profilename
limit
sessions_per_user 3;
Assign profile to user
SQL>alter user username profile profile name;
altering the profile also
SQL>alter profile profile name
limit
failed_login_attempts;
SQL>select * from dba_profiles where profile='P1';
we can drop profile also
SQL>drop profile profile name cascade;
when we drop the assigned profile than automatically assign the default profile.
PRIVILEGE MANAGEMENT
privilege is the permission to do task inside the database;
privileges are defined by oracle we cannot create or destroy the privilege.
minimum require to connect the database CREATE SESSION privilege.
By default SYS user had all privileges provided by oracle
privileges are two types
1>system level privilege
2>object level privilege
>system level privilege;
using this privilege we can impact the entire system database.
All DDL operations comes under this privilege i.e create,aleter,rename,drop,truncate
these are again two types
system privileges:
sysdba,sysoper are very powerful system privileges
when we grnat sysdba privilege to any user that user becomes as sys user .he can do any activity in database without anyother privilege.
To grant this sysdba previlege database requires password file.
sysoper previlege is same as sysdba but user who is having sysoper privilege cannot perform destructive tasks like drop database/tbs/role etc.
object level previleges:
we cannot operate at object level privileges.
OBJECT LEVEL PRIVILEGES;
All DML,DRL operations come under this privilege
SQL>select * from session_privs;
ROLE MANAGEMENT
to make privilege management easy we use roles
role is collection of one or more privileges.
when we create database time oracle create few roles these are default roles.
default and non default roles
default roles are connect,resource,export_full_database,recovery_catalog_owner etc
Nondefault roles:
these roles are created by user sys
syntax;
SQL>create role rolename;
particular user having roles
SQL>select username,default_role,granted_role from user_role_privs;
we have 3 types of users.
>end users
>developers
>DBA's
End users are the real users who access the business.
developers develop the project.
DBA's ae administrative the entire database.
SQL>select username from dba_users;
how many users are there in the database will display
when we create a database oracle automatically create default users inside a database.
outof all users sys user is sysdba and remaining users are developers.
syntax to create non default users;
SQL>create user username identified by password;
SQL>select username,password from dba_users;
NOTE:oracle always store the password in encrypted format.
SQL>selectuser_id,account_status,default_tablespace,temporary_tablespace from dba_users where username='username';
even though user exist in the database he require CREATE SESSION privilege to connect to the database.
SQL>grnat create session to username;
when user account locked the ora -28000 error will came that time you can unlock the account
SQL>alter user username account unlock;
we can also lock the account
SQL>alter user username account lock;
Particular user to assign a tablespace
SQL>alter user username default tablesapce tablesapcename;
this is for creating any tables,indexes any other objects will create in the tablespace only.
SQL>alter user username temporary tablespace tablespacename;
SQL>grant create table to username;
this previlige to create table to user
particular user want to some quota in the tablespace.
SQL>alter user username quota 5m on tablespacename;
SQL> select username,tablespace_name,bytes/(1024*1024)"MB",max_bytes/(1024*1024)"maxbytes" from dba_ts_quotas where username =username;
QUOTA MANAGEMENT
---------------------
Using this quotas concept we can resrict a user upto some maximum memory inside a tablespace.
SQL>alter user username quota 10m on tablespacename;
SQL>alter user username quota unlimited on tablespace;
Single user can have quotas on multiple tablespaces
PROFILE MANAGEMENT
Every user inside a database will have it's own profile.
when we create a database oracle will autimatically create a profile is DEFAULT.
This profile is assigned to every user by default if there is no profile explicitly assign.
SQL>select username,profile from dba_users;
SQL>select distinct(profile) from dba_proifiles;
PROFILE
------------------------------
MONITORING_PROFILE
DEFAULT
syntax to create user defined profile
SQL>create profile profilename
limit
sessions_per_user 3;
Assign profile to user
SQL>alter user username profile profile name;
altering the profile also
SQL>alter profile profile name
limit
failed_login_attempts;
SQL>select * from dba_profiles where profile='P1';
we can drop profile also
SQL>drop profile profile name cascade;
when we drop the assigned profile than automatically assign the default profile.
PRIVILEGE MANAGEMENT
privilege is the permission to do task inside the database;
privileges are defined by oracle we cannot create or destroy the privilege.
minimum require to connect the database CREATE SESSION privilege.
By default SYS user had all privileges provided by oracle
privileges are two types
1>system level privilege
2>object level privilege
>system level privilege;
using this privilege we can impact the entire system database.
All DDL operations comes under this privilege i.e create,aleter,rename,drop,truncate
these are again two types
system privileges:
sysdba,sysoper are very powerful system privileges
when we grnat sysdba privilege to any user that user becomes as sys user .he can do any activity in database without anyother privilege.
To grant this sysdba previlege database requires password file.
sysoper previlege is same as sysdba but user who is having sysoper privilege cannot perform destructive tasks like drop database/tbs/role etc.
object level previleges:
we cannot operate at object level privileges.
OBJECT LEVEL PRIVILEGES;
All DML,DRL operations come under this privilege
SQL>select * from session_privs;
ROLE MANAGEMENT
to make privilege management easy we use roles
role is collection of one or more privileges.
when we create database time oracle create few roles these are default roles.
default and non default roles
default roles are connect,resource,export_full_database,recovery_catalog_owner etc
Nondefault roles:
these roles are created by user sys
syntax;
SQL>create role rolename;
particular user having roles
SQL>select username,default_role,granted_role from user_role_privs;