Previous Topic

Next Topic

Dropping Indices

The DROP INDEX statement is used to delete a table index. The following example uses the DROP INDEX statement to drop the index idx_cust, on the table customer.

Example Dropping Indices


...
/* connect to a default database */
EXEC SQL CONNECT TO DEFAULT ;

/* drop the index idx_cust from the database */
EXEC SQL
     DROP INDEX idx_cust ON customer ;
if (sqlca.sqlcode)
{
    fprintf (stderr,
    "Drop index statement failed (%ld : %s) \n",
    sqlca.sqlcode, sqlca.sqlerrm);

EXEC SQL ROLLBACK WORK ;
    EXEC SQL DISCONNECT DEFAULT ;
    exit (1);
}

/* Commit changes */
EXEC SQL COMMIT WORK ;

printf ("Index dropped. \n");

/* Disconnect from the database */
EXEC SQL DISCONNECT DEFAULT ;
...