View
1. What is a view?
A view is a virtual data table. The data records in the data table are obtained by a query statement.
2. Create a view Criterion
To create a view, consider the following guidelines:
# View names must follow the rules of identifiers. They must not be the same as the names of tables in the schema.
# You can create views for other views. Nested views are allowed, but no more than 32 layers can be nested. A view can have a maximum of 1024 fields.
# You cannot associate rules with default definitions in views.
# View query cannot contain the compute clause, compute by clause, or into keyword
# The query of the definition view cannot contain the order by clause, unless there is a top clause in the SELECT statement selection list
In the following cases, you must specify the name of each column in the View:
# How columns in a view are derived from arithmetic expressions, built-in functions, or constants
# Two or more columns in the view have the same name (usually because the view definition contains a join, two or more different columns have the same name)
# You want the column in the view to specify a name different from the original column (you can also rename the column in the view ). The View column inherits the Data Type of the original column no matter whether it is renamed or not.
3. Create a view
-- Create a view
If(Exists(Select*FromSYS. ObjectsWhereName ='V _ stu'))
Drop ViewV_stu
Go
Create ViewV_stu
As
SelectID, name, age, sexFromStudent;
4. Modify the view
Alter ViewV_stu
As
SelectID, name, sexFromStudent;
Alter ViewV_stu (No., name, gender)
As
SelectID, name, sexFromStudent
Go
Select*FromV_stu;
Select*FromInformation_schema.views;