docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 3.4TutorialsDatabase Tutorial
Copyright © 2006, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com

     

Privileges
Building a Sample Database
The query() function
The big_query() function
Quoting
SQL Syntax
Conditions
Sorting
Limiting
Functions
Features Missing from MySQL
Insertion Syntax
The tablify Container
The Business Graphics Module
The emit and sqlquery Tags
Database Creation
Creating Tables
Indices
Dropping

Dropping

To delete indices, tables or databases, the DROP command is used in its variations:

To delete an index (where the CREATE INDEX syntax is used), the syntax is:

DROP INDEX name

To drop a table the syntax is:

DROP TABLE name

The table, its contents and definition will be deleted from the database irrevocably.

To drop a database altogether (where supported), you can use

DROP DATABASE name

The pike SQL-interface provides a specific-purpose function to drop a database: this is mainly for compatibility with MiniSQL where the operation of dropping a database is demanded to a specific-purpose API function, named drop_db.

Using SQL:

object db = Sql.sql("mysql://admin:pass@localhost");
mixed exception;
exception = catch {
  db->query("DROP DATABASE test");
};
if(exception)
{
  werror("Error while dropping the database: "+db->error()+"\n");
  throw(exception);
}

Using the API functions:

object db=Sql.sql("msql://admin:pass@localhost");
mixed exception;
exception=catch {
  db->drop_db("test");
};
if(exception)
{
  werror("Error while dropping the database: "+db->error()+"\n");
  throw(exception);
}

Notice that I haven't either tried to fetch results (there's no result to fetch anyways) and the exception handling has been very limited, and for diagnostic purposes only: these operations are really meant to be used only interactively.