MS SQL Basics Tutorial: Creating and Managing views

Source: Internet
Author: User

13.10.1 Create a View

SQL Server provides two ways to create a view using SQL Server Enterprise Manager and Transac-sql commands. When you create or use a view, you should note the following:

• Views can only be created in the current database, and can only be referenced in a view of 1024 columns;

• If the table referenced by the view is deleted, an error message is returned when the view is used, or you must re-create the view if you create a new structure with the same table to replace the deleted table view;

• If a column in the view is a function, a mathematical expression, a constant, or a column name from more than one table, you must define a name for the column;

• You cannot create an index on a view; You cannot refer to a view in a rule, default, or trigger definition;

• When querying data through a view, SQL SERVER not only checks whether the table referenced by the view exists, is valid, but also verifies that changes to the data violate the integrity constraints of the data. If the failure returns an error message, if it is correct, the query to the view is converted to a query to the referencing table.

1. Use SQL SERVER Enterprise Manager to create views

The steps for creating a view in SQL Server using SQL Server Enterprise Manager are:

(1) Start SQL Server Enterprise Manager and log on to the specified server;

(2) Open the database folder where you want to create the view, select the view icon, display all views of the current database in the right pane, right-click the icon, select the new View option in the pop-up menu, and open the New View dialog box. As shown in Figure 13-1. There are four areas in the new View dialog box: The table area, the column area SQL script area, the data result area (where the four areas in the dialog box are blank);

(3) When creating a view, first click on the button, open the Add Table dialog, as shown in Figure 13-2;

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.