如何检查一个表是否存在于Hive中? [英] How to check if a table exists in Hive?

查看:1680
本文介绍了如何检查一个表是否存在于Hive中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过.NET应用程序的ODBC驱动程序连接到Hive。是否有查询来确定表是否已经存在?



例如,在MSSQL中,您可以查询 INFORMATION_SCHEMA 表和Netezza中,您可以查询 _v_table 表。



任何帮助将不胜感激。

解决方案

有两种方法可以检查:

1。) @dimamah建议,只需在这里添加一点,对于这种方法,您需要

  1.1)启动** hiveserver **在运行查询
1.2之前)必须运行两个查询
1.2.1)USE< database_name>
1.2.2)SHOW TABLES LIKE'table_name'
1.2.3)然后使用Result set检查结果。



<2>)。第二种方法是使用HiveMetastoreClient APIs,在这里你可以直接使用API​​来检查是否 table_name 存在于特定的数据库中或不存在。



如需进一步的帮助,请通过生效11


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.

解决方案

There are two approaches by which you can check that:

1.) As @dimamah suggested, just to add one point here, for this approach you need to

 1.1) start the **hiveserver** before running the query
 1.2) you have to run two queries
      1.2.1) USE <database_name>
      1.2.2) SHOW TABLES LIKE 'table_name'
      1.2.3) Then you check your result using Result set.

2.) Second approach is to use HiveMetastoreClient APIs, where you can directly use the APIs to check whether the table_name exist in a particular database or not.

For further help please go through this Hive 11

这篇关于如何检查一个表是否存在于Hive中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆