The use of views in SQL (simple views) is suitable for entry-level SQL views.

Source: Internet
Author: User

The use of views in SQL (simple views) is suitable for entry-level SQL views.

Creating a view can better call data from one database to another (for example, transferring data from database 209 to database 205)

Example: Database 209 has different database names: Database (ais20140426092531 membrane database) Supplier table (t_Supplier), Database (ais2014010992652 glue) Supplier table (T_Supplier)

Supplier table data: Primary Key (FItemID), supplier name (FName), etc.

Supplier table data: Primary Key (FItemID), supplier name (FName), etc.

Now we need to put the fields of the membrane library supplier table and the glue library supplier table in the library 209 to the 205 database, in this way, you can use the view to achieve the desired effect (the example may be non-standard, but it is approximate)

SELECT FItemID, FName, 'file' AS 'fdbname'
From kis. ais20140425092531.dbo. t_Supplier AS t_Supplier_1
UNION ALL
SELECT FItemID, FName, 'gum 'AS 'fdbname'
From kis. ais2014010992652.dbo. t_Supplier AS t_Supplier_1


What is the difference between the Visual View and the table in SQL?

I sorted out their differences and contacts, maybe not so detailed and complete. I hope it will be helpful to you!

Difference: 1. views are compiled SQL statements. The table is not
2. The view does not have actual physical records. But tables have.
3. The table is the content and the view is the window.
4. the table only uses physical space, while the view does not occupy physical space. The view only exists in the logic concept. The table can be modified in time. However, only statements can be created for the view.
5. The table adopts the internal mode and tries to use the external mode.
6. view is a way to view data tables. You can query data composed of certain fields in a data table, but only a set of SQL statements. In terms of security, a view can give users no access to data tables, so that they do not know the table structure.
7. A table is a table in global mode and a real table. A view is a table in local mode and a virtual table.
8. Creating and deleting a view only affects the view and does not affect the corresponding basic table.

Link: A view is a table created on top of a basic table. Its structure (that is, the defined column) and content (that is, all data rows) come from the basic table, it exists based on the basic table. A view can correspond to one basic table or multiple basic tables. A view is the abstraction of a basic table and the new relationship established in a logical sense.

How can I call a created view in SQL to obtain the query result?

Use the same as the table. Use select * from v_yourview
A table is a physical two-dimensional table.
The view is only a logical table, which does not exist physically. This table is generated based on your query every time you use it.

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.