create table

创建表

CREATE TABLE page_view(viewTime INT, userid BIGINT,
                page_url STRING, referrer_url STRING,
                ip STRING COMMENT'IP Address of the User')
COMMENT'This is the page view table'
PARTITIONED BY(dt STRING, country STRING)
STORED AS SEQUENCEFILE;



In this example the columns of the table are specified with the corresponding types. Comments can be attached both at the column level as well as at the table level. Additionally the partitioned by clause(条款) defines the partitioning columns which are different from the data columns and are actually not stored with the data.【附加的是通过条款来定义分区列和通过数据列进行分区是不一样的,它们是不会和数据一样存储下来的】 When specified in this way, the data in the files is assumed to be delimited(分隔符) with ASCII 001(ctrl-A) as the field delimiter(分隔符)and newline as the row delimiter.【以这种方式标志一个表的时候,数据块默认的是以ASCII 001即【ctrl+a】来分隔数据的,用新建一行(换行)来分割行的】
Sequencefile:是hdfs中的容器,用于对一些小文件的组织起来统一存储.......
Mapfile:是序列化的Sequencefile

It is also a good idea to bucket the tables on certain columns so that efficient sampling queries can be executed against the data set. If bucketing is absent, random sampling can still be done on the table but it is not efficient as the query has to scan all the data. The following example illustrates the case of the page_view table that is bucketed on the userid column:

CREATE TABLE page_view(viewTime INT, userid BIGINT,
                page_url STRING, referrer_url STRING,
                ip STRING COMMENT'IP Address of the User')
COMMENT'This is the page view table'
PARTITIONED BY(dt STRING, country STRING)
CLUSTERED BY(userid) SORTED BY(viewTime) INTO32BUCKETS
ROW FORMAT DELIMITED
        FIELDS TERMINATED BY'1'
        COLLECTION ITEMS TERMINATED BY'2'
        MAP KEYS TERMINATED BY'3'
STORED AS SEQUENCEFILE;

转载于:https://my.oschina.net/u/270950/blog/165292

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值