In this article we will learn how to create a table with same schema of another table.
We use like operator in Apache Hive to copy schema from another table.
Syntax is : create table [new-table-name] like [old-table-name];
Practise below steps to understand better.
1) Create a new table called employee in Hive using this article.
2) Check the schema of Hive tables employee using describe command.
describe employee;
3) Create a new table called employee_india with same column names and data types of employee table.
create table employee_india like employee;
4) Now check column names and their data types of table employee_india.
describe employee_india;
We can copy schema not only from existing table, but also from existing existing view. Systax is also same , we just have to replace old-tablename with view name.
We use like operator in Apache Hive to copy schema from another table.
Syntax is : create table [new-table-name] like [old-table-name];
Practise below steps to understand better.
1) Create a new table called employee in Hive using this article.
2) Check the schema of Hive tables employee using describe command.
describe employee;
3) Create a new table called employee_india with same column names and data types of employee table.
create table employee_india like employee;
4) Now check column names and their data types of table employee_india.
describe employee_india;
We can copy schema not only from existing table, but also from existing existing view. Systax is also same , we just have to replace old-tablename with view name.
Great Article Artificial Intelligence Projects
ReplyDeleteProject Center in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai
hi
ReplyDeleteIm new to bigdata,, im confused..how this works..loading data from local to hive then hdfs..can someone give me a link or explain the stages..please
ReplyDeleteHi, I'm getting the error
ReplyDeleteMetaException(message:The table must be stored using an ACID compliant format (such as ORC)
Is there any other way to duplicates table which follow lazy format?