Tuesday, July 22, 2008

Char, Varchar2, Long etc Datatype Limits in Oracle

1)BFILE:
Maximum size: 4 GB-1 which is power(2,32)-1 bytes.
Maximum size of the file name: 255 characters
Maximum size of the directory name: 30 characters
Maximum number of open BFILEs: Limited by the value of the SESSION_MAX_OPEN_FILES initialization parameter, which itself is limited by the maximum number of open files the OS will allow.

2)BLOB:
Maximum size: (4 GB - 1) * DB_BLOCK_SIZE initialization parameter/ LOB Chunk size.

So, if db_block_size=8024K then maximum size=32T
SQL> select 4*1024*1024*1024*8*1024/1024/1024/1024/1024 from dual;
4*1024*1024*1024*8*1024/1024/1024/1024/1024
-------------------------------------------
32

As database block size vary from 2K to 32K so BLOB size can vary from 8TB to 128TB.
(8 TB to 128 TB)

Number of LOB columns per table: Limited by the maximum number of columns per table where maximum can be 1000.

3)CHAR:
Maximum size: 2000 bytes
Minimum and Default Size: 1 byte

4)CHAR VARYING
Maximum size:
4000 bytes

5)CLOB
Same as BLOB in the range of 4T to 128T.

6)Literals (characters or numbers in SQL or PL/SQL)
Maximum size:
4000 characters

7)LONG
Maximum size:
2 GB - 1

8)NCHAR
Maximum size:
2000 bytes

9)NCHAR VARYING
Maximum size:
4000 bytes

10)NCLOB
Same as BLOB in the range of 4T to 128T

11)NUMBER
Maximum size:
999...(in this way 38 9s) * power(10,125)
Minimum size: -999...(in this way 38 9s) *power(10,125)

12)RAW
Maximum size:
2000 bytes

13)VARCHAR
Maximum size:
4000 bytes
Minimum size: 1 byte.

14)VARCHAR2
Maximum size:
4000 bytes
Minimum size: 1 byte.

Monday, July 21, 2008

Benefits and Considerations of Using Bigfile tablespaces

Benefits of Bigfile Tablespaces
•In a database there can have maximum 65533 data files. Database is limited by the datafiles to 65533. In other way we can say in a database there can have maximum 65533 tablespaces because each tablespace must include at least one file.

Smallfile tablespace can contain up to 1024 files, but bigfile tablespaces contain only single file that can be 1024 times larger than a smallfile tablespace. Since database is limited by the total tablespace 65533 or in other word by the total data files 65533 and since bigfile tablespace's datafile can be 1024 times larger than of smallfile tablespace maximum size of database can largely expanded if you use bigfile tablespace.

The detail calculation of overall database size with the bigfile tablespace and smallfile tablespace are discussed in Overall Database Size

•With the use of bigfile tablespace you can reduce the number of datafiles of a ultra large tablespace and thus we can manage the database well. You can also adjust parameters to reduce the SGA space required for datafile information and the size of the control file.

•If you use Oracle-managed files to name the datafile, bigfile tablespaces make datafiles completely transparent for users as bigfile tablespaces contain only one datafile.

Considerations with Bigfile Tablespaces
•We should consider to use bigfile tablespace with Automatic Storage Management or other logical volume managers that support dynamically extensible logical volumes and striping or RAID.

•We should not use bigfile tablespace on a system that does not support striping because of negative implications for parallel execution and RMAN backup parallelization.

•We should not use bigfile tablespace if there is free space problem on a disk group, and the only way to extend a tablespace is to add a new datafile on a different disk group.

•We should not use bigfile tablespace on the system that impose limit to large file sizes.

•Overall, performance of database opens, checkpoints, and DBWR processes should improve if data is stored in bigfile tablespaces instead of smallfile tablespaces. Though in case of corrupted datafile restore time of the datafile is more than of smallfile tablespace case.

Related Documents
Overall Database Size

Overview of Extents and when extents are allocated

Extents is made up of a number of contiguous data blocks. One or more extents make a segment. When in a segment there is no space i.e segment is full, then to allow more space oracle allocates a new extent in that segment.

When Extents Are Allocated
When you create a table or index then oracle automatically creates an initial extent with a number of specified data blocks (with how many data blocks will be discussed later on) under the table's/ index's data segment.

In this case though no rows are inserted into the table or index but yet extents are allocated and reserve for the table's or index's rows.

Now, if the data blocks of a segment's initial extent become full and more space is required to hold new data, then oracle automatically allocates an incremental extent for that segment.

In this way, subsequent increment extents are allocated whenever data blocks of a segment's extent full.

When Extents Are Deallocated
With the Segment Advisor oracle automatically advice on which schema objects or on which tablespaces has space available for reclamation based on the level of space fragmentation within the object.

To access Segment Advisor from enterprise manager home go to Related Links> Select Advisor Central>Select Segment Advisor.

You can reclaim space manually of LB table by

alter table "LB" enable row movement;
alter table "LB" shrink space;


In general the extents of a segment do not return to the tablespace until you drop the schema objects using DROP TABLE or DROP CLUSTER statement.

The exception is following,
•TRUNCATE...DROP STORAGE statement.
•ALTER TABLE table_name DEALLOCATE UNUSED;
•Periodically, Oracle deallocates one or more extents of a rollback segment if it has the OPTIMAL size specified.

Overview of Oracle Data Blocks

•Oracle data block is smallest unit of data that oracle use to store data.

•Oracle store data in the datafile in terms of oracle data block.

•As we know each operating system has a block size. Oracle data block is not same as operating system block size. In fact oracle block size is multiple of OS block size.

•How much of a standard oracle block size will be is defined by the DB_BLOCK_SIZE initialization parameter.

•We can also define up to five non standard block sizes.

•Data block format is discussed in Oracle data block format

•How we can choose non standard block size is discussed in Choose of a non standard Blocksize

More Internet Explorer Keyboard Shortcuts

Shortcuts to Access Address Box
Note that if internet explorer's tab are enabled then for only the first tab these shortcuts work well. For subsequent tabs these shortcuts do not work.

1)ALT+D: These two combination select the text in address box so that you can give new address or edit existing address in the address box.

2)F4: It displays a list of addresses that you have in your address box.

3)CTRL+LEFT ARROW: When in the Address box, move the cursor left to the next logical break in the address (period or slash or hypen etc). First press F4 and then press CTRL+LEFT ARROW.

4)CTRL+RIGHT ARROW: When in the Address box, move the cursor right to the next logical break in the address (period or slash or hypen etc). First press F4 and then press CTRL+RIGHT ARROW.

5)CTRL+ENTER: In the address box after typing address when you press these two kwy combination it automatically adds www. at the begining and .com at the end. Suppose press ALT+D and simply type google and then press CTRL+ENTER and then observe it will
go as www.google.com

6)UP ARROW: Move forward through the list of AutoComplete matches.

7)DOWN ARROW: Move back through the list of AutoComplete matches.

Shortcuts to Access Favourites
1)CTRL+D: Add the current page to your favorites.

2)CTRL+B: Open the Organize Favorites dialog box.

3)ALT+UP ARROW: Move selected item up in the Favorites list in the Organize Favorites dialog box.

4)ALT+DOWN ARROW: Move selected item down in the Favorites list in the Organize Favorites dialog box

Shortcut to print preview
Press ALTER+P and then v in order to come print preview page. In the print preview page you can apply following shortcut keys.
1)ALT+P:Set printing options and print the page.

2)ALT+U: Change paper, headers and footers, orientation, and margins for this page.

3)ALT+HOME: Display the first page that to be printed.

4)ALT+LEFT ARROW: Display the previous page that to be printed.

5)ALT+A: Type the page number that you want displayed.

6)ALT+RIGHT ARROW: Display the next page that to be printed.

7)ALT+END: Display the last page that to be printed.

8)ALT+-:Zoom out.

9)ALT++:Zoom in.

10)ALT+Z: Display a list of zoom percentages.

11)ALT+C: Close Print Preview.

Related Documents:
Natural Windows Keyboard Shortcut
General Windows keyboard Shortcut.
Dialog Box and Accessibility Keyboard Shortcut

Archiving not possible: No primary destinations

Error Description:
Today I got a very interesting problem. The developer told me that they can't connect to database. It says ORA-00257: archiver error. Then I log on to the database and it was ok. I asked developer it is fine. After some time developers again asked me they are having the same problem. I then look for alert log and saw the following stack of message.

ARC0: Failed to archive thread 1 sequence 1192 (4)
Mon Jul 21 05:51:08 2008
ARC1: Archiving not possible: No primary destinations
ARC1: Failed to archive thread 1 sequence 1192 (4)
Mon Jul 21 05:51:08 2008
ARC0: Archiving not possible: No primary destinations
ARC0: Failed to archive thread 1 sequence 1192 (4)
Mon Jul 21 05:51:08 2008
ARC1: Archiving not possible: No primary destinations
ARC1: Failed to archive thread 1 sequence 1192 (4)

Cause of The Problem:

Unknown yet. Possibly hit oracle bug.

Solution of The Problem:

At first seems I guessed there is space issue and look for following thing as in described,
ORA-00257: archiver error. Connect internal only, until freed.

Step1: Look for archival destination.
SQL> archive log list

Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1203
Next log sequence to archive 1205
Current log sequence 1205
SQL> show parameter db_recovery_file_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /oradata1
db_recovery_file_dest_size big integer 50G

I also checked for settings whether LOG_ARCHIVE_DEST_10 is implicitly set or not. Yet it was set.
SQL> select DEST_NAME,DESTINATION from v$archive_dest where dest_name='LOG_ARCHIVE_DEST_10';

DEST_NAME
--------------------------------------------------------------------------------
DESTINATION
--------------------------------------------------------------------------------
LOG_ARCHIVE_DEST_10
USE_DB_RECOVERY_FILE_DEST

Step2: Let's check space in flash recovery area.

SQL> SELECT * FROM V$RECOVERY_FILE_DEST;

NAME
--------------------------------------------------------------------------------
SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
----------- ---------- ----------------- ---------------
/oradata1
5.3687E+10 32381952 0 2

So it was fine. I suddenly look for alert log and it was changed to

ORA-16038: log 2 sequence# 1160 cannot be archived
ORA-00354: corrupt redo log block header
ORA-00312: online log 2 thread 1: '/oradata1/arju/ARJU/redo02.log'

I immediately try to clear the logfile as it is described in ORA-16038,ORA-00354,ORA-00312 corrupt redo log block header
SQL> alter database clear unarchived logfile group 2;
Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;
^C alter system switch logfile
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation

But no hope. It stopped and in alert log again it shows error message Archiving not possible: No primary destinations.

Step3: I set LOG_ARCHIVE_DEST_9 explicitly to DB_RECOVERY_FILE_DEST

With the following statement whenever I explicitly set LOG_ARCHIVE_DEST_9 to use DB_RECOVERY_FILE_DEST then the error gone.
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_9='LOCATION=USE_DB_RECOVERY_FILE_DEST';
System altered.

In the alert log I put tail -f and wanted to see that status. Immediately status becomes as follows,

Cleared LOG_ARCHIVE_DEST_10 parameter default value
Mon Jul 21 05:52:04 2008
ALTER SYSTEM SET log_archive_dest_9='LOCATION=USE_DB_RECOVERY_FILE_DEST' SCOPE=BOTH;
Mon Jul 21 05:52:04 2008
Archiver process freed from errors. No longer stopped

And error gone. I tested with alter system switch logfile and it went normal.

SQL> alter system switch logfile;
System altered.

SQL> alter system switch logfile;

System altered.

I don't know what happened. Possibly this is oracle bug. Later I explicitly set log_archive_dest_9 to use LOCATION USE_DB_RECOVERY_FILE_DEST and unset log_archive_dest_9 and it went normal.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_10='LOCATION=USE_DB_RECOVERY_FILE_DEST';
System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_9='';

System altered.

Related Documents

ORA-16038,ORA-00354,ORA-00312 corrupt redo log block header
ORA-00257: archiver error. Connect internal only, until freed.

Sunday, July 20, 2008

Logminer fails with ORA-01284, ORA-00308, ORA-27047

Problem Description:
Whenever you try to run the logminer in the mining database (different from source database. Source database is one in which redo or archived redo logs are generated and mining database is one in which you try to analysis those logs) to add logfile using DBMS_LOGMNR.ADD_LOGFILE it generates error ORA-01284, ORA-00308, ORA-27047.

SQL> EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/export/home/oracle/o1_mf_1_61856_48637xkh_.arc', -
OPTIONS => DBMS_LOGMNR.NEW);

BEGIN DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/export/home/oracle/o1_mf_1_61856_48637xkh_.arc', OPTIONS => DBMS_LOGMNR.NEW); END;

*
ERROR at line 1:
ORA-01284: file /export/home/oracle/o1_mf_1_61856_48637xkh_.arc cannot be
opened
ORA-00308: cannot open archived log
'/export/home/oracle/o1_mf_1_61856_48637xkh_.arc'
ORA-27047: unable to read the header block of file
Additional information: 2
ORA-06512: at "SYS.DBMS_LOGMNR", line 68
ORA-06512: at line 1

But if you see in your mining database hard disk the archived redo log file actually exist.
SQL> !ls -l /export/home/oracle/o1_mf_1_61856_48637xkh_.arc
-rwxrwxrwx 1 oracle oinstall 24671232 Jul 21 00:38 /export/home/oracle/o1_mf_1_61856_48637xkh_.arc

Cause of The Problem:

To be able to run oracle logminer there are several requirements. If the requirements are not satisfy logminer will not run successfully. One of the requirement to run logminer is both the source database and the mining database must be running on the same hardware platform.

The database block sizes of the analyzing instance and the log source database must also be the same.

If they are different then logminer will not work and working with it will produce error ORA-01284, ORA-00308, ORA-27047.

Solution of The problem:
Use the mining database as the same hardware platform as of source database. If you don't have same platform then it is not possible. In that case you can use source database for mining.