Sriram Sanka – My Experiences with Databases & More

Oracle-MySQL-SQL SERVER-Python-Azure-AWS-Oracle Cloud-GCP etc

  • Enter your email address to follow this blog and receive notifications of new posts by email.

  • Total Views

    • 588,537 hits
  • $riram $anka


    The experiences, Test cases, views, and opinions etc expressed in this website are my own and does not reflect the views or opinions of my employer. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content.Product and company names mentioned in this website may be the trademarks of their respective owners.

Archive for December, 2010

Put the Database in ARCHIVE mode and enable flashback mode

Posted by Sriram Sanka on December 11, 2010


SQL> select banner from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> select log_mode from v$database;

LOG_MODE
------------
NOARCHIVELOG

SQL> alter system set db_recovery_file_dest_size=2g;

System altered.

SQL> alter system set db_recovery_file_dest='d:\oracle\product\10.2.0\flash_recovery_area';

System altered.

.

SQL> alter system set log_archive_dest_1='location=d:\archive\sriram';

System altered.

SQL> alter system set log_archive_dest_10='location=use_db_recovery_file_dest';

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 272629760 bytes
Fixed Size 1248504 bytes
Variable Size 117441288 bytes
Database Buffers 150994944 bytes
Redo Buffers 2945024 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

SQL> alter database flashback on;

Database altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL>
SQL> alter database open;

Database altered.

SQL> select * from v$flash_recovery_area_usage;

FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------ ------------------ ------------------------- ---------------
CONTROLFILE 0 0 0
ONLINELOG 0 0 0
ARCHIVELOG 67.58 0 87
BACKUPPIECE 31.95 0 2
IMAGECOPY 0 0 0
FLASHBACKLOG .38 0 1

6 rows selected.

Posted in Oracle Server Administration | Leave a Comment »

Read the file

Posted by Sriram Sanka on December 10, 2010


A Master piece from http://laurentschneider.com

An excellent piece of code handy for DBA`s


SQL> SELECT s.sid,
2 s.serial#,
3 pa.value || '\' || LOWER(SYS_CONTEXT('userenv','instance_name')) ||
4 '_ora_' || p.spid || '.trc' AS trace_file
5 FROM v$session s,
6 v$process p,
7 v$parameter pa
8 WHERE pa.name = 'user_dump_dest'
9 AND s.paddr = p.addr
10 AND s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID')
11 /

SID SERIAL#
---------- ----------
TRACE_FILE
--------------------------------------------------------------------------------
147 2101
D:\ORACLE\PRODUCT\10.2.0\ADMIN\ORCLE\UDUMP\orcl_ora_1000.trc

SQL>
SQL> sho parameter user_dump_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string D:\ORACLE\PRODUCT\10.2.0\ADMIN
\ORCLE\UDUMP
SQL> CREATE DIRECTORY udump_dest AS
2 'D:\ORACLE\PRODUCT\10.2.0\ADMIN\ORCLE\UDUMP';

Directory created.

SQL> CREATE OR REPLACE FUNCTION get_tracefile (file_name VARCHAR2)
2 RETURN VARCHAR2
3 IS
4 dest_loc CLOB;
5 src_loc BFILE;
6 ret VARCHAR2 (4000);
7 BEGIN
8 src_loc := BFILENAME ('UDUMP_DEST', file_name);
9 DBMS_LOB.OPEN (src_loc, DBMS_LOB.lob_readonly);
10 DBMS_LOB.createtemporary (dest_loc, TRUE);
11 DBMS_LOB.loadfromfile (dest_loc, src_loc, 4000);
12 ret := DBMS_LOB.SUBSTR (dest_loc, 4000);
13 DBMS_LOB.CLOSE (src_loc);
14 RETURN ret;
15 END;
16 /

Function created.

 

SQL>

SQL> SELECT get_tracefile (‘orcl_ora_1000.trc’) FROM DUAL;
GET_TRACEFILE(‘ORCL_ORA_1000.TRC’)——————————————————————————–Dump file d:\oracle\product\10.2.0\admin\orcle\udump\orcl_ora_1000.trcFri Dec 10 22:54:36 2010ORACLE V10.2.0.1.0 – Production vsnsta=0vsnsql=14 vsnxtr=3Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – ProductionWith the Partitioning, OLAP and Data Mining optionsWindows XP Version V5.1 Service Pack 3CPU                 : 1 – type 586, 1 Physical CoresProcess Affinity    : 0x00000000Memory (Avail/Total): Ph:269M/959M, Ph+PgF:1265M/2314M, VA:1606M/2047MInstance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 20
Windows thread id: 1000, image: ORACLE.EXE (SHAD)………………….

…………………………………..ETC

Posted in Oracle Server Administration, Uncategorized | Leave a Comment »

Handy Package DBMS_UTILITY

Posted by Sriram Sanka on December 10, 2010


Really Its  great handy package for Oracle People!

We can use this in so many different scenarios.

SQL> DECLARE
2 parnam VARCHAR2(256);
3 intval BINARY_INTEGER;
4 strval VARCHAR2(256);
5 partyp BINARY_INTEGER;
6 BEGIN
7 partyp := dbms_utility.get_parameter_value('max_dump_file_size',
8 intval, strval);
9 dbms_output.put('parameter value is: ');
10 IF partyp = 1 THEN
11 dbms_output.put_line(strval);
12 ELSE
13 dbms_output.put_line(intval);
14 END IF;
15 IF partyp = 1 THEN
16 dbms_output.put('parameter value length is: ');
17 dbms_output.put_line(intval);
18 END IF;
19 dbms_output.put('parameter type is: ');
20 IF partyp = 1 THEN
21 dbms_output.put_line('string');
22 ELSE
23 dbms_output.put_line('integer');
24 END IF;
25 END;
26 /
parameter value is: UNLIMITED
parameter value length is: 9
parameter type is: string

PL/SQL procedure successfully completed.

SQL> declare
2 ver varchar2(100);
3 com varchar2(100);
4 begin
5 dbms_utility.db_version(ver,com);
6 dbms_output.put_line(ver||'-'||com);
7 end;
8 /
10.2.0.1.0-10.2.0.1.0

PL/SQL procedure successfully completed.
SQL> declare
2 id number;
3 str varchar2(40);
4 begin
5 id:=dbms_utility.get_parameter_value('compatible',id,str);
6 dbms_output.put_line(str);
7 end;
8 /
10.2.0.1.0

PL/SQL procedure successfully completed.

SQL> create or replace procedure sriram
2 as
3 begin
4 NULL;
5 end;
6 /

Procedure created.

SQL> select object_id,status,object_name from user_objects
2 where lower(object_name)='sriram';

OBJECT_ID STATUS OBJECT_NAME
---------- ------- ----------------------------------------------
52565 VALID SRIRAM

SQL> exec dbms_utility.invalidate(52565);

PL/SQL procedure successfully completed.

SQL> select object_id,status,object_name from user_objects
2 where lower(object_name)='sriram';

OBJECT_ID STATUS OBJECT_NAME
---------- ------- ----------------------------------------------
52565 INVALID SRIRAM

SQL> exec dbms_utility.validate(52565);

PL/SQL procedure successfully completed.

SQL> select object_id,status,object_name from user_objects
2 where lower(object_name)='sriram';

OBJECT_ID STATUS OBJECT_NAME
---------- ------- ----------------------------------------------
52565 VALID SRIRAM

SQL>

We can use This package in different situations like to compile schema objects analtze database etc…..

Posted in Oracle Server Administration | Leave a Comment »

Get the trace file name and read it

Posted by Sriram Sanka on December 10, 2010


SQL> COL trace_file FOR A75

SQL> col VALUE format a50

SQL> col name format a20

SQL> select name,value

2  from v$parameter

3  where name='user_dump_dest';

NAME                 VALUE

-------------------- --------------------------------------------------
user_dump_dest       D:\ORACLE\PRODUCT\10.2.0\ADMIN\SRIRAM_TEST\UDUMP
SQL> SELECT s.sid,

            s.serial#,

            pa.value || '\' || LOWER(SYS_CONTEXT('userenv','instance_name')) ||

            '_ora_' || p.spid || '.trc' AS trace_file

     FROM   v$session s,

            v$process p,

            v$parameter pa

     WHERE  pa.name = 'user_dump_dest'

     AND    s.paddr = p.addr

     AND    s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');
SID SERIAL#
---------- ----------
TRACE_FILE
---------------------------------
  143        573 D:\ORACLE\PRODUCT\10.2.0\ADMIN\SRIRAM_TEST\UDUMP\sriramtest_ora_2280.trc
SQL> alter database backup controlfile to trace;

Database altered.

---You can read the file on windows using the below command
SQL> host notepad D:\ORACLE\PRODUCT\10.2.0\ADMIN\SRIRAM_TEST\UDUMP\sriramtest_ora_2280.trc

Posted in Oracle Server Administration | Leave a Comment »

 
Tales From A Lazy Fat DBA

Its all about Databases & their performance, troubleshooting & much more .... ¯\_(ツ)_/¯

Thinking Out Loud

Michael T. Dinh, Oracle DBA

Notes On Oracle

by Mehmet Eser

Oracle Diagnostician

Performance troubleshooting as exact science

deveshdba

get sum oracle stuffs

Data Warehousing with Oracle

Dani Schnider's Blog

ORASteps

Oracle DBA's Daily Work

DBAspaceblog.com

Welcome everyone!! The idea of this blog is to help the DBA in their daily tasks. Enjoy.

Anand's Data Stories

Learn. Share. Repeat.

Tanel Poder's blog: Core IT for geeks and pros

Oracle Performance Tuning, Troubleshooting, Internals

Yet Another OCM

Journey as an Oracle Certified Master

DBAtricksWorld.com

Sharing Knowledge is ultimate key to Gaining knowledge...

Neil Chandler's DB Blog

A resource for Database Professionals

DBA Kevlar

Tips, tricks, (and maybe a few rants) so more DBA's become bulletproof!

OraExpert Academy

Consulting and Training