Hypertable 的建表及插入

//建立一个简单的People的表
hypertable> create table People (age,gender,weight,height);

  Elapsed time:  0.15 s

//看看我们刚才建立成功的表

hypertable> describe table People
         -> ;
<Schema generation="1">
  <AccessGroup name="default">
    <ColumnFamily id="1">
      <Generation>1</Generation>
      <Name>age</Name>
      <deleted>false</deleted>
    </ColumnFamily>
    <ColumnFamily id="2">
      <Generation>1</Generation>
      <Name>gender</Name>
      <deleted>false</deleted>
    </ColumnFamily>
    <ColumnFamily id="3">
      <Generation>1</Generation>
      <Name>weight</Name>
      <deleted>false</deleted>
    </ColumnFamily>
    <ColumnFamily id="4">
      <Generation>1</Generation>
      <Name>height</Name>
      <deleted>false</deleted>
    </ColumnFamily>
  </AccessGroup>
</Schema>


  Elapsed time:  0.02 s


//插入
hypertable> insert into People values('2006-01-01 23:59:59',"com.test.www:tester",'age',"24");

  Elapsed time:  0.01 s
Avg value size:  2.00 bytes
   Total cells:  1
    Throughput:  173.25 cells/s
       Resends:  0
//查询

hypertable> select * from People where row = 'com.test.www:tester';
com.test.www:tester	age	24
com.test.www:tester	gender	man
com.test.www:tester	weight	190
com.test.www:tester	height	210

  Elapsed time:  0.00 s
Avg value size:  2.75 bytes
  Avg key size:  20.00 bytes
    Throughput:  155821.92 bytes/s
   Total cells:  4
    Throughput:  6849.32 cells/s


在Hypertable中,你必须在插入的时候,使用时间,以及行关键字.也就是说,在insert的时候,你只能插入一个列的值,而且还得插入时间信息和你的行关键字.在上面例子中的行关键字就是"com.test.www:tester",它表示了tester这样一个人,然后查询是关于这个人的所有信息.
你可以把行关键字直接写成tester也无所谓,只是个实体的标识符,而且是主键唯一的.

你可能感兴趣的:(table)