Search This Blog

Creating a new Hive table with same schema of anothe Hive table.

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.

22 comments:

  1. Im 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

    ReplyDelete
  2. Hi, I'm getting the error

    MetaException(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?

    ReplyDelete
  3. Good article about hadoop technology You may like Updated content at Hadoop Quiz all about hadoop

    ReplyDelete