first
Start the hbase shell client and enter the creation table:
1. Create the 'sutdent' table in HBase, as shown in the figure:
<1>Create a namespace, create a test namespace, and use the following describe command to view the detailed information of the created namespace. The specific command is as follows:
#1、创建命名空间
hbase(main):006:0> create_namespace 'test'
Took 0.8661 seconds
#2、查看所建立的命名空间的详细信息
hbase(main):009:0> describe_namespace 'test'
DESCRIPTION
{NAME => 'test'}
Quota is disabled
Took 1.1768 seconds
<2> Create a student table with 5 column families, including name, age, sex, id, and score. The specific commands are as follows:
#1、查看当前数据库中有哪些表
hbase(main):010:0> list
TABLE
0 row(s)
Took 0.0386 seconds
=> []
#2、创建表student5
hbase(main):023:0> create 'student5','info1','info2'
Created table student5
Took 2.5662 seconds
=> Hbase::Table - student5
#3、其数据内容如下:
hbase(main):025:0> put 'student5','rk01','info1:name','zhangsan'
Took 0.5119 seconds
hbase(main):026:0> put 'student5','rk01','info1:age','18'
Took 0.0185 seconds
hbase(main):027:0> put 'student5','rk01','info1:sex','man'
Took 0.0166 seconds
hbase(main):030:0> put 'student5','rk01','info2:id','11111'
Took 0.0918 seconds
hbase(main):031:0> put 'student5','rk01','info2:score','90'
Took 0.0137 seconds
#4、查看表信息:
hbase(main):033:0> scan 'student5'
ROW COLUMN+CELL
rk01 column=info1:age, timestamp=1681358763438, value=18
rk01 column=info1:name, timestamp=1681358735922, value=zhangsan
rk01 column=info1:sex, timestamp=1681358779985, value=man
rk01 column=info2:id, timestamp=1681359019121, value=11111
rk01 column=info2:score, timestamp=1681359031401, value=90
1 row(s)
Took 0.3260 seconds
2. Insert at least two pieces of data into the table (zhangsan, 18, man, 11111, 90)
#插入第一条数据
hbase(main):025:0> put 'student5','rk01','info1:name','zhangsan'
Took 0.5119 seconds
hbase(main):026:0> put 'student5','rk01','info1:age','18'
Took 0.0185 seconds
hbase(main):027:0> put 'student5','rk01','info1:sex','man'
Took 0.0166 seconds
hbase(main):030:0> put 'student5','rk01','info2:id','11111'
Took 0.0918 seconds
hbase(main):031:0> put 'student5','rk01','info2:score','90'
Took 0.0137 seconds
#插入第二条数据
hbase(main):020:0> put 'student5','rk02','info1:name','zhhuan'
Took 0.4455 seconds
hbase(main):021:0> put 'student5','rk02','info1:age','22'
Took 0.0158 seconds
hbase(main):022:0> put 'student5','rk02','info1:sex','woman'
Took 0.0163 seconds
hbase(main):023:0> put 'student5','rk02','info2:id','11112'
Took 0.0212 seconds
hbase(main):024:0> put 'student5','rk02','info2:score','90'
Took 0.0378 seconds
#插入第三条数据:
hbase(main):028:0> put 'student5','rk03','info1:name','zhjie'
Took 0.1387 seconds
hbase(main):029:0> put 'student5','rk03','info1:age','30'
Took 0.0198 seconds
hbase(main):031:0> put 'student5','rk03','info2:id','11113'
Took 0.0223 seconds
hbase(main):032:0> put 'student5','rk03','info1:sex','man'
Took 0.0303 seconds
hbase(main):034:0> put 'student5','rk03','info2:score','93'
Took 0.0146 seconds
3. Modify the gender of the name zhangsan to woman
#修改
hbase(main):046:0> put 'student5','rk01','info1:sex','woman'
Took 0.0497 seconds
#查询修改结果
4. Query all the names of women whose gender is female
hbase(main):003:0> scan 'student5',{FILTER=>"SingleColumnValueFilter('info1':'sex',=,'binary:woman') AND QualifierFilter(=,'binary:name') ",FORMATTER => 'toString'}
ROW COLUMN+CELL
rk01 column=info1:name, timestamp=1682042269553, value=zhangsan
rk02 column=info1:name, timestamp=1682041446301, value=zhhuan
2 row(s)
Took 0.6609 seconds
5. Delete the data whose name is Zhang San
#删除数据
hbase(main):017:0> deleteall 'student5','zhangsan'
Took 0.1570 seconds