Hive query to multiple db same table - hive

Lets say have multiple databases on hive, a table with same name exists in all the databases, is there a way to give wild characters ? for e.g in under ab1, ab2, ab3 databases a tables "t1" exists in all the 3 databases. can i run a extract query to get data from all the tables under all databases ?
I tried select * from ab*.t1; gives me an error

It's impossible to do with HIVE query!
Unless you want to do some scripting around.
You can use show databases like 'ab*' to retrieve list of databases and then manually build query, where you list all databases/tables.

Related

How to parameterize SELECT and FROM tables

I have a situation where I need to extract tables from one SQL database into another SQL database. There are about 100+ tables.
I would like to create a parameterized script for the SELECT and FROM tables so that the one script can be used to loop through all the tables.
Is this possible? I would really appreciate any assistance.

Impala Show Tables

I know in Impala (and other databases) I can run both of the following:
SHOW DATABASES
SHOW TABLES
I also know I can add optional LIKE or IN arguments e.g. to show me all the tables in database Bananas I could write:
SHOW TABLES IN Bananas
What I really want to know is a way of returning all the tables in the databases without having to recurse through (also showing database name and table name in separate fields.
I'll be running this via impala shell so I'd have to first return back all the database names and then produce a script line per database to give me the tables.
It's not a problem to do this as such, I just can't help wondering there must be a better way to end up with:
Unfortunately not yet. Impala will eventually support this by exposing tables for schema metadata (e.g. ANSI INFORMATION_SCHEMA), and IMPALA-1761 tracks that feature request.

Compare two tables with different schema in SQL Server

I have two tables in different databases with different schema, how can I compare them both?
Let's say I have the DB1 with the table history.Table1 and another DB2 with the same table but in a different schema, backup.Table1.
Now I need to compare what's different besides the schema name obviously.
Try SQL Compare from Redgate. They allow you to compare pretty much everything from the actual data to the schema.
I dont believe there is any native functionality in sqlserver.
Compare SQL Server schemas and deploy differences fast
Compare and deploy SQL Server database contents

is it possible to apply a query in hibernate which uses two databases?

I have two different databases (on same server) and i want to join tables across databases. I am using Hibernate, is it possible to create a query in hibernate which can join two tables in those databases?
Hibernate will create an SQL query for your HQL or Criteria query and this SQL will be sent through jdbc to the database. This means that hibernate does not support for what you are trying to do.
However, you can achieve the same result in some cases. Some databases give you the option to create an alias for a table that resides in a different database. So you will be able to write an SQL query that joins the two tables and execute it on the database.
We are doing that with DB2.
If you can do that, it depends on your database.
I guess, that it would impossible if you have two different databases (example DB2 and MySQL) but if both databases are of the same vendor, then maybe it's achievable.
You should try to find more info in you database server's documentation.

When querying tables/fields in Oracle database, how to see table schema in query results? (using SQuirreL SQL)

At my workplace we have a database with multiple schemas, and some table names may be repeated in different schemas. There are thousands of tables so it is not time-effective to wade through the entire list.
If I do a query where I want to find all the tables containing the word CUSTOMER in their names, for example:
select table_name from all_tables where table_name like '%CUSTOMER%' order by table_name
The results just look like this, with no clues of which schema the tables are located under.
TB_NEW_CUSTOMER
TB_NEW_CUSTOMER
TB_NEW_CUSTOMER
TB_VIP_CUSTOMER
TB_VIP_CUSTOMER
TB_VIP_CUSTOMER
Is there a way to query Oracle so that I know under which schemas the tables are located? We do not seem to have SQL+ because I got a 9000 error when trying the DESCRIBE command. I am tired of scrolling around the Objects tab in SQuirreL SQL!
Thank you very much.
Andy
Why wouldn't you also select the owner of those tables?