zoukankan      html  css  js  c++  java
  • [Hive_7] Hive 中的 DDL 操作


    0. 说明

      DDL(Data Definition Languages)语句:数据定义语言
      这些语句定义了不同的数据段、数据库、表、列、索引等数据库对象的定义。
      常用的语句关键字主要包括 create、drop、alter 等。


    1. create

      1.1 仅复制表结构

      创建user_par2,与user_par表结构一致,但是没有数据

      create table user_par2 like user_par; 

      1.2 复制表数据

      创建user_par2,与user_par完全一致,包括数据,但是分区会被变为字段

      create table user_par3 as select * from user_par; 




    2. drop

      2.1 删除分区

        alter table  user_par2 drop partition(province='sichaun');

    3. alter

    # 1.修改表名
        alter table wc rename to wc3;    
    
    # 2.添加列
        alter table customers add columns(wife string);
    
    # 3.删除列,不能用
        alter table customers drop column wife;
    
    # 4.替换所有列,修改字段名
        alter table customers replace columns(id int, name string, age int);
    
    # 5.将id列改名为no,类型为string
         alter table customers change column id no string;

  • 相关阅读:
    不能在注册表中识别出来python时的解决方法
    Biopython
    Biopython
    生信相关网站
    linux下的查找命令
    class
    不同版本的Eclipse安装SVN插件
    【如何快速的开发一个完整的iOS直播app】(原理篇)
    iOS 直播
    Ios-视频直播-知识点汇总-持续更新
  • 原文地址:https://www.cnblogs.com/share23/p/10225513.html
Copyright © 2011-2022 走看看