Jack,
It used to be DELETE ANY TABLE. I'm not sure if that has changed in recent
versions. Long ago, I setup the following procedure to allow a specific table to be
truncated, without out the DELETE ANY TABLE privilege. It must be owned by the owner
of the table. I haven't dealt with this issue in years, so if things have changed
since Oracle 7, somebody else can chime in.
Jay
CREATE OR REPLACE PROCEDURE TRUNC_TAB
(TAB_IN IN USER_TABLES.TABLE_NAME%TYPE)
-- Author : Tony Ziemba Sheck Cho 4/18/95
-- Modified :
-- 10/14/97 JMH
-- 08/06/99 JMH Allow only certain tables to be truncated.
-- 08/08/99 JMH Added more tables.
-- Description:
-- This procedure was developed to truncate a table using the table name that is
-- passed in as an input parameter. This procedure illustrates the use of the
-- dbms_sql package to execute SQL DDL statements within PL/SQL. As of v7.1
-- TRUNCATE cannot be executed on a table unless the user owns the table or
-- the user has DELETE ANY TABLE privelege. This procedure is a workaround to
-- those limitations.
--
AS
cursor_id integer; -- holds cursor id
return_value integer; -- holds call return value
str varchar2(150); -- string to hold DDL statement
e_wrongtable exception; -- exception when truncate is done on other tables.
BEGIN
IF tab_in in ('TS_SECURITY_ACCESS','GL_CODE_COMBINATIONS') THEN
str := 'truncate table '||tab_in;
cursor_id := dbms_sql.open_cursor;
dbms_sql.parse ( cursor_id,str,dbms_sql.native);
-- DDL statements are executed immediately. This may change
-- in future releases, in which case the following statement will
-- be needed.
-- return_value := dbms_sql.execute(cursor_id);
dbms_sql.close_cursor(cursor_id);
ELSE
RAISE e_wrongtable;
END IF;
EXCEPTION
WHEN e_wrongtable THEN
RAISE_APPLICATION_ERROR(-20000,'Procedure restricts tables that can be
truncated.');
WHEN OTHERS THEN
dbms_sql.close_cursor(cursor_id);
END;
/
>>> [EMAIL PROTECTED] 09/19/02 10:23AM >>>
Hi
I need to create a user/role that among other stuff must be able to
truncate a table. I can't figure out which privileges are needed (DBA is a
bit OTT :-))
Try them one by one does not sound appealing at all
TIA
Jack
**DISCLAIMER
This e-mail message and any files transmitted with it are intended for the use of the
individual or entity to which they are addressed and may contain information that is
privileged, proprietary and confidential. If you are not the intended recipient, you
may not use, copy or disclose to anyone the message or any information contained in
the message. If you have received this communication in error, please notify the
sender and delete this e-mail message. The contents do not represent the opinion of
D&E except to the extent that it relates to their official business.
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Jay Hostetter
INET: [EMAIL PROTECTED]
Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).