7

I see a table "test" in Impala when I do show tables;

I want to make a copy of the "test" table so that it is an exact duplicate, but named "test_copy". Is there a impala query I can execute to do this? If not, how can I do this?

Rolando
  • 58,640
  • 98
  • 266
  • 407

2 Answers2

14

You can use the "CREATE TABLE test_copy LIKE test" to create a table with the same metadata. Then you can use "INSERT INTO TABLE test_copy SELECT * FROM test" to copy the data.

Matt
  • 4,318
  • 1
  • 27
  • 28
9

You can do this by a single command: CREATE TABLE new_table AS (SELECT * FROM table);

Shahab Tajik
  • 91
  • 1
  • 1
  • 3
    While this will duplicate the data, it does not maintain the definition of a parent table and defaults to `STORED AS TEXTFILE`. – Aaron Bannin Oct 23 '18 at 22:54