Unable to drop existing master table in sql developer - oracle

I was using yeasterday many times Data Pump in Sql Developer Wizard to export and import data. After each export/import a new master table appeared under the "+" button in sql developer(view->dba).
I wanted to drop all this tables(about 10 tables) and I was successfull for all cases, except 2 of them. When I'm writing sql code: drop table x, it shows me error that this tables doesn't exists. It was working fine for every others tables..
When i run query select * from dba_tables where table_name='x' the table is there. I'm writing drop statement as system user.
select *
from dba_tables
where table_name in ('moj_dump_job'
, 'moj_job_data_pump');
OWNER TABLE_NAME
------------------------------ ------------------------------
SYSTEM moj_dump_job
SYSTEM moj_job_data_pump
drop table moj_dump_job;
Error starting at line : 1 in command -
drop table moj_dump_job
Error report -
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
I tired to drop this jobs, but it doesnt't work:
select owner_name, job_name
from DBA_DATAPUMP_JOBS;
OWNER_NAME JOB_NAME
------------------------------ ------------------------------
SYSTEM moj_job_data_pump
SYSTEM moj_dump_job
BEGIN
dbms_scheduler.drop_job(job_name => 'moj_dump_job');
END;
Error starting at line : 13 in command -
BEGIN
dbms_scheduler.drop_job(job_name => 'moj_dump_job');
END;
Error report -
ORA-27475: "SYSTEM.MOJ_DUMP_JOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 213
ORA-06512: at "SYS.DBMS_SCHEDULER", line 657
ORA-06512: at line 2
27475. 00000 - "unknown %s \"%s\".\"%s\""
*Cause: The specified object did not exist, privileges were not granted,
or the object was of the wrong type.
*Action: Specify an object of the correct type on which you have privileges.
Do you have any idea what can I do? Using schema name before table name doesn't help.
Best regards, Darek

Thank's for your help. It work's.
drop table "moj_dump_job"
drop table "moj_job_data_pump";
Table "moj_dump_job" dropped.
Table "moj_job_data_pump" dropped.
Now
select *
from dba_tables
where table_name in ('moj_dump_job'
, 'moj_job_data_pump');
select owner_name, job_name
from DBA_DATAPUMP_JOBS;
Both statements doesn't return any rows. That's perfect, but the 2 tables are still visible under view ->dba ->data pump -> export jobs. How to drop them from the tree?

The reason it was not working cause by default Oracle changes job name to uppercase. To avoid it need use '"my_job"'
As per Oracle doc
Follow SQL naming rules to name Scheduler objects in the
DBMS_SCHEDULER package. By default, Scheduler object names are
uppercase unless they are surrounded by double quotes. For example,
when creating a job, job_name => 'my_job' is the same as job_name =>
'My_Job' and job_name => 'MY_JOB', but different from job_name =>
'"my_job"'. These naming rules are also followed in those cases where
comma-delimited lists of Scheduler object names are used within the
DBMS_SCHEDULER package.

Related

error sql at level 1 insufficient privilage oracle

SQL> flashback table ticket to timestamp TO_TIMESTAMP('13-11-2018 22:30:56',
'dd-mm-yyyy hh24:mi:ss');
flashback table ticket to timestamp TO_TIMESTAMP('13-11-2018 22:30:56',
* 'dd-mm-yyyy hh24:mi:ss')
ERROR at line 1:
ORA-00604 : error occurred at recursive SQL level 1
ORA-01031 : insufficient privileges
P.S. : I already added flashback any table system privilege.
Most probably you have a trigger such as after event type which contains some operations that prevent you perform your command line operations related with them. Try to disable those triggers, and then retry flashback table ...
To detect the obstacle, use :
select owner, trigger_name
from user_triggers -- for current schema, might be replaced with "dba_triggers" for the whole
where trigger_type = 'AFTER EVENT';

How can I avoid errors with dbms_metadata.GET_DEPENDENT_DDL

I'm writing a custom program to dump the database metadata to files in order to manage them with version control. The default way that data pump or export works isn't ideal for a few reasons (eg. I'd like a separate directory per table).
Sql Developer provides a number of ways of creating export scripts for any object. One way is just by right-clicking the object and selecting Quick DDL. By viewing the logs it creates, one can see the actual SQL it issues to create the DDL script. I've used these scripts to write my custom program and for the most part, they've been perfect.
When I generate the DDL for a materialized view, the SQL it generates is:
SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW',:name,:owner) FROM DUAL
UNION ALL
SELECT DBMS_METADATA.GET_DEPENDENT_DDL('INDEX',TABLE_NAME, TABLE_OWNER) FROM (
SELECT table_name, table_owner FROM all_indexes
WHERE table_owner = :owner AND table_name = :name
AND index_name NOT IN (
SELECT constraint_name FROM sys.all_constraints
WHERE table_name = table_name AND constraint_type = 'P'
) AND ROWNUM = 1
)
UNION ALL
SELECT dbms_metadata.GET_DEPENDENT_DDL ('COMMENT', :name,:owner ) FROM DUAL
For this script, when executed via SQL Developer Quick DDL, it generates the metadata for the materialized view properly. When I run this script in a program (or even manually with SQL Developer itself), it produces the following errors:
ORA-31608: specified object of type COMMENT not found
ORA-06512: at "SYS.DBMS_METADATA", line 5805
ORA-06512: at "SYS.DBMS_METADATA", line 8436
ORA-06512: at line 1
31608. 00000 - "specified object of type %s not found"
*Cause: The specified object was not found in the database.
*Action: Correct the object specification and try the call again.
This particular materialized view doesn't have any comments (obviously), but I would have expected this part of the clause to just return 0 rows instead of generating an error (especially since SQL Developer uses this itself seemingly without errors).
Is there a way I can avoid this error, while still including comments in the metadata if they exist?
This issue exists on both Oracle 10g & 11g databases.
I was not able to test as I don't really know how to create mview without comment... However the below should work for you. Try to query dba_mview_comments instead of dual to not execute the function when you don't have comments.
UNION ALL
SELECT dbms_metadata.get_dependent_ddl ('COMMENT', :name, :owner)
FROM dba_mview_comments mvc
WHERE mvc.mview_name = :name AND
mvc.owner = :owner AND
length(comments) > 0 AND
rownum = 1

How to recreate public synonym "DUAL"?

Using SQLDeveloper 4.0.1.14 to create an export script (separate files & "drops" checked), it generated me those 4 lines among others in DROP.sql:
DROP SYNONYM "PUBLIC"."DUAL";
DROP SYNONYM "PUBLIC"."DBMS_SQL";
DROP SYNONYM "PUBLIC"."DBMS_LOCK";
DROP SYNONYM "PUBLIC"."DBMS_OUTPUT";
Now that I have accidentally passed the whole script using SYSTEM user, I can no longer do modification (create or drop tables) to the database, I have that error popping:
An error was encountered performing the requested operation:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
Vendor code 604
The problem is that I'm getting that error event when I try this:
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";
I precise that the SYS.DUAL table still exists as SELECT 1 FROM SYS.DUAL works but SELECT 1 FROM DUAL fails with ORA-00942: table or view does not exist.
I tried to recreate the synonym as SYSTEM and SYSDBA with the same failure.
Can I recreate those synonyms with another way?
Try it as SYS but without the doauble quotes, i.e.:
CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;
not
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";
As I understand it the double quotes make the object name case sensitive.
Update - If you have access to metalink then you will find the answer in note 973260.1, something aboput a trigger firing :
ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=FALSE SCOPE=MEMORY;
CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;
ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=true SCOPE=MEMORY;
The note suggest that if this doesnt work, query DBA_TRIGGERS to find a BEFORE CREATE trigger enabled, and if found disable it and then re-issue create synonym statement, then re-enable the trigger.

Getting Error-ORA-00604, while creating new procedure in oracle sql developer

I am getting error while creating procedure and package. Please anyone help me.
My procedure code-
CREATE OR REPLACE PROCEDURE IPROC(CID IN NUMBER, CNAME IN VARCHAR2, CON IN NUMBER, A_NO IN NUMBER, BAL IN NUMBER, TTYPE VARCHAR2)
AS
BEGIN
INSERT INTO CUSTOMER_TBL VALUES(CID,CNAME,CON,A_NO,BAL,TTYPE);
END;
Error-
Error report -
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.PLSCOPE_ACTION$ by 128 in tablespace SYSAUX
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
If you're experiencing this error only in Sql Developer, try to change, Tools > Preferences > Database > PL/SQL Compiler, the option PLSCope to None.
PLSCOPE_SETTINGS controls the compile time collection, cross reference, and storage of PL/SQL source code identifier data.
NONE: Disables collection of identifier data.
ALL: Enables the collection of all source code identifier data. This is the default in SqlDeveloper.
SqlDeveloper default for PLScope is All, and maybe is causing this error.
You have no space left in tablespace SYSAUX
Either you also have no space left or your HDD or max limits of SYSAUX are reached.
Also look at script mentioned in https://dba.stackexchange.com/questions/33645/sysaux-tablespace-is-98, maybe it will help you.
If you have acces to the dba_data_files table , This query will show you how much space you have and how much you have utilized.
If it is full add another file to the tablespace or ask dba to add another file to it.
SQL> select file_name, sum(bytes)/1024/1024/1024 "current_gb",sum(maxbytes)/1024/1024/1024 "total_gb" from dba_data_files where tablespace_name='SYSAUX' group by file_name;
FILE_NAME current_gb total_gb
------------------------------------------------------------ ---------- ----------
C:\AKS\AKDB\ORADATA\RESEARCH\SYSAUX01.DBF .546875 31.9999847
To add datafile
Alter tablespace SYSAUX ADD DATAFILE 'C:\AKS\AKDB\ORADATA\RESEARCH\SYSAUX02.DBF' size 100m autoextend of maxsize 2g;

Oracle DB - identifier too long

I have created a connection in SQL Developer and added several tables to database. Also, I have defined some triggers. They all work well except for one that gives "identifier too long" error. I am aware of 30 character limit, but i can't see what causes this particular error. With this code, I'm trying to implement the Short-circuit keys.
Tables:
Izvestaj (IzvestajID, Datum, Opis, Tekst, PredmerID, NarucilacID, OsobaID, IzvrsilacID)
Predmer (PredmerID, Datum, Naziv, IzvrsilacID, LokacijaID)
Izvrsilac (IzvrsilacID, Naziv)
Italic values represent the primary keys of relations (tables).
Triggers:
create or replace TRIGGER "T_IZM_IZV"
AFTER UPDATE OF IZVRSILACID ON PREDMER
FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
EXECUTE IMMEDIATE ('ALTER TRIGGER'||'T_ZABRANA_IZM_IZV'||'DISABLE');
UPDATE IZVESTAJ SET IZVRSILACID=:NEW.IZVRSILACID
WHERE PREDMERID=:NEW.PREDMERID;
EXECUTE IMMEDIATE ('ALTER TRIGGER'||'T_ZABRANA_IZM_IZV'||'ENABLE');
END;
create or replace TRIGGER "T_ZABRANA_IZM_IZV"
BEFORE UPDATE OF IzvrsilacID ON Izvestaj
FOR EACH ROW
BEGIN
RAISE_APPLICATION_ERROR(-20000, 'Direct altering of IzvrsilacID is forbidden');
END;
I have added some rows to table "Predmer" (Izvrsilac and Izvestaj also have some values inserted) and when I try to change value of column "IzvrsilacID" (foreign key), i get an error:
UPDATE "KORISNIK"."PREDMER" SET IZVRSILACID = '1' WHERE ROWID = 'AAAFBRAABAAALDxAAB' AND ORA_ROWSCN = '675526'
ORA-00972: identifier is too long
ORA-06512: at "KORISNIK.T_IZM_IZV", line 4
ORA-04088: error during execution of trigger 'KORISNIK.T_IZM_IZV'
One error saving changes to table "KORISNIK"."PREDMER":
Row 2: ORA-00972: identifier is too long
ORA-06512: at "KORISNIK.T_IZM_IZV", line 4
ORA-04088: error during execution of trigger 'KORISNIK.T_IZM_IZV'
What could cause this error? I've tried several things, even renaming triggers, tables and columns to one-letter names, but without any success.
P.S. Sorry about naming. I didn't want to translate table and column names to English because it would differ their length, which seems to cause an error in the first place.
These lines:
EXECUTE IMMEDIATE ('ALTER TRIGGER'||'T_ZABRANA_IZM_IZV'||'DISABLE');
EXECUTE IMMEDIATE ('ALTER TRIGGER'||'T_ZABRANA_IZM_IZV'||'ENABLE');
Should look like this:
EXECUTE IMMEDIATE ('ALTER TRIGGER '||'T_ZABRANA_IZM_IZV'||' DISABLE');
EXECUTE IMMEDIATE ('ALTER TRIGGER '||'T_ZABRANA_IZM_IZV'||' ENABLE');
Note the added spaces.
Without the spaces added, you were trying execute:
ALTER TRIGGERT_ZABRANA_IZM_IZVDISABLE
and
ALTER TRIGGERT_ZABRANA_IZM_IZVENABLE
which clearly isn't going to work.
Hope that helps.

Resources