phoenix常用命令


 1、登錄命令

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

    

  phoenix-sqlline localhost:2181:/hbase-unsecure

  

2、退出

  !quit

 

  !exit

 

3、幫助

 

4、列出metadata信息

  

5、創建表

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

  

6、查看當前庫中存在的表

 !tables

 

 phoenix中的表信息都存在SYSTEM.CATALOG表中,也可以通過下面的sql語句查看系統的表信息

 select * from SYSTEM.CATALOG;

  

  注意:

    1、如果不加雙引號,會自動將小寫轉為大寫

    2、phoenix表名區分大小寫

7、刪除表

  drop table ljc.student;

  

8、查看表結構

  !describe "METRIC_AGGREGATE"

  

  注意:

    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');

 

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');

 

如果,您認為閱讀這篇博客讓您有些收獲,不妨點擊一下右下角的【推薦】。
如果,您希望更容易地發現我的新博客,不妨點擊一下左下角的【關注我】。
如果,您對我的博客所講述的內容有興趣,請繼續關注我的后續博客,我是【劉超★ljc】。

本文版權歸作者,禁止轉載,否則保留追究法律責任的權利。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM