一、登陸命令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)