Posts

Showing posts from November, 2015

Exporting partitions from a Partitioned tables

Image
Exporting few partitions from a Partitioned table: There might scenerios where you dont want to export the entire partitioned table for backup purposes. In this situations you can use simple expdp to do that.. Here is an example of  Here is a sample expdp cmd to export part of entire partitioned tables. I have a table named AUDIT_LOGONS in my database, which has partitions as below image , I want to export a part of it. partitions AUDIT_LOGONS1,AUDIT_LOGONS2 only oracle@Linux1 $ expdp username/password directory=DPUMP dumpfile=AUDIT_PART1.dmp logfile=AUDIT_PART1.log TABLES=arvind.AUDIT_LOGONS:AUDIT_LOGONS4,arvind.AUDIT_LOGONS:AUDIT_LOGONS3 Export: Release 11.2.0.4.0 - Production on Mon Oct 12 16:29:59 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. Password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "arvind"...

ARCHIVE LOG Switch - shell script (for Oracle)

I think many of database admins will agree that it is always good idea to switch log file atleast every 20 mins or so. Especially when you have standby server setup. Doing this will ensure that redo logs are cleared up every 20 mins or so and they are shipped and applied onto standby database. Script Benefits: This is a simple shell script that uses plsql for checking the mount state of Database (oracle) and switch the archive log file when the open_mode of database is Read Write.   This script can be setup on both Primary and standby DB servers. This will avoid the enabling and disabling process on both servers after switchover/failover. You can setup this on crontab job on both Primary and standby DB servers, This will only switch log file if the DB is on Read Write mode ----------    Script Starts Here    ----------- #!/usr/bin/ksh #!/usr/bin/ksh ## ---- Created by Arvind Toorpu ## ----   Create Date 10/15/2015 ## ----   This script can be sch...

Split Fullname into firstname and last name thru sql - Oracle

Today I was working around some queries and I had a requirement where in the data in table was being stored a FULLNAME. Now I have Split Fullname into First Name and Last Name. I have all the fullnames in the column seperated by a empty space ' '. We can get the desired output by using the combination of SUBSTR and INSTR. Lets create a sample table : create table TESTTAB (ID number, FULLNAME varchar2(100)); Insert some data into it: Insert into TESTTAB (ID,FULLNAME) values (1,'Jaff Schdt'); Insert into TESTTAB (ID,FULLNAME) values (2,'Bradee Will'); Insert into TESTTAB (ID,FULLNAME) values (3,'Kuck Dahl'); Insert into TESTTAB (ID,FULLNAME) values (5,'Melyssa man'); Insert into TESTTAB (ID,FULLNAME) values (6,'Melyssa man'); Insert into TESTTAB (ID,FULLNAME) values (7,'Shart Elarpre'); Insert into TESTTAB (ID,FULLNAME) values (8,'Rock Dihl'); Insert into TESTTAB (ID,FULLNAME) values (9,'Hia Dodd'); Insert into TESTT...