Create an index view instance in phpmysql-PHP source code

Source: Internet
Author: User
Ec (2); Description: In the CREATEVIEW statement, the ANSI_NULLS and QUOTED_IDENTIFIER options must be set to ON. The OBJECTPROPERTY function reports this information table a through the ExecIsAnsiNullsOn or ExecIsQuotedIdentOn attribute for the view. The fields a1, a2, table B, field b1, b2 needs to get a view unionall two tables $ sqlCREATE script ec (2); script

Description:
When creating a VIEW statement, the ANSI_NULLS and QUOTED_IDENTIFIER options must be set to ON. The OBJECTPROPERTY function reports this information for the view through the ExecIsAnsiNullsOn or ExecIsQuotedIdentOn attribute.

Table a, field a1, a2
Table B, field b1, b2
You need to get a view to union all two tables.

$ SQL = 'create VIEW dbo. VIEW2
AS
SELECT * FROM
UNION ALL
(SELECT * FROM B )';

The preceding simple view creation does not have an index. Let's take a look at how to create an index view.

Creates a relational index for a specified table or view. You can create an index before entering data in the table. You can create a relational index for a table or view in another database by specifying a limited database tutorial name.
Syntax:

CREATE [UNIQUE] [CLUSTERED | NONCLUSTERED] INDEX index_name
ON(Column_name [ASC | DESC] [,... n])
[ [,... N]
[ON {filegroup_name | "default"}]

: =
{
[Database_name. [owner_name]. | owner_name.]
Table_or_view_name
}

: =
{
PAD_INDEX
| FILLFACTOR = fillfactor
| SORT_IN_TEMPDB
| IGNORE_DUP_KEY
| STATISTICS_NORECOMPUTE
| DROP_EXISTING
}


// -- Create a view
Create view v
With schemabinding
As
Select ID, name from dbo.
Go

// -- Create an index
Create unique clustered index v_index on v (ID)

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.