SQL> set define off
eg:
1. alter database drop logfile group 1;
2. alter database add logfile group 1 (
‘/u01/oralog/redo01a.log’,
‘/u02/oralog/redo01b.log’) size 250m reuse;
that’s it. Keep in mind that it’s not possible to drop the “CURRENT” log group (switch to another redo log group with: alter system switch logfile). If the status of the log group you want to recreate is “ACTIVE” then perform a global checkpoint (alter system checkpoint global).
Taken from: http://www.idevelopment.info/data/Oracle/DBA_tips/Database_Administration/DBA_34.shtml
./runInstaller -silent -responseFile /home/oracle/linux_x64/response/additional_agent.rsp
If you want to manually remove Oracle Home(s) from the Ora Inventory then try this one:
./runInstaller -silent -detachHome ORACLE_HOME=[absolute path to Oracle Home]
runInstaller is available in any Oracle Home under oui/bin.
* Shutdown the guest
* Find the vdisk image file and (if increasing) add size to the disk (in this case 2GB):
dd if=/dev/zero bs=1M count=2000 >> system.img
* Attach image file as block device in Dom0:
xm block-attach 0 ‘file:/OVS/templates/System.img’ xvda w
* List partitions:
fdisk -ul /dev/xvda
Disk /dev/xvda: 16.4 GB, 16462456320 bytes
255 heads, 63 sectors/track, 2001 cylinders, total 32153235 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 63 192779 96358+ 83 Linux
/dev/xvda2 192780 23824394 11815807+ 83 Linux
/dev/xvda3 23824395 28049489 2112547+ 82 Linux swap / Solaris
* In this case I want to resize xvda2 and I decided to drop and recreate the swap partition
(I’ve used fdisk to drop the swap partition and after the resizing I recreated it wih fdisk and mkswap)
* filesystem check of the partition you want to resize:
e2fsck -f /dev/xvda2
* try to resize the partition with parted:
parted /dev/xvda
-> print (to find the partition number)
-> resize [partition number] / set start and end
** if parted throws “File system has an incompatible feature enabled.” disable partition flags:
(to check which partition flags are set use: tune2fs -l /dev/xvda2)
Remove flags:
tune2fs -O ^has_journal /dev/xvda2
tune2fs -O ^dir_index /dev/xvda2
debugfs -w /dev/xvda2 -R “feature -ext_attr”
Recheck the filesystem: e2fsck -y -f /dev/xvda2
debugfs -w /dev/xvda2 -R “feature -resize_inode”
Recheck it again: e2fsck -y -f /dev/xvda2
* try parted again – it should work now
* after the resize set the partition flags again:
tune2fs -j /dev/xvda2
debugfs -w /dev/xvda2 -R “feature dir_index ext_attr resize_inode”
* recheck the partition:
e2fsck -y -f /dev/xvda2
* find the vdev id (for detaching):
xm block-list 0
* detach the virtual disk:
xm block-detach 0 [vdev id] -f
* Startup the guest
-> everything should be fine!
Symptoms:
While running an online index rebuild your session was killed or otherwise terminated abnormally. You are now attempting to run the index rebuild again and is throwing the error: ORA-08104: this index object ##### is being online built or rebuilt
Cause:
A session failure during an online index rebuild can leave the data dictionary in a state reflecting a rebuild is ongoing when in fact it is not.
Solution:
The dbms_repair.online_index_clean function has been created to cleanup online index rebuilds. Use the dbms_repair.online_index_clean function to resolve the issue.
Reference:
Metalink 375856.1
Do the following steps to recreate the database control which don’t place the database in quiesce state:
Make sure that the database and the listener is up and running.
1. Logon SQLPLUS as user SYS and drop the sysman account and mangement objects:
a. drop user sysman cascade;
b. drop role MGMT_USER;
c. drop user MGMT_VIEW cascade;
d. drop all public synonyms referencing SYSMAN tables
(select ‘drop public synonym ‘||synonym_name||’;’ from dba_synonyms where table_owner = ‘SYSMAN’)
2. Manually remove the following folders:
ORACLE_HOME/host_sid/
ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole_host_sid
3.Set the ORACLE_HOME and ORACLE_SID
From $ORACLE_HOME/bin issue the following command:
emca -config dbcontrol db -repos create
Here’s the way to go if you need to query financial data at Yahoo!Finance via Oracle SQL.
Pre-Requirements:
* Database version must be >= 10g
* HTTP access to *.yahoo.com. (You’ll need an appropriate ACL when you are on 11g!)
* Access to UTL_HTTP, DBMS_LOB, SYS.ANYTYPE and SYS.ANYDATASET
* STR Package (because of the Split functions -> can be found here)
Implementation:
The solution is implemented with the Oracle pipelined table function feature, so it’s possible to use it in a SQL statement with the TABLE keyword:
select * from table(finyho([REQUEST]))
Furthmore the returned resultset of FINYHO is dynamic (ANYDATASET) and only contains the requested data fields. This is accomplished with the interface implementation approach of the pipelined table function.
There are two possible request types:
* a single row result for each security. Returns the latest data (= GET Request)
* a historical data request which returns a predefined set of data fields for a specific time frame.
(= HISTORY Request)
Syntax of the GET Request:
Get|[SECURITIES]|[FIELDS]
SECURITIES is a + seperated list of security tickers (eg: MSFT or GOOG+APPL etc.)
FIELDS is a list of special tags which represents the data fields you would like to query
Here are the possible values for the FIELDS parameter:
| a | Ask | a2 | Average Daily Volume | a5 | Ask Size |
| b | Bid | b2 | Ask (Real-time) | b3 | Bid (Real-time) |
| b4 | Book Value | b6 | Bid Size | c | Change & Percent Change |
| c1 | Change | c3 | Commission | c6 | Change (Real-time) |
| c8 | After Hours Change (Real-time) | d | Dividend/Share | d1 | Last Trade Date |
| d2 | Trade Date | e | Earnings/Share | e1 | Error Indication |
| e7 | EPS Estimate Current Year | e8 | EPS Estimate Next Year | e9 | EPS Estimate Next Quarter |
| f6 | Float Shares | g | Day’s Low | h | Day’s High |
| j | 52-week Low | k | 52-week High | g1 | Holdings Gain Percent |
| g3 | Annualized Gain | g4 | Holdings Gain | g5 | Holdings Gain Percent (Real-time) |
| g6 | Holdings Gain (Real-time) | i | More Info | i5 | Order Book (Real-time) |
| j1 | Market Capitalization | j3 | Market Cap (Real-time) | j4 | EBITDA |
| j5 | Change From 52-week Low | j6 | Percent Change From 52-week Low | k1 | Last Trade (Real-time) With Time |
| k2 | Change Percent (Real-time) | k3 | Last Trade Size | k4 | Change From 52-week High |
| k5 | Percebt Change From 52-week High | l | Last Trade (With Time) | l1 | Last Trade (Price Only) |
| l2 | High Limit | l3 | Low Limit | m | Day’s Range |
| m2 | Day’s Range (Real-time) | m3 | 50-day Moving Average | m4 | 200-day Moving Average |
| m5 | Change From 200-day Moving Average | m6 | PCT Change From 200-day Moving Average | m7 | Change From 50-day Moving Average |
| m8 | PCT Change From 50-day Moving Average | n | Name | n4 | Notes |
| o | Open | p | Previous Close | p1 | Price Paid |
| p2 | Change in Percent | p5 | Price/Sales | p6 | Price/Book |
| q | Ex-Dividend Date | r | P/E Ratio | r1 | Dividend Pay Date |
| r2 | P/E Ratio (Real-time) | r5 | PEG Ratio | r6 | Price/EPS Estimate Current Year |
| r7 | Price/EPS Estimate Next Year | s | Symbol | s1 | Shares Owned |
| s7 | Short Ratio | t1 | Last Trade Time | t6 | Trade Links |
| t7 | Ticker Trend | t8 | 1 yr Target Price | v | Volume |
| v1 | Holdings Value | v7 | Holdings Value (Real-time) | w | 52-week Range |
| w1 | Day’s Value Change | w4 | Day’s Value Change (Real-time) | x | Stock Exchange |
| y | Dividend Yield |
Examples:
Get the Ask, Bid and Last Trade of Microsoft:
select * from table(finyho('Get|MSFT|abl1'))
Get the Symbol, Name, Last Trade Date, Last Trade (Price only), Dividend Yield and P/E Ratio of Google and GE:
select * from table(finyho('Get|GOOG+GE|snd1l1yr'))

Syntax of the HISTORY Request:
History|[SECURITY]|[STARTDATE]|[ENDDATE]
SECURITY is the security ticker (only one allowed!)
STARTDATE is the beginning of the time frame (Syntax: YYYYMMDD)
ENDDATE is the end of the time frame (Syntax: YYYYMMDD)
The History Request returns the following data fields:
DATE, OPEN, HIGH, LOW, CLOSE, VOLUME and ADJ CLOSE
Examples:
Historical Data of Microsoft from 01/02/2009 till 01/20/2010:
select * from table(finyho('History|MSFT|20090102|20100120'))
Historical Data of Google from 01/02/2009 till 01/20/2010:
select * from table(finyho('History|GOOG|20090102|20100120'))

Code:
The YAHOO package contains two functions. The ParseRequest function parses the Request parameter and creates the Yahoo URL. The Query function executes the HTTP request and stores the CSV response in a CLOB. The YHO_IMPL object is the interface implementation of the pipelined table function FINYHO and creates the ANYDATASET from the CLOB data.
References:
Using Pipelined and Parallel Table Functions
Yahoo Data Download
SQL Script:
Attention:
This code-snippet is for educational purpose only! I don’t know anything about possible Yahoo usage restrictions or licenses, copyrights etc. Use at your own risk!
Enjoy!
Sometimes it’s quite useful to know the line number of an exception:
RAISE NO_DATA_FOUND;
EXCEPTION WHEN NO_DATA_FOUND THEN
/*
Parse a line with this format:
ORA-NNNNN: at "SCHEMA.PROGRAM", line NNN
and return the line number of the exception
*/
DBMS_OUTPUT.put_line(
TRIM(trailing CHR(10) FROM
SUBSTR(DBMS_UTILITY.format_error_backtrace,
INSTR(DBMS_UTILITY.format_error_backtrace,’ ‘,-1,1)+1
)
)
);
END;
This is a simple function which parses a delimiter-seperated string (varchar2 or clob) and returns a string array.
1. Create the string array type
2. Create a package with two functions
FUNCTION Split(sText IN VARCHAR2, sDel IN VARCHAR2 := ‘,’) RETURN str_array;
FUNCTION Split(sText IN clob, sDel IN VARCHAR2 := ‘,’) RETURN str_array;
END Str;
FUNCTION Split(sText IN VARCHAR2, sDel IN VARCHAR2 := ‘,’) RETURN str_array IS
nStartIdx PLS_INTEGER := 1;
nEndIdx PLS_INTEGER := 1;
oRet str_array := str_array();
BEGIN
IF sText IS NULL THEN RETURN oRet; END IF;
nEndIdx := INSTR(sText, sDel, nStartIdx);
oRet.Extend;
oRet(oRet.LAST) := SUBSTR(sText, nStartIdx, nEndIdx – nStartIdx);
nStartIdx := nEndIdx + 1;
oRet.Extend;
oRet(oRet.LAST) := SUBSTR(sText, nStartIdx);
EXIT;
RETURN oRet;
END Split;
FUNCTION Split(sText IN clob, sDel IN VARCHAR2 := ‘,’) RETURN str_array IS
nStartIdx PLS_INTEGER := 1;
nEndIdx PLS_INTEGER := 1;
oRet str_array := str_array();
BEGIN
IF sText IS NULL THEN RETURN oRet; END IF;
IF DBMS_LOB.getlength(sText) = 0 THEN RETURN oRet; END IF;
nEndIdx := DBMS_LOB.INSTR(sText, sDel, nStartIdx);
oRet.Extend;
oRet(oRet.LAST) := DBMS_LOB.SUBSTR(sText, nEndIdx – nStartIdx, nStartIdx);
nStartIdx := nEndIdx + LENGTH(sDel);
oRet.Extend;
oRet(oRet.LAST) := DBMS_LOB.SUBSTR(lob_loc => sText, offset => nStartIdx);
EXIT;
RETURN oRet;
END Split;
END Str;
3. Test it