Saturday, 30 March 2013

Temp Tables - Part 3 - Volatile tables


Volatile temporary tables:

  • Uses Spool space.

  • No data dictionary access needed.
     
  • Table definition is kept in cache.
     
  • Table is local to session and not the query.
     
  • Table can be used multiple times with in the session.
     
  • Volatile tables can be dropped any with within the session using DROP TABLE. However if we don’t the table will get dropped automatically at the end of the session.
     
  • The volatile table must be explicitly created using the CREATE VOLATILE TABLE syntax.
     
  • Volatile tables don’t survive system restart.

Example of creating volatile table.

CREATE VOLATILE TABLE V_TEMP, NO FALLBACK
(
Empid integer,
Salary decimal(10,2)
Deptno integer
) ON COMMIT PRESERVE ROWS;

Note the highlighted 'ON COMMIT PRESERVE ROWS'  allows us to use the same volatile table again and again within the session.

  • BY default its 'ON COMMIT DELETE ROWS' , which means the data will be deleted after the query is committed.

  • For volatile tables we can also request a NO LOG option which means the transaction journal will not be used.

Example

CREATE VOLATILE TABLE V_TEMP, NO FALLBACK , NO LOG
(
Empid integer,
Salary decimal(10,2)
Deptno integer
) ON COMMIT PRESERVE ROWS;

LOG is default. Which means transaction journal will be maintained.

  • Irrespective of whether we explicitly specify or not the volatile tables are created under userid logged in.

CREATE VOLATILE TABLE username.table1 -->      (Explicit)
CREATE VOLATILE TABLE table1              -->  (Implicit)
CREATE VOLATILE TABLE databasename.table1 -->  This will give is an error message if the databasename specified is not actually the username.

  • Different sessions can use the same volatile table name. But a volatile table cannot use a name that is used by any of the following objects under the user id.

Permanent tables.
Temporary tables.
Views.
Macros.


  • We can create volatile tables with FALLBACK, however as these tables don’t survive system restart having fallback does not add much value. On the contrary they would take twice the spool space.

  • We cannot use following while creating Volatile tables

  1. Permanent Journaling

  1. Referential integrity. Referential integrity means relation between tables, which is stored in DBC. As volatile table don’t need data dictionary we cannot have referential integrity

  1. Check constraints

  1. Column compression.

CREATE VOLATILE TABLE         TEST1         ( salary integer compress 0 ) on commit preserve rows;

Above query would fail with below message:

CREATE TABLE Failed. 3706:  Syntax error: COMPRESS option not allowed for a volatile table.

  1. Default values for columns

CREATE VOLATILE TABLE         TEST1         ( salary integer default 0 ) on commit preserve rows;

Above query would fail with below error message:

CREATE TABLE Failed. 3706:  Syntax error: DEFAULT option not allowed for a volatile table. 

  1. Column titles

  1. Named indexes.

  • We cannot use HELP DATABASE command to find all the volatile tables under a userid. Reason being volatile tables are not stored in data dictionary

To do that we have to use the command HELP VOLATILE TABLE ;

This will show all the volatile tables under a particular user id.

HELP VOLATILE TABLE;

Table Name
Table Id
TEST1                        
06C4AA600000


  • Following are the commands that we cannot run on VT's

  1. HELP and COLLECT STATS: This is no longer true with TD13. With TD13 we can collect stats on volatile table.

  1. CREATE/DROP INDEX : we cannot have indexes on volatile table.

  1. ALTER TABLE.

ALTER TABLE TEST1 ADD  salary decimal(10,2)

Following is the error we would get

ALTER TABLE Failed. 5341:  Volatile table 'TEST1' not allowed in statement. 

  1. GRANT and REVOKE privileges

  • Volatile tables cannot be renamed.

  • Volatile tables cannot be loaded using multiload.

57 comments:

  1. Thanks for sharing this excellent post. Its really very informative and interesting. Keep update your blog. For a best Android training in Chennai please refer this site.
    Regards....
    Android Training in Chennai

    ReplyDelete
  2. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Regards,


    Salesforce training in Chennai

    ReplyDelete
  3. Wow! It was the best article , actually you have posted something new compared to others, because I read many articles related to this topic but I only get impressed with your post only, keep posting.
    Regards,
    Informatica training in chennai|Best Informatica Training In Chennai|Informatica course in Chennai

    ReplyDelete
  4. Thanku for sharing..
    SAS Institute introduced the SAS Certified Professional Program,training proper understanding of how the SAS software works. Among the five certification programs that SAS Institute has come up with, SAS training can be considered as the entry point into the big data and the data analytics industry.
    SAS online training in hyderabad

    ReplyDelete
  5. Thank you for taking the time to provide us with your valuable information.Keep on blogging like this unique informative post with us.java training classes

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
    python training in chennai | python training in bangalore

    python online training | python training in pune

    python training in chennai | python training in bangalore

    python training in tambaram

    ReplyDelete
  8. Appreciating the persistence you put into your blog and detailed information you provide
    python online training
    python training in OMR
    python training in tambaram

    ReplyDelete
  9. Thanks first of all for the useful info.
    the idea in this article is quite different and innovative please update more.

    python programming in bangalore
    python programming classes in bangalore
    Python Training in Nungambakkam

    ReplyDelete
  10. I am happy to find this post Very useful for me, as it contains lot of information

    ahmedabadclassifieds

    Guest posting sites

    ReplyDelete
  11. We are a group of volunteers and starting a new initiative in a community. Your blog provided us valuable information to work on.You have done a marvellous job!
    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Really you have done great job,There are may person searching about that now they will find enough resources by your post
    python training in rajajinagar
    Python training in bangalore
    Python training in usa

    ReplyDelete
  14. After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.

    Java training in Bangalore | Java training in Jaya nagar

    Java training in Bangalore | Java training in Electronic city

    Java training in Chennai | Java training institute in Chennai | Java course in Chennai

    Java training in USA

    ReplyDelete
  15. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    Data Science Training in Indira nagar
    Data Science training in marathahalli
    Data Science Interview questions and answers
    Data Science training in btm layout
    Data Science Training in BTM Layout
    Data science training in bangalore

    ReplyDelete
  16. Hi, thank you very much for new information, i learned something new. Very well written.It was so good to read and usefull to improve knowledge.Keep posting. If you are looking for any big data hadoop related information please visit our website.
    big data hadoop training in bangalore.

    ReplyDelete
  17. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing.. i Want to share Some data regarding the websphere training videos with free bundle videos is provided.

    ReplyDelete
  18. Thanks for sharing useful information. I learned something new from your bog. Its very interesting and informative. keep updating. If you are looking for any Big Data related information, please visit our website bigdata training institute in bangalore.

    ReplyDelete
  19. I am really happy with your blog because your article is very unique and powerful for new reader.

    Get Software Testing Training in Bangalore from Real Time Industry Experts with 100% Placement Assistance in MNC Companies. Book your Free Demo with eTechno Soft Solutions.

    ReplyDelete
  20. Nice and informative post..
    Thanks for sharing with us,
    We are again come on your website,
    Thanks and good day,
    If you need any logo then,
    Please visit our site,
    buylogo

    ReplyDelete
  21. I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can learn his living by doing blogging.thank you for thizs article. pega online training
    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  22. Thanks for sharing a very useful article. Am sure it helped to clear the doubts I had. Keep posting more. Also dont forget to check out our pages too.

    data science training in chennai

    ccna training in chennai

    iot training in chennai

    cyber security training in chennai

    ethical hacking training in chennai


    ReplyDelete
  23. Deep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings,
    Teradata Training in Bangalore

    ReplyDelete
  24. Thanks for this. I really like what you've posted here and wish you the best of luck with this blog and thanks for sharing

    Teradata Training in Bangalore

    ReplyDelete
  25. Thanks for sharing amazing information.Gain the knowledge and hands-on experience

    Teradata class in Bangalore

    ReplyDelete

  26. Quick up the best offer of AWS DevOps Training in Chennai from Infycle Technologies, Excellent software training in Chennai. A massive place to learn other technical courses like Power BI, Cyber Security, Graphic Design and Animation, Block Security, Java, Oracle, Python, Big data, Azure, Python, Manual and Automation Testing, DevOps, Medical Coding etc., with outstanding training with experienced trainers with a fresh environment with 100+ Live Practical Sessions and Real-Time scenario after the finalisation of the course the trainee will able to get through the interview in top MNC’s with an amazing package for more enquiry approach us on 7504633633, 7502633633.

    ReplyDelete

  27. This post is so interactive and informative.keep update more information…
    IELTS Coaching in anna nagar
    IELTS Coaching in Chennai

    ReplyDelete