Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

SQL DROP INDEX

Drop Index

The SQL DROP INDEX drops an existing index from the database system. To execute this command you must be the owner of the index.

Syntax:

DROP INDEX <index name>;

Parameters:

Name Description
index_name Name of the index for the table.

Example: SQL DROP INDEX

Sample table: agents


The statement bellow will create an INDEX TABLE 'test_index':

CREATE INDEX test_index
ON agents (agent_code ASC);

If we want to remove the index table 'test_index' of the base table 'agents', the following SQL statement can be used :

DROP INDEX test_index;

Drop Index in MySQL, PostgreSQL, Oracle, SQL Server

Drop Index in MySQL [5.7]

In MySQL, DROP INDEX drops the index named from the table. This statement is mapped to an ALTER TABLE statement to drop the index.

Syntax:

DROP INDEX index_name ON tbl_name
    [algorithm_option | lock_option] ...

algorithm_option:
    ALGORITHM [=] {DEFAULT|INPLACE|COPY}

lock_option:
    LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}

Drop Index in PostgreSQL 9.3.13

DROP INDEX -- remove an index

Syntax:

DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

Drop Index in Oracle 11g

In Oracle, DROP INDEX statement is used to remove an index or domain index from the database.

Syntax:

DROP INDEX [ schema. ] index [ FORCE ]

Drop Index in SQL Server 2014

In SQL Server DROP INDEX Removes one or more relational, spatial, filtered, or XML indexes from the current database. You can drop a clustered index and move the resulting table to another filegroup or partition scheme in a single transaction by specifying the MOVE TO option.

Syntax:

-- SQL Server Syntax
DROP INDEX
  { <drop_relational_or_xml_or_spatial_index> [ ,...n ] 
  | <drop_backward_compatible_index> [ ,...n ]
  }
<drop_relational_or_xml_or_spatial_index> ::=
  index_name ON <object> 
  [ WITH ( <drop_clustered_index_option> [ ,...n ] ) ]
<drop_backward_compatible_index> ::=
  [ owner_name. ] table_or_view_name.index_name 
<object> ::=
  {
  [ database_name. [ schema_name ] . | schema_name. ] 
  table_or_view_name
  }
<drop_clustered_index_option> ::=
  {
  MAXDOP = max_degree_of_parallelism
  | ONLINE = { ON | OFF }
  | MOVE TO { partition_scheme_name ( column_name ) 
  | filegroup_name
  | "default" 
  }
  [ FILESTREAM_ON { partition_scheme_name 
  | filestream_filegroup_name 
  | "default" }]
  }

 

See Also : CREATE INDEX for information on creating an index.

Practice SQL Exercises

Want to improve the above article? Contribute your Notes/Comments/Examples through Disqus.

Previous: Alter Index
Next: SQL Drop



SQL: Tips of the Day

SQL Server SELECT into existing table.

INSERT INTO dbo.TABLETWO
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

This assumes there's only two columns in dbo.TABLETWO - you need to specify the columns otherwise:

INSERT INTO dbo.TABLETWO
  (col1, col2)
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

Database: SQL Server

Ref: https://bit.ly/3y6tpA3