Kamran Agayev’s Oracle Blog

Kamran Agayev’s Oracle Blog

Performing Block Recovery without having RMAN backup

Posted by Kamran Agayev A. on March 10, 2010

It’s possible to perform Block Media Recovery with having only OS based “hot” backups and having NO RMAN backups. Look at the following demonstration. Here I:

- Create a new user and a table in that schema
- Take OS backup (hot backup) of the users01.dbf where the table resides
- Corrupt the data in that table and get block corruption error (Don’t wish you to get such errors in your production database! :) )
- Connect with RMAN and try to use BLOCKRECOVER command. As we haven’t any backup, we get an error
- Catalog the “hot backup” to the RMAN repository
- Use BLOCKRECOVER command and recover the corrupted data block using cataloged “hot backup” of the datafile
- Query the table and get the data back!

 Here is the scenario

SQL> CREATE USER usr IDENTIFIED BY usr;
User created.

SQL> GRANT DBA TO usr;
Grant succeeded.

SQL> CONN usr/usr
Connected.
SQL> CREATE TABLE tbl_corrupt_test (id NUMBER);
Table created.

SQL> INSERT INTO tbl_corrupt_test VALUES(1);
1 row created.

SQL> COMMIT;
Commit complete.

SQL> COLUMN segment_name FORMAT a45

SQL> SELECT segment_name, tablespace_name from dba_segments WHERE segment_name=’TBL_CORRUPT_TEST’;

SEGMENT_NAME                                  TABLESPACE_NAME
——————————————— ——————————
TBL_CORRUPT_TEST                              USERS

SQL> COLUMN segment_name FORMAT a15
SQL> COLUMN tablespace_name FORMAT a15
SQL> COLUMN name FORMAT a45

SQL> SELECT segment_name, a.tablespace_name, b.name FROM dba_segments a, v$datafile b
WHERE a.header_file=b.file# AND a.segment_name=’TBL_CORRUPT_TEST’;
SEGMENT_NAME     TABLESPACE_NAME NAME
—————  ————— ———————————–
TBL_CORRUPT_TEST USERS           /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf
SQL> ALTER TABLESPACE users BEGIN BACKUP;

Tablespace altered.

SQL> host cp /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf

SQL> ALTER TABLESPACE users END BACKUP;

Tablespace altered.

SQL> SELECT header_block FROM dba_segments WHERE segment_name=’TBL_CORRUPT_TEST’;

HEADER_BLOCK
————
          59

[oracle@localhost admin]$ dd of=/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf bs=8192 conv=notrunc seek=60 <<EOF
> corruption
> EOF
0+1 records in
0+1 records out

[oracle@localhost admin]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 – Production on Tue Mar 9 03:35:32 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> CONN usr/usr
Connected.

SQL> ALTER SYSTEM FLUSH BUFFER_CACHE;

System altered.

SQL> SELECT * FROM tbl_corrupt_test;
SELECT * FROM tbl_corrupt_test
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 60)
ORA-01110: data file 4:
‘/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf’
SQL> EXIT

[oracle@localhost admin]$ rman target sys

Recovery Manager: Release 10.2.0.1.0 – Production on Tue Mar 9 03:35:58 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

target database Password:
connected to target database: NEWDB (DBID=2953562798)

RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 60;

Starting blockrecover at 09-MAR-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of blockrecover command at 03/09/2010 03:36:13
RMAN-06026: some targets not found – aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore

RMAN> CATALOG DATAFILECOPY ‘/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf’;

cataloged datafile copy
datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf recid=1 stamp=713158624

RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 60;

Starting blockrecover at 09-MAR-10
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s) from datafile copy /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished blockrecover at 09-MAR-10

RMAN> EXIT

Recovery Manager complete.
[oracle@localhost admin]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 – Production on Tue Mar 9 03:37:28 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> CONN usr/usr
Connected.
SQL> SELECT * FROM tbl_corrupt_test;

        ID
———-
         1

SQL>

Posted in RMAN Backup and Recovery | Leave a Comment »

Manually corrupting the data block in Linux

Posted by Kamran Agayev A. on March 1, 2010

Sometimes, in order to test the RMAN’s  BLOCKRECOVER command, we need to corrupt the specific data block and recover it for testing purpose. To do it in Linux, use dd command. In the following example, let’s create a table and corrupt it manually (Don’t try it on the production database :) or you’ll be retired from the job )

SQL> CREATE TABLE corruption_test (id NUMBER);
Table created.

SQL> INSERT INTO corruption_test VALUES(1);
1 row created.

SQL> COMMIT;
Commit complete.

SQL> SELECT * FROM corruption_test;
        ID
———-
         1

SQL> SELECT header_block FROM dba_segments WHERE segment_name=’CORRUPTION_TEST’;
HEADER_BLOCK
————
          67

[oracle@localhost ~]$ dd of=/u02/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=68 << EOF
> testing corruption
> EOF
0+1 records in
0+1 records out

SQL> ALTER SYSTEM FLUSH BUFFER_CACHE;
System altered.

SQL> SELECT * FROM corruption_test;
select * from corruption_test
                     *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 68)
ORA-01110: data file 4: ‘/u02/oradata/orcl/users01.dbf’
SQL>

Now connect to the RMAN and recover the data block (not the whole datafile or database) using BLOCKRECOVER command as follows:

RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 68;

Starting blockrecover at 01-MAR-10

<… output trimmed … >
<… output trimmed … >

Finished blockrecover at 01-MAR-10

RMAN> exit

Connect to SQL*Plus and query the table:
SQL> SELECT * FROM corruption_test;

        ID
———-
         1

SQL>

Posted in Administration | 4 Comments »

Exclusive Interview with Hemant K Chitale

Posted by Kamran Agayev A. on February 2, 2010

Hemant K Chitale has 17 years of experience as an Oracle DBA. He has been a DBA on a wide variety of Unix platforms (some of them extinct now), Linux and Windows, from V6 to 10g. His career has spanned organisations from the Financial Services Industry to Manufacturing to Consulting. He has been a guide to junior DBAs and is in the habit of writing notes and case studies on technical issues in Oracle Database Administration. Portions of his spare time are spent on Oracle forums and on testing features of the Database. Database Performance and Backup and Recovery are his areas of interest. However, he does also have other interests in Non Fiction books and Serious Movies. “To learn and share knowledge” is a constant driver..

Could u please provide answer to the following questions as follows:

  • Brief information about yourself and your family

I have a wife and a 14 year old son in Secondary School.

  • Your education

My formal degree is in Finance.  However, I have done a Post  Graduate Diploma in Software Technology after I began working in I.T.

  • Your experience with Oracle. When you started first? Has it been interest of your side or just a coincidence?

I began with Oracle5 on DOS and Xenix.   When I joined Stock Holding Corporation of India Ltd, I began in Securities Trading Market Operations.  However, the systems we were using intrigued me.  The architecture was ahead of it’s time : Distributed Databases with Oracle5 on DOS sharing data with a “central” Oracle5 database on a Xenix server.

I moved to the I.T. department after my first year and soon started working on the Database sometime in 1991.

  • What was the motive behind to prefer Oracle? Who you have been influenced by?

Other than Oracle, the only “Database” I had seen was dBASE-III+  !  I liked Oracle for it’s multi-user support in V5.  V6 and V7 introduced Rollback Segments, Redo Logs, Row Locking (the “Transaction Processing Option”), PLSQL and I was hooked.

Years ago, before Oracle books came out, I read Steve Adam’s postings on newsgroups.   Then, later, Cary Millsap’s book “Optimizing Oracle Performance” Jonathan Lewis’s book “The Cost Based Optimizer”.

  • What would your preference of profession if not Oracle?

Teaching.  I like sharing knowledge.

  • What motivates you in your job?

The opportunities to “discover” different facets of databases and application design.  Some implementations really leave you with “awe” while others are “shocking”.  It’s always something new, exciting, challenging or disappointing or frustrating.  It is much more intellectual than Finance.

  • Do you give lectures on Oracle?

When I have had the occasion to.  I have conducted a 5 day DBA-I course once and a course in Advanced Replication (both in the 8i days).   Besides these, I have, on occasion, conducted 2-4 hour sessions.

  • Have you authored any book in Oracle?

Unfortunately, no.  I wish to and intend to.

  • Do you manage with your time as to read books on Oracle? What is the name of the book that you read recently?

I read non-Oracle books as well !  See my recommendations page http://web.singnet.com.sg/~hkchital/Recommendations.htm

The most recent Oracle books that I have been reading have been “Refactoring SQL Applications”  (ok, not strictly Oracle-only) by Stephane Faroult and “Advanced SQL Functions in Oracle 10g” by Richard Walsh Earp and Sikha Saha Bagui.

However, I am currently reading “The Professional” by Subroto Bagchi and “Fool’s Gold” by Gillian Tett.

  • What do you think on OTN forums?

A very useful platform, still underused.  There are many people I know that should be on OTN forums but, for whatever reasons that I cannot fathom, are averse.  I guess you have to have a certain attitude before you open up or spend time on forums.  This is an infinitely better way to spend your time than something silly as Facebook.

  • Do you refer to the documentation? And how often does it happen?

Very frequently.   Most often the SQL Reference (because I don’t  — and do not intend to – memorise syntax.  Syntax has to be understood rather than memorized). Also, the RMAN Reference (known as the “Backup and Recovery Reference”) and the Database Reference.

  • What is the biggest mistake you have ever made during your DBA career?

There was this time when I deleted an Online Redo Log when re-organising Logs. Fortunately, it wasn’t a CURRENT file but an INACTIVE one, so there was no harm done.  I could clear that quickly enough but did also bounce the database instance “to be safe”.

  • What was your greatest achivement as an Oracle DBA?

 Single-greatest ?  Actually multiple great ones.  Cross-Platform Migration from V6 to V7 in a short time-frame was one – although most DBAs would laugh at this now, back in those days it was my first Upgrade + Cross Platform + Cross Location migration.  Another one was implementing Oracle OPS in V7.   Building a Standby Database in V7 (DataGuard was a decade in the future !).  There have been a few Oracle Ebusiness Suite (10.7 and R11) upgrades that have been significant achievements.  As also storage-based D.R. implementations.

  • What is you priority to manage the challenges you face?

 Staying cool.  I can handle technology failures.  People’s unwillingness  to learn and/or share knowledge, particularly when it is needed, is something which makes me despair.  What makes me angry pushing a “never-live” project and continuing it as if it were a success.  I have seen instances of refusal to acknowledge that corrective action is required and that responsibility must be owned.

  • How would you describe the essence of your success? According to your definition of success, how successful have you been so far?

I wouldn’t say that I am successful yet !  I am trying to do a good job but am not near achieving my potential.

  • What are your best skills which make you differ from others?

Understanding the technology

  • What’s your major weakness?

Not understanding people – what motivates one person but not another, why does a person or a group of people behave in a certain manner ?  Humans just are weird !

  • Have you ever lost your spirit? If so, what has been the reason and how have you overcome it?

Yes.  Leading to depression.  The best person to talk to is your wife.  The next best person is someone outside the organization you work for.  However, fortunately, I have had good supervisors throughout my career, only that I have approached them too late.

  • What is the next success you would like to attain and your efforts to this end?

Ah!  That would be telling. 

  • How do you balance your daily life with your career?

“Work-Life balance” is an  empty phrase.  What you really need to do is to be happy – whether at work or at home or on OTN forums  (or, I wouldn’t say this about myself, playing computer games !)

  • Please describe your one day summary of activities?

Get up.   Read the newspaper.  Get ready for work.  Commute to work.  Do some work.  Return home.  Watch Television.  Spend time on the Internet (forums, lists, news etc).

Work should not be the most important part of the day – everything is equally important.

  • How many hours do you work and sleep in a day?

 4 to 6.  Sometimes I wake up in the night and can’t go back to sleep. 

  • Where and how do you spend your daily, weekly and annual holidays?

 Annual holidays in India with my parents, brothers and in-laws.  An additional visit to some other neighbouring country in the region, about once in two years.

  • Do you think about Oracle during vacations?

Only on rare occasions.

  • Do you have time or motivation to go in for any sports? If yes, which kind of sport do you go in for?

No.

  • What’s your favorite meal and non-alcoholic drink?

Indian Vegeterian  (which covers a whole gamut of different foods, believe me !).  Tea.

  • What foreign languages do you know?

Foreign to which country ?  Hindi, Marathi and Gujarati are Indian languages that are Foreign outside of India !

  • What’s your average typing speed?

I have a certified speed of 40 wpm on manual typewriters from 1981.   Computer keyboards nowadays are different from those typewriters but I have heard people say that I am “fast on the keyboard”.

  • Have you ever get involved in politics?

No.

  • What are your hobbies? 

Reading.  Non-fiction – economics, history, politics, science/technology and Oracle – besides a bit of  crime / detective fiction.

  • How do you spend your free time?

Television.  Crime Channels,  Knowledge Programs, News Programs and a few family programmes.

Reading. 

On Internet Forums and Email lists.

Internet News.

  • What’s your biggest ambition?

I am not known to be ambitious. 

  • What would be your advice to the beginners in Oracle?

Read the documentation, practice Oracle, learn, keep an open mind.

  • Would you like your children to follow in your footsteps or take a different path in life?

My son will NOT be an Oracle DBA.  That is 100% certain !  He knows what the job requires.

  • Do you have any followers of you?

Define “followers”.  I do not like any possible definition of the word.

  • What is your vision on the future of Oracle?

Cheaper licencing for the Database products.

  • Could you please take a photo in your office near to your desktop?

That’s not possible.

Posted in Expert Interviews | 5 Comments »

Chapter 10 – Managing the Undo Tablespace

Posted by Kamran Agayev A. on December 1, 2009

-          Every Oracle Database must have a method of maintaining information that is used to roll back, or undo, changes to the database. Such information consists of records of the actions of transactions, primarily before they are committed. These records are collectively referred to as undo

-          Undo records are used to L:

  • Rollback transactions when a ROLLBACK statement is issued
  • Recover the databsae
  • Provide read consistency

When a ROLLBACK statement is issued, undo records are used to undo changes that were made to the database by the uncommitted transaction. During database recovery, undo records are used to undo any uncommitted changes applied from the redo log to the datafiles. Undo records provide read consistency by maintaining the before image of the data for users who are accessing the data at the same time that another user is changing it.

-          In automatic undo management mode, you create an undo tablespace, and the server automatically manages undo segments and space among the various active sessions

-          When the instance starts, the database automatically selects the first available undo tablespace. If no undo tablespace is available, then the instance starts without an undo tablespace and stores undo records in the SYSTEM tablespace.

Undo Retention

-          After a transaction is committed, undo data is no longer needed for rollback or transaction recovery purposes. However, for consistent read purposes, long-running queries may require this old undo information for producing older images of data blocks. Furthermore, the success of several Oracle Flashback features can also depend upon the availability of older undo information. For these reasons, it is desirable to retain the old undo information for as long as possible.

-          When automatic undo management is enabled, there is always a current undo retention period, which is the minimum amount of time that Oracle Dataabase attempts to retain old undo information before overwriting it. Old (commiteed) undo information that is older than the current undo retention period is said to be expired. Old undo information with an age that is less than the current undo retention period is said to be unexpired.

-          Oracle database automatically tunes the undo retention period based on undo tablespace size and system activity. You can specify a minimum undo retention period (in seconds) by setting the UNDO_RETENTION parameter. The database makes its best effort to honor the specified minimum undo retention period, provided that the undo tablespace has space available for new transactions. When available space for new transactions becomes short, the databsae begins to overwrite expired undo. If the undo tbalespace has no space for new transactions after all expired undo is overwritten, the databsae may begin overwriting unexpired undo information. If any of this overwritten undo information is required for consistent read in a current long-running query, the query could fail with the snapshot too old error message.

-          To guarantee the success of long-running queries or Oracle Flashback operations, you can enable retention guarantee. If retention guarantee is enabled, the specified minimum undo retention is guaranteed, the database never overwrites unexpired undo data even if it means that transactions fail due to lack of space in the undo tablespace. If retention guarantee is not enabled, the database can overwrite unexpired undo when space is low, thus lowering the undo retention for the system. This option is disabled by default.

-          You enable retention guarantee by specifying the RETENTIN GUARANTEE clause for the undo tablespace when you create it with either the CREATE DATABASE or CREATE UNDO TABLESPACE statement.

Posted in My abstracts from Documentation 10gR2 | 8 Comments »

Chapter 9 – Managing Datafiles and Tempfiles

Posted by Kamran Agayev A. on December 1, 2009

-          Oracle database assigns each datafile two associated file numbers, an absolute file number and a relative file number, that are used to uniquely identify it. The absolute file number can be found in the FILE# column of the V$DATAFILE or V$TEMPFILE view. Relative file number uniquely identifieds a datafile within a tablespace. For small and medium size databases, relative file numbers usually have the same value as the absolute file number. However, when the number of datafiles in a database exceeds a threshold (typically 1023), the relative file number differs from the absolute file number.

-          When starting an instance, the DB_FILES parameter specifies the maximum number of database files that can be opened for this database. Default value is 200

-          If several disk drives are available to store the databsae, consider placing potentially contending datafiles on separate disks. This way, when users query information, both disk drives can work simultaneously, retrieving data at the same time

-          Datafiles should not be stored on the same disk drive that stores the databsae redo log files. if the datafiles and redo log files are stored on the same disk drive and that disk drive fails, the files cannot be used in your database recovery procedures.

-          To determine whether a datafile is auto-extensible, query the DBA_DATA_FILES view and examine the AUTOEXTENSIBLE column

-          To take a datafile offline when the database is in NOARCHIVELOG mode, use the ALTER DATABASE statement with both the DATAFILE and OFFLINE FOR DROP clauses

-          Clauses of the ALTER TABLESPACE statement allow you to change the online or offline status of all of the datafiles or tempfiles within a tablespace.

ALTER TABLESPACE tbs_test DATAFILE [ONLINE | OFFLINE]

To rename and relocate datafiles use the following steps:

·         Take the tablespace that contains the datafiles offline:

ALTER TABLESAPCE users OFFLINE NORMAL;

·         Rename the datafiles using the operating system

·         Use the ALTER TABLESPACE statement with the RENAME DATAFILE clause to change the filenames within the database

ALTER TABLESPACE users RENAME DATAFILE ‘file1’ TO ‘file2’;

·         Backup the database

 

-          To drop the datafile, the database must be open and the file must be empty. If you must remove a datafile that is not empty and that cannot be made empty by dropping schema objects, you must drop the tablespace that contains the datafile. You can’t drop the first or only datafile in a tablespace, or datafiles in a read only tablespace or SYSTEM tablespace.

-          If you want to configure the database to use checksums to verify data blocks, set the initialization parameter DB_BLOCK_CHECKSUM to TRUE. This causes the DBWn process and the direct loader to calculate a checksum for each block and to store the checksum in the block header when writing the block to disk.

The checksum is verified when the block is read, but only if DB_BLOCK_CHECKSUM is TRUE and the last write of the block stored a checksum. If corruption is detected, the database returns message ORA-01578 and writes information about the corruption to the alert log

Posted in My abstracts from Documentation 10gR2 | Leave a Comment »

Chapter 8 – Managing Tablespaces

Posted by Kamran Agayev A. on November 25, 2009

Chapter 8 – Managing Tablespaces

-          If the database has multiple tablespaces you can separate data of one application from the data of another to prevent multiple applications from being affected if a tablespace must be taken offline. You can store different datafiles of different tablespaces on different disk drives to reduce I/O contention and backup individual tablespaces

-          Create only enough tablespaces to fulfill your needs, and create these tablespaces with as few files as possible. If you need to increase the size of a tablespace, add one or two large datafiles, or create datafiles with autoextension enabled, rather than creating many small datafiles

-          SYSAUX tablespace, which acts as an auxiliary tablespace to the SYSTEM tablespace, is also always created when you create a database. It contains information about and the schemas used by various Oracle products and features, so that those products do not require their own tablespaces.

-          Locally managed tablespaces track all extent information in the tablespace itself by using bitmaps. It provides enhanced performance, and user reliance on the data dictionary is reduced, because the necessary information is stored in file headers and bitmap blocks

-          Create a locally managed tablespace by specifying LOCAL in the EXTENT MANAGEMENT vlause of the CREATE TABLESPACE statement. This is the default for new permanent tbalespaces, but you must specify the EXTENT MANAGEMENET LOCAL clause if you want to specify either the AUTOALLOCATE clause or the UNIFORM clause. You can have the database manage extents for you automatically with the AUTOALLOCATE clause (the default) or you can specify that the tablespace is managed with uniform extents of a specific size (UNIFORM)

-          AUTOALLOCATE means that the extent size are managed by Oracle. Oracle will choose the next optimal size for the extents starting with 64KB. As the segments grow and more extents are needed, oracle will start allocating larger and larger sizes ranging from 1Mb to eventually 64Mb extents.

-          UNIFORM T option tells the database to allocate and deallocate extents in the tablespace with the same unvarying size that you can specify or let extents default to 1Mb.

-          In a locally managed tablespace, there are two methods that Oracle Database can use to manage segment spaceL AUTOMATIC and MANUAL. Manual segment space management uses linked lists called “freelists” to manage free space in the segment, while automatic segment management uses bitmaps. Automatic segment space management is the more efficient method, and is the default for all new permanent, locally managed tablespaces.

-          To create a  bigfile tablespace, run CREATE BIGFILE TABLESPACE command. Oracle automatically creates a locally managed tablespace with automatic segment space management.

-          If default tablespace type was set to BIGFILE at database creation, but you want to create a traditional (smallfile) tablespace, then specify a CREATE SMALLFILE TABLESPACE statement to override the default tablespace that you are creating

-          Within a temporary tablespace, all sort operations for a given instance and tablespace share a single sort segment. The sort segment is created by the first statement that uses a temporary tablespace for sorting, after startup, and is released only at shutdown.

-          You can view the allocation and deallocation of space in a temporary tablespace sort segment using the V$SORT_SEGMENT view

-          When you create a temporary table, its rows are stored in your default temporary tablespace

-          Use CREATE BIGFILE TEMPORARY TABLESPACE statement to create a single tempfile tablespace

-          To rename a tempfile, you take the tempfile offline, use operating system commands to rename or relocate the tempfile, and then use the ALTER DATABASE RENAME FILE command to update the database controlfiles

-          Using temporary tablespace group, rather than a single remporary tablespace, can alleviate problems caused where one tablespace is inadequate to hold the results of a sort, particularly on a table that has many partitions.

-          You create at tablespace group implicitily when you include the TABLESPACE GORUP clause in the CREATE TEMPORARY TABLESPACE or ALTER TABLESPACE statement and the specified tablespace group does not currently exist.

ALTER TABLESPACE tmp_tbs TABLESPACE GROUP group2;

-          The view DBA_TABLESPACE_GROUPS lists tablespace groups and their member tablespaces

-          To assign tablespace group as a default temporary tablespace, use the following statement:

ALTER DATABASE db_name DEFAULT TEMPORARAY TABLESPACE group2;

-          You can create tablespaces with block sizes different from the standard database block size, which is specified by the DB_BLOCK_SIZE parameter.

-          Use the BLOCKSIZE clause of the CREATE TABLESPACE statement to create a tablespace with a block size different from the database standard block size. In order for the BLOCKSIZE clause to succeed, you must have already set the DB_CACHE_SIZE and at least one DB_nK_CACHE_SIZE parameter. Further, and the integer you specify in the BLOCKSIZE clause must correspond with the setting of one DB_nK_CACHE_SIZE parameter.

CREATE TABLESPACE tbs DATAFILE ‘/datafile/’ SIZE 10M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K BLOCKSIZE 8K;

-          You can’t take SYSTEM, UNDO and TEMPORARY tablespaces offline

-          When you take tablespace to OFFLINE usint IMMEDIATE clause, media recovery for the tablespace is required before the tablespace can be brought online.

-          If you must take tablespace offline, use the NORMAL clause (the default) if possible. This setting guarantees that the tablespace will not require recovery to come back online, even if after incomplete recovery you reset the redo log sequence using an ALTER DATABASE OPEN RESETLOGS statement .

-          Specify TEMPORARY only when you cannot take tablespace offline normally.  In this case, only the files taken offline because of errors need to be recovered before the tablespace can be brought online. Specify IMMEDIATE only after trying both the normal and temporary settings

-          You can drop items, such as tables or indexes, from a read-only tablespace, but you cannot create or alter objects in a read-only tablespace.

-          Before you can make a tablespace read-only, the tablespace must be online, can’t be active undo tablespace or SYSTEM tablespace

-          When there’re transactions waiting to commit, the ALTER TABLESPACE .. READ ONLY statement does not return immediately. It waits for all transactions started before you issued the ALTER TABLESPACE statement to either commit or rollback.

-          When substantial portions of a very large database are stored in read-only tablespaces that are located on slow-access devices or hierarchical storage you should consider setting the READ_ONLY_OPEN_DELAYED parameter to TRUE. This speed certain operations, primary opening the databsae, by causing datafiles in readonly tablespaces to be accessed for the first time only when an attempt is made to read data stored within them

-          You can’t rename the tablespace if

  • The tablespace is SYSTEM or SYSAUX tablespace
  • If any datafile in the tablespacea is offline or if the tablespace is offline

-          Use the CASCADE CONSTRAINTS clause to drop all referential integrity constraints from tables outside the tablespace that refer to primary and unique keys of tables inside the tablespace

-          Use INCLUDING CONTENTS AND DATAFILES to delete physical datafiles from OS. It an OS error prevents the deletion of a file, the DROP TABLESPACE statement still succeeds, but a message describing the error is written to the alert log

-          If SYSAUX tablesapce becomes unavailable, core database functionality will remain operational.

-          You can monitor the occupants of the SYSAUX tablespace using the V$SYSAUX_OCCUPANTS view.

-          Moving data using transportable tablespaces is much faster than performing either an export/import or unload/load of the same data. This is because the datafiles containing all of the actual data are just copied to the destination location, an you use an export/import utility to transfer only the metadata of the tablespace objects to the new database

-          Starting with Oracle Database 10g, you can transport tablespaces across platforms.

-          You can query the V$TRANSPORTABLE_PLATFORM view to see the platfors that are supported, and to determine each platform’s endian format(byte ordering)

-          If the source platform and the target platform are of different endianness, then an additional step must be done on either the source or target platform to convert the tablespace being transported to the target format.  If they are of the same endianness, then no conversion is necessary and tablespaces can be transported as if they were on the same platform.

To transport tablespace between database follow this procedure:

  • Check the endian format of both platforms by querying the V$TRANSPORTABLE_PLATFORM view
  • Pick a self containted set of tablespaces
  • Generate a transportable tablespace set. It consists of datafiles for the set of tablespaces being transported and an export file containing structural information (metadata) for the set of tablespaces.
  • Transport the tablespace set
  • Import the tablespace set

 

-          There may be logical or physical dependiencies between objects in the transportable set and those outside of the set. You can only transport a set of tablespaces that is self-contained. In this context “self-containted” means that there are no references from inside the set of tablespaces pointing outside of the tablespaces. To check whether the tablespace is self-containted, you can invoke the TRANSPORT_SET_CHECK procedure in the Oracle supplied package DBMS_TTS. After invoking this procedure, you can see all violations by selecting from the TRANSPORT_SET_VIOLATIONS view.

-          To convert tablespaces from one endian format to another, login to RMAN and run the following command:

RMAN> CONVERT TABLESPACE sales_1, sales_2 TO PLATFORM ‘Microsoft Windows NT’ FORMAT ‘/tmp/%U’;

-          Then transport both the datgafiles and the export file of the tablespaces to a place that is accessible to the target database

-          Use RMAN to convert the necessary transported datafiles to the endian format of the destination host format and deposit the results in /orahome/dbs as shown in the following examples

RMAN>CONVERT DATAFILE

‘/h1/finance/tbs_21.f’,

‘/h1/finance/tbs_22.f’

TO PLATFORM =”Solaris[tm] OE (32-bit)”

FROM PLATFORM=”HP Tru64 UNIX”

DB_FILE_NAME_CONVERT=’/h1/finance/work/try/”,’/h1/finance/dbs/tru’

PARALLELISM=5;

Posted in My abstracts from Documentation 10gR2 | Leave a Comment »