phoenix经常使用命令

 一、登陆命令sql

  ./sqlline.py localhost:2181:/hbase-unsecureui

    

  phoenix-sqlline localhost:2181:/hbase-unsecure

  

二、退出url

  !quitspa

 

  !exit3d

 

三、帮助code

 

四、列出metadata信息orm

  

五、建立表blog

  create table if not exists ljc.student(id integer primary key,name varchar(20));get

  

六、查看当前库中存在的表博客

 !tables

 

 phoenix中的表信息都存在SYSTEM.CATALOG表中,也能够经过下面的sql语句查看系统的表信息

 select * from SYSTEM.CATALOG;

  

  注意:

    一、若是不加双引号,会自动将小写转为大写

    二、phoenix表名区分大小写

七、删除表

  drop table ljc.student;

  

八、查看表结构

  !describe "METRIC_AGGREGATE"

  

  注意:

    phoenix/hbase对表名、字段名都是大小写敏感,若是直接写小写字母,不加双引号,则默认会被转换成大写字母

九、插入、更新

  Phoenix中不存在update的语法关键字,而是upsert ,功能上替代了Insert+update 

  upsert into ljc.student(id,name) values(1,'zhangsan');
    upsert into ljc.student(id,name) values(2,'lisi');
    upsert into ljc.student(id,name) values(3,'wangwu');
    upsert into ljc.student(id,name) values(4,'liuping');
    upsert into ljc.student(id,name) values(5,'zhouhong');

 

十、示例SQL

 create table if not exists ljc.student(id integer primary key,name varchar(20));
  upsert into ljc.student(id,name) values(1,'zhangsan');
  upsert into ljc.student(id,name) values(2,'lisi');
  upsert into ljc.student(id,name) values(3,'wangwu');
  upsert into ljc.student(id,name) values(4,'liuping');
  upsert into ljc.student(id,name) values(5,'zhouhong');
 
  create table if not exists ljc.score(id integer primary key,score integer);
  upsert into ljc.score(id,score) values(1,98);
  upsert into ljc.score(id,score) values(2,87);
  upsert into ljc.score(id,score) values(3,90);
  upsert into ljc.score(id,score) values(4,80);
  upsert into ljc.score(id,score) values(5,94);
 
  create table if not exists ljc.course(id integer primary key,course varchar(20));
  upsert into ljc.course(id,course) values(1,'yuwen');
  upsert into ljc.course(id,course) values(2,'shuxue');

 

若是,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】。
若是,您但愿更容易地发现个人新博客,不妨点击一下左下角的【关注我】。
若是,您对个人博客所讲述的内容有兴趣,请继续关注个人后续博客,我是【刘超★ljc】。

本文版权归做者,禁止转载,不然保留追究法律责任的权利。

相关文章
相关标签/搜索