How to check if a table exists in Hive?

2019-03-24 13:47发布

I am connecting to Hive via an ODBC driver from a .NET application. Is there a query to determine if a table already exists?

For example, in MSSQL you can query the INFORMATION_SCHEMA table and in Netezza you can query the _v_table table.

Any assistance would be appreciated.

标签: sql odbc hive
7条回答
戒情不戒烟
2楼-- · 2019-03-24 14:13

When programming on Hive by Spark SQL, you can use following method to check whether Hive table exists.

if (hiveContext.hql("SHOW TABLES LIKE '" + tableName + "'").count() == 1) {
    println(tableName + " exists")
}
查看更多
登录 后发表回答