Difference between revisions of "DROP TABLE"

From Lianjapedia
Jump to: navigation, search
m (1 revision: SQL)
(Description)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Removes a table and all its data from the database
+
Removes a table (and all its data) or a virtualtable from the database
 
+
  
 
==Syntax==
 
==Syntax==
 
DROP TABLE [<database>!]&#060;table&#062; [NODELETE]
 
DROP TABLE [<database>!]&#060;table&#062; [NODELETE]
 
  
 
==See Also==
 
==See Also==
[[ADATABASES()]], [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[BACKUP DATABASE]], [[CLOSE DATABASES]], [[CLOSE TABLES]], [[COMPILE DATABASE]], [[COPY DATABASE]], [[CREATE DATABASE]], [[CREATE TABLE]], [[CREATE INDEX]], [[CREATE VIEW]], [[DATABASE()]], [[DB_DATADIR]], [[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]], [[RESTORE DATABASE]], [[SET AUTOCATALOG]], [[SET EXCLUSIVE]], [[SQL USE|USE]], [[ZAP]]
+
[[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]], [[SQL USE|USE]], [[ZAP]]
 
+
  
 
==Description==
 
==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.
 
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.
 
You must have ALTER privilege on the table to issue the DROP TABLE command.
  
 
+
{| class="wikitable" width="100%"
{| class="wikitable"
+
 
!Keywords||Description
 
!Keywords||Description
 
|-
 
|-
|valign="top"|database||The name of the database to which the table belongs.  Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database.  Operating System file protection can be applied individually to the files for added security.  The directory is a sub-directory of the Recital data directory.  The environment variable / symbol DB_DATADIR points to the current Recital data directory and can be queried using the GETENV() function.  Files from other directories can be added to the database using the ADD TABLE command or via the database catalog and SET AUTOCATALOG functionality.  The '!' character must be included between the database name and the table name.
+
|valign="top"|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.
 
|table||The name of the table to be dropped.
 
|-
 
|-
|NODELETE||Remove the table from the database, but do not physically delete the files
+
|valign="top"|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==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
DROP TABLE hr!staff
+
create database if not exists doc
</code>
+
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
  
==Products==
+
// database is closed, database is specified
Recital Server, Recital
+
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
 +
</code>
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
Line 42: Line 58:
 
[[Category:Commands]]
 
[[Category:Commands]]
 
[[Category:Databases]]
 
[[Category:Databases]]
[[Category:Databases Commands]]
 

Latest revision as of 05:51, 4 January 2021

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