Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dba Privileges

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Creating role:

CREATE ROLE clerk IDENTIFIED BY bicentennial;


ALTER ROLE clerk IDENTIFIED EXTERNALLY;
CREATE ROLE admin_role IDENTIFIED USING hr.admin;
The following statement creates a global role:
CREATE ROLE supervisor IDENTIFIED GLOBALLY;
DROPING ROLES:

DROP ROLE clerk;

USER PRIVILEGES
Create a User and Grant the Create Session System Privilege
CREATE USER jward
IDENTIFIED BY AZ7BC2
DEFAULT TABLESPACE data_ts
QUOTA 100M ON test_ts
QUOTA 500K ON data_ts
TEMPORARY TABLESPACE temp_ts
PROFILE clerk;
GRANT create session TO jward;

Altering Users
ALTER USER avyrros
IDENTIFIED EXTERNALLY
DEFAULT TABLESPACE data_ts
TEMPORARY TABLESPACE temp_ts
QUOTA 100M ON data_ts
QUOTA 0 ON test_ts
PROFILE clerk;
CHANGING USER AUTHENTICATION:

ALTER USER andy


IDENTIFIED BY swordfish;

User and Profile Information in Data Dictionary Views

The following data dictionary views contain information about database users and profiles:
View

Description

DBA_USERS

Describes all users of the database

ALL_USERS

Lists users visible to the current user, but does not describe them

USER_USERS

Describes only the current user

DBA_TS_QUOTAS

Describes Tablespace quotas for users

USER_TS_QUOTAS
USER_PASSWORD_LIMIT
S

Describes the password profile parameters that are assigned to the


user

USER_RESOURCE_LIMIT
S

Displays the resource limits for the current user

DBA_PROFILES

Displays all profiles and their limits

RESOURCE_COST

Lists the cost for each resource

V$SESSION

Lists session information for each current session, includes user name

V$SESSTAT

Lists user session statistics

V$STATNAME

Displays decoded statistic names for the statistics shown in the


V$SESSTAT view

PROXY_USERS

Describes users who can assume the identity of other users

The following sections present some examples of using these views, and assume a
database in which the following statements have been executed:

CREATE PROFILE clerk LIMIT


SESSIONS_PER_USER 1
IDLE_TIME 30
CONNECT_TIME 600;
CREATE USER jfee
IDENTIFIED BY wildcat
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp_ts
QUOTA 500K ON users
PROFILE clerk;
CREATE USER dcranney
IDENTIFIED BY bedrock

DEFAULT TABLESPACE users


TEMPORARY TABLESPACE temp_ts
QUOTA unlimited ON users;
CREATE USER user Scott
IDENTIFIED BY scott1;
Listing All Users and Associated Information

SELECT USERNAME, PROFILE, ACCOUNT_STATUS FROM DBA_USERS;


Listing All Tablespace Quotas

SELECT * FROM DBA_TS_QUOTAS;


Listing All Profiles and Assigned Limits

SELECT * FROM DBA_PROFILES


ORDER BY PROFILE;
Viewing Memory Use for Each User Session

SELECT USERNAME, VALUE || 'bytes' "Current UGA memory"


FROM V$SESSION sess, V$SESSTAT stat, V$STATNAME name
WHERE sess.SID = stat.SID
AND stat.STATISTIC# = name.STATISTIC#
AND name.NAME = 'session uga memory';

Managing User Roles


CREATE ROLE clerk IDENTIFIED BY bicentennial;
ALTER ROLE clerk IDENTIFIED EXTERNALLY;
CREATE ROLE manager IDENTIFIED BY more work;

Role Authorization by an Application


CREATE ROLE admin_role IDENTIFIED USING hr.admin;

Role Authorization by an External Source


CREATE ROLE accts_rec IDENTIFIED EXTERNALLY;
The following statement creates a global role:

CREATE ROLE supervisor IDENTIFIED GLOBALLY;


Dropping Roles

DROP ROLE clerk;


Granting System Privileges and Roles

GRANT CREATE SESSION, accts_pay TO jward;


Granting the ADMIN OPTION
In the following statement, the security administrator grants the new_dba role to michael:
GRANT new_dba TO michael WITH ADMIN OPTION;
Granting Object Privileges

GRANT SELECT, INSERT, DELETE ON emp TO jfee, tsmith;


Granting Object Privileges on Behalf of the Object Owner
GRANT SELECT ON hr.employees TO blake WITH GRANT OPTION;
Revoking User Privileges and Roles
REVOKE CREATE TABLE, accts_rec FROM tsmith;
Revoking Object Privileges

REVOKE SELECT, insert ON emp FROM jfee, tsmith;


REVOKE ALL ON dept FROM human_resources;

The SET ROLE Statement

This example enables the role clerk, which you have already been granted, and specifies the
password.
SET ROLE clerk IDENTIFIED BY bicentennial;
You can disable all roles with the following statement:
SET ROLE NONE;

Specifying Default Roles

ALTER USER jane DEFAULT ROLE payclerk, pettycash;


Examples;
CREATE ROLE security_admin IDENTIFIED BY honcho;

GRANT CREATE PROFILE, ALTER PROFILE, DROP PROFILE,


CREATE ROLE, DROP ANY ROLE, GRANT ANY ROLE, AUDIT ANY,
AUDIT SYSTEM, CREATE USER, BECOME USER, ALTER USER, DROP USER
TO security_admin WITH ADMIN OPTION;
GRANT SELECT, DELETE ON SYS.AUD$ TO security_admin;
GRANT security_admin, CREATE SESSION TO swilliams;
GRANT security_admin TO system_administrator;
GRANT CREATE SESSION TO jward;
GRANT SELECT, DELETE ON emp TO jward;
GRANT INSERT (ename, job) ON emp TO swilliams, jward;

Table spaces:
SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS
FROM USER_TABLESPACES;
How To View the Data Files in the Current Database?
SQL> connect SYSTEM/fyicenter
Connected.
SQL> col tablespace_name format a16;
SQL> col file_name format a36;
SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES
FROM DBA_DATA_FILES;
CREATING TABLESPACE:
CREATE TABLESPACE lmtbsb DATAFILE '/u02/oracle/data/lmtbsb01.dbf'
SIZE 50M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
ALTER TABLE SPACE:
ALTER TABLESPACE lmtbsb
ADD DATAFILE '/u02/oracle/data/lmtbsb02.dbf' SIZE 1M;

CREATING BIGFILE TABLESPACE:


CREATE BIGFILE TABLESPACE bigtbs
DATAFILE '/u02/oracle/data/bigtbs01.dbf' SIZE 50G

(You can specify SIZE in kilobytes (K), megabytes (M), gigabytes (G), or
terabytes (T).)

Altering a Bigfile Tablespace:


ALTER TABLESPACE bigtbs RESIZE 80G;

Identifying a Bigfile Tablespace


The following views contain a BIGFILE column that identifies a tablespace as a bigfile
tablespace:

DBA_TABLESPACES

USER_TABLESPACES

V$TABLESPACE

Creating a Locally Managed Temporary Tablespace:


CREATE TEMPORARY TABLESPACE lmtemp TEMPFILE
'/u02/oracle/data/lmtemp01.dbf'
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;
The following statement makes the flights tablespace read-only:
ALTER TABLESPACE flights READ ONLY;

You might also like