Sunday, October 12, 2008

ORA-13600, QSM-00775, ORA-06512 when running DBMS_ADVISOR

Error Description
When using DBMS_ADVISOR on a table in SYS or SYSTEM schema, the following errors returned.

ORA-13600: error encountered in Advisor
QSM-00794: the statement can not be stored due to a violation of the invalid table reference filter

Below is an example.
SQL> conn system/s
Connected.

SQL> BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'emp_quick_tune',
attr1 => 'SELECT * FROM emp WHERE EMPNO = 7788');
END;
/

BEGIN
*
ERROR at line 1:
ORA-13600: error encountered in Advisor
QSM-00775: the specified SQL statement cannot be stored in the workload due to invalid table references
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 1501
ORA-06512: at "SYS.WRI$_ADV_SQLACCESS_ADV", line 176
ORA-06512: at "SYS.PRVT_ADVISOR", line 2594
ORA-06512: at "SYS.DBMS_ADVISOR", line 726
ORA-06512: at line 2

SQL> create table emp(empno number);

Table created.

SQL> BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'emp_quick_tune',
attr1 => 'SELECT * FROM emp WHERE EMPNO = 7788');
END;
/

BEGIN
*
ERROR at line 1:
ORA-13600: error encountered in Advisor
QSM-00794: the statement can not be stored due to a violation of the invalid table reference filter
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 1501
ORA-06512: at "SYS.WRI$_ADV_SQLACCESS_ADV", line 176
ORA-06512: at "SYS.PRVT_ADVISOR", line 2594
ORA-06512: at "SYS.DBMS_ADVISOR", line 726
ORA-06512: at line 2

Cause of the Problem
The quick_tune procedure performs an analysis and generates recommendations for a single SQL statement.
SQL Access Advisor maintains an internal list of non-tunable tables regardless of the contents of the INVALID_TABLE_LIST parameter.
The table owned by SYS, SYSTEM or any other pre-defined Oracle schema can be tuned and hence will return error.

Solution of The problem

Create the table in other schama rather than SYS, SYSTEM or any other pre-defined Oracle schema and run quick_tune procedure.

SQL> create table arju.emp(empno number);
Table created.

SQL> BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'emp_quick_tune',
attr1 => 'SELECT * FROM arju.emp WHERE EMPNO = 7788');
END;
/


PL/SQL procedure successfully completed.

Friday, October 10, 2008

How to know whether I use analyze or DBMS_STATS

Automatic statistics gathering should be sufficient for most of the cases. And automatic statistics gathering is done by default during an overnight batch window. In order to know more about automatic statistics gathering just have a look at Analyze and collecting Statistics on Tables Schemas Database Index and About STATISTICS_LEVEL parameter in Oracle

In most cases automatic statistics gather is sufficient but still you may need to gather manually statistics if you do huge insert or update or delete on the table. You might know we can gather statistics by two ways.

1)Analyze command.
2)DBMS_STATS package.

By querying from the dba_tables view you can say by which method you gathered statistics. Let's see it with an example.
I am creating two tables named with_analyze and with_dbms_stats. On table with_analyze use analyze to estimate statistics and on table with_dbms_stats use DBMS_STATS package to gather statistics.

SQL> Create table with_analyze(col1 number);

Table created.

SQL> Create table with_dbms_stats(col1 number);

Table created.

SQL> analyze table with_analyze compute statistics;

Table analyzed.

SQL> exec dbms_stats.gather_table_stats('SYS','WITH_DBMS_STATS');

PL/SQL procedure successfully completed.

Now let's have a look at GLOBAL_STATS column of user_tables(contain only currently user owned table) or dba_tables(contain all table) table or all_tables(contain all tables to which current user has permission).

If you gather statistics on a table with analyze command then GLOBAL_STATS field will be FALSE for that table.

If you gather statistics on a table with DBMS_STATS package then GLOBAL_STATS field will be TRUE for that table.
SQL> select table_name,last_analyzed, GLOBAL_STATS from dba_tables where 
table_name in ('WITH_ANALYZE','WITH_DBMS_STATS');


TABLE_NAME LAST_ANAL GLO
------------------------------ --------- ---
WITH_ANALYZE 10-OCT-08 NO
WITH_DBMS_STATS 10-OCT-08 YES

Related Documents
Analyze and collecting Statistics on Tables Schemas Database Index
About STATISTICS_LEVEL parameter in Oracle

Thursday, October 9, 2008

Oracle database consultancy in Bangladesh

Overview
Database is always critical issue and maintain of it is also the most important in an organization. Out of the database oracle is the most popular database in terms it's functionality, performance issue, security etc.

Performance of application greatly depends on performance of database. In order to maintain database you need plan and great experience. I started consultancy in Bangladesh in oracle database field.

Offered Services
Some of the great services that I offer to service are,

•Overall database design.

•Backup and recovery plan.

•Database Replication Implementation.

•Oracle Data Guard Administration.

•Oracle RAC setup.

•Oracle performance issues.

•Emergency solutions to problems in database.

•Various oracle features and their usage.

Consultancy Rate
If you like to hire me then you can follow either any of two packages.

1)BudgetPack
Rate=3000 taka per hour.
Details
•Maximum hours per month/per week will depend on your budget. If your budget is 15,000 taka then I will be limited to 5 hours.

•I recommend a session should span 3 hours. So per session the rate is 9,000 taka.

•You are free to discuss about your budget limit during consultancy phase.

2)Valuepack
Rate=2000 taka per hour.
The company must come to an agreement of assuring a minimum of one session per week with a minimum duration of 3 hours per session, for 3 months.

My Clients

1)Maestro (Pvt.) Ltd. - Software Development company since 2000. Website: http://maestrocomms.com/

2)Eastern Link BD (Pvt.) Ltd. - ISP since 2001. Website:http://smile.com.bd/

3)Drishtee Online (Pvt.) Ltd. - Nationwide Internet and Data Connectivity Service Provider.

4)Euphoria Solution Ltd. - Export/Import & Country wide distribution, BPO since 2004.

5)Skynet Technologies Ltd. - OSS (Operation, System and Support), Group holding.

Contact Details
If you want me as a consultant you can contact me at +8801710282272
Alternatively you can mail me for more details at a_arju@yahoo.co.uk

Wednesday, October 8, 2008

RMAN-00554,RMAN-04005,ORA-0103 when remote connection by rman

Whenever I try to connect remotely to a database through rman it fails with message RMAN-00554, RMAN-04005, ORA-0103.
In this example my source database is saturn and destination database is jupiter. From jupiter let me try to connect to saturn.
Source database
Before proceed let's see the parameter that we can use to connect to rman without tnsnames.ora. Our needed parameter is hostname/ipaddress, service_name and port number. These three can be found by issuing lsnrctl status in source machine.
Note that you must have a password file setup in the source database. This requires the use of the "orapwd" command and the initialization parameter "REMOTE_LOGIN_PASSWORDFILE".

bash-3.00$ hostname
saturn
SQL> show parameter remote_login
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE

bash-3.00$ lsnrctl status

LSNRCTL for Solaris: Version 10.2.0.1.0 - Production on 08-OCT-2008 06:07:54

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 10.2.0.1.0 - Production
Start Date 27-JUL-2008 02:00:31
Uptime 73 days 4 hr. 7 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=saturn)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "ARJU.SATURN.ARJUBD.COM" has 1 instance(s).
Instance "ARJU", status READY, has 1 handler(s) for this service...
The command completed successfully

Our interest is bolded. hostname=saturn, port=1521(default) and service_name=ARJU.SATURN.ARJUBD.COM
Try to connect to source database from destination database (from jupiter to saturn)
bash-3.00$ hostname
jupiter

bash-3.00$ rman target system/sistem@saturn/ARJU.SATURN.ARJUBD.COM

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Oct 8 05:48:50 2008

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

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01031: insufficient privileges

We did not used port here as port is default. If it was not default suppose it was 1522 then we would use rman target system/sistem@saturn:1522/ARJU.SATURN.ARJUBD.COM
Diagnosis why problem happens (In the source database)
In order to connect to rman a user must have the sysdba system privilege otherwise it will fail. As we are login through network password file authentication will be used. And in the password file user system must be entryed as sysdba.

SQL> !hostname
saturn
SQL> select * from v$pwfile_users;

USERNAME SYSDB SYSOP
------------------------------ ----- -----
SYS TRUE TRUE

As we see here in the passwordfile only SYS is there. So only sys can do the task to connect to rman through network. In order to permit system to logon through network grant him to SYSDBA.

SQL> grant sysdba to system;
Grant succeeded.

Now check the entry in passwordfile.
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP
------------------------------ ----- -----
SYS TRUE TRUE
SYSTEM TRUE FALSE


Check now from destination database (Here it is jupiter)

bash-3.00$ hostname
jupiter
bash-3.00$ rman target system/sistem@saturn/ARJU.SATURN.ARJUBD.COM

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Oct 8 05:50:13 2008

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

connected to target database: ARJU (DBID=2869417476)

And now it succeeds.

Related Documents
RMAN-06426: RECOVERY_CATALOG_OWNER role must be granted to user
Working with RMAN stored scripts in Recovery Catalog
Set up a Database for RMAN Backup

Tuesday, October 7, 2008

List of Patchset number in metalink

You want to download patchset from metalink but you don't know the patchset number. In that case it may take some moments to find patchset number. For example you want to upgrade your database version from 10.2.0.1 to 10.2.0.2. Now which patchset number you want to download? In this post the patchset number along with oracle version is below.

A)For Oracle9iR2, Base version 9.2.0.1
i)To upgrade to 9.2.0.2 patchset number 2632931.
ii)To upgrade to 9.2.0.3 patchset number 2761332
iii)To upgrade to 9.2.0.4 patchset number 3095277
iv)To upgrade to 9.2.0.5 patchset number 3501955
v)To upgrade to 9.2.0.6 patchset number 3948480
vi)To upgrade to 9.2.0.7 patchset number 4163445
vii)To upgrade to 9.2.0.8 patchset number 4547809

B)For Oracle10g, Base version 10.1.0.2
i)To upgrade to 10.1.0.3 patchset number 3761843
ii)To upgrade to 10.1.0.4 patchset number 4163362
iii)To upgrade to 10.1.0.5 patchset number 4505133

C)For Oracle10gR2 Base version 10.2.0.1
i)To upgrade to 10.2.0.2 patchset number 4547817
ii)To upgrade to 10.2.0.3 patchset number 5337014
iii)To upgrade to 10.2.0.4 patchset number 6810189
iv)For Warehouse build of 10.2.0.4 patchset number 7005587

D)For Oracle11gR1 Base version 11.1.0.6
i)To upgrade to 11.1.0.7.0 Patchset number 6890831
Related Documents
How to Download Patchset or Opatch from metalink

Who is connected to your windows machine using which port.

To access any application of another system either through WWW service, FTP service, POP3/SMTP services, or even just NetBIOS over TCP/IP you have to go through a port. In other sense if someone from outside access something on your system he enter through a port. And you sometimes might be curious to know who is accessing your system and which ports they are using.
With netstat tool you can easily identify it.
On windows system in order to know details of it just type netstat /? in command prompt.
Here is the output,

C:\Documents and Settings\Queen>netstat /?

Displays protocol statistics and current TCP/IP network connections.

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]

-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host
multiple independent components, and in these cases the
sequence of components involved in creating the connection
or listening port is displayed. In this case the executable
name is in [] at the bottom, on top is the component it called,
and so forth until TCP/IP was reached. Note that this option
can be time-consuming and will fail unless you have sufficient
permissions.
-e Displays Ethernet statistics. This may be combined with the -s
option.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.
-p proto Shows connections for the protocol specified by proto; proto
may be any of: TCP, UDP, TCPv6, or UDPv6. If used with the -s
option to display per-protocol statistics, proto may be any of:
IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
-r Displays the routing table.
-s Displays per-protocol statistics. By default, statistics are
shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
the -p option may be used to specify a subset of the default.
-v When used in conjunction with -b, will display sequence of
components involved in creating the connection or listening
port for all executables.
interval Redisplays selected statistics, pausing interval seconds
between each display. Press CTRL+C to stop redisplaying
statistics. If omitted, netstat will print the current
configuration information once.

In order to know all connection along with port now connection to your system just press netstat.
C:\Documents and Settings\Queen>netstat
The listing will appear with several fields.
-The protocol type.
-Hostname:port
-Foreign Address that is who is connected to your system.
-State of the connection.

Related Documents
How to Setup Windows Machine For Best Performance
How to Use Special Characters in Windows
Internet Explorer Keyboard Shortcuts
More Internet Explorer Keyboard Shortcuts

Open an application using keyboard shortcuts on windows

Mouse is a convenient way to do tasks since its inventory. But sometimes use of keyboard gives more quickly and flexible access than mouse. This is more true if you are a good typist. Suppose to open an application. In order to access Internet explorer with mouse we would do,
-Take mouse pointer to start menu and click the menu.
-Go to all programs.
-And move pointer to internet explorer and click on it. IE launches.

If you use keyboard shortcut then with three key combination you can open any application. To do this.
1.Write click on the application to which you want to create shortcut.
Select create shortcut. If your application resides on start menu>all programs then
you don't need this steps.

2.Right click on the shortcut and select properties.

3.A new windows appears. Click on shortcut tab.

4.In the shortcut key field press any key related to program for example in order to create shortcut for internet explorer in the shortcut key field press I.

5.Click ok and you are done.

6.Now press Ctrl+Alt+key_that_you_entered_in_the_shortcut_key_field for example in case of internet exploere press Ctrl+Alt+I and you will see Internet explorer will launch.

Next time you don't need to use mouse to access any application if you create shortcut key on that application.

Related Documents
How to Setup Windows Machine For Best Performance
How to Use Special Characters in Windows
Internet Explorer Keyboard Shortcuts
More Internet Explorer Keyboard Shortcuts