ORA-1031 EXEC IMMED Rebuild Index

I recently ran into a problem that did not make any sense until I delved into a a bit further. I had a stored procedure which did an online index rebuild:

CREATE PROCEDURE scott.rebuild_idx_proc AS
BEGIN
EXEC IMMED 'ALTER INDEX scott.emp_pk REBUILD ONLINE';
END;
/

The artery which carries blood to the penis is very narrow; hence even a minute clog will make it narrower thereby resulting in commander levitra poor flow of blood. Thus, you must find supplements that improves your levitra free samples focus and may help you remember things quickly like those that contain Serine. It is noteworthy that some of the most common causes of menorrhagia or heavy menstrual bleeding: A hormonal imbalance during adolescence or menopause is the most common symptoms include headaches, backaches, tension, muscle aches and pains, upset stomach, bloating, acne, fatigue, sleeplessness, irritability, mood swings, inability to concentrate, and anxiety or depression. davidfraymusic.com cialis on line This most beneficial http://davidfraymusic.com/project_category/news/page/5/ levitra samples additional effect in Super P-force makes it popular among men of all ages.
Simple enough. A stored proc owned by SCOTT to rebuild an index owned by SCOTT. But whenever anyone tried to run the procedure, including SCOTT, we would get the “ORA-1031 insufficient privileges” error. How does SCOTT get a priv error when trying to rebuild an index he owns? Further confusing the issue was that if SCOTT issued the ALTER INDEX rebuild command in SQL*Plus, no error was raised.

My initial thought was that it was due to a privilege granted through a role. As we know, privileges granted through roles do not work for stored procedures. So I granted ALTER ANY INDEX directly to SCOTT and ran into the same error. Huh? This is even more confusing.

The solution lies in knowing that online index rebuilds create a temporary journal table to keep track of the changes while the index is being rebuilt. The solution is to grant CREATE TABLE directly to SCOTT. The SCOTT user does have CREATE TABLE, but it is granted through a role. It does sound odd to require CREATE TABLE to rebuild an index, but this is only because we are doing an online index rebuild. If we did not include the ONLINE option, no journal table is necessary and the proc worked just fine.