- 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 - Drop index
Drop Index Statement
DROP> 表格用于删除或删除现有的数据库物体,如表格、索引、观点或程序。 每当我们使用DROP声明与数据库的任何物体一起时,它将永久清除这些物体及其相关数据。
因此,从数据库的表格中删除现有索引DROP INDEX。 使用了KQ指挥系统。 为了使用DROP INDEX指令,你需要具体说明你想要删除的特定指数的名称以及该指数与表格名称有关。 一旦你执行指挥,该指数就会从表上删除。
It is important to understand that dropping an index can have a significant impact on the performance of your database queries. Therefore, only try to remove an index if you are sure that it is no longer required.
Syntax
The syntax of the DROP INDEX 指挥——Q
DROP INDEX index_name ON table_name;
在这方面,
index_name is the name of the index that you want to drop.
table_name is the name of the table that the index is associated with.
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);
表格一经编制,让我们利用以下问询,在CUSTOMERS表中为“NAME”一栏编制索引。
SQL> CREATE INDEX INDEX_NAME on CUSTOMERS(NAME);
现在,让我们采用以下办法,列出在科罗塞罗群岛表格上建立的所有指数:
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在执行上述询问时,产出如下:
+----------------------------------+---------------------+------------------+ | index_name | index_description | index_keys | +----------------------------------+---------------------+------------------+ | INDEX_NAME | nonclustered | NAME | | | located on PRIMARY | | | PK__CUSTOMER__3214EC27CB063BB7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+---------------------+------------------+
让我们在使用DROP INDEX的消费物价指数表中删除“NAME”栏。 指挥
SQL> DROP INDEX INDEX_NAME ON CUSTOMERS;
Output
如果我们收集和处理上述问题,结果如下:
Commands completed successfully.
Verification
Let’s verify whether the index for the column named “NAME” is dropped or not using the following query −
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在你观察上述询问的结果时,你可以发现,从指数清单中删除“NAME”栏。
+----------------------------------+---------------------+------------------+ | index_name | index_description | index_keys | +----------------------------------+---------------------+------------------+ | PK__CUSTOMER__3214EC27CB063BB7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+---------------------+------------------+
DROP INDEX with IF EXISTS
DROP INDEX FI EXISTS > 说明中只有在表格中存在指数时才会采用。 当你想要放弃指数时,这一说法特别有用,但你无法确定指数是否存在。
IF EXISTS 条款确保,如果存在指数,则该表只能删除。 如果该指数不存在,则该指数只是终止该表。
Syntax
The syntax of the DROP INDEX FI EXISTS :
DROP INDEX IF EXISTS index_name ON table_name;
在这方面,
index_name is the name of the index that you want to drop.
table_name is the name of the table that the index is associated with.
Example
采用先前编制的表格,让我们在表格中使用以下表格编制“NAME”栏索引:
SQL> CREATE INDEX INDEX_NAME on CUSTOMERS(NAME);
让我们利用以下问询,列出在消费物价指数表中制定的所有指数:
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在执行上述询问时,产出如下:
+----------------------------------+---------------------+------------------+ | index_name | index_description | index_keys | +----------------------------------+---------------------+------------------+ | INDEX_NAME | nonclustered | NAME | | | located on PRIMARY | | | PK__CUSTOMER__3214EC27CB063BB7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+---------------------+------------------+
在建立指数之后,让我们利用以下询问,在消费物价指数表中降低的指数:
SQL> DROP INDEX IF EXISTS INDEX_NAME ON CUSTOMERS;
Output
当我们执行上述询问时,产出如下:
Commands completed successfully.
Verification
Let’s verify whether the index for the “NAME” is dropped or not using the following query −
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在你观察上述调查结果时,你可以发现,从指数清单中删除“NAME”栏。
+----------------------------------+---------------------+------------------+ | index_name | index_description | index_keys | +----------------------------------+---------------------+------------------+ | PK__CUSTOMER__3214EC27CB063BB7 | clustered, unique, | ID | | | primary key located | | | | on PRIMARY | | +----------------------------------+---------------------+------------------+
Example
现在,让我们努力删除一个指数,该指数没有存在。
SQL> DROP INDEX IF EXISTS INDEX_NAME ON CUSTOMERS;
Output
There are no indexes that exist, so the above query simply terminates the statement without giving any error.
Commands completed successfully.
Removing indexes created by PRIMARY KEY or UNIQUE
The DROP INDEX statement is notates by PRIMaire KEY or UNI Request restrictions. 为了减少与这些制约因素有关的指数,我们需要使用ALTER TABLE DROPCONTRAINT指令。
Syntax
The syntax of the ALTER TABLE DROPCONTRAINT claim in - - kou
ALTER TABLE table_name DROP CONSTRAINT constraint_name;
在这方面,
table_name is the name of the table that contains the ‘PRIMARY KEY’ constraint.
constraint_name is the name of the ‘PRIMARY KEY’ constraint that you want to drop.
Example
采用以前编制的表格,让我们首先尝试采用以下方式列出表格上的所有索引:
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在执行上述询问时,产出如下:
+----------------------------------+------------------- -+------------------+ | index_name | index_description | index_keys | +----------------------------------+---------------------+------------------+ | PK__CUSTOMER__3214EC27CB063BB7 | nonclustered | ID | | | located on PRIMARY | | +----------------------------------+---------------------+------------------+
在这方面, the “PK__CUSTOMER__3214EC27CB063BB7” is the name of the PRIMARY KEY constraint that was created on the “ID” column of the CUSTOMERS table.
现在,请删除“当代关键因素”限制造成的指数。
SQL> ALTER TABLE customers DROP CONSTRAINT PK__CUSTOMER__3214EC27CB063BB7;
Output
当我们执行上述询问时,产出如下:
Commands completed successfully.
Verification
让我们核实它是否被删除或没有使用以下询问:
SQL> EXEC sys.sp_helpindex @objname = N CUSTOMERS ;
在你观察上述询问的结果时,你可以发现,由于指数清单是空的,它会回去一个错误。
The object CUSTOMERS does not have any indexes, or you do not have permissions.Advertisements