DROP TABLE

From Lianjapedia
Jump to: navigation, search

Purpose

Removes a table (and all its data) or a virtualtable from the database

Syntax

DROP TABLE [<database>!]<table> [NODELETE]

See Also

ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, ALTER VIRTUALTABLE, CLOSE DATABASES, CLOSE TABLES, COMPILE DATABASE, COPY DATABASE, CREATE DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, CREATE VIRTUALTABLE, DATABASE(), DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY TABLES, DROP INDEX, DROP VIEW, ERASE, GETENV(), LIST DATABASE, LIST INDEXES, LIST TABLES, OPEN DATABASE, PACK DATABASE, REBUILD DATABASE, REINDEX DATABASE, SET AUTOCATALOG, SET EXCLUSIVE, USE, ZAP

Description

The DROP TABLE command removes a table and all its data from the database. When you drop the table, it removes the specified table and its associated index files and frees the disk space that the files occupied.

It is also used to remove a virtualtable from the database.

You must have ALTER privilege on the table to issue the DROP TABLE command.

Keywords Description
database The name of the database to which the table belongs. The '!' character must be included between the database name and the table name.
table The name of the table to be dropped.
NODELETE Remove the table from the database, but do not physically delete the files

Note that the database! prefix can be used whether the database is currently open or not (from v6.0).

Example

create database if not exists doc
open database doc
create table doc1 (field1 char(10))
create table doc2 (field1 char(10))
create table doc3 (field1 char(10))
dir
 
// database is open, database not specified
drop table doc1
close databases
 
// database is closed, database is specified
drop table doc!doc2
 
// database is open, database is specified
open database doc
drop table doc!doc3
close data
?
open database doc
dir
close databases