If EXISTS () under Oracle

Source: Internet
Author: User

Mother Egg. As a program that uses SQL Server for 4 to 5 years ape, start with Oracle really not used to. It's a hell of a different kind of notation. For example, write a statement like if EXISTS (SELECT * from sys.tables where name = ' xxxx ') BEGIN drop TABLE xxxx End and find that it is completely different under Oracle. Sister's. So Baidu Ah. Finally found

1) Under Oracle There is no if EXISTS (), Oracle to implement if EXISTS () so write

DeclareNum Number; begin       Select Count(1) intoNum fromAll_tableswheretable_name= 'TEST2'; ifNum=1    Then           ExecuteImmediate'drop table TEST2'; End   if; End;

You need to use a variable to store the results of the all_tables output and then judge
2) If ... under SQL Server. BEGIN ... The end to Oracle becomes the IF .... Then ...  END IF; and each sentence must be added; It still seems to be necessary.

3) use/to separate two statement blocks to execute

If EXISTS () under Oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.