- SQL - Discussion
- SQL - Useful Resources
- SQL - Useful Functions
- SQL - Quick Guide
- SQL - Questions and Answers
- SQL - Datatype Functions
- SQL - Conversion Functions
- SQL - JSON Functions
- SQL - Cursor Functions
- SQL - Logical Functions
- SQL - Statistical Functions
- SQL - Text & Image Functions
- SQL - Numeric Functions
- SQL - Aggregate Functions
- SQL - String Functions
- SQL - Date Functions
- SQL - Database Tuning
- SQL - IN vs EXISTS
- SQL - Group By vs Order By
- SQL - Common Table Expression
- SQL - Cursors
- SQL - Date & Time
- SQL - Auto Increment
- SQL - Using Sequences
- SQL - Handling Duplicates
- SQL - Sub Queries
- SQL - Transactions
- SQL - NULL Values
- SQL - Stored Procedures
- SQL - Default Constraint
- SQL - Check Constraint
- SQL - Null Functions
- SQL - Min & Max
- SQL - Hosting
- SQL - Injection
- SQL - Comments
- SQL - Wildcards
- SQL - Non-Clustered Index
- SQL - Clustered Index
- SQL - Unique Index
- SQL - Primary Key
- - 工会诉Join
- SQL - Inner Join
- SQL - Using Joins
- SQL - Aliases
- SQL - EXCEPT Operator
- SQL - INTERSECT Operator
- SQL - UNION vs UNION ALL
- SQL - UNION Operator
- SQL - BETWEEN Operator
- SQL - NOT NULL
- SQL - IS NOT NULL
- SQL - IS NULL
- SQL - NOT EQUAL
- SQL - NOT Operator
- SQL - CASE
- SQL - EXISTS Operator
- SQL - ANY, ALL Operators
- SQL - IN Operator
- SQL - LIKE Operator
- SQL - BOOLEAN (BIT) Operator
- SQL - AND & OR
- SQL - Having Clause
- SQL - Group By Clause
- SQL - Order By Clause
- SQL - Distinct Clause
- SQL - Top Clause
- SQL - Where Clause
- SQL - Rename Views
- SQL - Drop Views
- SQL - Update Views
- SQL - Create Views
- SQL - Sorting Results
- SQL - Delete Query
- SQL - Update Query
- SQL - Insert Into Select
- SQL - Select Into
- SQL - Select Query
- SQL - Insert Query
- SQL - Constraints
- SQL - Delete Table
- SQL - Drop Table
- SQL - Alter Tables
- SQL - Temporary Tables
- SQL - Clone Tables
- SQL - Truncate Table
- SQL - Rename Table
- SQL - Show Tables
- SQL - Create Table
- SQL - Backup Database
- SQL - Show Database
- SQL - Rename Database
- SQL - Select Database
- SQL - Drop Database
- SQL - Create Database
- SQL - Expressions
- SQL - Operators
- SQL - Data Types
- SQL - Syntax
- SQL - Databases
- SQL - RDBMS Concepts
- SQL - Overview
- SQL - Home
5. 图瓦卢
- 页: 1
- 页: 1
- 结构-创建指数
- 页: 1
- 页: 1
- 页: 1
- SQL - Foreign Key
- 文 件
- ∗ E/CN.6/2009/1。
- 页: 1
- 页: 1
- 文 件
- 页: 1
- 页: 1
- 文 件
- 页: 1
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SQL - Create Index
What is SQL index?
质量指数是快速检索数据库数据的有效途径。 图表或观点索引可大大改进查询和申请业绩。 虽然指数有助于加速查询,但用户无法直接看到这些指数。
An SQL index is a special table that provides an efficient way to search larger tables enabpng faster retrieval of required data. When we try to retrieve data from multiple tables using joins, indexes help to improve the performance.
在处理小表格时通常不需要设定一个指数;但是,如果表中包含大量记录,指数将大大提高查询率。 随着数据量的增长,结构指数对于优化任何相关数据库管理系统的业绩至关重要。 页: 1 服务器支持可用于此目的的多种指数。
下表是:
Clustered Indexes
Non-Clustered Indexes
Unique Indexes
Filtered Indexes
Full-text Indexes
How to create SQL Index?
CREATE INDEX 报表用于在数据库中建立一个或一个以上栏目的索引。
Syntax
以下简称:CREATE INDEX> statement in --
CREATE INDEX index_name ON table_name (column_name1, column_name2,…column_nameN);
在这方面,
index_name This specifies the name of the index that you want to create.
table_name This specifies the name of the table on which you want to create the index.
(column_name1, column_name2,…column_nameN) are the names of one or more columns on which the index is being created.
Example
首先,让我们努力利用以下询问建立一个名为CUSTOMERS的表格:
SQL> CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR(15) NOT NULL, AGE INT NOT NULL, ADDRESS VARCHAR(25), SALARY DECIMAL(10, 4), PRIMARY KEY(ID)); );
让我们利用以下询问,将一些价值观列入上述表格:
SQL> INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (1, Ramesh , 32 , Ahmedabad , 2000); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (2, Khilan , 25 , Delhi , 1500); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (3, kaushik , 23 , Kota , 2000); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (4, Chaitap , 25 , Mumbai , 6500); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (5, Hardik , 27 , Bhopal , 8500); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (6, Komal , 22 , MP , 9000); INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (7, Muffy , 24 , Indore , 5500);
Once the table is created, let us create an index for the column named “NAME” in the CUSTOMERS table using the following query −
SQL> CREATE INDEX index_name on CUSTOMERS(NAME);
Output
当我们执行上述询问时,产出如下:
Commands completed successfully.
Verification
The stored procedure named sp_helpindex contains information about all the indexes created on a table or view. You can get the pst of the indexes created on the CUSTOMERS table using the following query.
在这方面, we are calpng the sp_helpindex procedure by passing the name of the desired table as the @objname.
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在你观察上述询问的结果时,你可以找到“NAME”栏以及索引表中的ID。
+----------------------------------+----------------------+------------------+ | index_name | index_description | index_keys | +----------------------------------+----------------------+------------------+ | index_name | nonclustered located | NAME | | | on PRIMARY | | | PK__CUSTOMER__3214EC27FBADB0A7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+----------------------+------------------+
Creating an index on Multiple Fields
我们还可使用国家清单数据表编制多个领域或表列索引。 为此,你刚刚需要将各栏的名称(需要编制索引)传递给询问。
Example
Instead of creating a new table, let us consider the previously created CUSTOMERS table. 在这方面, we are trying to create an index on the columns “NAME” and “AGE” using the following query −
SQL> CREATE INDEX mult_index_data on CUSTOMERS(NAME, AGE);
Output
当我们执行上述询问时,产出如下:
Commands completed successfully.
Verification
现在,让我们采用以下办法,列出在科罗塞罗群岛表格上建立的所有指数:
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在你观察上述调查结果时,你可以在指数表中找到“NAME”和“AGE”等栏目。
+----------------------------------+----------------------+--------------+ | index_name | index_description | index_keys | +----------------------------------+----------------------+--------------+ | mult_index_data | nonclustered located | NAME, AGE | | | on PRIMARY | | | PK__CUSTOMER__3214EC27FBADB0A7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+----------------------+--------------+Advertisements