I need to move a hive table from one database to another. How can I do that?
相关问题
-
hive: cast array
> into map - Find function in HIVE
- Hive Tez reducers are running super slow
- Set parquet snappy output file size is hive?
- Hive 'cannot alter table' error
相关文章
- 在hive sql里怎么把"2020-10-26T08:41:19.000Z"这个字符串转换成年月日
- SQL query Frequency Distribution matrix for produc
- Cloudera 5.6: Parquet does not support date. See H
- converting to timestamp with time zone failed on A
- Hive error: parseexception missing EOF
- ClassNotFoundException: org.apache.spark.SparkConf
- How to get previous day date in Hive
- Hive's hour() function returns 12 hour clock v
If the tables are partitioned, then basically you can copy partitioned data from old table to new table and delete old tables.
use new_db;
Create new table in new database:
Insert data in new tables from old tables using the command:
You can try - CTAS
https://issues.apache.org/jira/browse/HIVE-2496
that improvement is still open. I know that it's possible in Impala, not in Hive currently.
Development seems stalled. You can vote up for that issue on that page to bring some attention.
There are many methods given in answers but no guide on when to use what,
Use CTAS when your target is a Managed table:
If you just want to do it with a simple table name change, but the location of the table doesn't change:
Using CREATE LIKE and INSERT:
create external table new_db.table like old_db.table location '(path of file in hdfs file)';
if you have partition in table then you have to add partition in new_db.table.
This might be helpful to you.
Some sample statements would look like:
The below import commands imports to an external table instead of a managed one