Data Center reconstruction-view and Data Center reconstruction

Source: Internet
Author: User

Data Center reconstruction-view and Data Center reconstruction

Views, stored procedures, triggers, and so on have long been heard, but they have never been really touched. They have been in a future State and cannot be escaped.

What happened to Data Center reconstruction? Keep this question. After reconstruction, make a summary.

View: in SQL, the basic unit of a level-1 Data Structure in external mode is view, which is a table constructed from several basic tables and (or) other views. It is actually a virtual table.

Note: When using a view, you should set the primary and Foreign keys of the joined table in advance.

In the data center charging system, when a student checks the balance, the two tables are used. The status and balance in the Card table are all from the student table.

View creation and deletion:

Method 1: use SQL statements to create a view

Create:

'Create VIEW <VIEW Name> (<list sequence>) AS <SELECT query statement> create view V_stuCard (CardNo, StudentNo, StudentName, Department, Grade, Class, Exlpain, Cstatuss, cash) as Select T_Student.StudentNo, T_Student. studentName, T_Student. department, T_Student. grade, T_Student. class, T_Student. explain, T_card.CardNo, T_card.Cash, T_Card. CStatus From T_Student, T_Card Where T_Student. cardNo = T_Card. cardNo
Delete:

'Delete: drop view <VIEW Name> drop view V_stuCard


Method 2: Right-click a view to create a view, which is relatively easy to use.

1. Create a view. Right-click the view to create a view.

2. Add the required table

3. Select a field after confirmation, and then check out the fields required for each table.

DeleteYes or you can right-click to delete it, which is convenient.

Write code at Layer D. the query statement is the same as the query table. You only need to change the table name to the view name. As shown above: "Select * from V_stuCard where CardNo = @ CardNo"

Why use a view? The view organically combines the data we need. If we need data in several tables, we have to query several tables to make our code heavy. Using the view not only reduces code, we can also write only one query statement.

Summary: I personally think that although method 2 is simple and easy to implement, it is recommended that you use SQL statements to create them. You should be familiar with the use of SQL statements.



The operation that cannot be completed on the view is () A updates View data B queries C defines A new basic table on the view D defines A new view on The View

The answer is C.

A view is a query window based on data tables. How can I create another data table in this query window?

Just like you can open a window in the house, but you cannot build a house in the window, right?

Which of the following statements about tables and views is incorrect?

I think we should select both ABCD.
Refer:
* Simplicity. What you see is what you need. A view not only simplifies users' understanding of data, but also simplifies their operations. Frequently Used queries can be defined as views, so that you do not have to specify all the conditions for each subsequent operation.
* Security. Users can only query and modify the data they can see through the view. Other data in the database is neither visible nor accessible. Database authorization commands allow each user to restrict the retrieval of a database to a specific database object, but cannot authorize the database to a specific row or column. Through views, users can be restricted to different subsets of data:

The permission can be restricted to a subset of rows in the base table.
The permission can be restricted to a subset of columns in the base table.
The permission can be restricted to the row and column subsets of the base table.
The permission can be restricted to the rows restricted by the connection of multiple base tables.
The permission can be restricted to the Statistical Summary of data in the base table.
The permission can be restricted to a subset of another view, or a subset of some views and merged base tables.

* Logical Data independence. View helps you avoid the impact of changes in the real table structure.

Ii. Advantages of views

(1) views can simplify user operations
(2) The view mechanism allows users to query the same data in different ways.
(3) views provide a certain degree of logical independence for database restructuring
(4) views can provide security protection for confidential data

Iii. view Security

View security prevents unauthorized users from viewing specific rows or columns. You can only view specific rows in the table as follows:

1. Add a column indicating the user name in the table;

2. Create a view. You can only see rows marked with your username;

3. Authorize the view to other users.

Iv. Logical Data independence

View can make applications and database tables independent to a certain extent. If there is no view, the application must be created on the table. With the view, the program can be built on the view, so that the program and the database table are separated by the view. The view can separate the program from the data in the following aspects:

1. If an application is created on a database table, you can create a view on the table when the database table changes. The view shields the changes in the table, so that the application can not move.

2. If an application is created on a database table and the application changes, you can create a view on the table to mask the application changes through the view so that the database table does not move.

3. If the application is built on a view, when the database table changes, you can modify the view on the table and use the view to shield the changes in the table so that the application can remain unchanged.

4. If an application is created on a view, you can modify the view on the table when the application changes. The view shields the application changes, so that the database does not move.

V. View writing format

Create view <VIEW Name> [(column name group)]
AS <subquery>

Drop view <index Name>

Note: views can be queried like basic tables. However, operations such as adding, deleting, and modifying data using views are limited.

(1) views exported from more than two basic tables
(2) View fields come from field expression Functions
(3) nested queries in view Definitions
(4) define a view on a view that cannot be updated... the remaining full text>

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.