Hbase shell操作表


啟動hbase shell

./bin/hbase shell

1、創建表,查看表

create 'tableName', 'familykey1','familykey2',....
   eg.
     create 'student','info','course'
list #查看表

2、查看表信息

    desc 'student'

3、 修改表結構

alter 'student',{'NAME'=>'course','VERSIONS'=>'3'}

4、insert數據到表中

table-->student  rowkey-->201601  familykey:column-->info:name  4:timestamp
    put 'tableName' ,'rowkey','familykey:column' ,'columnValue',timestamp    
    
    eg.
        put 'student','201601','info:name','liu',4
        put 'student','201601','info:age',15
        put 'student','201601','info:sex','nv'
        put 'student','201601','info:dept','PE'

5、獲取數據

get 'tableName','rowkey'
    
    eg.
        get 'student','201601'  #獲取student表中rowkey為201601的所有列族數據
        get 'student','201601','info:name'  #獲取student表中rowkey為201601且info列族中name的值

6、更新數據(和插入數據一樣,只是少了timestamp)

put 'tableName','rowkey','familykey:column' , 'columnValue'
    
eg.
   put 'student','201601','info:name','yangwj'

7、使用scan進行查詢

scan 'student',{COLUMN => 'info:dept'}  #查詢student表中所有列為info:dept的值
    
scan 'student',FILTER=>"RowFilter(=,'substring:2')"  ###?????

8、表的快照

   snapshot 'student','stu_snap'  #創建表的快照
    
    list_snapshots #顯示所有快照表
    
    clone_snapshot 'stu_snap','stu_info' #克隆快照從而生成新的表
    
    delete_snapshot 'stu_snap' #刪除快照

9、刪除表 (先禁用表再刪除)

   disable 'student'  #禁用表
    is_disabled 'student' #查看表是否被禁用 true:禁用
    drop 'student' #刪除表 

10、總結

 

完畢!

 

 


免責聲明!

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



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