Pages

Tuesday, July 22, 2014

IP address for sysdba connections

UTL_INADDR package provides a PL/SQL procedures to support internet addressing. It provides an API to retrieve host names and IP addresses of local and remote hosts.

Tested for my local sys connection

SQL> conn / as sysdba
Connected.
SQL> SELECT UTL_INADDR.get_host_address from dual;

GET_HOST_ADDRESS
--------------------------------------------------------------------------------
10.177.62.194

Reference:
http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/u_inaddr.htm#ARPLS071

Monday, May 5, 2014

Database auto start Windows

Mandatory configurations to check DB auto start is working.

start -> All programs -> Oracle-Homexx -> Configuration and Migration tools -> Administration assistanct for windows-> Oracle managed objects / computers/hostname/OH/databases/ right click on DB/ 'startup/shutdown options' check both the TAb

run -> regedit -> HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraDb11g_home1

Run -> services.msc -> Properties of DB service

ORACLE_HOME/database/oradim

server startup time: and DB startup time

systeminfo | find "Up Time"  (or) net statistics workstation | find "Statistics since"
net statistics server


select to_char(startup_time,'HH24:MI:SS DD-MON-YYYY') DB_started from v$instance;

Thursday, March 20, 2014

SQL monitor hidden parameters



Parameter session value instance value description
_sqlmon_binds_xml_format     default     default     format of column binds_xml in [G]V$SQL_MONITOR
_sqlmon_max_plan     80     80     Maximum number of plans entry that can be monitored. Defaults to 20 per CPU
_sqlmon_max_planlines     300     300     Number of plan lines beyond which a plan cannot be monitored
_sqlmon_recycle_time     60     60     Minimum time (in s) to wait before a plan entry can be recycled
_sqlmon_threshold     5     5     CPU/IO time threshold before a statement is monitored. 0 is disabled

Monday, December 30, 2013

What happens when DATAFILE RESIZE?

There is a need to understand what will be the impact when resizing some 8000 plus datafiles consecutively.  After some search did some test like enabled 10046 trace and captured what will happen when there is a datafile resize.

Used tkprof to format and provided the output to customer explaining the behavior.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show user
USER is "SYS"
SQL> oradebug setmypid
Statement processed.
SQL> alter session set tracefile_identifier='mytrace_10046';

Session altered.

SQL> alter session set events '10046 trace name context forever, level 12';

Session altered.

SQL> alter database datafile 'D:\ORACLE_DB\TESTDB\TESTDB\TESTDRP1.DBF' resize 150m;

Database altered.

SQL> ALTER SESSION SET EVENTS='10046 trace name context off';

Session altered.

SQL> oradebug tracefile_name
D:\ORACLE_DB\diag\rdbms\testdb\testdb\trace\testdb_ora_556_mytrace_10046.trc
SQL>

TKPROF Output.

alter database datafile 'D:\ORACLE_DB\TESTDB\TESTDB\TESTDRP1.DBF' resize 150m

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.02          0          0          0           0
Execute      1      0.01       1.96          0          0          3           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.01       1.99          0          0          3           0

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  control file sequential read                   31        0.03          0.10
  db file sequential read                         2        0.02          0.04
  Disk file operations I/O                        3        0.01          0.04
  Data file init write                            1        0.00          0.00
  db file single write                            1        0.00          0.00
  control file parallel write                     3        0.00          0.00
  rdbms ipc reply                                 1        0.21          0.21
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1       10.41         10.41

********************************************************************************

Recommendation given ,
-- See the above test, when there is a resize it will go through all this events
-- This test is done on my local machine where there is a very minimal load.
-- As it took 1.99s for a single file there will be more time considering your server.
-- Considering other factors like OS/ storage performance, it will take more time
-- Do it in a small batches and in a sequential manner. So that it will not harm database performance. 
-- Also it is best to test a small batch to estimate run  time in non business hours and proceed with the activity.

Thanks for reading, post your suggestions / comments on this. Happy reading.


how to filter records with symbol ~ (tilt)

There is one requirement for customer to select rows which has tilt at the beginning and at the end. After some searching found REGEXP_LIKE New Operator in 10G. Did some test case and seems so simple. Thought to post as I didn't get much detailed info on google.

Rows begins with ~
18:06:37 SQL> select * from test where REGEXP_LIKE (ID,'^~');

ID
--------------------
~test
~1~
~11~
~12~
~32~

Rows begin with ~ and number and ~
18:09:55 SQL> select * from test where REGEXP_LIKE (ID,'^~[0-9]~$');

ID
--------------------
~1~

Rows begin with ~ and any no. of digits and ends with ~
18:11:06 SQL> select * from test where REGEXP_LIKE (ID,'^~[0-9]*~$');

ID
--------------------
~1~
~11~
~12~
~32~

{m} Matches exactly m times
Bracket expression for specifying a matching list that should match any one of the expressions represented in the list. A nonmatching list expression begins with a circumflex (^) and specifies a list that matches any character except for the expressions represented in the list.
^-- beginning of line
$ End of line.

Rows begin with ~ and then 2 numbers and ends with ~
18:11:42 SQL> select * from test where REGEXP_LIKE (ID,'^~[0-9]{2}~$');

ID
--------------------
~11~
~12~
~32~

Thanks for reading, Please comment on post. Happy reading.


Reference:

REGEXP_LIKE New Operator in 10G (Doc ID 255953.1)
http://docs.oracle.com/cd/B19306_01/server.102/b14200/conditions007.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_posix001.htm#i690819
http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_posix002.htm#i690823