User Roles/privilege

Listing Privilege and Role Information
——————————————
To list the grants made for objects, a user can query the following data dictionary views:
ALL_COL_PRIVS, USER_COL_PRIVS, DBA_COL_PRIVS
ALL_COL_PRIVS_MADE, USER_COL_PRIVS_MADE
ALL_COL_PRIVS_RECD, USER_COL_PRIVS_RECD
ALL_TAB_PRIVS, USER_TAB_PRIVS, DBA_TAB_PRIVS
ALL_TAB_PRIVS_MADE, USER_TAB_PRIVS_MADE
ALL_TAB_PRIVS_RECD, USER_TAB_PRIVS_RECD
DBA_ROLES
USER_ROLE_PRIVS, DBA_ROLE_PRIVS
USER_SYS_PRIVS, DBA_SYS_PRIVS
COLUMN_PRIVILEGES
ROLE_ROLE_PRIVS, ROLE_SYS_PRIVS, ROLE_TAB_PRIVS
SESSION_PRIVS, SESSION_ROLES
——————————————
@@ all system privilege grants made to roles and users:
SELECT * FROM sys.dba_sys_privs;
@@ all the roles granted to users and other roles:
SELECT * FROM sys.dba_role_privs;
@@ all object privileges (not including column-specific privileges) granted to the specified user:
SELECT table_name, privilege, grantable FROM sys.dba_tab_privs
WHERE grantee = ‘JWARD’;
@@ To list all the column-specific privileges that have been granted, use the following query:
SELECT grantee, table_name, column_name, privilege
FROM sys.dba_col_privs;
@@ all roles currently enabled for the issuer:
SELECT * FROM session_roles;
@@ all system privileges currently available in the issuer’s security domain, both from explicit privilege grants and from enabled roles:
SELECT * FROM session_privs;
@@ all roles of a database and the authentication used for each role.
SELECT * FROM sys.dba_roles;
@@  all the object privileges granted to the SECURITY_ADMIN role:
SELECT table_name, privilege FROM role_tab_privs
WHERE role = ‘SECURITY_ADMIN’;
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
++++++++++++++++++++++++++++++++++++++++
+Viewing Privilege and Role Information
++++++++++++++++++++++++++++++++++++++++
To access information about grants of privileges and roles, you can query the following data dictionary views:
+++++++++++++++++
DBA_COL_PRIVS |
ALL_COL_PRIVS | DBA view describes all column object grants in the database. ALL view describes all column object grants for which the current user or PUBLIC is the object owner, grantor, or grantee. USER view describes column object grants for which the current user is the object owner, grantor, or grantee.
USER_COL_PRIVS |
+++++++++++++++++++++
ALL_COL_PRIVS_MADE  |
USER_COL_PRIVS_MADE |  ALL view lists column object grants for which the current user is object owner or grantor. USER view describes column object grants for which the current user is the grantor.
+++++++++++++++++++++
ALL_COL_PRIVS_RECD  |
USER_COL_PRIVS_RECD | ALL view describes column object grants for which the current user or PUBLIC is the grantee. USER view describes column object grants for which the current user is the grantee.
+++++++++++++++++++++
DBA_TAB_PRIVS |
ALL_TAB_PRIVS | DBA view lists all grants on all objects in the database. ALL view lists the grants on objects where the user or PUBLIC is the grantee. USER view lists grants on all objects where the current user is the grantee.
USER_TAB_PRIVS |
+++++++++++++++++++++
ALL_TAB_PRIVS_MADE  |
USER_TAB_PRIVS_MADE | ALL view lists the all object grants made by the current user or made on the objects owned by the current user. USER view lists grants on all objects owned by the current user.
+++++++++++++++++++++
ALL_TAB_PRIVS_RECD  |
USER_TAB_PRIVS_RECD | ALL view lists object grants for which the user or PUBLIC is the grantee. USER view lists object grants for which the current user is the grantee.
+++++++++++++++++++++
DBA_ROLES |This view lists all roles that exist in the database.
+++++++++++++++++
DBA_ROLE_PRIVS  |
USER_ROLE_PRIVS | DBA view lists roles granted to users and roles. USER view lists roles granted to the current user.
+++++++++++++++++
DBA_SYS_PRIVS   |
USER_SYS_PRIVS  | DBA view lists system privileges granted to users and roles. USER view lists system privileges granted to the current user.
+++++++++++++++++
ROLE_ROLE_PRIVS | This view describes roles granted to other roles. Information is provided only about roles to which the user has access.
ROLE_SYS_PRIVS  | This view contains information about system privileges granted to roles. Information is provided only about roles to which the user has access.
ROLE_TAB_PRIVS  | This view contains information about object privileges granted to roles. Information is provided only about roles to which the user has access.
SESSION_PRIVS   | This view lists the privileges that are currently enabled for the user.
SESSION_ROLES   | This view lists the roles that are currently enabled to the user.
+++++++++++++++++
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Listing Privilege and Role Information

——————————————

To list the grants made for objects, a user can query the following data dictionary views:

ALL_COL_PRIVS, USER_COL_PRIVS, DBA_COL_PRIVS

ALL_COL_PRIVS_MADE, USER_COL_PRIVS_MADE

ALL_COL_PRIVS_RECD, USER_COL_PRIVS_RECD

ALL_TAB_PRIVS, USER_TAB_PRIVS, DBA_TAB_PRIVS

ALL_TAB_PRIVS_MADE, USER_TAB_PRIVS_MADE

ALL_TAB_PRIVS_RECD, USER_TAB_PRIVS_RECD

DBA_ROLES

USER_ROLE_PRIVS, DBA_ROLE_PRIVS

USER_SYS_PRIVS, DBA_SYS_PRIVS

COLUMN_PRIVILEGES

ROLE_ROLE_PRIVS, ROLE_SYS_PRIVS, ROLE_TAB_PRIVS

SESSION_PRIVS, SESSION_ROLES

——————————————

@@ all system privilege grants made to roles and users:

SELECT * FROM sys.dba_sys_privs;

@@ all the roles granted to users and other roles:

SELECT * FROM sys.dba_role_privs;

@@ all object privileges (not including column-specific privileges) granted to the specified user:

SELECT table_name, privilege, grantable FROM sys.dba_tab_privs

WHERE grantee = ‘<>’;

@@ To list all the column-specific privileges that have been granted, use the following query:

SELECT grantee, table_name, column_name, privilege

FROM sys.dba_col_privs;

@@ all roles currently enabled for the issuer:

SELECT * FROM session_roles;

@@ all system privileges currently available in the issuer’s security domain, both from explicit privilege grants and from enabled roles:

SELECT * FROM session_privs;

@@ all roles of a database and the authentication used for each role.

SELECT * FROM sys.dba_roles;

@@  all the object privileges granted to the SECURITY_ADMIN role:

SELECT table_name, privilege FROM role_tab_privs

WHERE role = ‘SECURITY_ADMIN’;

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

++++++++++++++++++++++++++++++++++++++++

+Viewing Privilege and Role Information

++++++++++++++++++++++++++++++++++++++++

To access information about grants of privileges and roles, you can query the following data dictionary views:

+++++++++++++++++

DBA_COL_PRIVS |

ALL_COL_PRIVS | DBA view describes all column object grants in the database. ALL view describes all column object grants for which the current user or PUBLIC is the object owner, grantor, or grantee. USER view describes column object grants for which the current user is the object owner, grantor, or grantee.

USER_COL_PRIVS |

+++++++++++++++++++++

ALL_COL_PRIVS_MADE  |

USER_COL_PRIVS_MADE |  ALL view lists column object grants for which the current user is object owner or grantor. USER view describes column object grants for which the current user is the grantor.

+++++++++++++++++++++

ALL_COL_PRIVS_RECD  |

USER_COL_PRIVS_RECD | ALL view describes column object grants for which the current user or PUBLIC is the grantee. USER view describes column object grants for which the current user is the grantee.

+++++++++++++++++++++

DBA_TAB_PRIVS |

ALL_TAB_PRIVS | DBA view lists all grants on all objects in the database. ALL view lists the grants on objects where the user or PUBLIC is the grantee. USER view lists grants on all objects where the current user is the grantee.

USER_TAB_PRIVS |

+++++++++++++++++++++

ALL_TAB_PRIVS_MADE  |

USER_TAB_PRIVS_MADE | ALL view lists the all object grants made by the current user or made on the objects owned by the current user. USER view lists grants on all objects owned by the current user.

+++++++++++++++++++++

ALL_TAB_PRIVS_RECD  |

USER_TAB_PRIVS_RECD | ALL view lists object grants for which the user or PUBLIC is the grantee. USER view lists object grants for which the current user is the grantee.

+++++++++++++++++++++

DBA_ROLES |This view lists all roles that exist in the database.

+++++++++++++++++

DBA_ROLE_PRIVS  |

USER_ROLE_PRIVS | DBA view lists roles granted to users and roles. USER view lists roles granted to the current user.

+++++++++++++++++

DBA_SYS_PRIVS   |

USER_SYS_PRIVS  | DBA view lists system privileges granted to users and roles. USER view lists system privileges granted to the current user.

+++++++++++++++++

ROLE_ROLE_PRIVS | This view describes roles granted to other roles. Information is provided only about roles to which the user has access.

ROLE_SYS_PRIVS  | This view contains information about system privileges granted to roles. Information is provided only about roles to which the user has access.

ROLE_TAB_PRIVS  | This view contains information about object privileges granted to roles. Information is provided only about roles to which the user has access.

SESSION_PRIVS   | This view lists the privileges that are currently enabled for the user.

SESSION_ROLES   | This view lists the roles that are currently enabled to the user.

+++++++++++++++++

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Leave a comment »

Some Unix Command For oracle DBA

Some Useful unix Command Which is Frequentlly used In Oracle-UNIX  DBA

===================================================

To enable doskey mode in Unix
set -o vi
———————————————-
the “chgrp” command is used to change the group to a file:
root> chgrp <directory> group
———————————————-
The “awk” command it has its own scripting language:
For example, to display only the 6th field of the output from ‘who am i.’ (Field 6 is the IP address of your own
terminal session / PC.) you can use:
who am i | awk ‘{print $6}’
This can be used to automatically set the DISPLAY environment variable for users’ logins.
———————————————-
The “PS1″changes your prompt.
root> PS1=”Diego_Master:> “
Diego_Master:>
———————————————-
Enable FTP and TELNET Services
cd to /etc/xinetd.d
vi wu-ftpd
Change the disable field from “yes” to “no” and save changes.
vi telnet
Change the disable field from “yes” to “no” and save changes.
———————————————-
Information on Network
Display network interface configuration parameters
ifconfig -a
Address resolution display and control
arp -a
Check Routes:
netstat -rn
———————————————-
Cron Commands
Cron is a unix utility that allows tasks to be automatically run in the background at regular intervals by the cron
daemon often termed as cron jobs.
Crontab (CRON TABLE) is a file which contains the schedule of cron entries to be run and at specified times, you can
invoke it with the “crontab -e” command.
syntax
A crontab file has five fields for specifying day , date and time  followed by the command to be run at that
interval. You can also specify a range of values.
*     *     *     *     *  command to be executed
-     –     –     –     -
|     |     |     |     |
|     |     |     |     +—–> day of week (1 – 7) (monday = 1)
|     |     |     +———–> month (1 – 12)
|     |     +—————–> day of month (1 – 31)
|     +———————–> hour (0 – 23)
+—————————–> min (0 – 59)
The first 5 fields can be specified using the following rules:
*       – All available values or “first-last”.
3-4     – A single range representing each possible from the start to the end of the range inclusive.
1,2,5,6 – A specific list of values.
1-3,5-8 – A specific list of ranges.
0-23/2  - Every other value in the specified range.
———————————————-
Useful Files
Here are some files that may be of use:
Path Contents
——–       ————————–
/etc/passwd User settings
/etc/group Group settings for users.
/etc/hosts Hostname lookup information.
/etc/system Kernel parameters for Solaris.
/etc/sysconfigtab  Kernel parameters for Tru64.
———————————————-
More Examples:
ls -al | pg do a full directory listing and prompt to stop stuff whizzing off the page.
ls | wc -l count the files in the current directory.
ls -alt list files in date order
ls -alt | head -10 as above but only display the first 10
ls -s | awk ‘{if ($1 > 50) print $1 ” ” $2 }’ list all files over 50 blocks in size.
ls -alq List files with hidden characters. Very useful when you cannot delete a file for an unknown reason, as
sometimes a file can be created with hidden control characters. (very common when stty not set properly)
ls -1 Shows the files in a list (just the file names, this option is useful in shell scripts where the files names
need to be fed into another program or command for manipulation)
ls -1h The option “-h” comes handy to display the size of the files in a human readable form.
ls -lr The parameter -r shows the output in the reverse order
ls -lR The -R operator makes the ls command execute recursively—that is, go under to the subdirectories and show
those files too
———————————————-
COMMAND EFFECT
:.=   find out the current line number
:1 go to line 1
Ctrl-d page down
Ctrl-u page up
Shift-g go to end of file
i insert text at current position
Shift-a append text after end of current line
Shift-I insert text before start of current line
Esc get out of edit mode, back into normal vi command mode
dd delete current line
10dd delete 10 lines from current line on down
d shift-g delete all lines from current line and below
d 1 shift-g delete all lines from current line and above
. repeat previous command
shift-y yank (copy) current line
p paste that copy into line below
/data search forward for occurencies of string “data”
/ search forward for next occurrence of remembered search string
? search backward for next occurrence of remembered search string
:set ic make searches case insensitive
:1,$s/data/index/g replace all occurrencies of “data” with “index”
:1,$s/”//g remove all ” characters
:1,$s/$/ ;/ append ” ;” to the end of every line
:1,$s/^/rem / insert “rem ” to the start of every line
:w write (save) file
:q quit out of vi
:q! quit out of vi without saving changes
:wq write (save) file and quit out of vi
shift-z shift-z same as above “:wq” except does not write (change file modification times)
if you have not made any changes.
:n next file (when vi’ing a series of files, e.g. with using “vi *” at the command prompt)
u undo last command
shift-j Join next line onto end of current line
———————————————-

To enable doskey mode in Unix

set -o vi

———————————————-

the “chgrp” command is used to change the group to a file:

root> chgrp <directory> group

———————————————-

The “awk” command it has its own scripting language:

For example, to display only the 6th field of the output from ‘who am i.’ (Field 6 is the IP address of your own

terminal session / PC.) you can use:

who am i | awk ‘{print $6}’

This can be used to automatically set the DISPLAY environment variable for users’ logins.

———————————————-

The “PS1″changes your prompt.

root> PS1=”Daid_DB1:> “

Daid_DB1:>

———————————————-

Enable FTP and TELNET Services

cd to /etc/xinetd.d

vi wu-ftpd

Change the disable field from “yes” to “no” and save changes.

vi telnet

Change the disable field from “yes” to “no” and save changes.

———————————————-

Information on Network

Display network interface configuration parameters

ifconfig -a

Address resolution display and control

arp -a

Check Routes:

netstat -rn

———————————————-

Cron Commands

Cron is a unix utility that allows tasks to be automatically run in the background at regular intervals by the cron

daemon often termed as cron jobs.

Crontab (CRON TABLE) is a file which contains the schedule of cron entries to be run and at specified times, you can

invoke it with the “crontab -e” command.

syntax

A crontab file has five fields for specifying day , date and time  followed by the command to be run at that

interval. You can also specify a range of values.

*     *     *     *     *  command to be executed

-     –     –     –     -

|     |     |     |     |

|     |     |     |     +—–> day of week (1 – 7) (monday = 1)

|     |     |     +———–> month (1 – 12)

|     |     +—————–> day of month (1 – 31)

|     +———————–> hour (0 – 23)

+—————————–> min (0 – 59)

The first 5 fields can be specified using the following rules:

*       – All available values or “first-last”.

3-4     – A single range representing each possible from the start to the end of the range inclusive.

1,2,5,6 – A specific list of values.

1-3,5-8 – A specific list of ranges.

0-23/2  - Every other value in the specified range.

———————————————-

Useful Files

Here are some files that may be of use:

Path Contents

——–       ————————–

/etc/passwd User settings

/etc/group Group settings for users.

/etc/hosts Hostname lookup information.

/etc/system Kernel parameters for Solaris.

/etc/sysconfigtab  Kernel parameters for Tru64.

———————————————-

More Examples:

ls -al | pg do a full directory listing and prompt to stop stuff whizzing off the page.

ls | wc -l count the files in the current directory.

ls -alt list files in date order

ls -alt | head -10 as above but only display the first 10

ls -s | awk ‘{if ($1 > 50) print $1 ” ” $2 }’ list all files over 50 blocks in size.

ls -alq List files with hidden characters. Very useful when you cannot delete a file for an unknown reason, as

sometimes a file can be created with hidden control characters. (very common when stty not set properly)

ls -1 Shows the files in a list (just the file names, this option is useful in shell scripts where the files names

need to be fed into another program or command for manipulation)

ls -1h The option “-h” comes handy to display the size of the files in a human readable form.

ls -lr The parameter -r shows the output in the reverse order

ls -lR The -R operator makes the ls command execute recursively—that is, go under to the subdirectories and show

those files too

———————————————-

COMMAND EFFECT

:.=   find out the current line number

:1 go to line 1

Ctrl-d page down

Ctrl-u page up

Shift-g go to end of file

i insert text at current position

Shift-a append text after end of current line

Shift-I insert text before start of current line

Esc get out of edit mode, back into normal vi command mode

dd delete current line

10dd delete 10 lines from current line on down

d shift-g delete all lines from current line and below

d 1 shift-g delete all lines from current line and above

. repeat previous command

shift-y yank (copy) current line

p paste that copy into line below

/data search forward for occurencies of string “data”

/ search forward for next occurrence of remembered search string

? search backward for next occurrence of remembered search string

:set ic make searches case insensitive

:1,$s/data/index/g replace all occurrencies of “data” with “index”

:1,$s/”//g remove all ” characters

:1,$s/$/ ;/ append ” ;” to the end of every line

:1,$s/^/rem / insert “rem ” to the start of every line

:w write (save) file

:q quit out of vi

:q! quit out of vi without saving changes

:wq write (save) file and quit out of vi

shift-z shift-z same as above “:wq” except does not write (change file modification times)

if you have not made any changes.

:n next file (when vi’ing a series of files, e.g. with using “vi *” at the command prompt)

u undo last command

shift-j Join next line onto end of current line

———————————————-

Daid Kumar

Leave a comment »

Basic RAC Management Commands

Overview of Basic RAC Management Commands

The commands we will use are listed below. Remember that this document is a quick reference, and not an exhaustive list of all commands for managing your RAC environment.

Cluster Related Commands

crs_stat -t Shows HA resource status (hard to read)
crsstat Ouptut of crs_stat -t formatted nicely
ps -ef|grep d.bin crsd.bin evmd.bin ocssd.bin
crsctl check crs CSS,CRS,EVM appears healthy
crsctl stop crs Stop crs and all other services
crsctl disable crs* Prevents CRS from starting on reboot
crsctl enable crs* Enables CRS start on reboot
crs_stop -all Stops all registered resources
crs_start -all Starts all registered resources

* These commands update the file /etc/oracle/scls_scr/<node>/root/crsstart which contains the string “enable” or “disable” as appropriate.

Database Related Commands

srvctl start instance -d <db_name> -i <inst_name> Starts an instance
srvctl start database -d <db_name> Starts all instances
srvctl stop database -d <db_name> Stops all instances, closes database
srvctl stop instance -d <db_name> -i <inst_name> Stops an instance
srvctl start service -d <db_name> -s <service_name> Starts a service
srvctl stop service -d <db_name> -s <service_name> Stops a service
srvctl status service -d <db_name> Checks status of a service
srvctl status instance -d <db_name> -i <inst_name> Checks an individual instance
srvctl status database -d <db_name> Checks status of all instances
srvctl start nodeapps -n <node_name> Starts gsd, vip, listener, and ons
srvctl stop nodeapps -n <node_name> Stops gsd, vip and listener

Keep in mind that some resources will not start unless other resources are already online. We will now look at the general dependency list in greater detail.

There are three main background processes you can see when doing a ps –ef|grep d.bin.  They are normally started by init during the operating system boot process.  They can be started and stopped manually by issuing the command /etc/init.d/init.crs {start|stop|enable|disable}

  1. /etc/rc.d/init.d/init.evmd
  2. /etc/rc.d/init.d/init.cssd
  3. /etc/rc.d/init.d/init.crsd

Once the above processes are running, they will automatically start the following services in the following order if they are enabled.  This list assumes you are using ASM and have a service set up for TAF/load balancing.

  1. The nodeapps (gsd, VIP, ons, listener) are brought online.
  2. The ASM instances are brought online.
  3. The database instances are brought online.
  4. Any defined services are brought online.

Basic RAC Management Commands

crs_stat –t, crsstat

ps -ef|grep d.bin

We can use this command to verify that the CRS background processes are actually running.  It is implicit that they are running if the crs_stat command and crsstat script work. If they do not work, you will want to verify the background processes are really running.

crsctl check crs

This command verifies that the above background daemons are functioning.

crsctl stop crs

We’ll need to be logged onto the server as the root user to run this command. It will stop all HA resources on the local node, and it will also stop the above mentioned background daemons.

crsctl disable crs

This command will prevent CRS from starting on a reboot.  Note there is no return output from the command.

crsctl start crs

crs_stop -all

This is a handy script that stops the registered resources and leaves the CRS running.  This includes all services in the cluster, so it will bring down all registered resources on all nodes.

srvctl start nodeapps -n (node)

This will bring up the gsd, ons, listener, and vip. The same command can shut down the nodeapps by replacing start with stop.

srvctl start asm -n (node)

This will bring up our ASM instances on nodes green and red. Again, the same command will stop the ASM instances by replacing start with stop.

srvctl start instance -d (database) -I (instance)

srvctl start service -d (database) -s (service)

Now we will finish up by bringing our load balanced/TAF service named RAC online.

Daid Kumar

Comments (1) »

Oracle Architecture Summery

Hi

This is Somthing About oracle Architecture in Summery


–Oracle Architecture–

User Process

Server Process

SGA (System Global Area)
-Shared Pool

  • Library Cache
    • Text of the statement
    • The compiled version of the statement (Parse Tree)
    • The Execution Plan – tells how to run the statement, determined by the optimizer.
  • Data dictionary cache: Used during the Parse phase to resolve object names and validate access privileges.
    • Table and column definitions
    • User names, Passwords and Privileges

-Database Buffer cache: Holds the most recently used data.

  • The Least Recently Used (LRU) algorithm is used to age out blocks of data in the Buffer Cache. Each buffer in the buffer cache is equal to the size of the specified data block size.
  • DB_BLOCK_BUFFERS -parameter sets the number of buffers available.
  • DB_BLOCKSIZE – parameter sets the size of the data block

-Redo Log Buffer: Registers changes made to the database via the instance. Size is defined by LOG_BUFFER in the parameter file.

  • Stores records of changes: Block that changed, the new value, and location of the change.
  • The buffer is reused after the redo entries are recorded in the redo log files.

PGA (Program Global Area)
Used by one Process only and contains the following

  • Session Information
  • Sort Area
  • Cursor State
  • Stack Space

DBWR (Database Writer)
Writes changed data to the database file when one of the following conditions are met:

  • Dirty Buffers reach a threshold value
  • No free blocks are available
  • A timeout occurs
  • A DBWR checkpoint takes place

LGWR (Log Writer)
Writes changes registered in the redo log buffer to the database file when one of the following conditions are met:

  • When the redo log buffer is 1/3 full
  • A timeout occurs (about every 3 seconds)
  • Before DBWR writes modified blocks to the data files
  • A transaction COMMITS

SMON (System Monitor)
Checks for consistency and initiates recovery.

PMON (Process Monitor)
Cleans up resources after a process fails. Watches after the server process.

CKPT (Checkpoint Process)
Updates the database status information after changes are permanently written to the database file from the buffer cache.

Database Files
-Data files
-Redo log files
-Control files
-Parameter file
-Password file
-Archived redo log files

Query Processing

  • Parse: checks syntax
  • Execute:
  • Fetch: returns data to user

DML Statements
Requires Parse and Execute

  • Server process reads the data and rollback blocks from the data files.
  • Blocks that are read then are placed in the Buffer Cache.
  • Server process locks the data and objects.
  • Server Process records the changes to the rollback and data (new) in the redo log buffer.
  • The Server Process then records the rollback block “old” and updates the data block “new” in the database buffer cache. Both are marked “dirty buffers.”

Commit Processing

–Administration Tools–
SQL*Loader, Export Import utility, Password File utility

Server Manager
-Need no connection

  • EXIT
  • REMARK
  • SET
  • SHOW
  • SPOOL

-Need privileges

  • CONNECT/DISCONNECT
  • DESCRIBE
  • EXECUTE
  • SHOW SGA
  • SHOW ERRORS
  • SHOW PARAMETER

-Need special privileges

  • STARTUP/SHUTDOWN
  • RECOVER DATABASE
  • CONNECT INTERNAL

Oracle Enterprise Manager

  • Instance Manager
  • Schema Manager
  • Security Manager
  • Storage Manager
  • SQL Worksheet
  • Backup Manager
  • Data Manager

–Managing the Instance–
The two automatically created DBA users are:

  • SYS – Owner of the data dictionary
  • SYSTEM – Used by Oracle Tools

Authentication

  • Password File- to create or change password use the ORAPWD Utility.
  • OS authentication

Startup/Shutdown Stages

  • SHUTDOWN
  • NOMOUNT
  • MOUNT
  • OPEN

Performance View Availability

  • NOMOUNT: Performance views reading from memory are available. Remember that any view referencing a file, database, or thread is not available in this stage.
  • MOUNT: Performance views reading from files are available.
  • OPEN: All Performance views and Data Dictionary views are available.

Types of Shutdowns

  • ABORT
  • IMMEDIATE
  • TRANSACTIONAL
  • NORMAL

Trace Files

-ALERT FILE: set by BACKGROUND_DUMP_DEST

  • Contains detected block corruption errors.
  • Logs STARTUP/SHUTDOWN/ARCHIVE LOG/RECOVER.
  • All values of nondefault initialization parameters.

-TRACE FILES: set by USER_DUMP_DEST

  • Logs errors detected by background processes.

Remember that:
-ALTER SYSTEM and w/ DEFERRED commands are recorded in the ALERT file.

-ALTER SESSION: modifies the parameter for only the current session.

-Alter System: Globally changes the parameter value but only until instance is shutdown. -Restricted Sessions: ALTER SYSTEM command only limits future connects and does not disconnect current sessions.

-Terminating Sessions causes PMON to rollback the user’s transaction, release locks, and free reserved user resources. Inactive sessions will return “ORA-00028:your session has been killed” only when the user attempts to make a call.

–Creating a Database–
NO DATA DICTIONARY VIEWS are created by the CREATE DATABASE command.

PARAMETER FILE (Specify at least these parameters)

  • DB_NAME
  • CONTROL_FILES
  • DB_BLOCK_SIZE

File Locations
-Control Files

  • Oracle suggests at least 2 on two different disks

-Redo Log Files

  • One disk for each group member.

-Data Files

  • Separate objects with different life spans, temporary data, applications into separate tablespaces
  • Put tables and indexes in different tablespaces
  • Give redo logs there own tablespace

Parameter file

  • DB_NAME and DB_BLOCKSIZE cannot be changed after database creation.

Troubleshooting
A CREATE DATATBASE fails for the following reasons:

  • SQL Syntax errors
  • Files being created already exist
  • OS permissions are wrong or not enough space

Follow these steps to fix a failed CREATE DATABASE command

  • Shutdown database
  • Delete files created by CREATE DATABASE command
  • Correct errors
  • Reissue CREATE DATABASE command

–Creating Data Dictionary Views/Standard Packages–
The data dictionary is updated every time a DDL command is executed, or when a Table is expanded using DML.

SYSTEM TABLESPACE: OWNER is SYS
Contains the following:

  • BASE TABLES
    • Created by sql.bsq during database creation (automatically)
    • Information is encoded, tables are normalized, not accessed by users.
    • NEVER update the BASE TABLES directly: NO DML!
  • DATA DICTIONARY VIEWS
    • Data dictionary views on base tables; performance views and their synonyms are created by the catalog.sql script (MUST be RUN as SYS). The catalog.sql also runs a script called standard.sql
    • catproc.sql runs scripts required for PL/SQL, and creates views for tablespace point-in-time recovery, and the use of LOBs. (MUST be RUN as SYS)

Administrative Scripts

  • cat*.sql: catalog and data dictionary info.
  • dbms*.sql: database package specs.
  • prvt*.plb: wrapped database package code
  • utl*.sql: views and tables for utilities

Dependent Objects

  • After executing a DDL command a dependent object status is INVALID.
  • Loading views with the Import utility can also cause INVALID object status.
  • Oracle automatically recompiles invalid views and PL/SQL units the next time they are used.

–Storage Structure–

Database Blocks

  • Header (INITANS and MAXTRANS)
  • Free Space (PCTFREE)
  • Data Space (PCTUSED)

Storage Precedence

  • Segment overrides (except for MINIMUM EXTENT)
  • Tablespace overrides
  • Oracle default

Guidelines:

  • Altered storage parameters apply to new extents only.
  • SMON only coalesces extents in tablespaces where PCTINCREASE is set greater to zero.
  • Extents are coalesced when a DBA commands, SMON initiates a space transaction, or when the server needs to allocate an extent that is larger then any free adjacent free extents.

–Rollback Segments–

Rollback segments allow for:

-Transaction rollback: a copy of the old image of data is stored so that if a rollback is necessary the data restored its original state.

-Transaction recovery: In case of instance failure during a transaction, at the next startup uncommitted data can rollback. (Rollback segment must have redo logging enabled for this to occur.)

-Read consistency: Other users cannot see uncommitted data. The rollback segments provide the data to readers.

SELECT  owner,tablespace_name,segment_name,bytes,extents,max_extents
FROM    dba_segments
WHERE   extents*2 > max_extents;

ALTER ROLLBACK SEGMENT RB2 STORAGE (MAXEXTENTS 200);

Types of Segments

-System rollback segment: is found in the system tablespace and is created at database creation.

-Private rollback segments: Used by objects in any non-system tablespace. Must be named in the parameter file or brought online by command.

-Public rollback segments: Part of a pool available

-Deferred rollback segments: created and managed by Oracle when changes are made to data in a offline tablespace. Automatically dropped when not needed.

Note: multiple transactions can write to the same extent in a rollback segment.

Planning for Rollback Segments

-BATCH environments: create fewer and larger rollback segments in large tablespaces.

-OLTP environments: create many small rollback segments. 1 RBS to every 4 concurrent transactions.

Out of Space Solutions/Errors

-Tablespace: extend data files, enable autoextend, add files to tablespace.

-Rollback segment: increase maxextents, drop and recreate with larger extent size.

-SNAPSHOT TOO OLD: occurs when the before image in a rollback segment is overwritten by another transaction, or a slot in a rollback header has been reused. Fix by creating rollback segments with:

  • Higher MINEXTENTS
  • Larger extents
  • Increase OPTIMAL

Guidelines:

  • You must have at least 2 rollback segments
  • INITIAL=NEXT
  • Set OPTIMAL based on the size of an average transaction
  • Put rollback segments in a separate tablespace to reduce fragmentation and contention.
  • Rollback segments with MINEXTENTS=20 is recommended to help reduce extension.
  • Rollback segments must be offline to be dropped.
  • You cannot take a tablespace offline that contains an active rollback segment.
  • LOG_CHECKPOINT_INTERVAL specifies the number of O/S blocks written by LGWR that will trigger a log switch.
  • LOG_CHECKPOINT_TIMEOUT specifies the number of seconds between checkpoints.

–Managing Tables–

Types of Tables

-Regular tables have very little control over the distribution of rows sometimes called a heap-organized table.

-Partitioned tables have one or more partitions that store rows based on a key value. Each partition is a separate segment and can have multiple processes concurrently querying and manipulating.

-Index-organized tables

-Clustered tables

Row Structure

-Row header: stores the number of columns, row lock status and chaining information.

-Row data: Oracle stores the column length and value. Requires (1) byte to store column length for columns <=250 bytes. Requires (3) bytes for column lengths >250 bytes long in length. The column value is stored after the column length bytes.

Datatypes

-CHAR

-NCHAR -supports fixed-width or variable length character sets. (Fixed Length, stored with padded blanks, limit of 2000 bytes per row, default is 1 byte.)

-VARCHAR2

-NVARCHAR2 (Variable length, uses only the actual bytes needed to store the column value)

-NUMBER: stored as variable-length data, stores up to 38 digits, requires 1 byte for exponent, 1 byte for negative numbers if the digits equal less than 38 bytes.

-DATE: 7 bytes and fixed length, requires 8 bytes in memory.

-LONG, LONG RAW: up to 2G, single column per table, select returns data, data stored inline, no support for object types, and sequential access to chunks.

-LOBS: up to 4G, multiple columns per table, select returns locators, data stored either in-line or out-line, supports object types, and random access to chunks.

  • BOB
  • CLOB
  • BFILE stores unstructured data in OS files

-ROWID: consists of the data object number (locates the tablespace), block number (locates the block containing the row), relative file number (locates the file), and row number (locates the row directory entry for the row).

-VARRAYS: stores a list of a small number of elements i.e. multiple phone numbers. note: Version 7 databases only support up to 1022 data files because they use the restricted ROWID(block number, row number, file number) format.

–INDEXES–

Logical
-Single Column
-Concatenated colums (max is 32)

Guidelines:

  • Set INITRANS higher then on a table
  • Nonunique index keys can point to multiple rows.
  • Rebuild if ratio of DEL_LF_ROWS to LF_ROWS is >30%
  • Drop indexes prior to bulk loads, then rebuild. Load performance will increase and index space on rebuild will be used more efficiently.
  • Indexes marked invalid should be dropped and recreated.

B-Tree Index

  • Entry header: stores number of columns and locking info.
  • ROWID of a row contains the key values.
  • No index entry for columns that are null

Use when:

  • OLTP
  • High cardinality columns
  • Lots of updates

DML on B-Tree

  • INSERT: results in insertion of an index entry in the block.
  • UPDATE: results in a “logical delete” and an insert to the index. PCTFREE has no effect on an index except at creation.
  • DELETE: results only in a logical deletion. Space is not released until all entries in a block are deleted.
  • Reverse Key Indexes: reversing the data value of the key spreads the index updates across the index tree. Range searches cannot be performed. NOSORT keyword cannot be used.

Bitmap Index

  • -Require less space then other indexes.

Use when:

  • Table has millions of rows and key columns have low cardinality (few distinct values for the column)
  • When queries use multiple WHERE conditions involving OR.
  • When read-only or has low update activity on the key columns.
  • Data Warehousing

Bitmap indexes use restricted ROWID. Cannot be unique. CREATE_BITMAP_AREA_SIZE sets the amount of space the will be used for storing bitmap segments in memory, default is 8MB. Higher the cardinality the more memory needed.

–Constraints–

Constraint States
-Disabled
-Enabled novalidate
-Enabled valid
-Deferred:
checked only when a transaction commits, must be defined at creation.

  • Initially immediate: functions as a immediate constraint.
  • Initially deferred: specifies by default the constraint be enforced at commit. -Nondeferred: are enforced after every DML statement.

-Out-of-line constraints needed when:

  • A constraint names 2+ columns
  • A table is altered to add any constraint except NOT NULL

Triggers
-Event driven, no action on existing data

-Row trigger:
executes once for every row affected.

-Statement trigger
: executes once per statement.

Guidelines
-Put PK indexes in separate tablespace from the table

-Disable constraints before bulk loading

-Enable invalidate is faster then enable validate

-Enable Validate (default) locks the table and existing data must meet the validation rules, statements are rolled back if any data violates the constraint.

- The EXCEPTIONS clause dumps the data that violated the constraint in the exception table, (utlexcpt.sql) creates the exception table.

–Clusters–
Smaller then normal index and stores NULL values

Types

  • Index cluster: uses a “cluster index” to store, access or maintain data in index cluster.
  • Hash cluster: uses function to locate/retrieve row. Better performance then index cluster in applicable situations.

Use Index Cluster when:
-Uniform key distribution
-Rarely updated key
-Often joining master-detail tables

Use Hash Cluster except when:
-Often joining master-detail tables

Index-Organized tables

–Roles–

Predefined Roles:

  • Connect
  • Resource
  • DBA
  • EXP_FULL_DATABASE
  • IMP_FULL_DATABASE
  • DELETE_CATALOG_ROLE
  • EXECUTE_CATALOG_ROLE
  • SELECT_CATALOG_ROLE

–Views Summary–

DATA DICTIONARY VIEWS

  • DICTIONARY: names of all the data dictionary views.
  • DICT
  • DICT_COLUMNS: also names all the data dictionary views.
  • DBA_OBJECTS
  • DBA_DATA_FILES: file name, tablespace name, bytes, max bytes,
  • DBA_TABLESPACES: shows default storage parameters for all tablespaces in database. (tablespace name, next extent, max extents, pct increase, status)
  • DBA_SEGMENTS: shows the size and storage settings for all segements in the database.
  • DBA_EXTENTS: number of extents, the location, the owner, segment name, size, extent id, and the number of blocks used by a table.
  • DBA_ROLLBACK_SEGS: shows name and ID of each RBS, tablespace, owner, and the RBS status (ONLINE, OFFLINE).
  • DBA_FREE_SPACE: shows the number of extents in a table.
  • DBA_FREE_SPACE_COALESCED
  • DBA_TABLES: the analyze command updates the chaining information in the CHAIN_COUNT column and number of empty blocks.
  • DBA_OBJECTS: has the object status column (VALID, INVALID).
  • DBA_INDEXES: name, owner name, type, and status of index
  • DBA_IND_COLUMNS: index owners, what tables, and what columns
  • IND$
  • INDEX_STATS: blocks, PCT_USED, distinct keys, DEL_LF_ROWS, and LF_ROWS
  • INDEX_TYPE: indicates index type (bitmap or normal)
  • DBA_CONSTRAINTS: type, name, status, owner, deferrable, validated, enabled, of all constraints in database
  • DBA_CONS_COLUMNS
  • DBA_TRIGGERS DBA_TRIGGERS_COLS
  • DBA_TAB_COLUMNS
  • DBA_CLU_COLUMNS: names of the columnsin the cluster and table column
  • DBA_CLUSTER: information about all clusters in the database, function and number of keys in a hash cluster.
  • DBA_USERS: information about password expiration, locking dates, account status for all the database users.
  • DBA_TS_QUOTAS
  • DBA_PROFILES
  • DBA_SYS_PRIVS
  • SESSION_PRIVS
  • DBA_TAB_PRIVS
  • DBA_COL_PRIVS
  • DBA_ROLES: displays all the roles in the database and if they require a password.
  • DBA_ROLE_PRIVS
  • DBA_SYS_PRIVS
  • RESOURCE_COST: shows the weights assigned to resource limits.
  • ROLE_ROLE_PRIVS
  • ROLE_SYS_PRIVS
  • TOLE_TAB_PRIVS
  • SESSION_ROLES: shows currently enabled roles for a user.
  • ALL_DEF_AUDIT_OPTS
  • AUDIT_ACTIONS
  • DBA_AUDIT_EXISTS
  • DBA_AUDIT_OBJECT
  • DBA_AUDIT_SESSION
  • DBA_AUDIT_STATEMENT
  • DBA_AUDIT_TRAIL
  • DBA_OBJ_AUDIT_OPTS
  • DBA_PRIV_AUDIT_OPTS
  • DBA_STMT_AUDIT_OPTS
  • NLS_DATABASE_PARAMETERS: displays the database and national character sets.
  • NLS_INSTANCE_PARAMETERS: displays the values of the NLS initialization parameters listed in the parameter file.
  • NLS_SESSION_PARAMETERS: displays current NLS parameters

PERFORMANCE VIEWS

  • V$FIXED_TABLE
  • V$PARAMETER: displays current settings of any parameter.
  • V$CONTROLFILE: displays the names and locations of the control files.
  • V$SYSTEM_PARAMETER: shows the current system values.
  • V$CONTROLFILE_RECORD_SECTION: shows info stored in the control file. example:MAXDATAFILES
  • V$DATABASE: shows if in archive mode or not
  • V$DATAFILE
  • V$DATAFILE_HEADER
  • V$INSTANCE
  • V$OPTION
  • V$PROCESS
  • V$PWFILE_USERS: names the users with the SYSDBA or SYSOPER privileges.
  • V$SESSION: gives the SID and serial number of a user’s session.
  • V$SGA
  • V$VERSION
  • V$THREAD: number of redo logs groups, current log group, sequence number.
  • V$LOG: shows information about redo log files contained in the control file.
  • V$LOGFILE: names of all group members and contains the status of each log file member INVALID, STALE, DELETED, NULL
  • V$TABLESPACE
  • V$ROLLNAME: shows name and USN of RBS.
  • V$ROLLSTAT: shows the current and active extent of each rollback segment, status, optimal size, current size, high water mark, and
  • V$TRANSACTION: session address of user with an pending transaction along with the number of the assigned RBS.
  • V$SORT_SEGMENT: information about temporary segements, other tablespaces with sort segments, and status of sort extent pool.
  • V$SORT_USAGE: shows only the currently active sorts
  • V$NLS_VALID_VALUES
  • V$NLS_PARAMETERS

Joined Views

  • V$SESSION and V$SORT_USAGE: will show the user who is currently sorting.

PACKAGES

  • DBMS_LOB
  • DBMS_SESSION
  • SBMS_UTILITY
  • DBMS_SPACE: finds high water mark and number of blocks above it.
  • DBMS_ROWID contains the following functions:
    • ROWID_CREATE
    • ROWID_OBJECT
    • ROWID_RELATIVE_FNO
    • ROWID_BLOCK_NUMBER
    • ROWID_ROW_NUMBER
    • ROWID_TO_ABSOLUTE_FNO
    • ROWID_TO_EXTENDED
    • ROWID_TO_RESTRICTED
  • DBMS_SHARED_POOL
  • DBMS_SESSION.SET_ROLE
  • DBMS_SPACE.UNUSED_SPACE
  • DBMS_DDL.ANALYZE_SCHEMA: used to analyze all objects owned by a user.
  • DBMS_DDL.ANALYZE_OBJECT: used to analyze a specific object.
  • DBMS_UTILITY.ANALYZE_DATABASE: used to analyze all objects in a database.
  • VERIFY_FUNCTION
  • DBMS_SESSION_.SET_NLS

Daid Kumar

Comments (1) »