Reputation: 11
I have table Employee in hive which is partitioned.
Now i want to copy all the contents from Employee
to another table without defining any schema like:
My first table is like:
create table Employee(Id String,FirstName String,Lastname String);
But i don't want to define the same schema for the NewEmployee
table:
create table Newemployee(Id String,FirstName String,LastName String);
Upvotes: 1
Views: 15840
Reputation: 41
You can also use below code:
Create table dbname.tablename LIKE existing_table_or_Viewname LOCATION hdfs-path
Upvotes: 1
Reputation: 9
CREATE TABLE NewEmployee [ROW FORMAT SERDE] (if any) [STORED AS] Format AS SELECT * FROM Employee [SORT BY];
Rules while create table as create 1. The target table cannot be a partitioned table. 2. The target table cannot be an external table. 3. The target table cannot be a list bucketing table.
Upvotes: 0
Reputation: 51
Since, you have not mentioned any partitioning details so I am assuming that it does not have any significance. Please correct me, if I am wrong.
The query that you are looking for would be like this:
create table Newemployee as select * from Employee;
Upvotes: 4