Zurück

Akadia Information Technology


Die folgende Zusammenfassung ist eine Sammlung von Frequently Asked Questions rund um das Datenbanksystem Oracle.

Inhalt


Wichtige Views

Alle V$Views auslisten:

SELECT view_name from v$fixed_view_definition
WHERE view_name LIKE 'V$%'
ORDER BY view_name;

View Name

Description

V$FILESTAT

Statistics for tuning I/O?
Which view would you query to monitor I/O contention for datafiles?

V$SYSTEM_EVENT

Total waits for "buffer busy waits" since instance startup?

V$LOCK,
V$LOCKED_OBJECT

Which two views could you query to determine lock
contention on the EMP table?

V$DB_OBJECT_CACHE

Which view can be queried to check the amount of sharable
memory used by a cached object?

V$SYSSTAT

Statistics for Redo Log Buffer

V$SYSTEM_EVENT,
V$SESSION_WAIT
V$SESSION_EVENT

Which three views should you use to determine if a process
has waited for a resource?

$DATAFILE_HEADER

Which data dictionary view would you query to determine if a datafile is in backup mode?

V$SESSION_LONGOPS

Which data dictionary view can you query to check the progress
of a backup?

V$BACKUP

To see which Files are in BEGIN BACKUP MODE

Oracle-8 Database Administration

  • Which command will verify the integrity of each block in a table
    and validate all of the indexes on this table ?

analyze table dept validate structure cascade;

  • You need to export the ORDERS table in an open database with no users connected. How could you place the database in restriced session, to allow only users with RESTRICTED SESSION system privilege to logon to Oracle ?

alter system enable restricted session;

  • Which command would you use to add a datafile to an existing tablespace ?

alter tablespace TAB nologging add datafile '....' ....;

  • When would a temporary segment, created in a temporary tablespace of type
    TEMPORARY, be released ?

When the instance is shut down

  • Which data dictionary view could you query to display the number of blocks
    used by a table in each datafile ?

DBA_EXTENTS

OWNER VARCHAR2(30)
SEGMENT_NAME VARCHAR2(81)
PARTITION_NAME VARCHAR2(30)
SEGMENT_TYPE VARCHAR2(17)
TABLESPACE_NAME VARCHAR2(30)
EXTENT_ID NOT NULL NUMBER
FILE_ID NOT NULL NUMBER
BLOCK_ID NOT NULL NUMBER
BYTES NUMBER
BLOCKS NOT NULL NUMBER
RELATIVE_FNO NOT NULL NUMBER

  • An User account has been locked by the system. How would you unlock this account
    without dropping the objects in his schema

alter user scott account unlock;
alter user scott account lock;

  • With which functions could you use the NLS_CURRENCY paramter ?

Only with TO_CHAR and TO_DATE

  • Which two views could you query to display the names and locations of all
    controlfiles in a database ?

V$CONTROLFILE and V$SYSTEM_PARAMETER

  • Which data type allows to store multiple values within the same table column ?

VARRAY

  • When a user issues an UPDATE command, what happens after copies of the blocks are read into the buffer cache and before the changes are recorded in the redo log buffer ?

The Server places locks on the data

  • You are creating a rollback segment for an application. You have not yet determined the space needed by the average transaction. To which value should you set the OPTIMAL parameter when creating the rollback segment ?

Value greather than or equal to INITIAL * MINEXTENTS

  • What does a value of -1 in a user's tablespace quota indicate ?

Unlimited quota

  • If a database cannot be shut down, which command could you use to enable or disable enforcement of resource limits for an existing user during their current session ?

alter system set resource_limit=true;

  • Which storage parameter could cause higher processing costs because blocks
    will be considered free more often ?

raising PCTUSED

  • Which command could you use to create a table with a foreign key before
    creating the table containing the referenced key ?

CREATE SCHEMA

  • Which characteristics correctly describe extents ?

- Each segment in a database is created with at least one extent.
- Frequent de-allocation of extents can lead to a fragmented tablespace.

  • When does DBWR flush dirty buffers to a datafile?

Either before or after a COMMIT is issued

  • Which benefit does Oracle Fast COMMIT offer?

Minimal information is required to record the changes in the redo logs, due LRU is deferred.

Writes to the datafiles are deferred to reduce disk contention and I/O. Oracle's Fast COMMIT allows LGWR to record only the changes and SCN in the redo log files. The size of the transaction does not affect the time required to write to the redo log files. These writes are sequential and faster than writing entire blocks to the datafiles. Writes to the datafiles occur independently of the COMMIT.

  • Which two Server Manager line mode commands could you use to display
    the current size of the redo log buffer?

SHOW SGA
SHOW PARAMETER

  • Evaluate this Server Manager line mode command:

ALTER SYSTEM SET SORT_AREA_SIZE=163840 DEFERRED;

What affect would this command have on the SORT_AREA_SIZE initialization parameter?

It will be set to 163840 for all future sessions.

  • Which SHUTDOWN mode will only wait for the pending transaction of a current user to end before ending their session?

TRANSACTIONAL

  • Why would you set the REMOTE_LOGIN_PASSWORDFILE initialization parameter to NONE?

To use operating system authentication

To allow users to connect to the database using O/S authentication, set up the users in the operating system and set the REMOTE_LOGIN_PASSWORDFILE initialization parameter to NONE. To connect to the database using the SYSDBA role, log in to the operating system and connect to the database using this connect string: CONNECT / AS SYSDBA

  • If you administer several remote databases, how would using Oracle Enterprise Manager help you maintain the initialization parameters?

Database configurations can be stored in the OEM registry and not as external files.

  • Which SHUTDOWN mode waits for all current users to disconnect before shutting down the instance?

NORMAL

  • Why should the DBA check the ALERT file regularly?

To detect block corruption errors

  • Using Server Manager line mode, which three methods could you use to display the current locations of the control files for the current instance?

V$PARAMETER, V$CONTROLFILE, SHOW PARAMETER

  • You start an instance in NOMOUNT state. Which three dynamic performance views can you query?

V$SESSION, V$INSTANCE, V$PARAMETER

When an instance is started in NOMOUNT state, you can only access the views that read data from the SGA. V$PARAMETER, V$SESSION, and V$INSTANCE read from memory; V$DATABASE, V$DATAFILE and V$LOGFILE all read data from the control file. The database must be mounted for the control file to be opened. The data dictionary is only accessible when the database is open.

  • Which SHUTDOWN mode will only wait for the pending transaction of a current user to end before ending their session?

SHUTDOWN TRANSACTIONAL;

  • What would happen if the database name in the parameter file does not match the control file?

An instance would start, but the database would not be mounted.

When a database is created, the database name is specified in the CREATE DATABASE command and it must match the DB_NAME parameter. The database will not mount if the database name recorded in the control file does not match the database name in the STARTUP command.

  • Evaluate this command:

CREATE DATABASE prod
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXLOGHISTORY 100
LOGFILE
GROUP 1 '/disk3/log1a.rdo, /disk4/log1b.rdo',
GROUP 2 '/disk3/log2a.rdo, /disk4/log2b.rdo' REUSE
DATAFILE '/disk2/system01.dbf' SIZE 50M;

Which line will return an error under any condition?

==> GROUP 1 '/disk3/log1a.rdo, /disk4/log1b.rdo',

For any datafiles or redo log files that already exist, use the REUSE option in the CREATE DATABASE command. If the file does not exist, you must use the SIZE option to specify the size of the file to be created either in kilobytes (K) or megabytes (M).

  • According to the Optimal Flexible Architecture, how should you organize your database files?

Directly below the Oracle directory

  • When planning your database configuration, how should you organize the data storage?

Separate objects by lifespans to minimize fragmentation.

  • You issued a CREATE DATABASE command that failed because you were attempting to create log files that already existed. What should you do before reissuing the command?

Shut down the instance, delete any files created by the CREATE DATABASE command, and change the SIZE options to REUSE in the LOGFILE parameter of the CREATE DATABASE command.

  • Why must you recreate the control file if you change the MAXDATAFILES parameter for the PROD database?

To reallocate the space needed for the parameter

  • You need to be able to perform tablespace-point-in-time recovery. Which script creates the view used by the DBA when performing this type of recovery?

CATPROC.SQL

  • Which data dictionary category would a user with the SELECT ANY TABLE privilege query to find the owner of the PRODUCT1 table?

The data dictionary views categories:

ALL_ Accessible to all users and each view has an OWNER column, providing information on objects accessible by the user
DBA_  Accessible to the DBA or anyone with the SELECT ANY TABLE privilege, providing information on all the objects in the database and has an OWNER column
USER_  Accessible to all users, providing information on objects owned by the user
  • Which table contains the names of all the data dictionary views?

The DICTIONARY and DICT_COLUMNS data dictionary views provide an overview for all the data dictionary views.

  • Which category of scripts contain database package specifications and are usually run during the execution of catproc.sql?

dbms*.sql defines the database package specifications
cat*.sql provides catalog and data dictionary information
prvt*.plb provides wrapped package code
utl*sql creates views and tables for database utilities.

  • Which data dictionary view would you query to check the status of a view based on
     a table that was dropped?

If errors occur during compilation of objects, the STATUS column in DBA_OBJECTS is set to INVALID. Compiled objects that are available for use are marked VALID. In this example, the view would be marked as INVALID.

  • Which view would you query to display the value assigned to the MAXDATAFILES parameter for the PROD database?

SQL> select type,records_total from V$CONTROLFILE_RECORD_SECTION;

TYPE              RECORDS_TOTAL
----------------- -------------
DATABASE                      1
CKPT PROGRESS                 4
REDO THREAD                   4
REDO LOG                     62
DATAFILE                    256
FILENAME                    567
TABLESPACE                  256
RESERVED1                   256
RESERVED2                     1
LOG HISTORY                1696
OFFLINE RANGE               290
ARCHIVED LOG               1603
BACKUP SET                  305
BACKUP PIECE                514
BACKUP DATAFILE             526
BACKUP REDOLOG              160
DATAFILE COPY               512
BACKUP CORRUPTION           277
COPY CORRUPTION             305
DELETED OBJECT             1628
PROXY COPY                  640

  • What is the maximum number of control files that you can specify in the
    CONTROL_FILES parameter?

8

  • What would you do if your database has two redo log groups and Group 2 becomes corrupted?

Reinitialize the log files in Group 2 with the ALTER DATABASE CLEAR LOGFILE command.

You can clear a group if all its members become corrupt by issuing the ALTER DATABASE CLEAR LOGFILE command.  This command can be used even if there are only two redo log groups.  If you need to clear a redo log group that has not yet been archived, you must include the UNARCHIVED keyword in the command.

  • How often will a log switch occur if you set the LOG_CHECKPOINT_INTERVAL initialization parameter to 25?

After LGWR writes 25 operating system blocks

  • You are tuning the PROD database and need to determine the sequence number of the current redo log group.  Which view would you query to display the number of online redo log groups?

select SEQUENCE# from v$thread;

  • You query V$LOGFILE and find that log3a.rdo in group 3 has a status of NULL.
    What can be said about this file?

It is in use

V$LOGFILE displays each group, each member, and the status of each member. The values of the STATUS column can be: INVALID - inaccessible, STALE - incomplete, DELETED - no longer being used, NULL - in use

  • What is the advantage of running a database in ARCHIVELOG mode?

Complete recovery is possible even after the redo logs have been overwritten using
the archived redolog files

  • Which view would you query to determine if the PROD database is in NOARCHIVELOG mode?

select LOG_MODE from v$database;

  • If you query V$LOG and find that GROUP 3 is INACTIVE, what can be said about this group?

The group is no longer needed for instance recovery.

  • How would you drop a redo log member from an active group when archiving is enabled?

After the group is archived, issue the ALTER SYSTEM SWITCH LOGFILE command then the ALTER DATABASE DROP LOGFILE MEMBER command.

To drop a redo log member, use the ALTER DATABASE DROP LOGFILE MEMBER command. If the database is in ARCHIVELOG mode, you cannot drop an online member until it has been archived. If the group is active, you must force a log switch before dropping one of its members. You cannot drop the last valid member of a group. Dropping a member does not remove its O/S file.

  • What will the Oracle Server do if you issue the ALTER DATABASE ADD LOGFILE command without the GROUP option?

The syntax to add a redo log group:

ALTER DATABASE prod
ADD LOGFILE GROUP 2 ('/disk2/log2a.rdo',
'/disk3/log3b.rdo') SIZE 1M;

If you specify the GROUP option, you must use an integer value. If you do not use the GROUP option, the Oracle Server will automatically generate a value. Use the SIZE option if you are creating a new file. Use the REUSE option if the file already exists.

  • When moving datafiles, which function does the ALTER DATABASE RENAME FILE and ALTER TABLESPACE RENAME DATAFILE commands provide?

Reset internal file pointers in the control file.

  • What is the default value of the PCTINCREASE parameter for a tablespace?

50 (This is very bad, set it to 0)

  • You created a tablespace with MAXEXTENTS equal to 500. How could you increase the setting?

Use the ALTER TABLESPACE command to change the MINIMUM EXTENTS value or the DEFAULT STORAGE parameters for a tablespace.

  • When the USER_DATA tablespace was created, you over estimated the amount of space required for the user01.dbf datafile. How would you change the size of the datafile from 100M to 10M?

Use the RESIZE option with the ALTER DATABASE DATAFILE command.

  • How would you make an offline tablespace read-only?

Issue the ALTER TABLESPACE ONLINE command then the ALTER TABLESPACE READ ONLY command.

When you make a tablespace read-only, all the datafiles must be online and the tablespace can have no pending transactions or active rollback segments. To make a read-write tablespace read-only, use this command: ALTER TABLESPACE tablespace_name READ ONLY; To make a read-only tablespace read-write, use this command: ALTER TABLESPACE tablespace_name READ WRITE;

  • Evaluate this command:

CREATE TABLESPACE user_data
DATAFILE '/disk2/us_data01.dbf' SIZE 10M
MINIMUM EXTENT 500K
DEFAULT STORAGE
(INITIAL 100K NEXT 100K MAXEXTENTS 500 PCTINCREASE 0);

Why will this statement fail?

INITIAL and NEXT should be a multiple of MINIMUM EXTENT.

When MINIMUM EXTENT is specified, every extent allocated in the tablespace should be a multiple of MINIMUM EXTENT. In this case, NEXT and INITIAL should be multiples of 500K.

  • DB_BLOCK_SIZE for the PROD database is 2K. You created the USER_DATA01 tablespace without specifying a value for the NEXT parameter. What will be the size of the second extent allocated to the USER_DATA01 tablespace?

The default value of the NEXT parameter is 5 data blocks. In this case, the size of the second extent allocated can be determined by: 5 * DB_BLOCK_SIZE = 10K

  • When moving datafiles, when would you use the ALTER DATABASE command rather than ALTER TABLESPACE command?

When the tablespace is the SYSTEM tablespace

  • What would happen if DB_BLOCK_SIZE is 4K and you attempt to create
    a tablespace with INITIAL equal to 4K?

A syntax error would be returned.

The minimum INITIAL value allowed is: 2 * DB_BLOCK_SIZE

  • Which two are physical structures and part of an Oracle database?

Datafile and OS-Blocks

The physical structure of a database includes O/S blocks, datafiles,
control files, and online redo log files.

  • Which command would you use to change the size of the minimum extent allocated to the USER_DATA tablespace from 2M to 3M?

ALTER TABLESPACE MINIMUM EXTENT

Use the ALTER TABLESPACE command to change the MINIMUM EXTENT value or the DEFAULT STORAGE parameters for a tablespace.

  • Evaluate this command:

ALTER TABLESPACE data01 COALESCE;

Which background process performs the same task?

Coalescing merges neighboring free extents. This is automatically done by the SMON background process if the PCTINCREASE value for the tablespace is greater than zero. You can manually coalesce a tablespace by using this command: ALTER TABLESPACE tablespace_name COALESCE;
Query DBA_FREE_SPACE_COALESCED to determine if a tablespace needs to be coalesced.

  • What happens when free space drops below the PCTFREE threshold?

A block is removed from the free list when it falls below the PCTFREE threshold. It is returned to the free list when the used space falls below PCTUSED.

  • Which type of segment speeds data retrieval while minimizing disk contention?

An index can be partitioned to minimize disk contention while decreasing the amount of time required for queries.

  • Evaluate this command:

ALTER ROLLBACK SEGMENT rbs01 SHRINK TO 4M;

What would be the result if the current size of RBS01 is 3M?

The command is ignored.

The ALTER ROLLBACK SEGMENT command with the SHRINK option will shrink a rollback segment. If no value is specified, the Oracle Server will attempt to shrink to the OPTIMAL value. To shrink a rollback segment to a specific size, use this command:
ALTER ROLLBACK SEGMENT SHRINK TO integer K/M;
If the SHRINK TO size or OPTIMAL is greater than the current size of the rollback segment, the command is ignored.

  • Evaluate this command:

ALTER ROLLBACK SEGMENT rbs01 OFFLINE;

What will happen if RBS01 has pending transactions when the command is issued?

The segment is taken offline when all transactions are complete.

A rollback segment cannot be taken offline if it has pending transactions. If you use the ALTER ROLLBACK SEGMENT command to take it offline before the pending transactions end, the rollback segment will be marked as 'PENDING OFFLINE'. The rollback segment will not be taken offline until the transactions complete.

  • Which type of segment records changes for multiple transactions?

Rollback segments store the before image when changes are made to data in the database. A transaction can only be assigned to one rollback segment, however a rollback segment can store images for multiple concurrent transactions.

  • Which type of rollback segment is automatically dropped when it is no longer
    needed by the Oracle Server?

The SYSTEM rollback segments record changes made to objects in the SYSTEM tablespace.
Private rollback segments are acquired by an instance when they are named in the parameter file.
Public rollback segments are in the pool of rollback segments.
Deferred rollback segments are created by the Oracle Server when a user attempts to commit a transaction that will change data in a tablespace that is offline. The Oracle Server will drop these segments when they are no longer needed.

  • Which three methods can you use to decrease the probability of snapshot too old errors?

Use larger extent sizes.
Create rollback segments with higher OPTIMAL values.
Create rollback segments with high MINEXTENTS values

A snapshot too old error occurs when the Oracle Server cannot create a read consistent image of the data when a query is executed. The error is returned when a query is issued on a row with a lock, but before the query is finished the transaction commits and the rollback segment is overwritten. Reduce the chances of snapshot too old errors by creating rollback segments with high MINEXTENTS values, larger extent sizes, and high OPTIMAL values.

  • What is the recommended size for MINEXTENTS to reduce the possibility
    of rollback segment extension?

20

MINEXTENTS for a rollback segment should be greater than or equal to two. Oracle recommends a value of 20 to reduce the likelihood of extension. OPTIMAL should be greater than or equal to MINEXTENTS. PCTINCREASE cannot be specified and should be set to zero. INITIAL should always be equal to NEXT. All the extents allocated to a rollback segment should be the same size. Place rollback segments in tablespaces that do not contain data to minimize I/O contention and fragment.

  • Which three steps are necessary before you can take a tablespace offline that contains active rollback segments?

Before you can take a tablespace with active rollback segments offline:

Query DBA_ROLLBACK_SEGS to determine which rollback segments are in the tablespace and take the rollback segments offline.

Query V$TRANSACTIONS to determine the transaction currently using the rollback segments.

Query V$SESSION to determine the user with the pending transaction and terminate their session.

  • To which size should INITIAL and NEXT be set when defining DEFAULT STORAGE for a TEMPORARY tablespace?

DB_BLOCK_SIZE+(multiple of SORT_AREA_SIZE)

Temporary segments are based on the default storage parameters of the tablespace. For the TEMPORARY tablespace, INITIAL and NEXT should be equal to each other and a multiple of SORT_AREA_SIZE plus DB_BLOCK_SIZE. PCTINCREASE should always be equal to zero.

  • How are sort segments allocated during a sort in a TEMPORARY tablespace?

Several transactions can simultaneously share the same sort segment.

  • Why would you query V$SORT_SEGMENT?

To determine the number of extents allocated to a TEMPORARY tablespace containing a sort segment

  • Which two dynamic performance views could you join to determine the number of extents being used by an active sort?

V$SESSION
V$SORT_USAGE

Join V$SESSION and V$SORT_USAGE to display the username, session address, tablespace, contents, extents, and blocks for active sorts.

  • Which view could you query to display the Sort Extent Pool status?

V$SORT_SEGMENT

  • When altering a table, which parameter indicates the number of bytes above the high water mark that the table will have after deallocation?

KEEP

To deallocate all unused space in a table above the high water mark, use this command:

ALTER TABLE table DEALLOCATE UNUSED;

To deallocate unused space while keeping a specified number of bytes above the high water mark, use this command:

ALTER TABLE table DEALLOCATE UNUSED KEEP integer K/M;

If the size specified in the KEEP option is below MINEXTENTS, MINEXTENTS will be kept.

  • Which command would you issue to release all the space allocated to an empty table, 
    except for MINEXTENTS?

TRUNCATE TABLE <schema.table_name> DROP STORAGE;

  • Which function in the DBMS_ROWID package would you use to convert ROWID values into a relative file number?

The ROWID_RELATIVE_FNO function in the DBMS_ROWID package returns the relative file number of the file that stores the row. The ROWID_BLOCK_NUMBER function in the DBMS_ROWID package returns the block number stored in the row in the relative file. The ROWID_ROW_NUMBER function in the DBMS_ROWID package returns the sequence number of a given ROWID value.

  • Which parameter should you increase to avoid excessive row migration?

Increase PCTFREE

If PCTFREE is set too low, there may not be enough room in the data blocks to update existing rows. When there is insufficient space in the data block, the row is moved to a new data block and the old block stores a pointer to the new location. Row migration slows table scans because two blocks are scanned for one row.

  • If a column will store 266 bytes, how many bytes will the column length be in the block header?

3 ( 1 for columns length <= 250, 3 for columns length > 250 )

When row data is stored in a data block, the column length is recorded as either 1 byte for column lengths 250 bytes or less or 3 bytes for column lengths greater than 250 bytes.

  • The DESCRIPTION column in the PRODUCT table requires an average of 100 bytes per row . Which datatype could you use as a pointer to the DESCRIPTION column rather than storing this value again in the ORDERS table?

REF

The REF datatype is a relationship type that stores a pointer to the data in another table, rather than storing the actual data.

  • Evaluate this command:

ANALYZE TABLE orders ESTIMATE STATISTICS;

How many rows will be sampled if the ORDERS table contains 5000 rows?

1064

To detect row migration or chaining in a table, use the ANALYZE TABLE command. The COMPUTE STATISTICS option will return exact statistics because it analyzes all of the rows in the table. The ESTIMATE STATISTICS option will compute statistics based on 1064 rows. You can use the ESTIMATE STATISTICS option with a sample integer or percent to specify the number or percentage of rows that are scanned.

  • A new table with 100 free blocks has inserts filling 70 blocks followed by deletes freeing 20 blocks. Where is the resulting high water mark at this point?

70 Blocks (INITRANS Index > INITRANS Table)

The high water mark in a table is the last block ever used by the table. The high water mark is not reset when data is deleted. When a full table scan is performed, each block is read up to its high water mark.

  • You are creating an index for a table and are considering a value for INITRANS for this index. How should INITRANS be set for this index relative to the INITRANS value already set for the corresponding data table?

Higher

Because index entries are small, there are usually more entries per block so the INITRANS value should be higher than the table.

  • You have a table with an associated index. How is this index affected if the table is truncated?

The TRUNCATE command deletes all the rows in the table and releases all the unused space. The corresponding indexes will also be truncated. If the REUSE option is used with the TRUNCATE command, the data is deleted from the table and its corresponding indexes, but no space is deallocated. If the DROP option is used with the TRUNCATE command, the extents specified by MINEXTENTS are retained. A table cannot be truncated that is referenced by a foreign key.

  • How does a partitioned index differ from a nonpartitioned index?

Partitioned indexes allow an index to be spread across multiple tablespaces.

  • Which data dictionary view would you query to determine if an index is VALID?

DBA_INDEXES

  • Where do the parallel query slaves insert data when a parallel direct-load insert is performed?

To perform a parallel direct-load insert, use the PARALLEL hint in the INSERT INTO SELECT command. The parallel direct-load insert uses parallel query slaves to insert the data. The data is written to temporary segments until the transaction commits.

  • You have exported a file for subsequent import into another tablespace. In which sequence is the Import file loaded?

The order of import:

1. table definitions
2. table data
3. indexes on the table
4. integrity constraints, triggers, and bitmap indexes

  • Which SQL*Loader parameter specifies the number of logical records to load?

The LOAD parameter in the SQL*Loader command specifies the number of records to load. This value does not include any records that are skipped.

  • For which two reasons would you use direct-load inserts when loading data into a table?

Other rows in the same table can be concurrently modified by other users.
Data can be quickly copied from one table into another within the same database because it
bypasses the buffer cache.

Use the INSERT INTO SELECT command to perform a direct-load insert. This command can be used to copy data from one table to another table in the same database. The buffer cache is bypassed to speed up the insert. During a direct-load insert, users can be concurrently modifying existing data in the table. Data is loaded above the high water mark.

  • Which user needs a usage quota?

The QUOTA clause defines the amount of space in bytes that a user can use to create and maintain objects in a specified tablespace. The default value is no space and the maximum value is UNLIMITED.

  • Evaluate this command:

ALTER USER bill QUOTA 0 ON data01;

If a 20M table exists in the DATA01 tablespace owned by user BILL, which effect
will this command have ?

The objects created by user BILL in the DATA01 tablespace will remain, but no new extents can be allocated to the objects.

  • Which data dictionary view could a user query to display the number of bytes charged to their username?

USER_TS_QUOTAS

USER_TS_QUOTAS displays the names of tablespaces that the user has a QUOTA on, the number of bytes and blocks used, and the maximum number of bytes and blocks allowed.

  • Which four resource limits are averaged by specified weighting to give a composite limit?

When assigning a COMPOSITE_LIMIT to a profile, Oracle calculates a weighted sum for these resource limits:

PRIVATE_SGA
CPU_PER_SESSION
CONNECT_TIME
LOGICAL_READS_PER_SESSION

To specify the weights assigned to each limit, use the ALTER RESOURCE COST command.

  • Evaluate this statement:

ALTER PROFILE juan LIMIT
CPU_PER_SESSION 3600 (1/100 Sec)
IDLE_TIME 30; (Min)

How much time will be allowed in the next session for user JUAN?

36 seconds of cpu time and 30 minutes of inactivity

CPU_PER_SESSION is expressed in hundredths of seconds and IDLE_TIME is expressed in minutes

  • You ran the script to create the VERIFY_FUNCTION function and it altered the DEFAULT profile.

After the VERIFY_FUNCTION is enabled and the DEFAULT profile is altered, a user must change their password using these guidelines:

1. The new password must differ from the old password by more than three characters.
2. The password must have at least 4 characters.
3. The password cannot be equal to the username.
4. The password must have at least one alpha, one numeric, and one special character.

  • Which initialization parameter would you alter to disable the enforcement of resource limits?

To disable resource limits, set the RESOURCE_LIMIT parameter to FALSE. To enable the enforcement of resource limits for the current instance, use the ALTER SYSTEM command to set the RESOURCE_LIMIT initialization parameter to TRUE. To enable or disable the enforcement of resource limits for future sessions, alter the RESOURCE_LIMIT initialization parameter in the parameter file.

  • Which view would you query to display information about password expiration, locking dates, and account status for user CHAN?

DBA_USERS

  • You are administering password settings for a profile. Which parameter ensures that a user does not reuse the same password?

When the PASSWORD_MAX_REUSE parameter is set to UNLIMITED, a user can never reuse the same password.

  • Which object privilege do you need to grant privileges on an object not in your schema?

Object privileges are granted WITH GRANT OPTION. When object privileges are revoked, the revoke cascades.

  • Which system privilege do you need to grant a system privilege to another user?

    System privileges are granted WITH ADMIN OPTION. When system privileges are revoked, the revoke does not cascade.

  • Which privilege is required to TRUNCATE a table owned by another user?

DROP ANY TABLE

  • Which command could you use to set a default role for a user?

To define a default role for a user, you must grant the role to the user with the GRANT command. By default, all the roles granted to the user will be enabled when the user connects unless the ALTER USER DEFAULT ROLE command is used to limit the default roles.

  • Evaluate this command:

ALTER USER jennifer
DEFAULT ROLE ALL;

Which task would this accomplish?

Set all roles as default for user JENNIFER

  • Which three functions can be used with the NLS_SORT parameter?

The NLS_SORT parameter can be used with the NLS_UPPER, NLS_LOWER, NLS_INITCAP, and NLSSORT functions.

  • NLS Views

    NLS_SESSION_PARAMETERS: This View lists NLS parameters of the user session.
    NLS_DATABASE_PARAMETERS: This View lists permanent NLS parameters of the database
    NLS_INSTANCE_PARAMETERS: This View lists NLS parameters of the instance.

    SQL> select * from nls_session_parameters;

    PARAMETER                      VALUE
    ------------------------------ ------------------------------
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-YY
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-YY HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZH:TZM
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-YY HH.MI.SSXFF AM TZH:T
    NLS_DUAL_CURRENCY              $
    NLS_COMP

    SQL> select * from nls_database_parameters;

    PARAMETER                      VALUE
    ------------------------------ ------------------------------
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               WE8ISO8859P1
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-YY
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-YY HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZH:TZM
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-YY HH.MI.SSXFF AM TZH:T
    NLS_DUAL_CURRENCY              $
    NLS_COMP
    NLS_NCHAR_CHARACTERSET         WE8ISO8859P1
    NLS_RDBMS_VERSION              8.1.5.0.0


Oracle-8 Database Tuning

  • Which TKPROF option should you set to ignore recursive SQL ?

SYS Option

  • At which level does Oracle resolve deadlocks ?

Statement Level

  • What is an effect of setting the CACHE_SIZE_THRESHOLD parameter?

Limits the number of blocks cached for each table.

  • You discover excessive I/O to datafiles in the SYSTEM tablespace during
    normal operations. What are three likely causes for this problem?

- The Shared Pool is too small
- Data Segments are being written to the SYSTEM tablespace
- Sort Segments are being written to the SYSTEM tablespace

  • Which factor is most important in determining the OPTIMAL size for a rollback segment?

Transaction activity of the database during normal processing.

  • Which command would you use to reset the high-water mark on a table?

TRUNCATE

  • Given this formula:

              number of blocks that contain rows
    100 * -----------------------------------------------------
              number of blocks below the high-water mark

For non-empty tables, which value should be your target?

100

  • Your operating system does not support striping. Striping by hand is a very time-consuming task. Which two conditions might make striping by hand worthwhile?

- The database is using Parallel Query Option
- The application is performing many full table scans.

  • Which view can be queried to check the amount of sharable memory used by a cached object?

desc v$db_object_cache;

Name                             Null?     Type
------------------------------- -------- ----
OWNER                                     VARCHAR2(64)
NAME                                      VARCHAR2(1000)
DB_LINK                                   VARCHAR2(64)
NAMESPACE                                 VARCHAR2(15)
TYPE                                      VARCHAR2(24)
SHARABLE_MEM                              NUMBER
LOADS                                     NUMBER
EXECUTIONS                                NUMBER
LOCKS                                     NUMBER
PINS                                      NUMBER
KEPT                                      VARCHAR2(3)

  • Your database is installed on a multi-CPU system. If the Utlbstat/Utlestat utility shows contention for the redo copy latch, which action should you take?

    Increase the value of the LOG_SIMULTANEOUS_COPIES parameter. This Parameter specifies the number of redo buffer copy latches. For Single CPU Machines set it to 0, for Multi CPU Machines set it to 2 x Number of CPUs.

  • Your system has limited physical memory. You have an application that uses many large sorts. Which parameter can be set to improve the performance of these large sorts?

SORT_DIRECT_WRITES = True/False/Auto (Bypass Buffer Cache)

Set it to True if there is abundant memory. This parameter controls whether sort data will bypass the buffer cache to write intermediate sort to disk.

  • You query the V$LIBRARYCACHE view to determine the Reloads-to-Pins ratio.
    What is the ideal value for the SUM of the RELOADS for a database?

0

  • Which command would you use to organize space within an existing index?

ALTER INDEX REBUILD ...

  • In which two files will deadlock contention be recorded?

Alert Log File
User Process Trace File

  • Which two steps are necessary to evaluate the impact of reducing the buffer size?

Query the V$RECENT_BUCKET view
Set the Parameter DB_BLOCK_LRU_STATISTICS to TRUE

  • Which two views could you query to determine lock contention on the EMP table?

V$LOCK  (Lock currently held by the Oracle Server)
V$LOCKED_OBJECT (Lists all locks acuired by every transaction on the system)

  • A user complains that an exceptionally large update fails. What are the two most likely
    causes of this problem?

MAXEXTENTS has been set too low
Tablespace for Rollback Segments too small

  • What is an effect of setting the CACHE_SIZE_THRESHOLD parameter?

Limits the number of blocks cached for each table

  • You check the init.ora file and see that LOG_SIMULTANEOUS_COPIES = 2 for your four
    CPU machine. It is recommended that you set this parameter to which value if you see contention?

8 (Good Performance set it to 2 x Number of CPU's)

  • Your system has abundant physical memory. You have an application that uses many large sorts.
    Which two parameters can be set to improve the performance of these large sorts?

SORT_AREA_SIZE=<SIZE> (Increasing the size improves the efficiency of large sorts)
SORT_DIRECT_SORTS=TRUE (Can improve sort performance for abundant memory)

  • Which dynamic performance view would you query to display the total waits
    for "buffer busy waits" since instance startup?

V$SYSTEM_EVENT (Total Waits on en event since Instance startup)

  • What should you do if the hits on the LRU latch are less than 1% and your
    system has multiple CPUs?

Modify the DB_BLOCK_LRU_LATCHES parameter

  • In a joint effort with the system administrator to tune the system, you gather information about the database. Which view can be queried to provide statistics for tuning I/O?

V$FILESTAT (I/O Statistics, V$LOADSTAT ist for SQL*Loader)

  • Which statistics can be obtained by querying the V$SYSSTAT view?

Redo Log Buffer, select CLASS = 2

  • What will result in a very low value for the TKPROF Disk statistic?

Buffered Data

  • When tuning SQL, which mechanism will provide an efficient method for joining two tables when one table is significantly larger than the other?

Hash Join

  • You have an eight CPU machine. Which step would you take to increase performance on tables with a high number of concurrent inserts?

Recreate the table increasing the number of freelists.

  • Your database is installed on a multi-CPU system. If the Utlbstat/Utlestat utilities show contention for the redo copy latch, which action should you take?

Increase the value of the LOG_SIMULTANEOUS_COPIES parameter.

  • What does the MAX_DUMP_FILE_SIZE parameter limit?

The MAX_DUMP_FILE_SIZE parameter value is specified in O/S blocks and specifically limits the size of user trace files.

  • Which information does the V$EVENT_VIEW view provide?

The V$EVENT_NAME view lists all event names and their associated parameters.

SQL> select event#, substr(name,1,50) from v$event_name
     where rownum < 10;

EVENT#    SUBSTR(NAME,1,50)
--------- ---------------------------------------------
0         Null event
1         latch activity
2         latch free
3         free process state object
4         pmon timer
5         inactive session

  • Which view can you query to find information about system-wide waits per session?

V$SESSION_EVENTS

  • You query the V$SYSTEM_EVENT view with this command:

SELECT event, total_waits, total_timeouts,
time_waited, average_wait
FROM v$system_event;

  • Which event would indicate contention in the database buffer cache?

Buffer Busy Waits

  • For which reason should you enable tracing for a user session?

A user has complained about the time it is taking to execute an application process.

  • You query V$SESSION_WAIT and see a wait time of 2 for an event.
    Which information does this query provide?

Active session's last wait time

  • Which view can you query to see the total number of event waits since instance startup?

V$SYSTEM_EVENT

  • You have run the UTLBSTAT/UTLESTAT utilities and the report.txt shows a latch hit ratio of 0.99. What does this value indicate about latch activity for the database?

A latch hit ratio of 99% is optimal. Latch contention should be always be 1% or less. To resolve redo latch contention, increase LOG_SIMULTANEOUS_COPIES and decrease LOG_SMALL_ENTRY_MAX_SIZE.

  • When viewing latch statistics in the report.txt, with which column should you be most concerned?

HIT_RATIO

  • Which view will provide basic instance statistics?

The V$SYSSTAT view provides basic instance statistics cumulated since instance start up.

  • Which view could be queried to determine the type of user connection?

    SELECT sid, username, type, server
    FROM v$session;

    SELECT sid, username, type, server
      FROM v$session;

    SID       USERNAME                        TYPE        SERVER
    --------- ------------------------------ ---------- ---------
    1                                         BACKGROUND DEDICATED

  • You have a hybrid system processing reports at night. What can you do to handle heavy transaction processing during the day and report processing at night?

Use many small rollback segments during the day and fewer large rollback segments at night.
The segments not being used for reporting should remain offline until they are needed.

  • Using a hybrid system, OLTP for day and DSS for night, what is the most efficient method of altering the parameters for day and night use?

Reset the parameters for day and night using a separate pfile.

  • What can you use to identify SQL areas that are possibly causing performance problems?

SQL Trace can be set at instance or session level and provides detailed information regarding the execution of a SQL statement.

  • When creating queries, which keyword will create a sort and incur I/O and processing overhead?

When DISTINCT is used, the data is sorted. If the statement selects a large number of rows, the server may generate temporary segments to handle the sort runs. This process incurs I/O and processing overhead, and should be avoided.

  • What can be used to join two tables when one is significantly larger than the other?

Hash Join

  • Which information is stored in the lookup tables used in star queries?

Information about entries for attributes in the fact table. Lookup tables are small tables joined to the fact table using a PK-FK join.

  • Which two things can you track using the DBMS_APPLICATION_INFO package?

Performance and Resource Usage

DBMS_APPLICATION_INFO contains procedures needed to register and then track a module. When an application calls these procedures, they record and read information into and from the V$SESSION and V$SQLAREA views.

  • Which clause can increase response time if not used properly in an SQL statement?

Statements including group functions impact performance. Use a WHERE clause to exclude unwanted rows. HAVING should only be used with an aggregate condition. Inappropriate use of the HAVING clause increases response time.

  • Which two procedures within the DBMS_APPLICATION_INFO package can be used to track module performance?

READ_MODULE reads the last module and action names set by SET_ACTION or SET_MODULE. READ_CLIENT_INFO reads the last client information set for the session.

  • Which two parameters, when set, have a negative impact on CPU performance?

DB_BLOCK_CHECKSUM
LOG_BLOCK_CHECKSUM

  • Which init.ora parameter, when set to TRUE, will cause Oracle to bring all SGA pages into memory when the instance is started?

PRE_PAGE_SGA

Instance start up time is increased using this parameter, but it can reduce the number of page faults that occur. The reduction in page faults allows the instance to reach its maximum performance capability more quickly

  • What does the RELOADS column of the V$LIBRARYCACHE view represent?

The number of object definitions that have been aged out of the library cache for lack of space.

  • Which information does the PINS column of the V$LIBRARYCACHE view represent?

The number of executions of SQL statements or procedures in the library cache.

  • Which two views can be queried to gather information about UGA space usage for all MTS users?

V$SESSTAT
V$STATNAME

SELECT SUM(value) || 'bytes' "Total session memory"
  FROM v$sesstat, v$statname
 WHERE name = 'session uga memory'
   AND v$sesstat.statistic# = v$statname.statistic#;

  • Which objects should you consider keeping in the shared pool?

Pinning sequences in the shared pool will prevent the numbers from being lost, which is normal when they are aged out.

  • Which view can you query to determine the amount of sharable memory used by a
    cached PL/SQL object ?

SELECT SUM(sharable_mem)
FROM v$db_object_cache
WHERE type = 'PACKAGE' OR type = 'PACKAGE BODY' OR
type = 'FUNCTION' OR type = 'PROCEDURE';

  • What is the recommended number of bytes to allow in the shared pool per user per open cursor?

Oracle recommends allowing about 250 bytes in the shared pool per user per open cursor. This can be tested during peak times using this query:

SELECT SUM(250 * users_opening)
FROM v$sqlarea;

  • Due to operating system memory limitations, you need to set the SHARED_POOL_RESERVED_SIZE. Which additional parameter should you also increase by the same amount?

SHARED_POOL_SIZE

  • Which parameter is used to determine the number of blocks for multiple buffer pools?

DB_BLOCK_BUFFERS

Determine the size of each buffer pool by subtracting the number of buffers for each buffer pool from the total number of buffers defined for the entire buffer cache. If this constraint is violated, the database will not mount.

  • What is affected by the value of DB_BLOCK_BUFFERS?

The buffer cache holds copies of the data blocks from the datafiles. The DB_BLOCK_BUFFERS parameter specifies the number of blocks in the buffer cache.

  • What can you code into your queries to store the data blocks in the buffer cache?

Cache Hint Clause: Using this method causes the Oracle server to place the table blocks at the most recently used end of the LRU list.

  • Which two can you query to evaluate the effect of an increase or decrease to the size of the database buffer cache? (Tuning Buffer Cache).

V$SYSSTAT
V$RECENT_BUCKET

  • Which information about the database buffer cache is obtained by querying V$RECENT_BUCKET?

Number of additional cache hits gained by adding additional buffer cache blocks

  • Which information can be used to size the RECYCLE pool?

Total number of buffer cache blocks used by each object. The RECYCLE buffer pool should be large enough to be retained for the duration of the transaction.

  • What should be your tuning goal when sizing the KEEP buffer pool?

Retain as many objects in memory as you can.

  • When are dirty blocks flushed from the data buffer cache?

When the server process is searching the LRU list, DBWR managers the buffer cache by writing dirty blocks to the datafiles to ensure that there are free blocks for servers.

- When Dirty List exceeds threshold
- Independent of COMMIT
- No more free Blocks in LRU-List

  • When will DBWR write dirty blocks to the datafiles?

when the dirty list exceeds its size threshold

  • The database is using the Oracle Parallel Server option. Which view can you query to analyze the database buffer cache?

V$CACHE is created with the catparr.sql script. It can be viewed to monitor the number of buffer pool blocks by object and is intended for use with Oracle Parallel Server.

  • You can create the V$CACHE view which is useful for Oracle Parallel Server. Which information can be queried with this view?

Objects currently being cached

  • Which two copies of a single database block can be found in the database buffer cache at all times?

- Current block
- Read consistent block for rollback

The buffer cache may hold multiple copies of a single database block. Only one current copy exists, but server processes may need to reconstruct read-consistent copies using rollback information.

  • What is the minimum number of buffers that must be allocated to each buffer pool ?

50 times the number of LRU latches

  • You have been monitoring buffer cache performance and see that the values have been increasing for 'free buffer inspected'. What does an increase in this value indicate?

Number of buffers skipped to find a free buffer.

  • You view the alert.log and see this error:

"Checkpoint not complete; unable to allocate file"

What does this indicate?

LGWR has waited for DBWR to finish.

  • Which resource is used when a process writes changes to the redo log buffer?

The redo allocation latch controls the allocation of space for redo entries in the redo log buffer. There is only one redo allocation latch.

  • When does a process release the redo allocation latch on a single CPU machine?

When the process copies the entry into the buffer, there is only one redo allocation latch per instance. The number of CPU's only has an effect on redo copy latches.

  • The V$SYSTEM_EVENT view indicates there have been waits for the event 'log buffer space'.
     What does this indicate?

The LOG_BUFFER parameter needs to be increased.

  • You have two redo log groups, with two members each. Which two events will occur when a redo log group fills in an archived database?

A checkpoint occurs.
One member of the log group will be archived.

  • In which tablespace should you place stored packages and database triggers?

Stored objects such as database triggers and packages are part of the data dictionary and should be stored in the SYSTEM tablespace.

  • What is one method of striping tablespaces by hand?

To allocate extents explicitly, use this command:

ALTER TABLE tablename
ALLOCATE EXTENT (DATAFILE 'filename' SIZE sizeM);

  • Where are temporary segments created in a default user setup?

If you do not explicitly set the temporary tablespace during user creation, sorts occur in the SYSTEM tablespace.

  • Which two parameters control the use of asynchronous I/O?

DISK_ASYNCH_IO
TAPE_ASYNCH_IO

  • The Reservations application has many volatile tables with indexes. What should be your tuning goal for indexes of this type?

Indexes on volatile tables can present a performance problem and should be monitored and rebuilt frequently.

  • What is one disadvantage of using large extents?

Having enough contiguous storage space

  • You issue this statement:

DELETE * FROM parts;

What will be the state of the high-water mark for the PARTS table after this statement has completed?

not changed, DELETE statements have no effect on the high water mark. The TRUNCATE statement must be issued to reset the high water mark.

  • Which command can be used to monitor the space used by indexes?

ANALYZE INDEX index_name VALIDATE STRUCTURE;

  • You issued the ANALYZE command against the ITEM table and detected row migration. Which storage parameter should you increase to prevent further chaining to this table?

PCTFREE

Migration is caused by PCTFREE being set too low; there is not enough room in the block for updates. All tables that are updated should have PCTFREE set to allow enough space within the block for updates.

  • When creating large extents, what should you use as the basis for size?

multiple of 5 * DB_FILE_MULTIBLOCK_READ_COUNT

Multiply by five, because Oracle tries to allocate blocks on five block boundaries.

  • What does Oracle do with empty index blocks?

If you delete all entries for an index block, Oracle puts the block back on the free list.