Application of the IDC Billing System View

Source: Internet
Author: User
I learned about the view in database learning and self-examination a year ago. At that time, I only learned the theory. This time I personally practiced it in the reconstruction of the data room charging system, which deepened my understanding of the view. Definition: from the outside of the database system, the view allows you to view data in the database from a specific perspective. From the perspective of the database system, the view is composed of SELECT statement groups.

I learned about the view in database learning and self-examination a year ago. At that time, I only learned the theory. This time I personally practiced it in the reconstruction of the data room charging system, which deepened my understanding of the view. Definition: from the outside of the database system, the view allows you to view data in the database from a specific perspective. From the perspective of the database system, the view is composed of SELECT statement groups.

I learned about the view in database learning and self-examination a year ago. At that time, I only learned the theory. This time I personally practiced it in the reconstruction of the data room charging system, which deepened my understanding of the view.

Definition:

From the outside of the database system, the view allows you to view data in the database from a specific perspective. Within the database system, the view is a virtual table defined by a query composed of SELECT statements, which does not exist in the database. For example, there are academic departments, security departments, and discipline departments in the higher-level training. These departments are the views, and the departments that need to be assigned a meeting should be notified. The employees in these departments are from different stages (basic tables), and each person is unique.

Operation:

Because the view only stores SQL Select statements, creating a view is actually writing Select statements.

1. Create a view:

CREATE VIEW <视图名> ( <列表序列> )

ASThe preceding figure shows how to directly create a view using a T_ SQL statement in the query analyzer. You can also create a view using a graphical method in the Enterprise Manager.2. View revocation:DROP VIEW3. view update:If a view is exported from a single basic table using only the selection and projection operations and contains the primary key of the basic table, such a view is called the "row and column subset View ", update operations (insert, modify, and delete) can be performed, but the phrase "with check option" must be added during definition.Application:In the charging system of the IDC room, you need to know the student's card number, the amount in the card, the time on and off the machine, and the rate. Check that the "card balance" is in T_Card, view "computer time" in T_StuRecord, you can use the view to put the required data together and combine it into a new table.Create this view in the query Analyzer:Create viewV_ManageOnlineAs select T_Card.cardNo, cash, loginTimeFrom T_Card, T_StuRecordWhere T_Card. cardNo = T_StuRecord. cardNo and T_StuRecord. logoutTime = nullAfter successful creation:There is basically no difference between using a view and a basic table in code:Public Function ManageDown () As DataTable Implements IManageUpStu. manageDown Dim strSQL As String = "select * from V_ManageOnline" Dim helper As New SqlHelper. sqlHelper Dim dt = helper. getDataTable (strSQL, CommandType. text) Return dt End FunctionFinally, let's talk about the benefits of using a view. It allows users to view and modify only some specific data they are concerned with. Other databases or tables are neither visible nor accessible, which improves the security of the database. When you need data from multiple tables, you do not need to query data from one table. You only need a simple View query statement. The view hides complex join operations between tables, greatly simplifying data operations. Although I heard about the view a year ago, I thought it was so easy now. This is the process of learning, step by step, layer by layer.

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.