In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to understand SQL Server database using views to deal with complex data query relationships, the content is very detailed, interested friends can refer to, hope to be helpful to you.
SQL Server database using views to deal with complex data query relationships is the main content of this article. The content is as follows: when I assisted the educational administration system, I made a page to query the workload of a single teacher and the whole college teacher. This operation was designed to include three tables in this database and a teacher information table in a different database. If you use ordinary SQL statements is very difficult to achieve, because I just started to do the video playback system, the database table comparison is less, does not involve such a complex processing relationship, it is very difficult at first.
Later, I thought that using view can solve the complex relationship of multiple tables, but whether the other table is in a different database can still be operated. After testing, it is possible to establish a view relationship between two tables in different databases, so that the view is a virtual table. We put together the tables in different databases or tables in the same database that need to be queried, and then select the required fields. Recreate a new virtual table, and then the view can be manipulated as a new table. This provides us with a lot of convenience.
A view is a continuation table, a table that is inverted from one or more tables or views, and its structure and data are based on queries against the table.
Advantages of views:
1. Views allow users to select specific data and or specific tasks, while unwanted or useless data can no longer be displayed in the view.
two。 The view greatly simplifies the operation of the database, and the operation of the table can be done through the view operation.
3. Views allow different users to see different or the same data sets in different ways, which is quite convenient.
4. In some cases, because the amount of data in the table is too large, the table is often divided horizontally or vertically in the design of the table, but the change in the structure of the table has a negative impact on the application, and the view can be used to reorganize the data. so that the external schema remains the same, and the original application can overload the data through the view.
5. The view provides a simple and effective security mechanism.
Disadvantages of the view:
If the view deals with a very large amount of data, it puts a lot of pressure on the sql database, and the execution speed is relatively slow, which is not as good as stored procedures, so if stored procedures can be used to implement them, stored procedures are preferred.
The main ways to create views are as follows:
1. Creating views with sql server Management platform
two。 Use the create view command in the Transact-sql statement to create a view
3. Create a view using the view template of the sql sever management platform
Be aware of when creating a view:
1. A view can only be created in the current database, and a maximum of 1024 cases can be referenced in the view. The number of records in the view is determined by the number of records in its base table.
two。 If the base table or view referenced by the view is deleted, the view can no longer be used until a new base table or view is created
3. If a column in the view is a function, a mathematical expression, a constant, or the same column name from multiple tables, you must define a name for the column.
4. You can no longer create an index on a view, and you can no longer reference a view in rules, defaults, or triggers
5. When querying data through a view, sql server checks to ensure that all database objects involved in the statement exist, that each database object is valid in the context of the statement, and that data modification statements cannot violate data integrity rules.
6. The name of the view must follow the rules of the identifier and must be unique to each user. In addition, the name must not have any table with the same name as the user. This is the created view, where TeacherInfo is added from another database.
On how to understand SQL Server database using views to deal with complex data query relationships is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
-- hbase shell filter-- create 'test1',' lf', 'sf'-- lf: column family of LONG values
© 2024 shulou.com SLNews company. All rights reserved.