Oracle NZ - Francisco Munoz Alvarez

22. June 2008

Differences between UNDO and REDO

Filed under: Oracle FAQ, Undo, Redo Logs, Questions — admin @ 12:55

To clear this question we have this table: 

UNDO REDO
Record of How to undo a change How to reproduce a change
Used for Rollback, Read-Consistency Rolling forward DB Changes
Stored in Undo segments Redo log files
Protect Against Inconsistent reads in multiuser systems Data loss

UNDO 

Undo tablespaces are special tablespaces used solely for storing undo information. You cannot create any other segment types (for example, tables or indexes) in undo tablespaces. Each database contains zero or more undo tablespaces. In automatic undo management mode, each Oracle instance is assigned one (and only one) undo tablespace. Undo data is managed within an undo tablespace using undo segments that are automatically created and maintained by Oracle.

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: 

  • Roll back transactions when a ROLLBACK statement is issued
  • Recover the database
  • Provide read consistency
  • Analyze data as of an earlier point in time by using Oracle Flashback Query
  • Recover from logical corruptions using Oracle Flashback features 

When a ROLLBACK statement is issued, undo records are used to undo changes that was 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. 

REDO 

Redo log files record changes to the database as a result of transactions and internal Oracle server actions. (A transaction is a logical unit of work, consisting of one or more SQL statements run by a user.) 

Redo log files protect the database from the loss of integrity because of system failures caused by power outages, disk failures, and so on. 

Redo log files must be multiplexed to ensure that the information stored in them is not lost in the event of a disk failure. 

The redo log consists of groups of redo log files. A group consists of a redo log file and its multiplexed copies. Each identical copy is said to be a member of that group, and each group is identified by a number. The LogWriter (LGWR) process writes redo records from the redo log buffer to all members of a redo log group until the file is filled or a log switch operation is requested. Then, it switches and writes to the files in the next group. Redo log groups are used in a circular fashion. 

HOW TO DETECT UNDO: 

There are some views that show information related to undo activity: 

  • V$UNDOSTAT: histogram-like view that shows statistics for 10-minute intervals.
  • V$TRANSACTION: present time view providing information on current transactions.
  • V$SESSTAT: individual session statistics, which includes one for undo usage.
  • V$UNDOSTAT will provide who did hint, recording the longest running query for that 10-interval, through the MAXQUERYID column which may be linked to V$SQL and use columns PARSING_USER_ID or PARSING_SCHEMA_NAME the get a grip on the suspect.
  • V$TRANSACTION linked with V$SESSION will show current used undo blocks for ongoing transactions. This query may help:

SELECT a.sid, a.username, b.used_urec, b.used_ublk
FROM v$session a, v$transaction b
WHERE a.saddr = b.ses_addr
ORDER BY b.used_ublk DESC

  • V$SESSTAT provides another view, which uses the undo kind of view, but we must avoid getting lost in the maze of Oracle statistics and focusing on just one: Undo change vector size, which will accumulate the bytes of undo used during the session lifetime. Following query is designed to pinpoint who is having a high undo activity.

SELECT a.sid, b.name, a.value
FROM v$sesstat a, v$statname b
WHERE a.statistic# = b.statistic#
AND a.statistic# = 176<– Which stands for undo change vector size
ORDER BY a.value DESC

HOW TO DETECT REDO: 

To find sessions generating lots of redo, you can use either of the following methods. Both methods examine the amount of undo generated. When a transaction generates undo, it will automatically generate redo as well. The methods are: 1) Query V$SESS_IO. This view contains the column BLOCK_CHANGES which indicates how much blocks have been changed by the session. High values indicate a session generating lots of redo. 

The query you can use is:      

SELECT s.sid, s.serial#, s.username, s.program, i.block_changes
FROM v$session s, v$sess_io i
WHERE s.sid = i.sid
ORDER BY 5 desc, 1, 2, 3, 4;

  1. Run the query multiple times and examine the delta between each occurrence of BLOCK_CHANGES. Large deltas indicate high redo generation by the session. 
  2. Query V$TRANSACTION. These view contains information about the amount of    undo blocks and undo records accessed by the transaction (as found in the USED_UBLK and USED_UREC columns).

The query you can use is:      

SELECT s.sid, s.serial#, s.username, s.program, t.used_ublk, t.used_urec
FROM v$session s, v$transaction t
WHERE s.taddr = t.addr
ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;

Run the query multiple times and examine the delta between each occurrence of USED_UBLK and USED_UREC. Large deltas indicate high redo generation by the session. You use the first query when you need to check for programs generating lots of redo when these programs activate more than one transaction. The latter query can be used to find out which particular transactions are generating redo. 

RESUMEN 

UNDO 

  • Record of how to undo a change.
  • Used for Rollback, read-consistency
  • Stored in Undo Segments
  • Protect against inconsistent reads in multiuser systems

REDO 

  • Record of how to reproduce a change
  • Used for Rolling forward database changes
  • Stored in redo log files
  • Protect against data loss.

An undo segment is just a segment, like a table or an index or a hash cluster or a materialized view is a segment. The clue is in the name. And the rule is that if you modify part of a segment, any segment, regardless of its type, you must generate redo so that the modification can be recovered in the event of media or instance failure. Therefore, you modify EMP; the changes to the EMP blocks are recorded in redo. The modification to EMP also has to be recorded in UNDO, because you might change your mind and want to reverse the transaction before you commit. Therefore, the modification to EMP causes entries to be made in an undo segment. But that’s a modification to a segment -this time, an undo segment. Therefore, the changes to the undo segment also have to be recorded in redo, in case you suffer a media or instance failure.  

If your database now crashed and you had to restore a set of datafiles, including those for the undo tablespace, from 10 days ago, you would of course do what Oracle always does: start reading from your archived redo, rolling the 10 day old files forward in time until they were 9, then 8, then 7 then 6 and so on days old, until you get to the time where the only record of the changes to segments (any segment) was contained in the current online redo log, and then you’d use that redo log to roll the files forward until they were 8 minutes old, 7 minutes, 6, 5, 4,… and so on, right up until all changes to all segments that had ever been recorded in the redo had been applied. At which point, your undo segments have been re-populated. So now you can start rolling back those transactions which were recorded in the redo logs, but which weren’t committed at the time of the database failure.   

I can’t emphasize enough, really, that undo segments are just slightly special tables. They’re fundamentally not very different from EMP or DEPT, except that new inserts into them can over-write a previous record, which never happens to EMP, of course. If you generate change vectors when you update EMP, you generate change vectors when you generate undo.   Why do we store the before and after image in redo and then duplicate half of that by repeating the store of the before image in undo? Because redo is written and generated sequentially and isn’t cached for long in memory (most log buffers are a few megas in size, tops). 

Therefore, using redo to rollback a mere mistake or as a result of a change of mind, whilst theoretically do-able, would involve wading through huge amounts of redo sequentially, looking for one little before image in a sea of changes made by lots of people and all of that wading would be done by reading stuff off disk (like it is in a recovery scenario). Undo, on the other hand, is stored in the buffer cache (just as EMP is stored in the buffer cache), so there’s a good chance that reading that will only require logical I/O, not physical. And your transaction is dynamically linked to where it’s written its undo, so you and your transaction can jump straight to where your undo is, without having to wade through the entire undo generated by other transactions. In performance terms, there is no comparison. Splitting ‘you need this for recovery’ from ‘you need this for changes of mind’ was a stroke of genius on the part of Oracle: other databases merely have ‘transaction logs’ which serve both purposes, and suffer in performance and flexibility terms accordingly. 

USEFUL SCRIPTS: 

To see the redo generated since instance started: 

col name format a30 heading ‘Statistic|Name’
col value heading ‘Statistic|Value’
start title80 “Redo Log Statistics”
spool rep_out\&db\red_stat
SELECT name, value
FROM v$sysstat
WHERE name like ‘%redo%’
order by name
/
spool off
pause Press enter to continue
ttitle off

The redo generated during my session since the session started: 

select value redo_size
from v$mystat, v$statname
where v$mystat.STATISTIC# = v$statname.STATISTIC#
and name = ‘redo size’
/

The redo generated by current user sessions: 

select v$session.sid, username, value redo_size
from v$sesstat, v$statname, v$session
where v$sesstat.STATISTIC# = v$statname.STATISTIC#
and v$session.sid = v$sesstat.sid
and name = ‘redo size’
and value > 0
and username is not null
order by value
/

Provide a current status for redo logs: 

column first_change# format 999,999,999 heading Change#
column group# format 9,999 heading Grp#
column thread# format 999 heading Th#
column sequence# format 999,999 heading Seq#
column members format 999 heading Mem
column archived format a4 heading Arc?
column first_time format a25 heading First|Time
break on thread#
set pages 60 lines 132 feedback off
start title132 ‘Current Redo Log Status’
spool rep_out\&db\log_stat
select thread#, group#, sequence#,bytes, members,archived,status,first_change#,to_char(first_time,’dd-mon-yyyy hh24:mi’) first_time
from sys.v_$log
order by thread#, group#;
spool off
pause Press Enter to continue
set pages 22 lines 80 feedback on
clear breaks
clear columns
ttitle off
/

Best Regards, 

Francisco Munoz Alvarez
www.oraclenz.com

What is the difference between Rollback and Undo Tablespace? OTN Forum By user user503050

Filed under: Oracle FAQ, Rollback, Undo, Questions — admin @ 11:23

There might be confusion while undo and rollback segment terms are used interchangeably in db world. It is due to the compatibility issue of oracle.

Undo

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:

  • Roll back transactions when a ROLLBACK statement is issued
  • Recover the database
  • Provide read consistency
  • Analyze data as of an earlier point in time by using Flashback Query

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.

Undo vs Rollback

Earlier releases of Oracle Database used rollback segments to store undo. Oracle9i introduced automatic undo management, which simplifies undo space management by eliminating the complexities associated with rollback segment management. Oracle strongly recommends (Oracle 9i and on words) to use undo tablespace (automatic undo management) to manage undo rather than rollback segments.

To see the undo management mode and other undo related information of database-

SQL> show parameter undo

NAME                               TYPE      VALUE
———————————— ———–   ——————————
undo_management         string     AUTO
undo_retention                integer   900
undo_tablespace              string     UNDOTBS1

Since the advent of Oracle9i, less time-consuming and suggested way is—using Automatic Undo Management—in which Oracle Database creates and manages rollback segments (now called “undo segments”) in a special-purpose undo tablespace. Unlike with rollback segments, we don’t need to create or manage individual undo segments—Oracle Database does that for you when you create the undo tablespace. All transactions in an instance share a single undo tablespace. Any executing transaction can consume free space in the undo tablespace, and when the transaction completes, its undo space is freed (depending on how it’s been sized and a few other factors, like undo retention). Thus, space for undo segments is dynamically allocated, consumed, freed, and reused—all under the control of Oracle Database, rather than manual management by someone.

Switching Rollback to Undo

1. We have to create an Undo tablespace. Oracle provides a function (10g and up) that provides information on how to size new undo tablespace based on the configuration and usage of the rollback segments in the system.

DECLARE
utbsiz_in_MB NUMBER;
BEGIN
utbsiz_in_MB ;= DBMS_UNDO_ADV.RBU_MIGRATION;
end;
/

CREATE UNDO TABLESPACE UNDOTBS
DATAFILE ‘/oradata/dbf/undotbs_1.dbf’
SIZE 100M AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED RETENTION NOGUARANTEE;

Note: In undo tablespace creation, “SEGMENT SPACE MANAGEMENT AUTO” can not be set

2.Change system parameters

SQL> alter system set undo_retention=900 scope=both;
SQL> alter system set undo_tablespace=UNDOTBS scope=both;
SQL> alter system set undo_management=AUTO scope=spfile;
SQL> shutdown immediate
SQL> startup

UNDO_MANAGEMENT is a static parameter. So database needs to be restarted.

Regards,

Francisco Munoz Alvarez

19. June 2008

EM mess - by Slyt - OTN Forum

Filed under: Questions — admin @ 23:48

I tried to run EM on certain host:

[oracle@SQLAB db10g]$ emctl dbconsole start

 TZ set to

Poland
EM Configuration issue. /u01/app/oracle/product/10.2.0/db10g/SQLAB_e2k not found.

OK. No such dir indeed. So:

[oracle@SQLAB db10g]$ emca -config dbcontrol db -repos createblablabla
Do you wish to continue? [yes(Y)/no(N)]: Y
2008-06-19 13:12:12 oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at

/u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-11-47-PM.log.
2008-06-19 13:12:13 oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) …
2008-06-19 13:12:13 oracle.sysman.emcp.EMReposConfig invoke
SEVERE: Error creating the repository
2008-06-19 13:12:13 oracle.sysman.emcp.EMReposConfig invoke
INFO: Refer to the log file

at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_repos_create_<date>.log for more details.
2008-06-19 13:12:13 oracle.sysman.emcp.EMConfig perform
SEVERE: Error creating the repository
Refer to the log file at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-11-47-PM.log for more details.
Could not complete the configuration. Refer to the log file at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-11-47-PM.log for more details.

 What log says:

emca_2008-06-19_01-11-47-PM.logCheck if repos user already exists.stare 6: WHERE username=UPPER(’&EM_REPOS_USER’);
nowe 6: WHERE username=UPPER(’SYSMAN’);
stare 8: IF ( ‘&EM_CHECK_TYPE’ = ‘EXISTS’) THEN
nowe 8: IF ( ‘NOT_EXISTS’ = ‘EXISTS’) THEN
stare 11: raise_application_error(-20000, ‘&EM_REPOS_USER does not exists..’);
nowe 11: raise_application_error(-20000, ‘SYSMAN does not exists..’);
stare 14: ELSIF ( ‘&EM_CHECK_TYPE’ = ‘NOT_EXISTS’ ) THEN
nowe 14: ELSIF ( ‘NOT_EXISTS’ = ‘NOT_EXISTS’ ) THEN
stare 17: raise_application_error(-20001, ‘&EM_REPOS_USER already exists..’);
nowe 17: raise_application_error(-20001, ‘SYSMAN already exists..’);
stare 21: raise_application_error(-20002, ‘Invalid Check type &EM_CHECK_TYPE’);
nowe 21: raise_application_error(-20002, ‘Invalid Check type NOT_EXISTS’);
DECLARE
*
ERROR at line 1:
ORA-20001: SYSMAN already exists..
ORA-06512: at line 17
What next ? Should I drop user SYSMAN and try again ?

>>>>Francisco Munoz Alvarez Answer

 Hi SlyT, Yes you need to drop the repository first.


emca -deconfig dbcontrol db -repos drop
emca -repos create
emca -config dbcontrol db

Best Regards,

Francisco Munoz Alvarez
www.oraclenz.com

>>> SlyT Replay

Hi Francisco,
not so easy …

 
[oracle@SQLAB e2k]$ emca -deconfig dbcontrol db -repos dropblablabla
Do you wish to continue? [yes(Y)/no(N)]: Y
2008-06-19 13:42:57 oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged

at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-42-42-PM.log.
2008-06-19 13:42:57 oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed.
2008-06-19 13:42:57 oracle.sysman.emcp.EMReposConfig dropRepository
INFO: Dropping the EM repository (this may take a while) …
2008-06-19 13:42:58 oracle.sysman.emcp.util.PlatformInterface executeCommand
WARNING: Error executing /u01/app/oracle/product/10.2.0/db10g/sysman/admin/emdrep/bin/RepManager -connect (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=SQLAB)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=e2k))) -repos_user SYSMAN -action drop -verbose -output_file /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_repos_drop_2008-06-19_01-42-57-PM.log
2008-06-19 13:42:58 oracle.sysman.emcp.EMReposConfig invoke
SEVERE: Error dropping the repository
2008-06-19 13:42:58 oracle.sysman.emcp.EMReposConfig invoke
INFO: Refer to the log file at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_repos_drop_<date>.log for more details.
2008-06-19 13:42:58 oracle.sysman.emcp.EMConfig perform
SEVERE: Error dropping the repository
Refer to the log file

at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-42-42-PM.log for more details.
Could not complete the configuration. Refer to the log file at /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_2008-06-19_01-42-42-PM.log for more details.


 >>> Francisco Munoz Alvarez Answer

Can you post the log information?

Cheers,

Francisco Munoz Alvarez
www.oraclenz.com
 

>>> Slyt Replay

It’s a little bit log, I would attached it but I can not see the way. So (some messages translated from my native language):

2008-06-19 13:42:57 oracle.sysman.emcp.util.PlatformInterface executeCommand
CONFIG: Starting execution: /u01/app/oracle/product/10.2.0/db10g/sysman/admin/emdrep/bin/RepManager -connect (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=SQLAB)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=e2k))) -repos_user SYSMAN -action drop -verbose -output_file /u01/app/oracle/product/10.2.0/db10g/cfgtoollogs/emca/e2k/emca_repos_drop_2008-06-19_01-42-57-PM.log
2008-06-19 13:42:58 oracle.sysman.emcp.util.PlatformInterface executeCommand
CONFIG: Exit value of 50
2008-06-19 13:42:58 oracle.sysman.emcp.util.PlatformInterface executeCommand
CONFIG: Enter SYS user’s password :
Enter repository user password :
Getting temporary tablespace from database…
Could not connect to SYS/(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=SQLAB)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=e2k))): ORA-01017: incorrect user/password; login failed (DBD ERROR: OCISessionBegin)
2008-06-19 13:42:58 oracle.sysman.emcp.util.PlatformInterface executeCommand
CONFIG: stty: standard input: Invalid argument
stty: standard input: Invalid argument
stty: standard input: Invalid argument
stty: standard input: Invalid argument

>>> Francisco Munoz Alvarez Answer

Dear Slyt,

You enter the wrong SYS password:

CONFIG: Enter SYS user’s password :
Enter repository user password :
Getting temporary tablespace from database…
Could not connect to SYS/(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=SQLAB)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=e2k))): ORA-01017:
incorrect user/password; login failed (DBD ERROR: OCISessionBegin)
 
Look for the right password and try again.

Best Regards,

Francisco Munoz Alvarez
www.oraclenz.com

>>> SlyT Replay

Dear Francisco ;D,
Thank you very much for your fast and reliable support.
Everything is OK now.

Best regards,
Slawomir Trojniak

17. June 2008

want to migrate 9.2.0.1db on windows data to 10.2.0.2 db on SunOs10, and planning to use full exp/imp..will this work ? by DBA2008 - OTN Forum

Filed under: Oracle FAQ, Questions — admin @ 00:10

Hi DBA2008,

I recommend you to create all the structure first, then import all the data.

Pre-create tablespaces, users, and tables in the new database to improve space usage by changing storage parameters. When you pre-create tables using SQL*Plus, either run the database in the original database compatibility mode or make allowances for the specific data definition conversions that occur during import. You need to specify IGNORE=Y on Import when items have been pre-created.

Note: If the new Oracle Database will be created on the same computer as the source database, and you do not want to overwrite the source database data files, then you must pre-create the tablespaces and specify DESTROY=N when you import.

This is the Upgrade Compatibility Matrix for Upgrading to 10g:

Source Database

Destination Database
8.1.7.4   (or higher) 10.2.x
9.0.1.4   (or higher) 10.2.x
9.2.0.4   (or higher) 10.2.x
10.1.0.2 (or higher) 10.2.x

  

This is the Upgrade Compatibility Matrix for Upgrading to 11g: 

Source Database

Destination Database
9.2.0.4   (or higher) 11.1.x
10.1.0.2 (or higher) 11.1.x
10.2.0.1 (or higher) 11.1.x

      

The Data Pump method for moving data between different database versions is different than the method used by original Export/Import. With original Export, you had to run an older version of Export (exp) to produce a dump file that was compatible with an older database version. With Data Pump, you can use the current Export (expdp) version and simply use the VERSION parameter to specify the target database version.

Keep the following information in mind when you are using Data Pump Export and Import to move data between different database versions:

  • If you specify a database version that is older than the current database version, certain features may be unavailable. For example, specifying VERSION=10.1 will cause an error if data compression is also specified for the job because compression was not supported in 10.1.
  • On a Data Pump export, if you specify a database version that is older than the current database version, then a dump file set is created that you can import into that older version of the database. However, the dump file set will not contain any objects that the older database version does not support. For example, if you export from a version 10.2 database to a version 10.1 database, comments on indextypes will not be exported into the dump file set.
  • Data Pump Import can always read dump file sets created by older versions of the database.
  • Data Pump Import cannot read dump file sets created by a database version that is newer than the current database version, unless those dump file sets were created with the version parameter set to the version of the target database. Therefore, the best way to perform a downgrade is to perform your Data Pump export with the VERSION parameter set to the version of the target database.
  • When operating across a network link, Data Pump requires that the remote database version be either the same as the local database or one version older, at the most. For example, if the local database is version 10.2, the remote database must be either version 10.1 or 10.2. If the local database is version 10.1, then 10.1 is the only version supported for the remote database

More information, please refer to: https://metalink.oracle.com/metalink/plsql/f?p=130:14:4088601010728200477::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,551141.1,1,1,1,helvetica

Regards,

Francisco Munoz Alvarez

16. June 2008

How to create a Temp Tablespace Group on 10g? by America OTN Forum

Filed under: Oracle FAQ, Temp Tablespace, Questions — admin @ 13:35

Tablespace Groups

Oracle now has the concept of grouping multiple tablespaces together in what they call a tablespace group. This allows you to create multiple temporary tablespaces, assign these temporary tablespaces to a tablespace group, and then use the tablespace group as the default temporary tablespace for the database or user. The benefit this has is that a single SQL statement or set of SQL statements may use more than the one temporary tablespace you have created in the past and now span multiple tablespaces. This has the following benefits if you create your temporary tablespaces and tablespace groups properly.

  1. You can tailor user load to individual temporary tablespaces.
  2. You can allow large sort operations to span and consume multiple temporary tablespaces if needed.
  3. Finer granularity so you can distribute operations across temporary tablespaces.
  4. Reduced contention when multiple temporary tablespaces are defined.

The Life of a Tablespace Group

You can implicitly create a tablespace group during the creation of a temporary tablespace with the CREATE TEMPORARY TABLESPACE command and by specifying the TABLESPACE GROUP clause. There is no CREATE TABLESPACE GROUP statement. Therefore, during the creation of a temporary tablespace called GTEMP01 we can add this tablespace to a tablespace group called GTEMP by using the following statement.

CREATE TEMPORARY TABLESPACE GTEMP01TEMPFILE ‘C:\ORACLE\PRODUCT\10.1.0\ORADATA\DATEN\GTEMP01.DBF’ SIZE 100M TABLESPACE GROUP GTEMP;

The tablespace group name must be an existing tablespace group name or one that does not exists. In addition, it must not be the name of an existing tablespace or you will get an error such as the following that notifies you that the tablespace already exists.

CREATE TEMPORARY TABLESPACE GTEMPTEMPFILE ‘C:\ORACLE\PRODUCT\10.1.0\ORADATA\DATEN\GTEMP.DBF’ SIZE 100M
SQL> /
CREATE TEMPORARY TABLESPACE GTEMP*ERROR at line 1:ORA-01543: tablespace ‘GTEMP’ already exists

We can also switch a tablespace’s group, add a tablespace to a group or create a new tablespace group by using the following statement.

ALTER TABLESPACE GTEMP02 TABLESPACE GROUP GTEMP;
ALTER TABLESPACE GTEMP03 TABLESPACE GROUP GTEMP;

If you wanted to remove a tablespace from a tablespace group and not assign it to a new tablespace group, you would use the following statement where the TABLESPACE GROUP clause is used but an empty string is used for the group.

ALTER TABLESPACE GTEMP03 TABLESPACE GROUP ”;

You cannot get rid of a tablespace group explicitly. In order for a tablespace group to be implicitly removed from the database, you need to alter those tablespaces to either use another tablespace group or alter them not to use any tablespace groups by assigning them to an explicit tablespace.

DBA_TABLESPACE_GROUPS View

You can always take a look at what tablespace groups you have defined by looking at the DBA_TABLESPACE_GROUPS view. Issue the following SQL and you can see what we have already defined for our running example.

SQL> SELECT group_name, tablespace_name
FROM dba_tablespace_groups;

GROUP_NAME                         TABLESPACE_NAME
—————————— ——————-
GTEMP                                       GTEMP01
GTEMP                                       GTEMP02

Setting the Default Temporary Tablespace

Now that we have defined multiple tablespaces to be part of a tablespace group called GTEMP, we can now use this tablespace group just as any other tablespace. One use of a tablespace group can be for the default temporary tablespace. If you wish to assign this new tablespace group as the default temporary tablespace, just issue the following SQL. Now any user who you have not given a temporary tablespace at user creation time will be assigned this new tablespace group as their temporary tablespace.

SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE GTEMP;
Database altered.

The temporary tablespace within large organizations that require many sort operations typically would experience high levels of contention. It was then left up to the DBA to segregate sort operations by users and create islands of temporary tablespaces so that those operations would not contend for similar resources that are associated with a single temporary tablespace. The problem with this is that the very large operations would typically need independent large temporary tablespaces. This would lead to wasted resources. With the addition of tablespace groups, Oracle now allows us to group multiple temporary tablespaces together so that we have one more choice in the usage patterns of these temporary tablespaces. We now need to ask ourselves if an operation truly needs its own individual temporary tablespace or the operation can span multiple temporary tablespaces and work without contention with the other operations that are occurring. If so, we can consolidate, reduce disk consumption, and possibly contention.

Regards,

Francisco Munoz Alvarez

can someone tell any difference between express edition and standard edition for oracle 10g - by seyiisq -OTN Forum

Filed under: Oracle FAQ, Questions — admin @ 01:48

Oracle XE:

Express Edition (XE) is a free, downloadable version of the Oracle database server. Oracle XE can only be used on single processor machines. It can only manage up to 4 GB of data and 1 GB of memory. ISVs can embed XE in 3rd party products and redistribute it freely.

Oracle Standard Edition:

Standard Edition is designed for smaller businesses and enterprises. It offers a subset of the features/ functionality implemented in Enterprise Edition. Database options like Data Guard, Partitioning, Spatial, etc. is not available with Standard Edition (from 10g one can use RAC with Standard Edition). Standard Edition can only be licensed on servers with a maximum capacity of four processors.

Oracle Standard Edition One:

Standard Edition One is a low cost, entry-level version of the Oracle Standard Edition database server. Standard Edition One can only be licensed on small servers with a maximum capacity of two processors.

If you need more information you can refer to:

http://www.orafaq.com/faq/what_is_the_difference_between_the_enterprise_standard_and_personal_editions_of_oracle

Regards,

Francisco Munoz Alvarez

11. June 2008

What does g in Oracle 10g signify?

Filed under: Oracle FAQ, General — admin @ 04:05

“G”rid is nothing but a term that is there to tell us that there are resources which are scattered at several different locations/pc’s but we are using and maintaining those resources as one. For us its just one thing that we are managing. The basic goal of grid computing is the transparency that should be given to the end user and admin from the complexity of managing lots of resources in different environments. Think it like power which you use in your home. Do you care from which transformer, power house the power is coming?  

It could be that your transformer isn’t able to send you so “transparently” from some another one it is requested and is given to you. Did it bother you ever no right? That’s sort of grid is.

If you think about it, its not “totally new” that is from just 10g onwards. Think about RAC in 9i, what is that? You have so many servers acting as the components of one cluster which you manage. What is this? A Grid of servers which are serving you.  Think about ASM. What it does, manage 10.000 disks but for you it’s just a single disk group that you manage not 10.000 disks.  

So is not a new concept from 10g onwards. Please note that there is no component except GC that you can actually download/buy and install and say hey look this is my grid. It’s a term, a logical term. From 10g onwards, it has got formally introduced in Oracle database systems.

   

By Aman Sharma - Oracle OTN Forum

10. June 2008

New SQL Developer 1.5 - Free by Oracle

Filed under: News — admin @ 14:11

For the fans of the old and good SQL*PLUS, TOAD (commercial use, but exists a free version with several limitations) and PL/SQL DEVELOPER (commercial use and version of evaluation for 30 days), who not yet know Oracle SQL Developer, I recommend try it, this tools is free and you can download it from OTN. This graphical tool from Oracle had the project initiated back in 2006 and is not only for developers use, is also for DBA’s. Currently, Oracle SQL Developer 1.5 is certified not only to be used with to Oracle Databases 9i (9.2.0.1), 10g, 11g, but also you can use to connect with MySQL, SQL Server, Sybase and Access. (This tool is developed in Java, and can be used under platforms Windows, Linux and Mac OSX)For the fact of this software use a JDBC driver, is not necessary install any client software to use it, just download the zip file from OTN, unzip it and is ready to use.  Because it has a graphic interface, Oracle SQL Developer facilitates the navigation by objects of the data base (tables, views, procedures, constraints, etc…), allowing the creation, edition, deletion and visualization of the codes sources not only of objects, but also of users of data base.  One another important function that it offers is to allow the generation of execution plan of the SQL’s submitted.
Some of the capacities of Oracle SQL Developer 

  • Create connections with different databases

  • Navigate between objects

  • Create objects

  • Edit Objects

  • Consult and to manipulate objects (DML)

  • Export and generate DDL of objects

  • Make copies and comparisons between schemas and objects

  • Process commands

  • Edit PL/SQL code

  • Execute and debug PL/SQL code

  • Execute and create personalized reports

  • Migration integrated Workbench

  • Allow integration with control version systems (CVS)

sqldeveloper_win sqldeveloper

Please, be free to download it and test it.

Regards, 

Francisco Munoz Alvarez 

Note: Based on Eduardo Legatti notes.

Oracle OpenWorld Latin America and Asia Pacific 2008?

Filed under: General — admin @ 12:58

There isn’t an Oracle OpenWorld Asia Pacific scheduled for this year.

This year (2008) Oracle will not realise the Latin American and Asia Pacific Open World.

Here is a list of events currently scheduled for 2009.

  • Oracle OpenWorld Brazil – Sao Paulo, March 10 – 12, 2009
  • Oracle OpenWorld Japan – Tokyo, April 22 – 24, 2009
  • Oracle FY10 Global Kickoff – Las Vegas, June 8 – 11, 2009
  • Oracle OpenWorld 2009 San Francisco, October 11 – 15, 2009

I’ll keep all post if any change occur.

Cheers,

Francisco Munoz Alvarez

 

6. June 2008

Logging or Not Logging:That is the Question v1.7

Filed under: White Papers — admin @ 05:13

What is a Redo? 

Let’s conduct a brief summary about the redo process. When Oracle blocks are changed, including undo blocks, oracle records the changes in a form of vector changes which are referred to as redo entries or redo records. The changes are written by the server process to the redo log buffer in the SGA. The redo log buffer is then flushed into the online redo logs in near real time fashion by the log writer LGWR.  

The redo logs are written by the LGWR when: 

  • When a user issue a commit.
  • When the Log Buffer is 1/3 full.
  • When the amount of redo entries is 1MB.
  • Every three seconds 
  • When a database checkpoint takes place. The redo entries are written before the checkpoint to ensure recoverability. 

Redo Generation and Recoverability 

The purpose of redo generation is to ensure recoverability.  This is the reason why, Oracle does not give the DBA a lot of control over redo generation. If the instance crashes, then all the changes within SGA will be lost. Oracle will then use the redo entries in the online redo files to bring the database to a consistent state. When a tablespace is put in backup mode the redo generation behaviour changes. As long as the table space is in backup mode Oracle will write the entire modified block to the redo log. This is done due to the reason Oracle can not guaranty that a block was not copied while it was updating as part of the backup. 

Important points about LOGGING and NOLOGGING 

Despite the importance of the redo entries, Oracle gave users the ability to limit redo generation on tables and indexes by setting them in NOLOGGING mode.  NOLOGGING affect the recoverability. Before going into how to limit the redo generation, it is important to clear the misunderstanding that NOLOGGING is the way out of redo generation, this are some points regarding it: 

  • NOLOGGING is designed to handle bulk inserts of data which can be easy re-produced.
  • Regardless of LOGGING status, writing to undo blocks causes generation of redo.
  •  LOGGING should not be disabled on a primary database if it has one or more standby databases. For this reason oracle introduced the ALTER DATABASE FORCE LOGGING command in Oracle 9i R2. (Means that the NOLOGGING attribute will not have any effect on the segments) If the database is in FORCE LOGGING MODE. NOLOGGING can be also override at tablespace level using ALTER TABLESPACE … FORCE LOGGING.
  • Any change to the database dictionary will cause redo generation. This will happen to protect the data dictionary.  An example: if we allocated a space above the HWM for a table, and the system fail in the middle of one INSERT /*+ APPEND */ , the Oracle will need to rollback that data dictionary update.  There will be redo generated but it is to protect the data dictionary, not your newly inserted data (Oracle will undo the space allocation if it fails, where as your data will disappear).
  • The data which are not logged will not be able to recover. The data should be backed up after the modification.
  • Tables and indexes should be set back to LOGGING mode when the NOLOGGING is no longer needed.
  • NOLOGGING is not needed for Direct Path Insert if the database is in NO ARCHIVE LOG MODE. (See table 1.1) 

Table Mode

Insert Mode ArchiveLog Mode Result
LOGGING APPEND ARCHIVE LOG REDO GENERATED
NOLOGGING APPEND ARCHIVE LOG NO REDO
LOGGING NO APPEND ARCHIVE LOG REDO GENERATED
NOLOGGING NO APPEND ARCHIVE LOG REDO GENERATED
LOGGING APPEND NO ARCHIVE LOG NO REDO
NOLOGGING APPEND NO ARCHIVE LOG NO REDO
LOGGING NO APPEND NO ARCHIVE LOG REDO GENERATED
NOLOGGING NO APPEND NO ARCHIVE LOG REDO GENERATED

Table 1.1 

  • The data which is not able to reproduce should not use the NOLOGGING mode. If data which can not be reloaded was loaded using NOLOGGING. The data cannot be recovered when the database crashes before backing the data.
  • NOLOGGING does not apply to UPDATE, DELETE, and INSERT.
  • NOLOGGING will work during certain situations but subsequent DML will generate redo. Some of these situations are:
    • direct load INSERT (using APPEND hint),
    • CREATE TABLE … AS SELECT,
    • CREATE INDEX.
  • If the LOGGING or NOLOGGING clause is not specified when creating a table, partition, or index the default to the LOGGING attribute, will be the LOGGING attribute of the tablespace in which it resides. 

If the database has a physical standby database, then NOLOGGING operations will render data blocks in the standby “logically corrupt” because of the missing redo log entries. If the standby database ever switches to the primary role, errors will occur when trying to access objects that were previously written with the NOLOGGING option, you will an error like this:

 

ORA-01578: ORACLE data block corrupted (file # 3, block # 2527)

ORA-01110: data file 1: ‘/u1/oracle/dbs/stdby/tbs_nologging_1.dbf’

ORA-26040: Data block was loaded using the NOLOGGING option”

 

That doesn’t sound good, and certainly I can’t imagine a happy DBA called at 3:00 AM to recover a database and that error message comes up.

 
**If you want to read the full paper please download it from: Logging or Not Logging, This is the Question. 
 
 

Cheers,

Francisco Munoz Alvarez

Next Page »

Powered by WordPress