zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    css font-family(字体样式)
    360浏览器兼容模式,页面不能正常渲染
    SVN 如何更换IP地址
    Update 出现在的问题
    安装node-sass
    vue 里面输出带标签的html
    css 内容超出宽度自动换行
    js 判断各种数据类型
    Java_面向对象三大特征
    Java_基础(二)
  • 原文地址:https://www.cnblogs.com/likai198981/p/2983518.html
Copyright © 2011-2022 走看看