1 How Views Are Used Views provide a means to present a different representation of the data that resides within the base tables. Views are very powerful because they allow you to tailor the presentation of data to different types of users. 2 Views are often used to provide an additional level of table security by restricting access to a predetermined set of rows and/or columns of a table For example, Figure 8-5 shows how the STAFF view does not show the SAL or COMM columns of the base table EMP. to hide data complexity For example, a single view might be defined with a join, which is a collection of related columns or rows in multiple tables. However, the view hides the fact that this information actually originates from several tables. to simplify commands for the user For example, views allow users to select information from multiple tables without actually knowing how to perform a join. to present the data in a different perspective from that of the base table For example, the columns of a view can be renamed without affecting the tables on which the view is based. to isolate applications from changes in definitions of base tables For example, if a view's defining query references three columns of a four column table and a fifth column is added to the table, the view's definition is not affected and all applications using the view are not affected. to express a query that cannot be expressed without using a view For example, a view can be defined that joins a GROUP BY view with a table, or a view can be defined that joins a UNION view with a table. to save complex queries For example, a query could perform extensive calculations with table information. By saving this query as a view, the calculations can be performed each time the view is queried.
from A,B,C
where A.AId = B.AId and B.CId = C.CId and (A.AId = '0' or A.AId = '1')
select A.AId,B.CId,C.Cname,C.CProperty
from A,B,C
where A.AId = B.AId and B.CId = C.CId and (A.IfCom = '0' or A.IfCom = '1')
关于这个问题不是说不可以,当然可以。
只是以楼主题目中的要求来看,这种操作是毫无意义的视图的创建不是为了某一次特定查询而创建的。
按楼主的要求,应该是用动态SQL为佳。
Views provide a means to present a different representation of the data that resides within the base tables. Views are very powerful because they allow you to tailor the presentation of data to different types of users. 2 Views are often used
to provide an additional level of table security by restricting access to a predetermined set of rows and/or columns of a table
For example, Figure 8-5 shows how the STAFF view does not show the SAL or COMM columns of the base table EMP. to hide data complexity
For example, a single view might be defined with a join, which is a collection of related columns or rows in multiple tables. However, the view hides the fact that this information actually originates from several tables. to simplify commands for the user
For example, views allow users to select information from multiple tables without actually knowing how to perform a join. to present the data in a different perspective from that of the base table
For example, the columns of a view can be renamed without affecting the tables on which the view is based. to isolate applications from changes in definitions of base tables
For example, if a view's defining query references three columns of a four column table and a fifth column is added to the table, the view's definition is not affected and all applications using the view are not affected. to express a query that cannot be expressed without using a view
For example, a view can be defined that joins a GROUP BY view with a table, or a view can be defined that joins a UNION view with a table. to save complex queries
For example, a query could perform extensive calculations with table information. By saving this query as a view, the calculations can be performed each time the view is queried.
select * from 视图 where ifcom=1;