DROP TABLE
Odstraní tabulku a odebere adresář přidružený k tabulce ze systému souborů, pokud tabulka není EXTERNAL
tabulka. Pokud tabulka neexistuje, je vyvolána výjimka.
V případě externí tabulky jsou z databáze metastore odebrány pouze informace o přidružené metadatech.
Syntax
DROP TABLE [ IF EXISTS ] table_identifier
Parametr
POKUD EXISTUJE
Je-li tento parametr zadán, není vyvolána žádná výjimka, pokud tabulka neexistuje.
table_identifier
[database_name.] table_name
: Název tabulky, volitelně kvalifikovaný s názvem databáze.delta.`<path-to-table>`
: Umístění existující rozdílové tabulky.
Příklady
-- Assumes a table named `employeetable` exists.
DROP TABLE employeetable;
-- Assumes a table named `employeetable` exists in the `userdb` database
DROP TABLE userdb.employeetable;
-- Assumes a table named `employeetable` does not exist.
-- Throws exception
DROP TABLE employeetable;
Error: org.apache.spark.sql.AnalysisException: Table or view not found: employeetable;
(state=,code=0)
-- Assumes a table named `employeetable` does not exist,Try with IF EXISTS
-- this time it will not throw exception
DROP TABLE IF EXISTS employeetable;