Monday, March 9, 2009

Oracle Date Conversion function - TO_DATE()

TO_DATE in Oracle pl/sql is to convert char data type to a value of DATE data type.

TO_DATE( String, format, nls_param )

String : is the string to convert to date
format : is the format that will be used to convert string to a date.
nls_param : is the nls_languageused to convert string to a date.

Examples:
SQL> select to_date('APR/03/2009' ,'MON-DD-YYYY HH24:MI:SS') DATE from dual;
SQL> select to_date('20080312','YYYYMMDD') from dual;
SQL> select to_date('20080312','YYYYDDMM') from dual;
SQL> select to_date('2006/11/14 18', 'yyyy/mm/dd hh24') from dual;

Thursday, February 19, 2009

How to Kill Oracle Sessions?

There are two main ways to Kill Oracle User Sessions.
1. Directly the session of User.

ALTER SYSTEM KILL SESSION;

2. Identifying the User Process and kill it.

SELECT b.object_name,c.SERIAL#,a.*
FROM V$LOCKED_OBJECT a,DBA_OBJECTS b,v$session c
WHERE a.object_id = b.object_id
AND a.SESSION_ID = c.SID
order by a.SESSION_ID;


ALTER SYSTEM KILL SESSION 'sid,serial#'

In these cases the session will be "marked for kill". It will then be killed as soon as possible.