1

I want to duplicate a table by changing the name of the duplicated table by adding today's date.

The date should be generated automatically (the day of the execution of the request)

Example :

Original Table Name = x

Duplicate Table Name = x_20221216 <-- today's date

UVB
  • 9
  • 4

1 Answers1

1

create table x_20221216 as select * from x

Kurt
  • 1,708
  • 1
  • 3
  • 11
  • Thank you but I want to generate the date automatically (the day of the execution of the request) – UVB Dec 16 '22 at 15:08
  • That is called "dynamic sql" and I'm not sure the best way to perform it in hive. Typically you would have a shell script or programming language build the sql statement as a string using whatever functions are available for date formatting, then you just execute that string on the dbms. – Kurt Dec 16 '22 at 22:34