Sqlite 简明教程

SQLite - DROP Table

SQLite DROP TABLE 语句用于删除表定义及其相关的所有数据、索引、触发器、约束和权限规范。

SQLite DROP TABLE statement is used to remove a table definition and all associated data, indexes, triggers, constraints, and permission specifications for that table.

使用此命令时必须小心,因为一旦表被删除,表中所有可用的信息也将永远丢失。

You have to be careful while using this command because once a table is deleted then all the information available in the table would also be lost forever.

Syntax

以下是 DROP TABLE 语句的基本语法。您可以选择指定数据库名称以及表名称,如下所示:

Following is the basic syntax of DROP TABLE statement. You can optionally specify the database name along with table name as follows −

DROP TABLE database_name.table_name;

Example

让我们首先验证 COMPANY 表,然后我们将其从数据库中删除。

Let us first verify COMPANY table and then we will delete it from the database.

sqlite>.tables
COMPANY       test.COMPANY

这意味着 COMPANY 表在数据库中可用,因此让我们将其删除,如下所示:

This means COMPANY table is available in the database, so let us drop it as follows −

sqlite>DROP TABLE COMPANY;
sqlite>

现在,如果您尝试使用 .TABLES 命令,则您将不再找到 COMPANY 表。

Now, if you try .TABLES command, then you will not find COMPANY table anymore.

sqlite>.tables
sqlite>

它什么也没有显示,这意味着您的数据库中的表已成功删除。

It shows nothing which means the table from your database has been dropped successfully.