• hive之alter table


    Alter Table

    Most table properties can be altered with Alter Table statements, which change metadata about the table but not the data itself. These statements can be used to fix mistakes in schema, move partition locations and so on.

    1. Renamign a Table: hive> alter table log_messages rename to logmsgs;

    2. Adding, Modifying, and Dropping a Table Partition

        hive> alter table log_messages add if not exists

              > partition(year = 2013,month = 1,day = 1) location '/logs/2013/01/01'

              > partition(year = 2013,month = 1,day = 2) location '/logs/2013/01/02';

        hive> alter table log_messages partition(year = 2013, month = 2, day = 2)
              > set location '/hive/ourbucket/logs/2013/02/02';


        hive> alter table log_messages drop if exists partition(year = 2013, month = 2, day = 2);

       For managed tables, the data for the partition is deleted, along with the metadata, even if the partition was created using alter table ... add partition. For external tables, the data is not deleted.

        hive> alter table log_messages

              > change column hms hours_minutes_seconds int

              > comment 'hour minute second description'

              > after(first) description;

        hive> alter table log_messages add columns(

              > app_name string comment 'the name of Application',

              > session_id long comment 'the current session id');

        The following example removes all the existing columns and replaces them with the new columns specified:

        hive> alter table log_messages replace columns(

              > hours_mins_secs int comment '......',

              > severity string comment '......',

              > message string comment '......');

        Alter Table Properties:

        hive> alter table log_messages set tblproperties(

              > 'notes' = '.......');

        Alter Storage Properties

        Miscellaneous Alter Table Statements

  • 相关阅读:
    twitter分享问题(三)——Required oauth_verifier parameter not provided
    旋转数组的最小数字
    关系型数据库基础之:简单的数据查询
    twitter分享问题(一)——MISSING_ARG_APIKEY
    extern "C"的理解
    从一个链接错误探究GCC的链接库顺序
    GAE 博客——B3log Solo 0.4.0 正式版发布了!
    不使用资源文件动态创建对话框的做法
    GAE 博客——B3log Solo 0.4.0 正式版发布了!
    CodeBlocks启动多个进程实例的做法
  • 原文地址:https://www.cnblogs.com/likai198981/p/2983518.html
Copyright © 2020-2023  润新知