Hi, ALTER TABLE ... RENAME just renames table and its files leaving the location in the same database to save work and space. Other alternative is going to another database (which basically means another sub-directory of warehouse and create the table with CREATE TABLE <NEW> AS SELECT * from TABLE <SOURCEDB>.<OLD>.
It would be useful if Hive had ALTER TABLE RENAME LOCATION utility as well. HTH Dr Mich Talebzadeh LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>* http://talebzadehmich.wordpress.com On 13 March 2016 at 00:52, Marcin Tustin <mtus...@handybook.com> wrote: > I you wish to keep it in its current location consider creating an > external table. > > > On Saturday, March 12, 2016, Rex X <dnsr...@gmail.com> wrote: > >> Hi Mich, >> >> I am doing this, because I need to update an existing big hive table, >> which can be stored in any arbitrary customized location on hdfs. But when >> we do Alter Table Rename, Hive will automatically move the files to the >> subdirectory of the corresponding database, /user/hive/warehouse/test.db/ >> in your case. >> >> I want to keep its original location. >> >> >> >> >> >> >> On Sat, Mar 12, 2016 at 4:17 PM, Mich Talebzadeh < >> mich.talebza...@gmail.com> wrote: >> >>> I do not see much point in renaming a table from A to B but still >>> looking at files A for this table. What is the purpose of renaming the >>> table but having the same file system? >>> >>> hive> >>> *create table a (col1 int);*hive> >>> *show create table a;*CREATE TABLE `a`( >>> `col1` int) >>> ROW FORMAT SERDE >>> 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' >>> STORED AS INPUTFORMAT >>> 'org.apache.hadoop.mapred.TextInputFormat' >>> OUTPUTFORMAT >>> 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' >>> >>> *LOCATION* >>> * 'hdfs://rhes564:9000/user/hive/warehouse/test.db/a'* >>> >>> hive> >>> *alter table a rename to b;*hive> *show create table a;* >>> FAILED: SemanticException [Error 10001]: Table not found a >>> >>> hive> *show create table b;* >>> CREATE TABLE `b`( >>> `col1` int) >>> ROW FORMAT SERDE >>> 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' >>> STORED AS INPUTFORMAT >>> 'org.apache.hadoop.mapred.TextInputFormat' >>> OUTPUTFORMAT >>> 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' >>> >>> *LOCATION* >>> *'hdfs://rhes564:9000/user/hive/warehouse/test.db/b'* >>> >>> HTH >>> >>> Dr Mich Talebzadeh >>> >>> >>> >>> LinkedIn * >>> https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw >>> <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>* >>> >>> >>> >>> http://talebzadehmich.wordpress.com >>> >>> >>> >>> On 13 March 2016 at 00:01, Rex X <dnsr...@gmail.com> wrote: >>> >>>> Based on the Hive doc below: >>>> >>>> >>>> Rename Table >>>> >>>> *ALTER TABLE table_name RENAME TO new_table_name;* >>>> >>>> This statement lets you change the name of a table to a different name. >>>> >>>> *As of version 0.6, a rename on a managed table moves its HDFS location >>>> as well. (Older Hive versions just renamed the table in the metastore >>>> without moving the HDFS location.)* >>>> >>>> >>>> Is there any way to rename a table without changing the location? >>>> >>> >>> >> > Want to work at Handy? Check out our culture deck and open roles > <http://www.handy.com/careers> > Latest news <http://www.handy.com/press> at Handy > Handy just raised $50m > <http://venturebeat.com/2015/11/02/on-demand-home-service-handy-raises-50m-in-round-led-by-fidelity/> > led > by Fidelity > >