Previous Topic

Next Topic

Dropping Tables

The DROP TABLE statement deletes all data and indices for a table and erases its entry in the system catalog.

The following example uses the DROP TABLE statement to drop the table tmp_customer.

Example Dropping Tables


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

/* drop the table tmp_customer from the database */
EXEC SQL DROP TABLE tmp_customer ;
if (sqlca.sqlcode)  {
  fprintf (stderr,
  "Drop table 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 ("Table dropped. \n");

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