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.