Professional Documents
Culture Documents
com
GnanaSekar. A
TABLE O F CONTENTS
DBA - 1
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
DBA - 2
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Physical Files
Data files
store the data dictionary, user objects, and before-images of data that are modified by
current transactions. A database has at least one data file.
Redo log
files
contain a record of changes made to the database to ensure reconstruction of the data
in case of failures. A database requires at least two redo log files.
Control files
contain the information needed to maintain and verify database integrity. A database
needs at least one control file.
Backgroung Processes
The background processes in an instance perform common functions that are needed to service the
requests from several concurrent users, without compromising the integrity and performance of the
whole system. Each Oracle instance may use several background processes, depending on the
configuration, but every instance comprises these five background processes by default:
DBWR
The server process records changes to rollback and data blocks in the buffer cache.
The database writer (DBWR) writes the dirty buffers from the database buffer cache
to the data files. It ensures that sufficient number of free buffers—buffers that can be
overwritten when server processes need to read in blocks from the data files—are
available in the database buffer cache. Database performance is improved because
server processes only make changes in the buffer cache, and the DBWR defers
writing to the
data files until one of the following events occur:
· The number of dirty buffers reaches a threshold value
· A process scans a specified number of blocks when scanning for free buffers and
cannot find any
· A timeout occurs
· A DBWR checkpoint can be triggered by various events such as closing
· of the database, (Checkpoint is a means of synchronizing the database buffer
cache with the data file.)
LGWR
The Log Writer (LGWR) is a background process that writes entries from the redo
log buffer into the redo log files. The LGWR performs sequential writes to the redo
log file under the following situations:
· When the redo log buffer is one-third full
· When a timeout occurs (every three seconds)
· Before DBWR writes modified blocks in the database buffer cache to the
· data files
· When a transaction commits
DBA - 3
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
SMON
· Performs automatic instance recovery.
· Reclaims space used by temporary segments no longer in use.
· Merges contiguous areas of free space in the datafiles.
PMON
· Cleans up abnormally terminated connections.
· Rolls back uncommitted transactions.
· Releases locks held by a terminated process.
· Frees SGA resources allocated to the failed process.
CKPT
Checkpoint Process is responsible for updating the database status information
whenever changes in the buffer cache are permanently recorded in the database.
Shared Pool
· Size defined by SHARED_POOL_SIZE in parameter file
· Library cache contains statement text, parsed code, and an execution plan. Since
the library cache stores this information, if a query is reexecuted before its
execution plan is aged out by other statements, the server process does not need
to parse the statement. Thus the library cache helps improve the performance of
applications.
· Data dictionary cache stores the most recently used data dictionary information,
such as table and column definitions, usernames, passwords, and privileges.
During the parse phase, the server process looks for the information in the
dictionary cache to resolve the object names specified in the SQL statement and
to validate the access privileges. If necessary, the server process initiates the
loading of this information from the data files.
Database Buffer
Cache
· Number of buffers defined by DB_BLOCK_BUFFERS
· Size of a buffer based on DB_BLOCK_SIZE
· Stores the most recently used blocks
Redo Log
Buffer
· Size defined by LOG_BUFFER
· Records changes made through the instance
· Used sequentially
· Circular buffer
DBA - 4
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Parameter File
The parameter file, commonly referred to as the init<SID>.ora file, is a text file that can be maintained
using a standard operating system editor. By default, it is located in the $ORACLE_HOME/dbs
directory on a UNIX machine and in the %ORACLE_HOME%\database directory on NT. The
parameter file is only read during instance startup. If the file is modified, shut down and restart the
instance to make the new parameter values effective. The uses of parameter file are :
· Size the System Global Area (SGA) components to optimize performance.
· Set database and instance defaults.
· Set database limits.
· Define (on database creation only) various physical attributes of the database, such as the database
block size.
· Specify control files, archived log files, and trace file locations.
DBA - 5
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
STARTUP Command
Example
Startup Stages
------------------------NOMOUNT
------------------------MOUNT
SHUTDOWN Command
Syntax
DBA - 6
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
SID SERIAL#
------ ---------
7 15
3. Create a Database
Variable Description
ORACLE_HOME Set to the directory where the Oracle software will be
installed (Example: /u01/app/oracle/product/8.0.3)
ORACLE_SID Specifies the instance name and must be unique for
Oracle instances running on the same machine.
PATH Search path which must include $ORACLE_HOME/bin
On NT Set the variable ORACLE_SID to use SVRMGR30. Create the service and the password
file with ORADIM80.
DBA - 7
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Script Purpose
catalog.sql Creates commonly used data dictionary views
catproc.sql Runs all scripts required for PL/SQL on the server
DBA - 8
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
· Is a binary file that is necessary for the database to start and operate successfully.
· Every time an instance mounts an Oracle database, it reads the control file to locate the data files
and online redo log files.
· Is updated continuously during database use and must be available whenever the database is
mounted or opened.
· Provides information about database consistency used during recovery.
· If any of the control files currently being used by the database becomes unavailable, then the
database cannot function properly.
· In summary, control file contains the following information
¾ Database name
¾ Data file location
¾ Redo log file location
¾ Tablespace names
¾ Current log sequence number
¾ Checkpoint information
¾ Log history
¾ Backup information
DBA - 9
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
· Redo log files are used in a situation such as an instance failure to recover committed data that has
not been written to the data files. The redo log files are only used for recovery.
Member
Member Member
Disk 2
· A set of identical copies of online redo log files is called an online redo log group .
· The background process LGWR concurrently writes the same information to all online redo log
files in a group.
· The Oracle server needs a minimum of two online redo log file groups for the normal operation of
a database.
· Each online redo log file in a group is called a member .
· Each member in a group has identical log sequence numbers and the same size. The log sequence
number is assigned each time the Oracle server starts writing to a log group to identify each redo
log file uniquely. The current log sequence number is stored in the control file and in the header of
all data files.
DBA - 10
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
SVRMGR> SELECT *
2> FROM v$logfile;
DBA - 11
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Database
Extent
Oracle
O/S Block
block
Tablespaces
· A tablespace can belong to only one database.
· Each tablespace consists of one or more operating system files.
· Tablespaces can be brought online while the database is running.
· Except for the SYSTEM tablespace or a tablespace with an active rollback segment, tablespaces
can be taken offline, leaving the database running.
· Tablespaces can be switched between read-write and read-only status.
· Controlling space allocation and assigning space quotas to users
· Controlling availability of data by taking individual tablespaces online or offline
· Distributing data storage across devices to improve I/O performance and to reduce I/O contention
against a single disk
· Performing partial backup and partial recovery operations
· Keeping large amounts of static data on read-only devices
Data Files
· Each tablespace in an Oracle database consists of one or more files called data file s. These are
physical structures that conform with the operating system on which the Oracle server is running.
· A data file can belong to only one tablespace.
· An Oracle server creates a data file for a tablespace by allocating the specified amount of disk
space plus a small overhead.
· The database administrator can change the size of a data file after its creation or can specify that a
data file should dynamically grow as objects in the tablespace grow.
Segments
· A segment is the space allocated for a specific type of logical storage structure within a tablespace.
The following are examples of segments:
¾ Table segment
¾ Index segment
¾ Temporary segment
¾ Rollback segment
· A segment such as a data segment may span multiple files that belong to the same tablespace.
Extents
· An extent is a set of contiguous number of blocks.
· Each type of segment is made up of one or more extents.
· An extent may not span a data file, but must exist in one data file.
Data Blocks
DBA - 12
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
· At the finest level of granularity, the data in an Oracle database is stored in data blocks.
· One data block corresponds to one or more physical file blocks allocated from an existing data file.
· Data block size is specified for each Oracle database by the initialization parameter
DB_BLOCK_SIZE when the database is created.
· The smallest unit of input-output.
SYSTEM Tablespace
· Automatic created after the database is created
· Required in all databases for database operation
· Contains data dictionary information, definitions of stored procedures, packages, and database
triggers
· Contains the SYSTEM rollback segment
· Should not contain user data although it is allowed
Non-SYSTEM Tablespace
· Enable more flexibility in database administration
· Can store rollback segments, temporary segments, application data, and application indexes
Creating Tablespaces
Example
· INITIAL defines the size of the first extent. The minimum size of the first extent is two blocks,
that is (2*DB_BLOCK_SIZE). The default size is 5 blocks, that is (5* DB_BLOCK_SIZE).
· NEXT refers to the size of the second extent. The minimum size of the next extent is one block.
The default size is 5 blocks, that is (5* DB_BLOCK_SIZE).
· MINEXTENTS is the number of extents allocated when the segment is created. The minimum
and default is 1.
· PCTINCREASE is the percent by which the extent size grows. The size of an extent is calculated
using the following formula:
· MAXEXTENTS determines the maximum number of extents that a segment can have. The
minimum value is 1. The default maximum value depends on the data block size. The maximum
size can also be specified by the keyword UNLIMITED, which is equivalent to a value of
2147483645.
DBA - 13
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
ALTER DATABASE
DATAFILE ‘/DISK5/app03.dbf’
AUTOEXTEND ON NEXT 10M MAXSIZE 500M;
READ-ONLY Tablespace
Making tablespaces read-only prevents further write operations on the data files. The purpose of read-
only tablespaces is to ensure that no changes are made and to eliminate the need to perform backup and
recovery of large, static portions of a database. The Oracle server never updates the files of a read-only
tablespace, and therefore the files can reside on read-only media, such as CD ROMs or WORM drives.
DBA - 14
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Dropping Tablespaces
· A tablespace that still contains data cannot be dropped without the INCLUDING CONTENTS
option.
· Once a tablespace has been dropped, its data is no longer in the database.
· When a tablespace is dropped, only the file pointers in the control file of the associated database
are dropped. The database files still exist and must be deleted explicitly at the operating system
level.
· Even if a tablespace is switched to read-only it can still be dropped, along with segments within it.
This is possible because the DROP command only updates the data dictionary (which has to be
read-write), but not the physical files that make up the tablespace.
· It is recommended that you take the tablespace offline before dropping it to ensure that no
transactions access any of the segments in the tablespace.
TABLESPACE_NAME CONTENTS
STATUS
--------------- ---------- ----
--
SYSTEM PERMANENT
ONLINE
RBS PERMANENT
ONLINE
TEMP TEMPORARY
ONLINE
DATA01 PERMANENT
ONLINE
4 rows selected.
DBA - 15
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
INITRANS
Which defaults to 1 for a data segment, and 2 for an indexs segment, guarantees
minimum level of concurrency. For example, if set to 3, INITRANS ensures that at
least three transactions can concurrently make changes to the block. If necessary,
additional transaction slots can be allocated from the free space in the block, to
permit more concurrent transactions to modify rows in the block.
DBA - 16
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
MAXTRAN
S
Which has a default value of 255, sets the limit for the number of concurrent
transactions that can make changes to a data or an index block. When set, this value
restricts use of space for transaction slots and therefore guarantees that there is
sufficient space in the block for use by row or index data.
PCTFREE
For a data segment specifies the percentage of space in each data block reserved for
growth resulting from updates to rows in the block. The default for PCTFREE is 10
percent.
PCTUSED
For a data segment represents the minimum percentage of used space that Oracle
Server tries to maintain for each data block of the table. A block is put back on the
free list when its used space falls below PCTUSED. The free list of a segment is a
list of blocks that are candidates for accommodating future inserts. A segment, by
default, is created with one free list. Segments can be created with a higher number
of free lists by setting the FREELISTS parameter of the storage clause. The default
for PCTUSED is 40 percent.
DBA - 17
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
8. Rollback Segment
Transaction Rollback
When a transaction makes changes to a row in a table, the old image is saved in the rollback segment.
If the transaction is rolled back, the value in the rollback segment is written back to the row, restoring
the original value.
Read Consistency
When transactions are in progress, other users in the database should not see any uncommitted changes
made by these transactions. In addition, a statement should not see any changes that were committed
after the statement commences execution. The old values in the rollback segments are also used to
provide the readers a consistent image for a given statement.
Transaction Recovery
If the instance fails when transactions are in progress, Oracle server needs to rollback the uncommitted
changes when the database is opened again. This rollback is known as transaction recovery and is only
possible if changes made to the rollback segment are also protected by the redo log files.
1 2
Transaction 1 Transaction 2
4 3
DBA - 18
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
4. Transactions use extents of a rollback segment in an ordered circular fashion, moving from one to
the next after the current extent is full. A transaction writes a record to the current location in the
rollback segment and advances the current pointer by the size of the record.
1 2
1 2
5 3
4 3
4
5. The pointer or the head of the rollback segment moves to the next extent when the current extent is
full. When the last extent that is currently available is full, the pointer can only move back to the
beginning of the first extent if that extent is free. The pointer cannot skip over an extent and move
to the second or any other extent. If the first extent is being used, the transaction will allocate an
additional extent for the rollback segment. This is called an exten d. Similarly, if the head tries to
move into an extent and that extent is active, the rollback segment will allocate an additional
extent. A rollback segment may grow in this manner until it reaches the maximum number of
extents specified by the MAXEXTENTS parameter.
6. The OPTIMAL parameter specifies the size in bytes that a rollback segment must shrink to, if
possible. Specifying OPTIMAL minimizes the waste of space in a rollback segment. If the
OPTIMAL parameter is specified, a rollback segment can release space on completion of
transactions that caused the growth.
Example :
Specify the following initialization parameter to ensure rollback segments are brought online at
STARTUP:
ROLLBACK_SEGMENTS=(rbs01)
DBA - 19
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
DBA - 20
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
9. Temporary Segment
· Temporary segments are used when statements such as the following are executed and the Oracle
server cannot perform the sorting needed in memory because it is bigger than SORT_AREA_SIZE
¾ SELECT. . . ORDER BY
¾ CREATE INDEX
¾ SELECT DISTINCT
¾ SELECT. . . GROUP BY
· The amount of memory used by a process for sorting is determined by the SORT_AREA_SIZE
initialization parameter. If the sort volume exceeds this size, several sort runs are needed, and
intermediate results are stored on disk.
· Temporary segments are created and used by the Oracle server in the tablespace that has been
assigned to the user for sorting.
· V$SORT_SEGMENT
This view gives the status of the sort extent pool used by the instance.
· V$SORT_USAGE
This view only shows currently active sorts for the instance.
ROWID in Oracle 8
ROWID Format
OOOOOO FFF BBBBBB RRR
Data object Relative file Block number Row number
number number
DBA - 21
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
· Row Number identifies the position of the row directory slot in the block header.
Example :
In this example:
· AAAArs is the data object number.
· AAD is the relative file number.
· AAAAUa is the block number.
· AAA is the row number for the department with DEPTNO=10.
· The high water mark for a table indicates the last block that was ever used for the table.
· As data is inserted into the table, the high water mark is moved to mark the last block used.
· The high water mark is not reset when rows are deleted from the table.
· The high water mark is stored in the segment header of the table.
· When the Oracle server performs full table scans, it reads all the blocks up to the high water mark.
· If large extents have been allocated to a table, but have not been used fully, it is possible to
manually deallocate space from the table by the following command. The space thus released is
available for use by other segments in the tablespace.
DBA - 22
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Example 1 : To verify the integrity of each data block of scott’s employees table.
· The statistics generated by the ANALYZE command will be stored in the data dictionary. E.g.
dba_tables.
· The COMPUTE STATISTICS option will generate statistics based on a full table scan, while the
ESTIMATE STATISTICS will generate statistics based on a sample.
· When statistics are generated, the CHAIN_CNT column of the data dictionary view
DBA_TABLES is updated with the number of rows that are chained or migrated. If a large number
of rows are migrated, then the table needs to be reorganized to eliminate migration.
DBMS_ROWID Package
DBA - 23
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
B-Tree Index
Index entry
Root
Branch
· At the top of the index is the root, which contains entries that point to the next level in the index.
· At the next level are branch blocks, which in turn point to blocks at the next level in the index.
· At the lowest level are the leaf nodes, which contain the index entries that point to rows in the
table. The leaf blocks are doubly linked to facilitate scanning the index in an ascending as well as
descending order of key values.
Example : Create a normal B-Tree index on the last_name column of scott’s employees table
Example : Create a reverse key index on the ord_no column of scott’s ord table
CREATE UNIQUE INDEX scott.ord_ord_no_idx
ON scott.ord(ord_no) REVERSE
PCTFREE 30
STORAGE(INITIAL 200K NEXT 200K
PCTINCREASE 0 MAXEXTENTS 50)
TABLESPACE indx01;
Bitmap Index
A bitmap index is also organized as a B-tree, but the leaf node stores a bitmap for each key value
instead of a list of ROWIDS. Each bit in the bitmap corresponds to a possible ROWID, and if the bit is
set, it means that the row with the corresponding ROWID contains the key value.
Example : Create a bitmap index on the region_id column of scott’s ord table
DBA - 24
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
B-tree Bitmap
Suitable for high-cardinality columns Suitable for low-cardinality columns
Updates on keys relatively inexpensive Updates to key columns very expensive
Inefficient for queries using OR predicates Efficient for queries using OR predicates
Useful for OLTP Useful for DSS
· Check all the index blocks for block corruption. Note that this command does not verify whether
index entries correspond to data in the table.
· Populate the INDEX_STATS view with information about the index.
Types of Constraints
Constraint Description
NOT NULL Specifies that a column cannot contain null values
UNIQUE Designates a column or combination of columns as unique
PRIMARY KEY Designates a column or combination of columns as the table’s primary key
FOREIGN KEY Designates a column or combination of columns as the foreign key in a referential
integrity constraint
DBA - 25
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
CHECK Specifies a condition that each row of the table must satisfy
Disabled Constraints
A constraint that is disabled is not checked, even though the constraint definition is still stored in the
data dictionary. Data in the table as well as new data that is entered or updated may not conform to the
rules defined by the constraint.
If a constraint is enabled novalidate, new data that violates the constraint cannot be entered. However,
the table may contain data that is invalid—that is, data that violates the constraint. This is usually an
intermediate stage that ensures that all new data is checked before being accepted into the table.
· No locks on table
· Primary/unique keys must use nonunique indexes
DBA - 26
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Enabled Constraints
If a constraint is in this state, then all data in the table is guaranteed to adhere to the constraint. In
addition, this state prevents any invalid data from being entered. This is the normal state of operation of
a constraint for online transaction processing.
· Locks table
· Can use unique or nonunique indexes
· Needs valid table data
Deferred Constraints
Deferred constraints are constraints that are checked only when a transaction
commits. If any constraint violations are detected at commit time, the entire
transaction is rolled back. These constraints are most useful when both the
parent and child rows in a foreign key relationship are entered at the same
time, as in the case of an order entry system, where the order and the items
in the order are entered at the same time.
DBA - 27
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
1. Create a cluster
DBA - 28
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Index-Organized Tables
DBA - 29
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Example
where
SQL*Loader Features
· One or more input files can be used.
· Several input records can be combined into one logical record for loading.
· Input fields can be fixed or variable length.
· Input data can be in any format—character, binary, packed decimal, date, and zoned decimal.
· Data can be loaded from different types of media such as disk, tape, or named pipes.
· Data can be loaded into several tables in one run.
· Options are available to either replace or to append to existing data in the tables.
· SQL functions can be applied on the input data before the row is stored in the database.
· Column values can be autogenerated based on rules. For example, a sequential key value can be
generated and stored in a column.
· Data can be loaded directly into the table, bypassing the database buffer cache.
DBA - 30
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
· Bad file: is used by the utility to write the records that are rejected during the load (This can occur
during input record validation by the utility or during record insertion by the Oracle server.)
· Log file: is created by SQL*Loader and contains a record of the load
· Discard file: is a file that can be created, if necessary, to store all records
· that did not satisfy the selection criteria
Example :
Example 1 : Export scott’s EMP and DEPT tables with direct path export.
Name the exported file as emp.dmp and the log file as exp.log.
DBA - 31
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Import Behavior
· Order of Import
Table symbol 224 \f "Wingdings" \s 10à} Data symbol 224 \f "Wingdings" \s 10à}B-tree Indexes
symbol 224 \f "Wingdings" \s 10à}Constraints, Triggers, Bitmap indexes
· Tablespace used for the object
Same tablespace as in the source database, if possible
User’s default tablespace
Example 1 : Create a new user called PETER and assign tablespace quota to him.
Guidelines
Once a quota of 0 is assigned, the objects owned by the user remain in the revoked tablespace but they
cannot be allocated any new space. For example, if a table that is 10 MB exists in tablespace data01,
and the tablespace data01 quota is altered to 0, no more new extents can be allocated for that table.
DBA - 32
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
or
Guidelines
· When the user is dropped, all his objects(all tables, indexes, views.......) are dropped
· The CASCADE option drops all objects in the schema before dropping the user. This must be
specified if the schema contains any objects.
· A user who is currently connected to the Oracle server cannot be dropped.
DBA_USERS DBA_TS_QUOTAS
USERNAME USERNAME
USER_ID TABLESPACE_NAME
CREATED BYTES
ACCOUNT_STATUS MAX_BYTES
LOCK_DATE BLOCKS
EXPIRY_DATE MAX_BLOCKS
DEFAULT_TABLESPACE
TEMPORARY_TABLESPACE
A value of -1 in MAX_BLOCKS or MAX_BYTES column indicates that the user has unlimited quota
on a tablespace.
DBA - 33
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Resource Description
CPU_PER_SESSION Total CPU time measured in hundredths of seconds
SESSIONS_PER_USER Number of concurrent sessions allowed for each username
CONNECT_TIME Elapsed connect time measured in minutes
IDLE_TIME Periods of inactive time measured in minutes
LOGICAL_READS_PER _SESSION Number of data blocks (physical and logical reads)
PRIVATE_SGA Private space in the SGA measured in bytes (for MTS only)
Resource Description
CPU_PER_CALL CPU time per call in hundredths of seconds
LOGICAL_READS_PER _CALL Number of data blocks
Set the initialization parameter RESOURCE_LIMIT to TRUE in the parameter file. Then restart the
databse.
or
Enforce the resource limits by enabling the parameter with the ALTER SYSTEM command so that you
do not need to restart the database
DBA - 34
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Password Management
Parameter Description
FAILED_LOGIN_ATTEMPTS Number of failed login attempts before lockout of the
account
PASSWORD_LOCK_TIME Number of days for which the account remains locked
upon password expiration
PASSWORD_LIFE_TIME Lifetime of the password in days after which the
password expires
PASSWORD_GRACE_TIME Grace period in days for changing the password after the
first successful login after the password has expired
PASSWORD_REUSE_TIME Number of days before a password can be reused
PASSWORD_REUSE_MAX Maximum number of times a password can be reused
PASSWORD_VERIFY_FUNCTION PL/SQL function that makes a password complexity
check before a password is assigned
Example :
DBA - 35
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
SYSTEM Privileges
· System privileges enable users to perform particular actions in the database
· There are about 80 system privileges.
· The ANY-keyword in the privileges signifies that users have the privilege in every schema.
· The GRANT command adds a privilege to a user or a group of users.
· The REVOKE command deletes the privileges.
Category Examples
INDEX CREATE ANY INDEX
ALTER ANY INDEX
DROP ANY INDEX
TABLE CREATE TABLE
CREATE ANY TABLE
ALTER ANY TABLE
DROP ANY TABLE
SELECT ANY TABLE
UPDATE ANY TABLE
DELETE ANY TABLE
SESSION CREATE SESSION
ALTER SESSION
RESTRICTED SESSION
TABLESPACE CREATE TABLESPACE
ALTER TABLESPACE
DROP TABLESPACE
UNLIMITED TABLESPACE
Example 1 : Allow user1 to connect to the database and create his own tables
Example 2 : Allow scott to connect to the database and to further grant the privilege to
other users or roles
DBA - 36
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
1. The DBA grants the CREATE TABLE system privilege to USER 1 with the ADMIN OPTION.
2. USER 1 creates a table.
3. USER 1 grants the CREATE TABLE system privilege to SCOTT.
4. SCOTT creates a table.
5. The database administrator revokes the CREATE TABLE system privilege from USER 1.
The result:
1. The table of USER 1 still exists but the user cannot create any new tables.
2. SCOTT still has the table and the CREATE TABLE system privilege.
DBA - 37
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
The view SESSION_PRIVS lists the privileges that are available for the current session to a
user—in our example, for the user SCOTT.
PRIVILEGE
-----------------------
--
CREATE SESSION
ALTER SESSION
CREATE TABLE
SELECT ANY TABLE
CREATE CLUSTER
CREATE SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE PROCEDURE
9 rows selected.
Object Privileges
· Object privileges enables users to access and manipulate a specific object
· Each object privilege that is granted authorizes the grantee to perform someoperation on the
object.
· The table below summarizes the object privileges that can be granted on each type of object.
DBA - 38
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
"Wingding
s" \s 10ü}
INDEX symbo symb
l 252 ol 252
\f \f
"Wing "Win
dings" gding
\s s" \s
10ü} 10ü}
INSERT symbo
l 252
\f
"Wing
dings"
\s
10ü}
REFERENCES symbo
l 252
\f
"Wing
dings"
\s
10ü}
SELECT symbo symb symbol
l 252 ol 252 252 \f
\f \f "Wingding
"Wing "Win s" \s 10ü}
dings" gding
\s s" \s
10ü} 10ü}
UPDATE symbo symb
l 252 ol 252
\f \f
"Wing "Win
dings" gding
\s s" \s
10ü} 10ü}
DBA - 39
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Example 2 : Allow user1 to update ename and sal columns of the emp table and also allow
user1 to grant the object privileges to other users or roles
1. USER 1 is granted the SELECT object privilege with the GRANT OPTION.
2. USER 1 grants the SELECT privilege on EMP to USER 2.
The result:
3. Later, the SELECT privilege is revoked from USER 1. This revoke is cascaded to USER 2 as well.
Query DBA_TAB_PRIVS to return all object privileges granted to the specified user.
Query DBA_COL_PRIVS to list all the column specific privileges that have been granted use the
following query:
What is role?
Roles are named groups of related privileges that are granted to users or other roles. They are designed
to ease the administration of privileges in the database.
DBA - 40
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Role Characteristics
· Granted to and revoked from users with the same commands used to grant and revoke system
privileges
· May be granted to any user or role, except to itself (even indirectly)
· Can consist of both system and object privileges
· May be enabled or disabled for each user granted the role
· Can require a password to enable
· Each role name must be unique among existing usernames and role names
· Are not owned by anyone; are not in any schema
· Have their descriptions stored in the data dictionary
Benefits of Roles
· Reduced granting of privileges
· Dynamic privilege management
· Selective availability of privileges
· Granted through the OS
· No cascading revokes
· Improved performance
Manapulating Roles
Example 6 : Grant the role to scott and enable him to grant the role to other users
DBA - 41
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
No
Workaround:
Export all of the objects from the tablespace
Drop the tablespace including contents
Recreate the tablespace
Import the objects back in
No
Workaround:
Do a user-level export of user A
create new user B
import system/manager fromuser=A touser=B
drop user A
DBA - 42
This watermark does not appear in the registered version - http://www.clicktoconvert.com
GnanaSekar. A
Because you can change the sizes of datafiles, you can add more space
to your database without adding more datafiles. This is beneficial if
you are concerned about reaching the maximum number of datafiles
allowed in your database.
Manually reducing the sizes of datafiles allows you to reclaim unused
space in the database. This is useful for correcting errors in
estimates of space requirements.
Also, datafiles can be allowed to automatically extend if more space
is required. Look at the following command:
1. A very simple but easily overlooked hint, do not have any indexes
and/or constraints (primary key) on your load tables during the
load process. This will significantly slowdown load times.
2. Add the following option in the command line: DIRECT=TRUE. This
will effectively bypass most of the RDBMS processing.
3. Turn off database logging by specifying the NOLOGGING option. This
option can only be used with direct data loads.
4. Run multiple load jobs concurrently.
ORA-01555: Snapshot too old - Ask you users to STOP working while you
are exporting or use CONSISTENT=NO
ORA-01562: Failed to extend rollback segment - Set COMMIT=Y while
importing
DBA - 43