Home » SQL & PL/SQL » SQL & PL/SQL » ora-20000: unable to analyze table (11.2.0.1.0)
ora-20000: unable to analyze table [message #603073] Wed, 11 December 2013 05:16 Go to next message
grpatwari
Messages: 288
Registered: June 2008
Location: Hyderabad
Senior Member
Hi All,

I have connected as sys and set current schema to WOWNER. I have created the table SI_MESSAGE_AUDIT with interval partition(without schema name). Also created the procedure to drop the partition and scheduler job(to drop the 14 days partitions).

When it runs the scheduler, the scheduler is looking the table into sys user. I am getting the error
" Error while dropping Partition from SI_MESSAGE_AUDIT ORA-20000: Unable to analyze TABLE "SYS"."SI_MESSAGE_AUDIT" "

Please find the script which I have executed.



CREATE TABLE SI_MESSAGE_AUDIT
   (AUDIT_ID NUMBER(10,0), 
	BUSINESS_SERVICE_ID VARCHAR2(45 BYTE), 
	MSG_RECIEVED_TIMESTAMP TIMESTAMP (6), 
	MESSAGE_TYPE VARCHAR2(20 BYTE), 
	MESSAGE_IDENTIFIER VARCHAR2(500 BYTE), 
	MESSAGE_PAYLOAD CLOB, 
	MESSAGE_PAYLOAD_CCSID NUMBER(4,0), 
	BROKER_NAME VARCHAR2(50 BYTE), 
	MESSAGE_FLOW_NAME VARCHAR2(100 BYTE), 
	EXECUTION_GROUP_NAME VARCHAR2(50 BYTE), 
	INSERT_TIMESTAMP TIMESTAMP (6), 
	UPDATE_TIMESTAMP TIMESTAMP (6), 
	MESSAGE_CORRELATION_ID VARCHAR2(60 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
	  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
	  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
	  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
	  TABLESPACE WMBDATA 
	 LOB (MESSAGE_PAYLOAD) STORE AS BASICFILE (
	  TABLESPACE WDATA ENABLE STORAGE IN ROW CHUNK 8192 RETENTION 
	  NOCACHE LOGGING 
	  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
	  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) 
	PARTITION BY RANGE (Insert_Timestamp)
	INTERVAL (Numtodsinterval(1,'day')) 
	(PARTITION p_first_JUL_PART VALUES LESS THAN (TO_DATE('01-AUG-2013','DD-MON-YYYY')));

--------------------------------------------------------
--  DDL for Index PK_SI_MSG_AUDIT
--------------------------------------------------------

  CREATE UNIQUE INDEX PK_SI_MSG_AUDIT ON SI_MESSAGE_AUDIT (AUDIT_ID) 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE WDATA ;




create or replace procedure purge_partition(i_tablename varchar2,i_noofdays number) as

v_totpartitions number;
v_high_value varchar2(1024);
v_date date;
v_sql varchar2(300);
v_count number:=0;
v_date_cut date:=sysdate - i_noofdays-1;
v_code number;
v_errm VARCHAR2(1000);
begin

   DBMS_STATS.gather_table_stats(USER,i_tablename);

   select count(*) into v_totpartitions
   FROM USER_TAB_PARTITIONS
   where table_name = upper('i_tablename');


	FOR I IN (SELECT HIGH_VALUE, PARTITION_NAME
    FROM USER_TAB_PARTITIONS
    WHERE TABLE_NAME=i_tablename
    AND PARTITION_POSITION<>1
    ) LOOP

		execute immediate 'SELECT ' ||I.high_value || ' from dual' INTO v_date;
	   IF V_DATE < v_date_cut THEN

      v_count:=v_count +1;
      v_sql:='ALTER TABLE '|| i_tablename||' DROP PARTITION '|| I.PARTITION_NAME || ' update global indexes';
     
       execute immediate v_sql;
	   END IF;
	END LOOP;
 
	 insert into AUDIT_LOG (JOB_NAME, REC_COUNT, DELETED_DATE) 
	 VALUES ('DROPPING BEFORE '||v_date_cut||' DAYS PARTITIONS  FROM '||i_tablename, v_count, sysdate);
 
	COMMIT; 
	
   EXCEPTION
      WHEN OTHERS THEN
         v_code := SQLCODE;
         v_errm := SUBSTR(SQLERRM, 1 , 64);
         insert into audit_log values ('Error while dropping Partition from '||i_tablename||' '|| v_errm,v_code, sysdate);
         commit;
  end purge_partition;
/




PROMPT
PROMPT CREATING SCHEDULER JOB for SI_MESSAGE_AUDIT
PROMPT ===========================================
PROMPT

BEGIN
  DBMS_SCHEDULER.DROP_JOB ('Purging_Audit_data');
END;
/

BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
   JOB_NAME           =>  'Purging_Audit_data',
   JOB_TYPE           =>  'plsql_block',
   job_action         =>  'begin purge_partition(''SI_MESSAGE_AUDIT'',14); end;',
   START_DATE         =>   systimestamp-1,
   repeat_interval    =>  'FREQ=DAILY; INTERVAL=1; BYHOUR=23; BYMINUTE=59', /* Runs every day at 11:59 PM*/
   auto_drop          =>   FALSE,
   enabled            =>   true,
   COMMENTS           =>  'Dropping the Daily Audit partitions');
END;
/



Please advise on this.
Re: ora-20000: unable to analyze table [message #603075 is a reply to message #603073] Wed, 11 December 2013 05:24 Go to previous messageGo to next message
gazzag
Messages: 1119
Registered: November 2010
Location: Bedwas, UK
Senior Member
Any use?
Re: ora-20000: unable to analyze table [message #603077 is a reply to message #603073] Wed, 11 December 2013 05:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

- Never ever use SYS (or SYSDBA) but for maintenance purpose (startup, shutdown, backup, recover)
- SYS/SYSDBA is special
- SYS/SYSDBA is Oracle proprietary (try to open a SR/TAR starting with "i did that with SYS/SYSDBA" and you'll see the immediate answer)
- SYS/SYSDBA does not act like any other user
- When you use SYS/SYSDBA Oracle deactivates some code path and activates others
(no flashback query for it, no read only transactions, no triggers, no consistency...)
- Whatever you do with SYS/SYSDBA will neither validate nor invalidate the same thing with any other user.

NEVER EVER use SYS/SYSDBA for anything that can be done by another user.
Use SYS/SYSDBA ONLY for something that can't be done by someone else.


Re: ora-20000: unable to analyze table [message #603078 is a reply to message #603077] Wed, 11 December 2013 05:33 Go to previous messageGo to next message
grpatwari
Messages: 288
Registered: June 2008
Location: Hyderabad
Senior Member
Actually DBAs will run these scripts by setting current schema as WOWNER because they don't have the WOWNER passwords (WOWNER password owns application team)
Re: ora-20000: unable to analyze table [message #603079 is a reply to message #603078] Wed, 11 December 2013 05:36 Go to previous messageGo to next message
gazzag
Messages: 1119
Registered: November 2010
Location: Bedwas, UK
Senior Member
SYS is not a DBA. Like Michel says, it's a highly privileged account for specialised used. Create another user and grant the privileges it requires to do whatever it is you want to achieve.
Re: ora-20000: unable to analyze table [message #603081 is a reply to message #603078] Wed, 11 December 2013 05:45 Go to previous message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Each DBA should have his own account with his needed privilege and never use SYS but for what I mentioned.
In addition, a DBA does not need to know an account password to connect with it, he can use the proxy authentication.

Previous Topic: Accessing data from MS Access into Oracle using Oracle procedure
Next Topic: shortest way to concatenate multiple messages based on column multiple values.
Goto Forum:
  


Current Time: Fri Apr 03 18:56:28 CDT 2026