MYSQL.drop_table

MYSQL.drop_table — deletes a table from the database.

Syntax

MYSQL.drop_table (tablename)

Arguments

tablename

A string naming the table.

Returns

On success, nil, or an error on failure.

Description

This method of the MYSQL class causes a table to be deleted from the database. All rows in the table will also be deleted. This method is equivalent to MYSQL.query("DROP TABLE tablename").

This method is defined in the Gamma library /usr/cogent/require/MySQLSupport.g. It is made available to a Gamma program with the statement: require("MySQLSupport");.

Example

This example is taken from Section 2.2, “Tutorial 2: create_pets.g”

...

  /* Remove any previously-created table called "pets"  This is essentially
     the same as issuing the command: mysql.query("DROP TABLE IF EXISTS pets");*/
  try mysql.drop_table ("pets"); catch;  

  /* Create the "pets" table, and add columns to it. */
  mysql.create_table("pets");

...

The try/catch statement allows the processor to continue even if there is an error.