manual/english/Deleting_a_table.md
Deleting a table is performed in 2 steps internally:
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.
<!-- intro -->DROP TABLE products;
Query OK, 0 rows affected (0.02 sec)
POST /cli -d "DROP TABLE products"
{
"total":0,
"error":"",
"warning":""
}
$params = [ 'table' => 'products' ];
$response = $client->indices()->drop($params);
Array
(
[total] => 0
[error] =>
[warning] =>
)
utilsApi.sql('DROP TABLE products')
{u'error': u'', u'total': 0, u'warning': u''}
await utilsApi.sql('DROP TABLE products')
{u'error': u'', u'total': 0, u'warning': u''}
res = await utilsApi.sql('DROP TABLE products');
{"total":0,"error":"","warning":""}
sqlresult = utilsApi.sql("DROP TABLE products", true);
{total=0, error=, warning=}
sqlresult = utilsApi.Sql("DROP TABLE products", true);
{total=0, error="", warning=""}
let sqlresult = utils_api.sql("DROP TABLE products", Some(true)).await;
{total=0, error="", warning=""}
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.
DROP TABLE IF EXISTS products;
POST /cli -d "DROP TABLE IF EXISTS products"
$params =
[
'table' => 'products',
'body' => ['silent' => true]
];
$client->indices()->drop($params);
utilsApi.sql('DROP TABLE IF EXISTS products')
{u'error': u'', u'total': 0, u'warning': u''}
await utilsApi.sql('DROP TABLE IF EXISTS products')
{u'error': u'', u'total': 0, u'warning': u''}
res = await utilsApi.sql('DROP TABLE IF EXISTS products');
{"total":0,"error":"","warning":""}
sqlresult = utilsApi.sql("DROP TABLE IF EXISTS products", true);
{total=0, error=, warning=}
sqlresult = utilsApi.Sql("DROP TABLE IF EXISTS products", true);
{total=0, error="", warning=""}
let sqlresult = utils_api.sql("DROP TABLE IF EXISTS products", Some(true)).await;
{total=0, error="", warning=""}