Sunday, March 30, 2008

Function-based index

A function-based index indexes a funciton's return value.
It can be a:
  • Built-in SQL function
  • PL/SQL function
  • A user-written function

It relieves the server from having to invoke the function for every key value as it performs a search on the indxed expression.

For example:

CREATE INDEX table1_ix ON TABLE1(my_function(column1, column2));

Now any query that contains the expression my_function(column1, column2) in the WHERE clause may be able to take advantage of this index (otherwise, it would force a full table scan)

Reversed-key indexes

From: Oracle reverse key index tips

It has been suggested that using reverse-key indexes will speed-up Oracle INSERT statements, especially with an increasing key, like an index on an Oracle sequence (which is used for the primary key of the target table). For large batch inserts, Oracle reverse key indexes will greatly speed-up data loads because the high-order index key has been reversed.

Note: An Oracle reverse key index DOES NOT change the functionality of the index, and it's not the same as reversing the index key values.

In general, an Oracle reverse key index relieve data block contention (buffer busy waits) when inserting into any index where the index key is a monotonically increasing value which must be duplicated in the higher-level index nodes.

With the index key reversal, only the lowest-level index node is changed, and not all of the high-order index nodes, resulting in far faster insert speed. For updates, Oracle updates the index nodes with each update statement.

Depending on the size of your update batch, it's often faster to drop, update and then re-build the index. If you have more than one CPU, you might consider doing a parallel index rebuild for faster speed. It splits-up the full-table scan.

ROWID

More explanation at: Overview of ROWID and UROWID Datatypes

Oracle uses rowids internally for the construction of indexes. Each key in an index is associated with a rowid that points to the associated row's address for fast access. End users and application developers can also use rowids for several important functions:
  • Rowids are the fastest means of accessing particular rows.
  • Rowids can be used to see how a table is organized.
  • Rowids are unique identifiers for rows in a given table.

There are Restricted ROWIDs and Extended ROWIDs.

Structure of a Restricted ROWID

An example ROWID is

ROWID ENAME
------------------ ----------
00000DD5.0000.0001 KRISHNAN

As shown, a restricted rowid's VARCHAR2/hexadecimal representation is in a three-piece format, block.row.file:

  • The data block that contains the row (block DD5 in the example). Block numbers are relative to their datafile, not tablespace. Two rows with identical block numbers could reside in two different datafiles of the same tablespace.
  • The row in the block that contains the row (rows 0, 1, 2 in the example). Row numbers of a given block always start with 0.
  • The datafile that contains the row (file 1 in the example). The first datafile of every database is always 1, and file numbers are unique within a database.

Structure of an Extended ROWID

ROWID LAST_NAME
------------------ ----------
AAAAaoAATAAABrXAAA BORTINS
AAAAaoAATAAABrXAAE RUGGLES
AAAAaoAATAAABrXAAG CHEN
AAAAaoAATAAABrXAAN BLUMBERG

An extended rowid has a four-piece format, OOOOOOFFFBBBBBBRRR:

  • OOOOOO: The data object number that identifies the database segment (AAAAao in the example). Schema objects in the same segment, such as a cluster of tables, have the same data object number.
  • FFF: The tablespace-relative datafile number of the datafile that contains the row (file AAT in the example).
  • BBBBBB: The data block that contains the row (block AAABrX in the example). Block numbers are relative to their datafile, not tablespace. Therefore, two rows with identical block numbers could reside in two different datafiles of the same tablespace.
  • RRR: The row in the block.

7-44. Data Dictionary

The data dictionary can be used to query about users, objects, constraints and storage.

By querying the Oracle with SELECT * FROM dictionary WHERE table_name like 'USER_%', we get the list of views that the user owns.

For example:

To find out the name of the view used to retrieve the indexes that INVENTORY user owns, we query the SELECT * FROM dictionary WHERE table_name like 'USER_IND%'. There should be a row where the table_name is USER_INDEXES.

To list all constraints that the INVENTORY user can see, we should use the view ALL_CONSTRAINTS. We use ALL because we want to include other user's constraints and its own constraints.

To list the names of tables created in your schema: SELECT table_name, tablespace_name FROM user_tables;

To see significant information about any sequences in the database that you have access to: SELECT sequence_name, min_value, max_value, increment_by FROM all_sequences WHERE sequence_owner IN ('MDSYS', 'XDB');

To see which users in this database are currently able to log in: SELECT username, account_status FROM dba_users WHERE account_status = 'OPEN';

To see what information you can view about all the indexes in the database: DESCRIBE dba_indexes;

7-29. B-Tree index leaf entry characteristics

In a B-tree index on a nonpartitioned table:
  • Key value are repeated if there are multiple rows that have the same key value unless the index is compressed
  • There is no index entry corresponding to a row that has all key columns that are NULL. Therefore, a WHERE clase specifying NULL will always result in a full table scan.
  • Restricted ROWID is used to point to the rows of the table because all rows belong to the same segment.

7-24. Dropping a table

Dropping a table removes:
  • Data
  • Table structure
  • Database triggers
  • Corresponding indexes
  • Associated object privileges

Optional clauses for the DROP TABLE statement:

  • CASCADE CONSTRAINTS: Dependent referential integrity constraints are removed as well.
  • PURGE: No flashback possible

Some considerations:

If you do not use the PURGE option, the table definition, associated indexes, and triggers are placed in a recycle bin. That means that the space taken up by the table and its indexes still counts against user's allowed quota for the tablespaces involved. Use PURGE RECYCLEBIN command to empty the recycle bin or FLASHBACK TABLE command to recover schema objects if PURGE clause was not used in DROP TABLE statement

7-19. Deferred and nondeferred constraints

Constraints are checked at the time of:

  • Statement execution, for nondeferred constraints
  • COMMIT, for deferred constraints

So the order is (case: DML statement, followed by COMMIT):

  1. Nondeferred constraints checked
  2. COMMIT issued
  3. Deferred constraints checked
  4. COMMIT complete

Non-deferred constraints are enforced at the end of every DML statement and a violation causes the statement to roll back.

Deferred constraints are enforced when a transaction is committed and a violation causes the transaction to roll back.

A constraint that is defined as deferrable can be specified as one of the following:

  • Initially immediable: specifies that by default it must function as an immediate constraint unless explicitly set otherwise using SET CONSTRAINT {constraint name, ... ALL} {IMMEDIATE DEFERRED}
  • Initially deferred: specifies that by default the constraint must be enforced only at the end of the transaction.

7-17. Constraint States

To better deal with situations where data must be temporarily in violation of a constraint, you can designate a constraint to be in various states.
An integrity constraint can be ENABLED or DISABLED. This applies to newly entered data.
An integrity constraint can VALIDATE or NOVALIDATE existing data.
To sumarize, an integrity constraint can be in one of the four states:
  • DISABLE NOVALIDATE (often used when the data is from an already validated source and the table is read-only, so no new data is being entered into the table).
  • DISABLE VALIDATE (used when the existing data must be validated but the data is not going to be modified and the index is not otherwise needed for performance).
  • ENABLE NOVALIDATE (used so that existing constraint violations can be corrected, and at the same time, new violations are not allowed to enter the system).
  • ENABLE VALIDATE (both new and existing data must conform to the constraint)

7-6. Naming database objects

Non-quoted names are stored in uppercase and not case sensitive

Thursday, March 27, 2008

6-28. Oracle Password Verification Function: VERIFY_FUNCTION

The Oracle server provides a password complexity verification function named VERIFY_FUNCTION. This function is created with the /rdbms/admin/utlpwdmg.sql script. The password complexity verification function must be created in the SYS schema. It can be used as a template for you customized password verification.

The supplied password verification function enforces these password restrictions:
  • The minimum length is four characers.
  • The password cannot be the same as the username.
  • The password must have at least one alphabetic, one numeric, and one special character.
  • The password must differ from the prvious password by at least three letters.

In adittion to creating VERIFY_FUNCTION, the utlpwdmg script also changes the DEFAULT profile with the following ALTER PROFILE command:

ALTER PROFILE default LIMIT
PASSWORD_LIFE_TIME 60
PASSOWRD_GRACE_TIME 10
PASSWORD_REUSE_TIME 1800
PASSWORD_REUSE_MAX UNLIMITED
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LOCK_TIME 1/1440
PASSWORD_VERIFYH_FUNCTION verify_function;

6-23. Profiles and users

Users are assigned only one profile at any given time.

Profiles:


  • Control resource consumption
  • Manage account status and password expiration

Control resource consumption

Profiles enable the administrator to control the following system resources:

  • CPU: may be limited on a per-session or per-call basis (in hundredths of a second)
  • Network/Memory: each DB session consumes system memory resources and network resources (if the session is from a user who is not local to the server). You can supply: Connect time, idle time, concurrent sessions or Private SGA.
  • Disk I/O: This limits the amount of data a user can read either at the per-session or per-call level. Reads/Session and Reads/Call place a limitation on the total number of reads from both memory and the disk.

Profiles also allow a composite limit. Composite limits are based on a weighted combination of CPU/Session, Reads/Session, Connect Time, and Private SGA. Composite limits are discussed in more detail in the Oracle Database Security Guide.

Manage account status and password expiration

Oracle password management is implemented with user profiles. You should set it by clicking on the Password tab in the desired Profile from Enterprise Manager. Profiles can provide many standard security features including the following:

Account locking:

  • The FAILED_LOGIN_ATTEMPTS parameter specifies the number of failed login attempts before the lockout of the account.
  • The PASSWORD_LOCK_TIME parameter specifies the number of days for which the account is locked after the specified number of failed login attempts.

Password aging and expiration:

  • The PASSWORD_LIFE_TIME parameter determines the lifetime of the password in days, after which the password expires.
  • The PASSWORD_GRACE_TIME parameter specifies a grace period in days for changing the password after the first successful login after the password has expired.

Password history (mutually exclusive parameters):

  • PASSWORD_REUSE_TIME: specifies that a user cannot reuse a password for a given number of days
  • PASSWORD_REUSE_MAX: specifies the number of password changes that are required before the current password can be reused.

Password complexity verification:

  • The PASSWORD_VERIFY_FUNCTION parameter names a PL/SQL function that performs a password complexity check before a password is assigned. Passowrd verification functions must be owned by SYS user and must return a Boolean value.

6-21. Secure Roles

It is possible to:
  • Make a role nondefault: when the role is granted to a user, deselect the DEFAULT check box. The user must now explicitly enable the role before the role's privileges can be exercised. This is done by issuing SET ROLE ; command
  • Have a role require addtional authentication: they can be password, external or global
  • Create secure application roles that can be enabled only by executing a PL_SQL procedure successfully: The PL/SQL procedure can check things such as the user's network address, which program the user is running, time of day, or other elements needed to proerly secure a group of permissions. See http://www.dba-oracle.com/t_get_ip_address_utl_inaddr_sys_context.htm

6-19. Predefined Roles

There are some predefined roles such as:

  • CONNECT
  • RESOURCE
  • SCHEDULER_ADMIN
  • DBA
  • SELECT_CATALOG_ROLE

Notes:

  • CONNECT is granted automatically to any user created with Enterprise Manager
  • In earlier versions of the database (before 10gR2), the CONNECT role included more privileges, such as CREATE TABLE and CREATE DATABASE LINK, which have been removed for security reasons.
  • Granting the RESOURCE ROLE includes granting the UNLIMITED TABLESPACE privilege

Functional Roles

Other roles that authorize you to administer special functions are created when that functionality is installed. For example:

  • XDBADMIN: contains the privileges required to administer XML database if that feature is installed.
  • AQ_ADMINISTRATOR_ROLE: privileges to administer advanced queuing
  • HS_ADMIN_ROLE: includes the privileges needed to administer heterogeneous services.

6-16. Revoking Object Privileges with GRANT OPTION

Cascading effects can be observed when revoking a system privilege that is related to a DML operation. For example, if the SELECT ANY TABLE privilege is granted to a user, and that user has created procedures that use the table, all procedures that are contained in the user's schema must be recompiled before they can be used again.
Revoking object privileges also cascades when given WITH GRANT OPTION.

6-15. Revoking System Privileges

System privileges, which have been granted directly with a GRANT command, can be revoked by using the REVOKE SQL statement. Users with ADMIN OPTION for a system privilege can revoke the privilege from any other database user.
There are no cascading effects when a system privilege is revoked, regardless of whether it is given the ADMIN OPTION.

6-12. System privileges

  • RESTRICTED SESSION: allows to log in even if the database has been opened in restricted mode
  • SYSDBA and SYSOPER: These privileges allows you to shutdown, start up, and perform recovery and other administrative tasks in the database. SYSOPER allows a user to perform basic operational tasks, but without the ability to look at the user data. It includes the following system privileges:
    - STARTUP and SHUTDOWN
    - CREATE SPFILE
    - ALTER DATABASE OPEN/MOUNT/BACKUP
    - ALTER DATABASE ARCHIVELOG
    - ALTER DATABASE RECOVER (complete recovery only, Any form of incomplete recovery, such as UNTIL TIME | CHANGE | CANCEL | CONTROLFILE requires connnecting as SYSDBA)
    - RESTRICTED SESSION
    The SYSDBA system privilege additionally authorizes incomplete recovery and deletion of a database. Effectively, the SYSDBA system privilege allows a user to connect as the SYS user.
  • DROP ANY object
  • CREATE, MANAGE, DROP, and ALTER TABLESPACE
  • CREATE ANY DIRECTORY (potential security hole)
  • GRANT ANY OBJECT PRIVILEGE: grant object permissions on objects you do not own
  • ALTER DATABASE and ALTER SYSTEM: allows renaming a data file or flushing the buffer cache

6-5. Predefined Accounts: SYS and SYSTEM

  • SYS and SYSTEM accounts have the DBA role granted to them by default
  • SYS is granted SYSDBA privilege, SYSTEM is not
  • To connect to the SYS account, you must use the AS SYSDBA clase
  • SYS account in addition has all privileges with ADMIN OPTION
  • SYS account owns the data dictionary
  • SYS account owns the Automatic Workload Repository (AWR)
  • SYS account owns the data dictionary
  • Only users with SYSDBA or SYSOPER privilege, are allowed to start up and shutdown the database instance
For more on SYS and SYSOPER go to 6-12. System privileges

SYS and SYSTEM accounts are not used for routine operations. Create privileged users for that. For example, Jim has a low privilege account called jim and a privileged account called jim_dba. This method allows the principle of least privilege to be applied, eliminates the need for account sharing, and allows individual actions to be audited.

6-4. Database User Accounts

A database user can belong to a consumer group which Oracle Resource Manager uses to balance the allocation of resources (CPU, memory, etc) according to user-defined rules. More info on
http://www.oracle.com/technology/oramag/oracle/04-nov/o64tuning.html

Oracle/PLSQL: NVL Function

In Oracle/PLSQL, the NVL function lets you substitute a value when a null value is encountered.

The syntax for the NVL function is:

NVL( string1, replace_with )

string1 is the string to test for a null value.

replace_with is the value returned if string1 is null.

Null Values in Group By

It is known that Null <> Null. When two different NULL values are compared, the result is NULL (not TRUE), i.e. the two NULL values are not considered to be equal. Applying the same rule to the GROUP BY clause would force SQL to place each row with a NULL grouping column into a separate group by itself.

But creating a separate group for every row with a NULL in a grouping column is confusing and of no useful value, so designers wrote the SQL standard such that NULL values are considered equal for the purposes of a GROUP BY clause. Therefore, if two rows have NULL values in the same grouping columns and matching values in the remaining non-NULL grouping columns, the DBMS will group the rows together.

Simply put if the grouping column contains more than one null value, the null values are put into a single group.

For example, the grouped query:
SELECT A, B,SUM(amount_purchased) AS 'C'
FROM customers
GROUP BY A, B
ORDER BY A, B
will display a results table similar to

ABC
NULLNULL61438.0000
NULL101196156.0000
AZNULL75815.0000
AZ10336958.0000
CA10178252.0000
LANULL181632.0000

for CUSTOMERS that contain the following rows.

ABamount_purchased
NULLNULL45612.00000
NULLNULL15826.00000
NULL10145852.0000
NULL10174815.0000
NULL10175489.0000
AZNULL75815.0000
AZ10336958.0000
CA10178252.0000
LANULL96385.0000
LANULL85247.0000

Sunday, March 16, 2008

Mechanics of Connecting over TCP/IP

Expert Oracle Database Architecture 9i and 10g Programming Techniques And Solutions - page 60

We’ll investigate the most common networking case: a network-based connection request over a TCP/IP connection. In this case, the client is situated on one machine and the server resides on another machine, with the two connected on a TCP/IP network. It all starts with the client. The client makes a request using the Oracle client software (a set of provided application program interfaces, or APIs) to connect to database. For example, the client issues the following:


$ sqlplus scott/tiger@ora10g.localdomain

Here, the client is the program SQL*Plus, scott/tiger is the username/password, and ora10g.localdomain is a TNS service name. TNS stands for Transparent Network Substrate and is “foundation” software built into the Oracle client that handles our remote connections, allowing for peer-to-peer communication. The TNS connection string tells the Oracle software how to connect to the remote database. Generally, the client software running on yourmachine will read a file called tnsnames.ora. This is a plain-text configuration file commonly found in the [ORACLE_HOME]\network\admin directory ([ORACLE_HOME] represents the full path to your Oracle installation directory). It will have entries that look like this:

ORA10G.LOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora10g)
)

This configuration information allows the Oracle client software to map the TNS connection string we used, ora10g.localdomain, into something useful—namely, a hostname, a port on that host on which a “listener” process will accept connections, the service name of the database on the host to which we wish to connect, and so on. A service name represents groups of applications with common attributes, service level thresholds, and priorities. The number of instances offering the service is transparent to the application, and each database instance may register with the listener as willing to provide many services. So, services are mapped to physical database instances and allow the DBA to associate certain thresholds and priorities with them.
This string, ora10g.localdomain, could have been resolved in other ways. For example, it could have been resolved using Oracle Internet Directory (OID), which is a distributed Lightweight Directory Access Protocol (LDAP) server, similar in purpose to DNS for hostname resolution. However, use of the tnsnames.ora file is common in most small to medium installations where the number of copies of such a configuration file is manageable.
Now that the client software knows where to connect to, it will open a TCP/IP socket connection to the server with the hostname localhost.localdomain on port 1521. If the DBA for our server has installed and configured Oracle Net, and has the listener listening on port 1521 for connection requests, this connection may be accepted. In a network environment, we will be running a process called the TNS listener on our server. This listener process is what will get us physically connected to our database. When it receives the inbound connection request,it inspects the request and, using its own configuration files, either rejects the request (e.g., because there is no such database, or perhaps our IP address has been disallowed connections to this host) or accepts it and goes about getting us connected.
If we are making a dedicated server connection, the listener process will create a dedicated server for us. On UNIX, this is achieved via a fork() and exec() system call (the only way to create a new process after initialization in UNIX is via fork()). The new dedicated server process inherits the connection established by the listener, and we are now physically connected to the database. On Windows, the listener process requests the database process to create a new thread for a connection. Once this thread is created, the client is “redirected” to it, and we are physically connected. Diagrammatically in UNIX, it would look as shown in Figure 2-4.

On the other hand, the listener will behave differently if we are making a shared server connection request. This listener process knows the dispatcher(s) we have running in the instance. As connection requests are received, the listener will choose a dispatcher process from the pool of available dispatchers. The listener will either send back to the client the connection information describing how the client can connect to the dispatcher process or, if possible, “hand off” the connection to the dispatcher process (this is operating system– and database version–dependent, but the net effect is the same). When the listener sends back the connection information, it is done because the listener is running on a well-known hostname and port on that host, but the dispatchers will be accepting connections on randomly assigned ports on that server. The listener is made aware of these random port assignments by the dispatcher and will pick a dispatcher for us. The client then disconnects from the listener and connects directly to the dispatcher. We now have a physical connection to the database.Figure 2-5 illustrates this process.

Friday, March 14, 2008

Automatic Storage Management

5-26. What is ASM?

  • Is a portable and high-performance cluster file system
  • Manages Oracle database files
  • Spreads data across disks to balance load
  • Mirrors data
  • Solves many storage management challenges
  • Allows increasing the size of DB without having to shut down the DB to adjust storage allocation
5-27. ASM: Key Features and Benefits

  • Stripes files, but not logical volumes
  • Provides online disk reconfiguration and dynamic rebalancing
  • Allows for adjustable rebalancing speed
  • Provides redundancy on a per-file basis (rather than on a volume basis)
  • Supports only Oracle database files (data files, log files, control files, archive logs, Recovery Manager (RMAN) backup sets, etc)
  • Is cluster aware (so there's no need for a Cluster Logical Volume Manager or a Cluster File System)
  • Is automatically installed

5-28. ASM: Concepts

  • ASM disk group
  • ASM file
  • ASM disk
  • Allocation unit
  • Physical block

Sunday, March 9, 2008

Startup and shutdown types

http://mioracle.blogspot.com/2008/02/arranque-y-parada.html

4-21. Oracle Database Instance states

Oracle DB can be in one of the following states:

  1. SHUTDOWN
  2. NOMOUNT (instance started): An instance is typically started only in NOMOUNT mode during database creation, during re-creation of control files, or during certain backup and recovery scenarios.
  3. MOUNT (control file opened for this instance): here the data files and online redo log files are NOT opened so specific maintenance tasks can be performed such as 1) renaming data files (though data files on an offline tablespace can be renamed while the db is open), 2) enabling and disabling online redo log file archiving options, 3) perfoming full database recovery, etc.
    Note: a database may be left in MOUNT mode even thoug an OPEN request has been made. This may be because the database needs to be recovered in some way.
  4. OPEN: this includes opening the online data files and the redo log files.

You can also start up a database instance in restricted mode so that it is available to users with administrative privileges only. to start an instance in restricted mode, select the "Restrict access to database" option on the Advanced Startup Options page.

Starting an instance includes the following tasks:

  • Searching /database for a file of a particular name in this order:
    • spfile.ora
    • If not found, spfile.ora
    • If not found, init.oraThis is the file that contains initialization parameters for the instance. Specifying the PFILE parameter with STARTUP overrides the default behavior.
  • Allocating the SGA
  • Starting the background processes
  • Opening the alert.log file and the trace files

4-15. Initialization Parameter Files

There are two types of parameter files:
  1. Server parameter file: This is the preferred type of initialization parameter file. It is a binary file that can be written to and read by the database server and must not be edited manually. It resides in the server that the Oracle database is executing on, and is persistent across shutdown and startup. this is often referred to as a server parameter file (SPFILE). The default name of this file, which is automatically sought at startup, is app/user/product/11.1.0/db_1/database/spfile.ora.
  2. Text initialization parameter file: This type of initialization parameter file can be read by the database server, but it is not written to by the server. The initialization parameter settings must be set and changed manually by using a text editor so that they are persistent across shutdown and startup. the default name of this file, which is automatically sought at startup if an SPFILE is not found, is init.ora.

4-10. Setting up iSQL*PLUS for SYSDBA and SYSOPER access

For a user to login to iSQL*PLUS as SYSDBA or SYSOPER you must set up the user in the OC4J user manager by performing the following steps:
  1. Create a user
  2. Grant the webDba role to the user




$ cd $ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus
$ $JAVA_HOME/bin/java -Djava.security.properties=$ORACLE_HOME/oc4j/j2ee/home/config/jazn.security.props -jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar -user "iSQL*Plus DBA/admin" -password welcome -shell

JAZN> add user "iSQL*Plus DBA" username password
JAZN> grantrole webDba "iSQL*Plus DBA" username

4-9. Using iSQL*Plus

ISQL*Plus has a server-side listener process that must be started before you can connect with a browser. To start this server process, use:

isqlplusctl start

After thes server process is started, connect to it by entering the following URL in a browser:

http://host:port/isqlplus

The port number that is used by iSQL*Plus is usually 5560 unless Oracle Universal Installer detects that something is already using that port. Check $ORACLE_HOME/install/portlist.ini to find the port used by iSQL*PLUS

4-3. Management Framework

There are three major components of the Oracle database management framework:
  • The database instance that is being managed
  • A listener that allows connections to the database
  • The management interface. This may be either a management agent running on the database server (which connects it to Oracle Enterprise Manager Grid Control) or the stand-alone Oracle Enterprise Manager Database Control. this is also referred to as Database Console.

Each of these componenets must be explicitly started before you can use the services of the component and must be shut down cleanly when shutting down the server hosting the Oracle database.

Start up order is important. these components must be started in this order:

  1. Management interface. After this is activated, it can be used to start the other components. Use emctl start dbconsole
  2. Database instance. Either from dbconsole or executing STARTUP command within SQL*PLUS
  3. Listener. Notice that the listener could actually be started before the database instance but there is no point of starting a listener if there is no instance running. Use lsnrctl start

3-14. Using the DBCA to Delete a Database

To delete (or configure) a database in UNIX or Linux, you must set ORACLE_SID in the shell from which DBCA is launched. Start the DBCA by entering dbca in a terminal window, and click Next on the Welcome page. to delete the database, perform the following steps:
  1. On the Operations page, select Delete a Database, and click Next.
  2. Select the database that you wanted to delete (in class, hist), and click Finish.
  3. Click Yes to confirm your deletion.

Dropping a database involves removing its data files, redo log files, control files, and initialization parameter files. The DROP DATABASE statement deletes all control files and all other database files listed in the control file. To use the DROP DATABASE statement successfully, all the following conditions must apply:

  • The database must be mounted and closed.
  • The database must be mounted exclusively - not in shared mode.
  • The database must be mounted as RESTRICTED.

An example of this statement is:

DROP DATABASE;

The DROP DATABASE statement has no effect on archieved log files nor does it have any effect on copies or backups of the database. It is best to use Recovery Manager (RMAN) to delete such files. If the database is on raw disks, then the actual raw disk special files are not deleted.

Monday, March 3, 2008

2-19. Installation Option: Silent Mode

To install and configure Oracle products with OUI in silent mode, perform the following steps:
  1. Create the oraInst.loc file, if it does not already exist.
  2. Prepare a response file based on file templates that are delivered with the Oracle software OR record a response file:
    .runInstaller -record -destinationFile
  3. Run OUI in silent or suppressed mode.
  4. If required, run NetCA and DBCA in silent mode.

For details, check Oracle 10g: Administration Workshop I, page 2-19

2-18. Oracle Advanced Installation Options

  • With OUI, you can create configurations that use Automatic Storage Management.
  • You can install and configure the Enterprise Manager (EM) framework. Oracle Enterprise Manager Database Control is installed in the same Oracle home as the database and is configured to run on a stand-alone OC4J instance. You have to perform a separate installation to get EM central management capabilities.
  • if you choose to use Oracle Enterprise Manager Database Control, you can optionally configure the database to use the Oracle-recommended default backup strategy.
  • If you choose to use Oracle Enterprise Manager Database Control during the installation, you can configure Enterprise Manager to send e-mail alerts to an e-mail address that you specify. These alerts can include issues such as disk space reaching a critical limit or a database shutting down unexpectedly.
  • The Oracle Database 10g installation supports RAC features, particularly the installation of Cluster Ready Services (CRS)
  • Oracle homes can be cloned by using the Enterprise Configuration Management tool. This tool enables users to create clone requests and then schedule and process them. This tool is available via EM Grid Control.

2-5. Command line tools

To administer Enterprise Manager, use:

emctl start status set stop

To stop and start iSQL*Plus, use:

isqlplusctl start stop

To administer the listener, use:

lsnrctl help start status stop

1-21. Segments

  • Data segments: Each nonclustered, non-indexed-organized table has a data segment. All of the table's data is stored in the extents of its data segment. For a partitioned table, each partition has a data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.
  • Index segments: each index has an index segment that stores all of its data. For a partitioned index. each partition has an index segment.
  • Undo segments: one UNDO tablespace is created by the database administrator to temporarily store undo information. This information in an undo segment is used to generate read-consistent database information and, during database recovery, to roll back uncommitted transactions for users.
  • Temporary segments: Temporary segments are created by the Oracle database when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segment's extents are returned to the instance for future use. Specify a default temporary tablespace for every user or a default temporary tablespace, which is used databasewide.

1-19. Data block size

The size of the data block can be set at the time of the creation of the database. The default size of 8 KB is adequate for most databases. If your database supports a data warehouse application that has large tables and indexes, then a larger block size may be beneficial.
If your database supports a transactional application where reads and writes are random, then specifying a smaller block size may be beneficial.
The maximum block size depends on your OS. The minimum Oracle block size is 2 KB and should rarely (if ever) be used.

1-17. Tablespaces

A database is divided into logical storage units called tablespaces, which group related logical structures together. For example, tablespaces commonly group all of an application's objetcs to simplify some administrative operations. You may have a tablespace for application data and an additional one for application indexes.