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

  • 相关阅读:
    CentOS安装配置
    扩展多线程应用程序 CLR 和 线程
    OEA体验 :元数据编写
    字符串的逆序之旅
    学习之响应式Web设计:Media Queries和Viewports
    Windows Azure Virtual Machine Role (4) 在VHD中安装需要的功能
    java开发web service快速入门(视频)
    淘宝技术发展(Java时代:脱胎换骨)
    Contoso 大学 使用 EF Code First 创建 MVC 应用
    负载均衡原理与实践详解 第三篇 服务器负载均衡的基本概念网络基础
  • 原文地址:https://www.cnblogs.com/likai198981/p/2983518.html
Copyright © 2011-2022 走看看