hbase 基本的JavaApi 数据操作及数据过滤(filter)
本文主要是hbase的表操作、数据操作、数据查询过滤等,如果对JDBC或ADO有了解,容易理解HBASE API。
hbase版本是2.0。
1、为了方便先贴helper的部分代码(文末git上有完整的测试代码),主要是为了复用Connection。
- public class HBaseHelper implements Closeable {
- private Configuration configuration = null;
- private Connection connection = null;
- private Admin admin = null;
- private HBaseHelper(Configuration configuration) throws IOException {
- this.configuration = configuration;
- this.connection = ConnectionFactory.createConnection(this.configuration);
- admin = this.connection.getAdmin();
- }
- public static HBaseHelper getHBaseHelper(Configuration configuration) throws IOException {
- return new HBaseHelper(configuration);
- }
- @Override
- public void close() throws IOException {
- admin.close();
- connection.close();
- }
- public Connection getConnection() {
- return connection;
- }
- public Configuration getConfiguration() {
- return configuration;
- }
... ...
}
初始化,用来初始化hbase配置,连接hbase,获取本文中的hbase辅助操作类HbaseHelper。
- //初始化
- private void setUp() throws IOException{
- conf = HBaseConfiguration.create();
- conf.set("hbase.master","192.168.31.10");
- //The port the HBase Master should bind to.
- // conf.set("hbase.master.port","16000");
- //The port for the HBase Master web UI. Set to -1 if you do not want a UI instance run.
- // conf.set("hbase.master.info.port","16010");
- //The port the HBase RegionServer binds to.
- // conf.set("hbase.regionserver.port","16020");
- //The port for the HBase RegionServer web UI Set to -1 if you do not want the RegionServer UI to run.
- // conf.set("hbase.regionserver.info.port","16030");
- conf.set("hbase.zookeeper.quorum","192.168.31.10");
- //Property from ZooKeeper’s config zoo.cfg. The port at which the clients will connect.
- // HBase数据库使用的端口
- //conf.set("hbase.zookeeper.property.clientPort", "2181");
- //单机
- conf.set("hbase.rootdir","file:///opt/hbase_data");
- conf.set("hbase.zookeeper.property.dataDir","/opt/hbase_data/zookeeper");
- helper = HBaseHelper.getHBaseHelper(conf);
- }
2、命名空间、表创建、删除、exist等
- public void createNamespace(String namespace) {
- try {
- NamespaceDescriptor nd = NamespaceDescriptor.create(namespace).build();
- admin.createNamespace(nd);
- } catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- }
- }
- public void dropNamespace(String namespace, boolean force) {
- try {
- if (force) {
- TableName[] tableNames = admin.listTableNamesByNamespace(namespace);
- for (TableName name : tableNames) {
- admin.disableTable(name);
- admin.deleteTable(name);
- }
- }
- } catch (Exception e) {
- // ignore
- }
- try {
- admin.deleteNamespace(namespace);
- } catch (IOException e) {
- System.err.println("Error: " + e.getMessage());
- }
- }
- public boolean existsTable(String table)
- throws IOException {
- return existsTable(TableName.valueOf(table));
- }
- public boolean existsTable(TableName table)
- throws IOException {
- return admin.tableExists(table);
- }
- public void createTable(String table, String... colfams)
- throws IOException {
- createTable(TableName.valueOf(table), 1, null, colfams);
- }
- public void createTable(TableName table, String... colfams)
- throws IOException {
- createTable(table, 1, null, colfams);
- }
- public void createTable(String table, int maxVersions, String... colfams)
- throws IOException {
- createTable(TableName.valueOf(table), maxVersions, null, colfams);
- }
- public void createTable(TableName table, int maxVersions, String... colfams)
- throws IOException {
- createTable(table, maxVersions, null, colfams);
- }
- public void createTable(String table, byte[][] splitKeys, String... colfams)
- throws IOException {
- createTable(TableName.valueOf(table), 1, splitKeys, colfams);
- }
- public void createTable(TableName table, int maxVersions, byte[][] splitKeys,
- String... colfams)
- throws IOException {
- //表描述器构造器
- TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(table);
- //列族描述构造器
- ColumnFamilyDescriptorBuilder cfDescBuilder;
- //列族描述器
- ColumnFamilyDescriptor cfDesc;
- for (String cf : colfams) {
- cfDescBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(cf));
- cfDescBuilder.setMaxVersions(maxVersions);
- cfDesc = cfDescBuilder.build();
- tableDescriptorBuilder.setColumnFamily(cfDesc);
- }
- //获得表描述器
- TableDescriptor tableDescriptor = tableDescriptorBuilder.build();
- if (splitKeys != null) {
- admin.createTable(tableDescriptor, splitKeys);
- } else {
- admin.createTable(tableDescriptor);
- }
- }
//禁用表- public void disableTable(String table) throws IOException {
- disableTable(TableName.valueOf(table));
- }
- public void disableTable(TableName table) throws IOException {
- admin.disableTable(table);
- }
- public void dropTable(String table) throws IOException {
- dropTable(TableName.valueOf(table));
- }
//删除前,先禁用表- public void dropTable(TableName table) throws IOException {
- if (existsTable(table)) {
- if (admin.isTableEnabled(table)) disableTable(table);
- admin.deleteTable(table);
- }
- }
样例:
- //插入testtable表数据
- private void initTestTable() throws IOException{
- String tableNameString = "testtable";
- if(helper.existsTable(tableNameString)){
- helper.disableTable(tableNameString);
- helper.dropTable(tableNameString);
- }
- helper.createTable(tableNameString,"info","ex","memo");
- helper.put(tableNameString,"row1","info","username","admin");
- helper.put(tableNameString,"row1","ex","addr","北京大道");
- helper.put(tableNameString,"row1","memo","detail","超级用户,地址:北京大道");
- helper.put(tableNameString,"row2","info","username","guest");
- helper.put(tableNameString,"row2","ex","addr","全国各地");
- helper.put(tableNameString,"row2","memo","detail","游客,地址:全国到处都是");
- helper.close();
- }
2、插入(或是更新)数据
- public void put(String table, String row, String fam, String qual,
- String val) throws IOException {
- put(TableName.valueOf(table), row, fam, qual, val);
- }
- //插入或更新单行
- public void put(TableName table, String row, String fam, String qual,
- String val) throws IOException {
- Table tbl = connection.getTable(table);
- Put put = new Put(Bytes.toBytes(row));
- put.addColumn(Bytes.toBytes(fam), Bytes.toBytes(qual), Bytes.toBytes(val));
- tbl.put(put);
- tbl.close();
- }
- public void put(String table, String row, String fam, String qual, long ts,
- String val) throws IOException {
- put(TableName.valueOf(table), row, fam, qual, ts, val);
- }
- //带时间戳插入或更新单行
- public void put(TableName table, String row, String fam, String qual, long ts,
- String val) throws IOException {
- Table tbl = connection.getTable(table);
- Put put = new Put(Bytes.toBytes(row));
- put.addColumn(Bytes.toBytes(fam), Bytes.toBytes(qual), ts,
- Bytes.toBytes(val));
- tbl.put(put);
- tbl.close();
- }
- //插入或者更新一个rowKey数据,一个Put里有一个rowKey,可能有多个列族和列名
- public void put(String tableNameString, Put put) throws IOException {
- TableName tableName = TableName.valueOf(tableNameString);
- Table table = connection.getTable(tableName);
- if (put != null && put.size() > 0) {
- table.put(put);
- }
- table.close();
- }
2.1、批量插入,根据实际的业务来组装数据,最终就是利用API放入put列表
- //批量插入数据,list里每个map就是一条数据,并且按照rowKey columnFamily columnName columnValue放入map的key和value
- public void bulkInsert(String tableNameString, List<Map<String, Object>> list) throws IOException {
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- List<Put> puts = new ArrayList<Put>();
- if (list != null && list.size() > 0) {
- for (Map<String, Object> map : list) {
- Put put = new Put(Bytes.toBytes(map.get("rowKey").toString()));
- put.addColumn(Bytes.toBytes(map.get("columnFamily").toString()),
- Bytes.toBytes(map.get("columnName").toString()),
- Bytes.toBytes(map.get("columnValue").toString()));
- puts.add(put);
- }
- }
- table.put(puts);
- table.close();
- }
- //批量插入,外部组装put放入list
- public void bulkInsert2(String tableNameString, List<Put> puts) throws IOException {
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- if (puts != null && puts.size() > 0) {
- table.put(puts);
- }
- table.close();
- }
样例:
- //批量插入
- private void bulkInsertTestTable() throws IOException{
- String tableNameString = "testtable";
- if(!helper.existsTable(tableNameString)){
- helper.createTable(tableNameString,"info","ex","memo");
- }
- System.out.println(".........批量插入数据start.........");
- List<Map<String,Object>> mapList = new ArrayList<>();
- for(int i=1;i<201;i++){
- Map<String,Object> map = new HashMap<>();
- map.put("rowKey","testKey"+i);
- map.put("columnFamily","info");
- map.put("columnName","username");
- map.put("columnValue","guest"+i);
- map.put("rowKey","testKey"+i);
- map.put("columnFamily","ex");
- map.put("columnName","addr");
- map.put("columnValue","北京路"+i+"号");
- map.put("rowKey","testKey"+i);
- map.put("columnFamily","memo");
- map.put("columnName","detail");
- map.put("columnValue","联合国地球村北京路第"+i+"号");
- mapList.add(map);
- }
- helper.bulkInsert(tableNameString,mapList);
- System.out.println(".........批量插入数据end.........");
- }
- //批量插入2
- private void insertByRowKey(String table,String rowKey) throws IOException{
- Put put = new Put(Bytes.toBytes(rowKey));
- String columnFamily ;
- String columnName ;
- String columnValue ;
- for(int i=0;i<10;i++){
- columnFamily = "info";
- columnName = "username"+i;
- columnValue = "user111";
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- columnFamily = "ex";
- columnName = "addr"+i;
- columnValue = "street 111";
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- columnFamily = "memo";
- columnName = "detail"+i;
- columnValue = "sssss zzz 111222 ";
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- }
- System.out.println("----> put size:"+put.size());
- helper.put(table,put);
- }
- private void bulkInsertTestTable2(String tableNameString) throws IOException{
- // String tableNameString = "testtable";
- if(!helper.existsTable(tableNameString)){
- helper.createTable(tableNameString,"info","ex","memo");
- }
- List<Put> puts = new ArrayList<>();
- for(int i=0;i<10;i++){
- String rowKey = "rowKey"+i;
- Put put = new Put(Bytes.toBytes(rowKey));
- String columnFamily = "info";
- String columnName = "username2";
- String columnValue = "user"+i;
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- columnFamily = "ex";
- columnName = "addr2";
- columnValue = "street "+i;
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- columnFamily = "memo";
- columnName = "detail2";
- columnValue = "aazzdd "+i;
- put.addColumn(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName),Bytes.toBytes(columnValue));
- System.out.println("put size:"+put.size());
- puts.add(put);
- }
- helper.bulkInsert2(tableNameString,puts);
- }
3、删除数据,由于hbase数据是三个维度的,所以删除数据有多种操作
- //根据rowKey删除所有行数据
- public void deleteByKey(String tableNameString,String rowKey) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Delete delete = new Delete(Bytes.toBytes(rowKey));
- table.delete(delete);
- table.close();
- }
- //根据rowKey和列族删除所有行数据
- public void deleteByKeyAndFamily(String tableNameString,String rowKey,String columnFamily) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Delete delete = new Delete(Bytes.toBytes(rowKey));
- delete.addFamily(Bytes.toBytes(columnFamily));
- table.delete(delete);
- table.close();
- }
- //根据rowKey、列族删除多个列的数据
- public void deleteByKeyAndFC(String tableNameString,String rowKey,
- String columnFamily,List<String> columnNames) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Delete delete = new Delete(Bytes.toBytes(rowKey));
- for(String columnName:columnNames){
- delete.addColumns(Bytes.toBytes(columnFamily),Bytes.toBytes(columnName));
- }
- table.delete(delete);
- table.close();
- }
4、基本的查询,唯一要注意的是cell里的value必须按位移和长度来取
- //根据rowkey,获取所有列族和列数据
- public List<Cell> getRowByKey(String tableNameString,String rowKey) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Get get = new Get(Bytes.toBytes(rowKey));
- Result result = table.get(get);
- // Cell[] cells = result.rawCells();
- List<Cell> list = result.listCells();
- table.close();
- return list;
- }
- //从Cell取Array要加上位移和长度,不然数据不正确
- public void dumpResult(Result result) {
- for (Cell cell : result.rawCells()) {
- System.out.println("Cell: " + cell +
- ", Value: " + Bytes.toString(cell.getValueArray(),
- cell.getValueOffset(), cell.getValueLength()));
- }
- }
5、过滤,这个是HBASE查询的重要部分
5.1、根据rowKey来过滤
- //根据rowKey过滤数据,rowKey可以使用正则表达式
- //返回rowKey和Cells的键值对
- public Map<String,List<Cell>> filterByRowKeyRegex(String tableNameString,String rowKey,CompareOperator operator) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Scan scan = new Scan();
- //使用正则
- RowFilter filter = new RowFilter(operator,new RegexStringComparator(rowKey));
- //包含子串匹配,不区分大小写。
- // RowFilter filter = new RowFilter(operator,new SubstringComparator(rowKey));
- scan.setFilter(filter);
- ResultScanner scanner = table.getScanner(scan);
- Map<String,List<Cell>> map = new HashMap<>();
- for(Result result:scanner){
- map.put(Bytes.toString(result.getRow()),result.listCells());
- }
- table.close();
- return map;
- }
5.2、根据列值、列值正则等方式过滤
- //根据列族,列名,列值(支持正则)查找数据
- //返回值:如果查询到值,会返回所有匹配的rowKey下的各列族、列名的所有数据(即使查询的时候这些列族和列名并不匹配)
- public Map<String,List<Cell>> filterByValueRegex(String tableNameString,String family,String colName,
- String value,CompareOperator operator) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- Scan scan = new Scan();
- //正则匹配
- SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes(family),
- Bytes.toBytes(colName),operator,new RegexStringComparator(value));
- //完全匹配
- // SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes(family),
- // Bytes.toBytes(colName),operator,Bytes.toBytes(value));
- //SingleColumnValueExcludeFilter排除列值
- //要过滤的列必须存在,如果不存在,那么这些列不存在的数据也会返回。如果不想让这些数据返回,设置setFilterIfMissing为true
- filter.setFilterIfMissing(true);
- scan.setFilter(filter);
- ResultScanner scanner = table.getScanner(scan);
- Map<String,List<Cell>> map = new HashMap<>();
- for(Result result:scanner){
- map.put(Bytes.toString(result.getRow()),result.listCells());
- }
- return map;
- }
5.3、根据列名前缀、列名正则、多个列名等过滤
- //根据列名前缀过滤数据
- public Map<String,List<Cell>> filterByColumnPrefix(String tableNameString,String prefix) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- //列名前缀匹配
- ColumnPrefixFilter filter = new ColumnPrefixFilter(Bytes.toBytes(prefix));
- //QualifierFilter 用于列名多样性匹配过滤
- // QualifierFilter filter = new QualifierFilter(CompareOperator.EQUAL,new SubstringComparator(prefix));
- //多个列名前缀匹配
- // MultipleColumnPrefixFilter multiFilter = new MultipleColumnPrefixFilter(new byte[][]{});
- Scan scan = new Scan();
- scan.setFilter(filter);
- ResultScanner scanner = table.getScanner(scan);
- Map<String,List<Cell>> map = new HashMap<>();
- for(Result result:scanner){
- map.put(Bytes.toString(result.getRow()),result.listCells());
- }
- return map;
- }
5.4、过滤器集合,多个过滤器同时按通过策略来过滤
- //根据列名范围以及列名前缀过滤数据
- public Map<String,List<Cell>> filterByPrefixAndRange(String tableNameString,String colPrefix,
- String minCol,String maxCol) throws IOException{
- Table table = connection.getTable(TableName.valueOf(tableNameString));
- //列名前缀匹配
- ColumnPrefixFilter filter = new ColumnPrefixFilter(Bytes.toBytes(colPrefix));
- //列名范围扫描,上下限范围包括
- ColumnRangeFilter rangeFilter = new ColumnRangeFilter(Bytes.toBytes(minCol),true,
- Bytes.toBytes(maxCol),true);
- FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
- filterList.addFilter(filter);
- filterList.addFilter(rangeFilter);
- Scan scan = new Scan();
- scan.setFilter(filterList);
- ResultScanner scanner = table.getScanner(scan);
- Map<String,List<Cell>> map = new HashMap<>();
- for(Result result:scanner){
- map.put(Bytes.toString(result.getRow()),result.listCells());
- }
- return map;
- }
6、过滤器介绍
6.1、比较操作,如等于、大于、小于
- public enum CompareOperator {
- // Keeps same names as the enums over in filter's CompareOp intentionally.
- // The convertion of operator to protobuf representation is via a name comparison.
- /** less than */
- LESS,
- /** less than or equal to */
- LESS_OR_EQUAL,
- /** equals */
- EQUAL,
- /** not equal */
- NOT_EQUAL,
- /** greater than or equal to */
- GREATER_OR_EQUAL,
- /** greater than */
- GREATER,
- /** no operation */
- NO_OP,
- }
6.2、比较器,主要是继承ByteArrayComparable的类
- RegexStringComparator 支持正则表达式的值比较
- Scan scan = new Scan();
- RegexStringComparator comp = new RegexStringComparator("you."); // 以 you 开头的字符串
- SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"), CompareOp.EQUAL, comp);
- scan.setFilter(filter);
- SubStringComparator 用于判断一个子串是否存在于值中,并且不区分大小写。
- Scan scan = new Scan();
- SubstringComparator comp = new SubstringComparator("substr"); // 查找包含的字符串
- SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"), CompareOp.EQUAL, comp);
- scan.setFilter(filter);
- BinaryComparator 二进制比较器,不用反序列化直接进行字节比较,比较高效。
- Scan scan = new Scan();
- BinaryComparator comp = new BinaryComparator(Bytes.toBytes("my hbase"));
- ValueFilter filter = new ValueFilter(CompareOp.EQUAL, comp);
- scan.setFilter(filter);
- BinaryPrefixComparator 前缀二进制比较器。只比较前缀是否相同。
- Scan scan = new Scan();
- BinaryPrefixComparator comp = new BinaryPrefixComparator(Bytes.toBytes("test")); //
- SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"), CompareOp.EQUAL, comp);
- scan.setFilter(filter);
注意:BitComparator、RegexStringComparator、SubStringComparator只能与EQUAL和NOT_EQUAL搭配使用,因为这些比较器的compareTo()方法匹配时返回0,不匹配的时候返回1,如果和LESS或GREATER搭配就会出错。
基于字符串的比较器比基于字节的比较器更慢,也更消耗资源。
6.3、过滤器,部分介绍
- 行键过滤器
- RowFilter 对某一行的过滤。
- Scan scan = new Scan();
- RowFilter filter = new RowFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("row1")));
- scan.setFilter(filter);
- 列族过滤器
- FamilyFilter 用于过滤列族(也可以在Scan 过程中通过设定某些列族来实现该功能)
- Scan scan = new Scan();
- FamilyFilter filter = new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("info"))); // 列族为 info
- scan.setFilter(filter);
- 列名过滤器
QualifierFilter 列名全匹配- Scan scan = new Scan();
- QualifierFilter filter = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("username"))); // 列名为 username
- scan.setFilter(filter);
- ColumnPrefixFilter 用于列名(Qualifier)前缀过滤,即包含某个前缀的所有列名。
- Scan scan = new Scan();
- ColumnPrefixFilter filter = new ColumnPrefixFilter(Bytes.toBytes("addr")); // 前缀为 addr
- scan.setFilter(filter);
- MultipleColumnPrefixFilter
- MultipleColumnPrefixFilter 与 ColumnPrefixFilter 的行为类似,但可以指定多个列名(Qualifier)前缀。
- Scan scan = new Scan();
- byte[][] prefixes = new byte[][]{Bytes.toBytes("my-prefix-1"), Bytes.toBytes("my-prefix-2")};
- MultipleColumnPrefixFilter filter = new MultipleColumnPrefixFilter(prefixes); 、
- scan.setFilter(filter);
- ColumnRangeFilter 列名范围过滤器可以进行高效的列名内部扫描。关键字:已排序
- Scan scan = new Scan();
- ColumnRangeFilter filter = new ColumnRangeFilter(Bytes.toBytes("minColumn"), true, Bytes.toBytes("maxColumn"), false);
- scan.setFilter(filter);
- DependentColumnFilter 尝试找到该列所在的每一行,并返回该行具有相同时间戳的全部键值对。
- Scan scan = new Scan();
- DependentColumnFilter filter = new DependentColumnFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"));
- scan.setFilter(filter);
- 列值过滤器
- SingleColumnValueFilter 列值比较
- 列族 info 下的列 username的列值和字符串 "admin" 相等的数据 :
- Scan scan = new Scan();
- SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("username"), CompareOp.EQUAL, Bytes.toBytes("admin"));
- scan.setFilter(filter);
6.4、代码:
https://github.com/asker124143222/hbaseHello
https://github.com/asker124143222/hbaseDemo
hbase 基本的JavaApi 数据操作及数据过滤(filter)的更多相关文章
- for循环中进行联网请求数据、for循环中进行异步数据操作,数据排序错乱问题解决;
for循环中进行联网请求数据,由于网络请求是异步的,第一个网络请求还没有回调,第二次第三次以及后续的网络请求又已经发出去了,有可能后续的网络请求会先回调:这时我们接收到的数据的排序就会错乱:怎么才能让 ...
- MySQL的数据库,数据表,数据的操作
数据库简介 概念 什么是数据库?简单来说,数据库就是存储数据的"仓库", 但是,光有数据还不行,还要管理数据的工具,我们称之为数据库管理系统! 数据库系统 = 数据库管理系统 + ...
- coreData数据操作
// 1. 建立模型文件// 2. 建立CoreDataStack// 3. 设置AppDelegate 接着 // // CoreDataStack.swift // CoreDataStackDe ...
- SQL语言-----数据操作
数据操作 增加数据,insert into 标准格式 insert into 表名 (字段的列表)value(数据列表): 使用set insert into 表名 set 字段1=值,2.....: ...
- MySQL表操作及数据操作
表操作 表相当于一个文件,其形式与现实中的表格相同.表中的每条记录都有相应的字段,字段就类似于表格的表头. 表操作详细: #对表进行操作(文件) #首先要切换到指定库(即文件夹)下:use db1; ...
- JAVA IO操作:数据操作流:DataOutputStream和DataInputStream
掌握DataOutputStream和DataInputStream的作用. 可以使用DataOutputStream和DataInputStream写入和读取数据. 在IO包中提供了两个与平台无关的 ...
- 笔记-mongodb数据操作
笔记-mongodb数据操作 1. 数据操作 1.1. 插入 db.COLLECTION_NAME.insert(document) 案例: db.inventory.insertOn ...
- 使用Hive或Impala执行SQL语句,对存储在HBase中的数据操作
CSSDesk body { background-color: #2574b0; } /*! zybuluo */ article,aside,details,figcaption,figure,f ...
- HBase伪分布式安装(HDFS)+ZooKeeper安装+HBase数据操作+HBase架构体系
HBase1.2.2伪分布式安装(HDFS)+ZooKeeper-3.4.8安装配置+HBase表和数据操作+HBase的架构体系+单例安装,记录了在Ubuntu下对HBase1.2.2的实践操作,H ...
随机推荐
- 1071: [SCOI2007]组队
1071: [SCOI2007]组队 https://lydsy.com/JudgeOnline/problem.php?id=1071 分析: dp+单调性. A*(hi–minH)+B*(si–m ...
- ELKStack入门篇(五)之实用架构解析
(1)用户通过nginx或haproxy访问ELK日志统计平台,IP地址为keepalived的vip地址. (2)nginx将请求转发到kibana (3)kibana到elasticsearch获 ...
- tidb测试环境安装,离线部署
1.环境以及规划 机器:centos7.5 ; 文件系统为ext4:内存16g:cpu8核,共三个节点: ip hostname roles --- tidb tipd tikv --- tidb t ...
- JS的发布订阅模式
JS的发布订阅模式 这里要说明一下什么是发布-订阅模式 发布-订阅模式里面包含了三个模块,发布者,订阅者和处理中心.这里处理中心相当于报刊办事大厅.发布者相当与某个杂志负责人,他来中心这注册一个的杂志 ...
- dsp6657的helloworld例程测试-第一篇
环境搭建可以参考http://blog.sina.com.cn/s/blog_ed2e19900102xi2j.html 1. 先从mcsdk导入工程,helloworld例程 2. 提示有错误,估计 ...
- Vue视图
1. 基本模板语法 1.1 插值 文本 数据绑定最常见的形式就是使用“Mustache”语法 (双大括号) 的文本插值 v-text 指令也可以用于数据绑定,如果要更新部分的 textContent ...
- SOAPUI参数中xml中CDATA包含问题
<![CDATA[ <Request> <CardNo>000002629518</CardNo> <SecrityNo/> <BankTr ...
- linux下,将一个目录中的图片文件合成为gif图片
# {} 为文件所在目录位置 # {} 为gif图片位置 convert -delay -depth -layers optimize -quality -loop {} {}
- PHP基础知识试题
转载于:http://www.php.cn/toutiao-415599.html 1.PHP中传值与传引用的区别,什么时候传值,什么时候传引用? 按值传递:函数范围内对值任何改变在函数外部都会被忽略 ...
- JavaScript 中函数的参数
functionName(parameter1, parameter2, parameter3) { // 要执行的代码…… } 参数规则 JavaScript 函数定义时形参没有指定数据类型. Ja ...