Posts

Showing posts from April, 2018

ADD/Remove UNDO tablespace in oracle database

ADD/Remove UNDO tablespace in oracle database:- =====================================  every database having default undo tablespace, if you want to change it do follow below procedure. 1. first create new tablespace with new(as you want to create) Example:- CREATE UNDO TABLESPACE <NEW_NAME> DATAFILE '<datafile_location/name.dbf>' SIZE 1000M AUTOEXTEND OFF ONLINE RETENTION NOGUARANTEE BLOCKSIZE 8K FLASHBACK ON; ALTER SYSTEM SET UNDO_TABLESPACE = <NEW_NAME>; ALTER SYSTEM SET UNDO_RETENTION = <SET as per NEED>; Once new one created, if you want drop old one follow steps below. check any session already using old one  with below sql SQL> select tablespace_name, owner, segment_name, status from dba_rollback_segs where TABLESPACE_NAME='UNDOTBS1' and status='ONLINE'; you will get SID&Serial# if any in use, kill them if have or else you can proceed to drop old one. To kill SQL> alter system kill session 'SID,

ADD/Remove TEMP tablespace in oracle database

ADD/Remove TEMP tablespace in oracle database:- =====================================   To add new Temp tablespace and change it as default do follow below procedure. 1. First create New temptablespace and change it to default temp. CREATE TEMPORARY TABLESPACE <NEW_TEMP_NAME> TEMPFILE '<teampfile location.dbf' SIZE 1000M AUTOEXTEND OFF TABLESPACE GROUP '' EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M; ALTER DATABASE DEFAULT TEMPORARY TABLESPACE <NEW_TEMP_NAME>; Remove the old temptable space , before remove you must check any session already in use or not. to check use below query to get live session(SID&serial#)  those who use old temp. SELECT b.tablespace,b.segfile#,b.segblk#,b.blocks,a.sid,a.serial#, a.username,a.osuser, a.status FROM v$session a,v$sort_usage b WHERE a.saddr = b.session_addr; THEN kill session if any session in use. alter system kill session 'SID_NUMBER, SERIAL#'; we can drop old temporary tablespace.

SQL write Query with Tuning tips

Query Performance Tuning ====================  In this post i will give few tips while writing sql query, how we can write better query with less cost  If you follow below steps keep in mind while writing query you can tune up your sql while writning  time. Below are some tips which can be used as guideline.   Make sure am not expert, But what i learn have been post here to help some one.    If you know more points or you want to add on more please post in comment session it help to me and also others to learn.    Even though i can miss some silly points or known point as well.    so please help to remind them !!! DISTINCT:-  Do not use, If the objective can be achieved otherwise. DISTINCT incurs an extra sort operation and therefore slows your queries down.    Indexed columns:- Do not modify indexed columns with functions like RTRIM, TO_CHAR, UPPER, TRUNC, As this will prevent the optimizer from identifying the index. If possible perform the modification on the co