每周总结
【Table】表的操作命令
3.1增
1.已存在的表中新增列族
alter ‘stu2:student1’,’schoolinfo’
2.在命名空间中新建表
create ‘stu2:student1’,’baseinfo’
create ‘stu2:student2’,{NAME=>’baseinfo’},{NAME=>’schoolinfo’}
3.表中插入数据
put ‘stu2:student1’,’1001’,’baseinfo:sex’,’male’
put ‘stu2:student1’,’1001’,baseinfo:age’,’18’
put ‘stu2:student1,’1002’,’baseinfo:name’,’小红’
put ‘stu2:student1,’1002’,’baseinfo:sex’,’female’
put ‘stu2:student1,’1001’,baseinfo:age’,’20’
3.2删
1.删除命名空间:
drop_namespace ‘stu3’
2.删除表:删表之前必须先禁用表
disable ‘stu2:student’ 注:is_disabled命令查看表是否被禁用
关闭后要启用才能操作表 enable ‘stu2:student2’
drop ‘stu2:student’
3.删除某列族的全部数据
alter ‘ stu2:student3 ’, ‘delete’ => ‘ schoolinfo ’
4.删除某行的数据
deleteall ‘stu2:student3’,’1001 ’
5.删除某rowkey的某一列数据
delete ‘stu2:student2,’1001’,’schoolinfo:sex’
6.清空表数据
Disable ‘stu2:student2’需要先禁用 【启用表 enable ‘stu2:student2’】
Truncate ‘stu2:student2’
3.3改
更新指定字段的数据
put ‘stu2:student1’,’1001’,’baseinfo:name’,’小刚’
Put ‘stu2:student1,’1001’,’baseinfo:age’,’100’
3.4查
1.查看表结构
describe ‘stu2:student’
2.查看表数据
Scan ‘stu2:student’
3.根据条件查看表数据(关键字大写)
scan ‘stu2:student1’,{LIMIT=>1}
4.查看指定行或者指定列族:列的数据
get ‘stu2:student1’,’1001’
get ‘stu2:student1,’1001’,’baseinfo:name’
4.其他命令
1.统计表数据行数
Count ‘stu2:student1’
2.显示stu开头的表
List ‘stu.*’
3.变更表信息,将baseinfo列族中的数据存放3个版本
Alter ‘stu2:student1’,{NAME=>’schoolinfo’,VERSIONS=>3}
验证一下
Get ‘stu2:student1’,’1001’,{COLUMN=>’schoolinfo:schoolname’,VERSIONS=>3}
4.查看状态
Status
5.判断表是否存在
Exists ‘stu2:student’