Search code examples
sqldatabaseimpala

How to get the current database name in Impala? I actually googled a lot for this, but i didn't find anything related


I have a requirement to show the name of the TABLE NAME , DATABASE NAME and ROW COUNT of the given table using IMPALA, i am able to show the ROW COUNT and TABLE NAME using below query and got stuck in getting current database name,I actually googled a lot but i didn't find anything related. any one can help me in this?

select count(*) as rowcount,'table name' from table1
union
select count(*) as rowcount,'table name' from table2
union
select count(*) as rowcount,'table name' from table3
union
select count(*) as rowcount,'table name' from table4

Solution

  • From this https://issues.apache.org/jira/browse/IMPALA-675 , you can use select current_database() to get the database name.