Create two-table join query views in Oracle

Source: Internet
Author: User

Create two-table join query views in Oracle

In project development, multi-table queries are sometimes used, and there are many methods, such as association, such as views. However, View queries are the fastest for queries, if your database has a lot of field information, you need to query the whole table. For example, if you want to query two tables, we can extract the fields and put them in the view, in this way, you only need to query the fields in the view, and other fields can be ignored. Next I will record how to create a view in Oracle

Most people operate databases with Scott permissions, but Scott does not have the permission to create views. Therefore, we need to enter the Administrator System Account and grant Scott the permission to create views. After entering System, we enter the following statement:

 

Grant create any view to scott
In this way, we have the right to create a view for the Scott account. Then we exit the System account, return to the Scott account, and run the following statement:

 

 

Create or REPLACE view jjdb_zpjqbASselect j. JQH, j. BJSJ, j. BJRXM, j. BJDH, j. GXDWDM, z. ZPLX, z. ZPFS, z. ZPJE, z. BJNRfrom JJDB j, ZPJQB zwhere j. jjdbh = z. jjdbh;

Looking at the code above, we created a view named jjdb_zpjqb, where the fields are the fields between select and from. Of course, the condition in where is the joined field of the two tables. You always have to give him a condition for joining two tables.

 

 

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.