Deleting a table

Deleting a table is performed in 2 steps internally:

  1. Table is cleared (similar to TRUNCATE)
  2. All table files are removed from the table folder. All the external table files that were used by the table (such as wordforms, extensions or stopwords) are also deleted. Note that these external files are copied to the table folder when CREATE TABLE is used, so the original files specified in CREATE TABLE will not be deleted.

Deleting a table is possible only when the server is running in the RT mode. It is possible to delete RT tables, PQ tables and distributed tables.

โ€นโ€บ
  • SQL
  • JSON
  • PHP
  • Python
  • javascript
  • Java
  • C#
๐Ÿ“‹
DROP TABLE products;
โ€นโ€บ
Response
Query OK, 0 rows affected (0.02 sec)

Here is the syntax of the DROP TABLE statement in SQL:

DROP TABLE [IF EXISTS] table_name

When deleting a table via SQL, adding IF EXISTS can be used to delete the table only if it exists. If you try to delete a non-existing table with the IF EXISTS option, nothing happens.

When deleting a table via PHP, you can add an optional silent parameter which works the same as IF EXISTS.

โ€นโ€บ
  • SQL
  • JSON
  • PHP
  • Python
  • javascript
  • Java
  • C#
๐Ÿ“‹
DROP TABLE IF EXISTS products;
โ€นโ€บ
Response
{u'error': u'', u'total': 0, u'warning': u''}