Home » SQL & PL/SQL » SQL & PL/SQL » Invalid Synonym in SQL Plus Vs Toad (Oracle 11g Release 2)
Invalid Synonym in SQL Plus Vs Toad [message #615414] Tue, 03 June 2014 10:28 Go to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
Hi,
we have a job that drops and recreate few tables daily 3 am.
i have select Grant on that table with in this job,

as part of major release Grants/Synonyms where created on entire schema, All synonyms Valid.
I see through Toad that all the synonyms are valid, but somehow other person noticed this by this SQL

select owner, object_type, status object_status, count(*)
from dba_objects
where status <> 'VALID'
group by owner, object_type, status

OWNER                          OBJECT_TYPE         OBJECT_STATUS   COUNT(*)
------------------------------ ------------------- ------------- ----------
APPLICATIONUSR                   SYNONYM             INVALID                9



At same time from Toad this doesn't show as invalid Synonym,
question is while we drop and recreate and then grant on the table to that user, the existing synonyms which was invalid when we drop becomes valid correct ?

Thanks
Re: Invalid Synonym in SQL Plus Vs Toad [message #615416 is a reply to message #615414] Tue, 03 June 2014 10:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
question is while we drop and recreate and then grant on the table to that user, the existing synonyms which was invalid when we drop becomes valid correct ?


Post evidences not claims.
Show us what you do and get so we can reproduce the same thing.

Quote:
I see through Toad that all the synonyms are valid, but somehow other person noticed this by this SQL


One more proof TOAD is b...t and you just have to throw it away.

Re: Invalid Synonym in SQL Plus Vs Toad [message #615417 is a reply to message #615414] Tue, 03 June 2014 10:49 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why don't you simply truncate those tables?
Re: Invalid Synonym in SQL Plus Vs Toad [message #615418 is a reply to message #615417] Tue, 03 June 2014 11:14 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>we have a job that drops and recreate few tables daily 3 am
foolish & wasteful activity.
Why not just TRUNCATE TABLE?


Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: Invalid Synonym in SQL Plus Vs Toad [message #615420 is a reply to message #615418] Tue, 03 June 2014 12:53 Go to previous messageGo to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
code is something like this.
CREATE OR REPLACE PROCEDURE WEBSYSTEM.BKUP_TABLES
IS
   V_Table_Present   NUMBER
BEGIN
      
	  BEGIN
	  SELECT COUNT (*)
        INTO V_Table_Present
        FROM user_tables
       WHERE table_name IN
                ('PYCOMMONTEMPLATE_BKUP',
                 ....
				 ....);
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         V_Table_Present := 0;
   END;
   IF V_Table_Present > 0 then
  EXECUTE IMMEDIATE 'drop table PYCOMMONTEMPLATE_BKUP';
...
...
  end if;

      EXECUTE IMMEDIATE
         'create table  PYCOMMONTEMPLATE_BKUP as select * from  PAYMENTSCOMMONTEMPLATE';
	....
	EXECUTE IMMEDIATE
         'Grant select on PYCOMMONTEMPLATE_BKUP to READ_ONLYROLE,APPLICATIONUSR';
        ....
		....
END;


and i was reading this arcticle and took into consideration about space and performance while loading these tables daily..
there are 9 tables in total and will have around 10 mil rows in total for those 9 tables.

1) if you use a normal insert, it will use the free space below the high water mark (HWM) before using space above the HWM.

If you use a direct path load (sqlldr direct=y, insert /*+ APPEND */ as select), then we only load above the existing HWM and will not reuse the existing free space (but any subsequent normal inserts would - even after the direct path load)

Reference --> https://asktom.oracle.com/pls/apex/f?p=100:11:0%3A%3A%3A%3AP11_QUESTION_ID:492636200346818072


Thanks
Re: Invalid Synonym in SQL Plus Vs Toad [message #615421 is a reply to message #615420] Tue, 03 June 2014 13:19 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Quote:
and i was reading this arcticle


It seems that the rational for whatever it was you read from whatever source ... was dealing with mass insert of additional data. But you aren't inserting/appending additional data, you are completely dropping your tables and reloading from scratch.

So the question still stands .. why not truncate instead of drop/create? Truncate will leave all dependencies, indexes, triggers, etc, etc, in place, generates less redo and so is MUCH faster.


Somehow your comment "and i was reading this arcticle " reminds me of http://www.youtube.com/watch?v=bufTna0WArc

Re: Invalid Synonym in SQL Plus Vs Toad [message #615422 is a reply to message #615420] Tue, 03 June 2014 13:20 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
azeem87 wrote on Tue, 03 June 2014 23:23

there are 9 tables in total and will have around 10 mil rows in total for those 9 tables.


Just 9 tables? 10 million rows in total? Not too many to be so much worried about. DB is about the size. 10, 100, 1000... million, billion, how much is the size of the data?

Quote:

1) if you use a normal insert, it will use the free space below the high water mark (HWM) before using space above the HWM.

That does not mean you need to DROP and CREATE tables each time. Truncate brings the HWM down to where it should be for a normal start. You have not read Tom's answer properly.

Quote:
Reference --> https://asktom.oracle.com/pls/apex/f?p=100:11:0%3A%3A%3A%3AP11_QUESTION_ID:492636200346818072


And didn't you pay attention to this statement by Tom in his very first reply "

"TRUNCATE will reset the HWM of a table back to 'zero' and will truncate the associated indexes on the table as well."

Not a good idea to drop and create tables for your requirement. If they daily loading tables, then truncate it before the next insert happens.

[Updated on: Tue, 03 June 2014 13:26]

Report message to a moderator

Previous Topic: how to display only char data only or numeric data only not both
Next Topic: how to user REGEXP for inserting data from one table to another table
Goto Forum:
  


Current Time: Wed Apr 24 22:35:21 CDT 2024