Phoenix常用命令 操作hbase

1、登录命令
./sqlline.py localhost:2181:/hbase-unsecure

615800-20170820101755334-85512092.png


phoenix-sqlline localhost:2181:/hbase-unsecure

615800-20170820101854537-2120547098.png


2、退出

!quit

615800-20170820102015787-1949478196.png


!exit

615800-20170820102055662-207300675.png


3、帮助
 

615800-20170820102231834-1400422109.png



4、列出metadata信息
 

615800-20170820102517850-730665238.png



5、创建表

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

615800-20170820102726006-1626489840.png



6、查看当前库中存在的表
 !tables
 

615800-20170820102901490-1844828666.png



phoenix中的表信息都存在SYSTEM.CATALOG表中,也可以通过下面的sql语句查看系统的表信息
select * from SYSTEM.CATALOG;
  

615800-20170820103106068-588727772.png


注意:

  1. 如果不加双引号,会自动将小写转为大写
  2. phoenix表名区分大小写

7、删除表

drop table ljc.student;

615800-20170820103640646-1376449843.png



8、查看表结构

  !describe "METRIC_AGGREGATE"

615800-20170820103844068-474229884.png



注意: phoenix/hbase对表名、字段名都是大小写敏感,如果直接写小写字母,不加双引号,则默认会被转换成大写字母
9、插入、更新
  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');

615800-20170820104130771-1930713302.png



10、示例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');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值