咱們已經知道Trafodion中的表實際上是映射和存儲在HBase表中的, 本文經過一個簡單DEMO介紹一下Trafodion中建立的表是如何映射到HBase表。測試
1.建立Trafodion測試表並插入樣例數據編碼
SQL>create table mytable(a integer not null, b char(10), primary key (a)); --- SQL operation complete. SQL>insert into mytable values (1, 'abc'), (2, 'def'); --- 2 row(s) inserted. SQL>select * from mytable; A B ----------- ---------- 1 abc 2 def --- 2 row(s) selected. ---------------------
2.經過HBase Shell查詢前面建立的表code
hbase(main):002:0> scan 'TRAFODION.SEABASE.MYTABLE' ROW COLUMN+CELL \x80\x00\x00\x01 column=#1:\x01, timestamp=1475979256797, value=\x80\x00\x00\x01 \x80\x00\x00\x01 column=#1:\x02, timestamp=1475979256797, value=\x00abc \x80\x00\x00\x02 column=#1:\x01, timestamp=1475979256800, value=\x80\x00\x00\x02 \x80\x00\x00\x02 column=#1:\x02, timestamp=1475979256800, value=\x00def
3.經過上述結果,咱們能夠驗證如下結論排序
Trafodion中全部的原生HBase表都擁有相同的表結構,經過Trafodion訪問原生HBase表有兩種模式:ROW和CELL。io
下面經過一個例子簡單介紹如何經過Trafodion來訪問原生的HBase表。table
1.HBase Shell下建立測試表並插入一條記錄select
hbase(main):001:0> create 'nativetab','colfam1' 0 row(s) in 0.4610 seconds => Hbase::Table - nativetab hbase(main):002:0> put 'nativetab','row1','colfam1:col1', hbase(main):003:0* 'val1' 0 row(s) in 0.1370 seconds hbase(main):004:0> scan 'nativetab' ROW COLUMN+CELL row1 column=colfam1:col1, timestamp=1475892882126, value=val1 1 row(s) in 0.0270 seconds.
2.Trafodion CLI 經過CELL模式訪問上述表二進制
SQL>select * from hbase."_CELL_"."nativetab"; ROW_ID COL_FAMILY COL_NAME COL_TIMESTAMP COL_VALUE ---------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- -------------------- ----------------------------------------------------------------------------- row1 colfam1 col1 1475892882126 val1 --- 1 row(s) selected.
3.Trafodion CLI 經過ROW模式訪問上述表im
SQL>select * from hbase."_ROW_"."nativetab"; ROW_ID COLUMN_DETAILS ---------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- row1 colfam1:col1val1 --- 1 row(s) selected.
做者:Post_yuan,易鯨捷資深交付工程師。數據