1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
mysql> show tables;
+
---------------------------+
| Tables_in_hive_yz_test |
+
---------------------------+
| BUCKETING_COLS |
| CDS |
| COLUMNS_V2 |
| DATABASE_PARAMS |
| DBS |
| DB_PRIVS |
| GLOBAL_PRIVS |
| IDXS |
| INDEX_PARAMS |
| NUCLEUS_TABLES |
| PARTITIONS |
| PARTITION_EVENTS |
| PARTITION_KEYS |
| PARTITION_KEY_VALS |
| PARTITION_PARAMS |
| PART_COL_PRIVS |
| PART_COL_STATS |
| PART_PRIVS |
| ROLES |
| ROLE_MAP |
| SDS |
| SD_PARAMS |
| SEQUENCE_TABLE |
| SERDES |
| SERDE_PARAMS |
| SKEWED_COL_NAMES |
| SKEWED_COL_VALUE_LOC_MAP |
| SKEWED_STRING_LIST |
| SKEWED_STRING_LIST_VALUES |
| SKEWED_VALUES |
| SORT_COLS |
| TABLE_PARAMS |
| TAB_COL_STATS |
| TBLS |
| TBL_COL_PRIVS |
| TBL_PRIVS |
| TYPES |
| TYPE_FIELDS |
| VERSION |
+
---------------------------+
39
rows
in
set
(0.00 sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
mysql>
desc
DBS;
+
-----------------+---------------+------+-----+---------+-------+
| Field | Type |
Null
|
Key
|
Default
| Extra |
+
-----------------+---------------+------+-----+---------+-------+
| DB_ID |
bigint
(20) |
NO
| PRI |
NULL
| |
|
DESC
|
varchar
(4000) | YES | |
NULL
| |
| DB_LOCATION_URI |
varchar
(4000) |
NO
| |
NULL
| |
|
NAME
|
varchar
(128) | YES | UNI |
NULL
| |
+
-----------------+---------------+------+-----+---------+-------+
例子:acorn_3g数据库的信息如下,表示该库ID为81,路径为hdfs://YZSJHL19-42.opi.com/warehouse.test/acorn_3g.db
mysql>
select
*
from
DBS
where
NAME
=
'acorn_3g'
;
+
-------+------+-------------------------------------------------------+----------+
| DB_ID |
DESC
| DB_LOCATION_URI |
NAME
|
+
-------+------+-------------------------------------------------------+----------+
| 81 |
NULL
| hdfs://YZSJHL19-42.opi.com/warehouse.test/acorn_3g.db | acorn_3g |
+
-------+------+-------------------------------------------------------+----------+
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
mysql>
select
*
from
TBLS
where
TBL_NAME=
'user_act'
and
DB_ID=81 \G
*************************** 1. row ***************************
TBL_ID: 41231
CREATE_TIME: 1366188055
DB_ID: 81
LAST_ACCESS_TIME: 0
OWNER: xianbing.liu
RETENTION: 0
SD_ID: 263311
TBL_NAME: user_act
TBL_TYPE: MANAGED_TABLE
VIEW_EXPANDED_TEXT:
NULL
VIEW_ORIGINAL_TEXT:
NULL
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
hdfs://YZSJHL19-42.opi.com/warehouse.test/acorn_3g.db/user_act
mysql>
select
*
from
SDS
where
SD_ID=263311 \G
*************************** 1. row ***************************
SD_ID: 263311
CD_ID: 263311
INPUT_FORMAT: org.apache.hadoop.mapred.TextInputFormat
IS_COMPRESSED:
LOCATION: hdfs://YZSJHL19-42.opi.com/warehouse.test/acorn_3g.db/user_act
NUM_BUCKETS: -1
OUTPUT_FORMAT: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
SERDE_ID: 263301
IS_STOREDASSUBDIRECTORIES:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
mysql>
desc
CDS;
+
-------+------------+------+-----+---------+-------+
| Field | Type |
Null
|
Key
|
Default
| Extra |
+
-------+------------+------+-----+---------+-------+
| CD_ID |
bigint
(20) |
NO
| PRI |
NULL
| |
+
-------+------------+------+-----+---------+-------+
1 row
in
set
(0.00 sec)
mysql>
select
*
FROM
CDS
where
CD_ID=263311;
+
--------+
| CD_ID |
+
--------+
| 263311 |
+
--------+
1 row
in
set
(0.00 sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
mysql>
select
*
from
COLUMNS_V2
where
CD_ID=263311
order
by
integer_idx;
+
--------+---------+---------------+-----------+-------------+
| CD_ID | COMMENT | COLUMN_NAME | TYPE_NAME | INTEGER_IDX |
+
--------+---------+---------------+-----------+-------------+
| 263311 |
NULL
| id |
bigint
| 0 |
| 263311 |
NULL
| action_id |
int
| 1 |
| 263311 |
NULL
| user_id |
bigint
| 2 |
| 263311 |
NULL
| request | string | 3 |
| 263311 |
NULL
| visit_time | string | 4 |
| 263311 |
NULL
| source_id |
int
| 5 |
| 263311 |
NULL
| sess_id | string | 6 |
| 263311 |
NULL
| mobile_number | string | 7 |
| 263311 |
NULL
| from_id | string | 8 |
| 263311 |
NULL
| app_id | string | 9 |
| 263311 |
NULL
| version | string | 10 |
| 263311 |
NULL
| reg_type |
int
| 11 |
| 263311 |
NULL
| uniqid | string | 12 |
| 263311 |
NULL
| failure |
int
| 13 |
+
--------+---------+---------------+-----------+-------------+
2.5 SERDES和SERDE_PARAMS (序列化)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
acorn_3g.user_act表对应的SERDE_ID=263301表示 采用hive默认序列化类org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe , DELIMITED字符为
'\t'
(即创建表时指定的 ...DELIMITED
BY
'\t'
...)
mysql>
select
*
FROM
SERDES
where
SERDE_ID=263301;
+
----------+------+----------------------------------------------------+
| SERDE_ID |
NAME
| SLIB |
+
----------+------+----------------------------------------------------+
| 263301 |
NULL
| org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe |
+
----------+------+----------------------------------------------------+
mysql>
select
SERDE_ID,PARAM_KEY,
REPLACE
(PARAM_VALUE,
'\t'
,
'\\t'
)
from
SERDE_PARAMS
where
SERDE_ID=263301;
+
----------+----------------------+---------------------------------+
| SERDE_ID | PARAM_KEY |
REPLACE
(PARAM_VALUE,
'\t'
,
'\\t'
) |
+
----------+----------------------+---------------------------------+
| 263301 | field.delim | \t |
| 263301 | serialization.format | \t |
+
----------+----------------------+---------------------------------+
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
mysql>
desc
PARTITION_KEYS;
+
--------------+---------------+------+-----+---------+-------+
| Field | Type |
Null
|
Key
|
Default
| Extra |
+
--------------+---------------+------+-----+---------+-------+
| TBL_ID |
bigint
(20) |
NO
| PRI |
NULL
| |
| PKEY_COMMENT |
varchar
(4000) | YES | |
NULL
| |
| PKEY_NAME |
varchar
(128) |
NO
| PRI |
NULL
| |
| PKEY_TYPE |
varchar
(767) |
NO
| |
NULL
| |
| INTEGER_IDX |
int
(11) |
NO
| |
NULL
| |
+
--------------+---------------+------+-----+---------+-------+
mysql>
select
*
FROM
PARTITION_KEYS
WHERE
TBL_ID=41231;
+
--------+--------------+-----------+-----------+-------------+
| TBL_ID | PKEY_COMMENT | PKEY_NAME | PKEY_TYPE | INTEGER_IDX |
+
--------+--------------+-----------+-----------+-------------+
| 41231 |
NULL
| log_date | string | 0 |
+
--------+--------------+-----------+-----------+-------------+
PARTITIONS
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
mysql>
desc
PARTITIONS;
+
------------------+--------------+------+-----+---------+-------+
| Field | Type |
Null
|
Key
|
Default
| Extra |
+
------------------+--------------+------+-----+---------+-------+
| PART_ID |
bigint
(20) |
NO
| PRI |
NULL
| |
| CREATE_TIME |
int
(11) |
NO
| |
NULL
| |
| LAST_ACCESS_TIME |
int
(11) |
NO
| |
NULL
| |
| PART_NAME |
varchar
(767) | YES | MUL |
NULL
| |
| SD_ID |
bigint
(20) | YES | MUL |
NULL
| |
| TBL_ID |
bigint
(20) | YES | MUL |
NULL
| |
+
------------------+--------------+------+-----+---------+-------+
mysql>
select
*
FROM
PARTITIONS
WHERE
TBL_ID=41231
order
by
PART_NAME limit 5;
+
---------+-------------+------------------+---------------------+--------+--------+
| PART_ID | CREATE_TIME | LAST_ACCESS_TIME | PART_NAME | SD_ID | TBL_ID |
+
---------+-------------+------------------+---------------------+--------+--------+
| 168301 | 1366259946 | 0 | log_date=2013-03-01 | 231621 | 41231 |
| 168321 | 1366260063 | 0 | log_date=2013-03-02 | 231641 | 41231 |
| 168331 | 1366260176 | 0 | log_date=2013-03-03 | 231651 | 41231 |
| 168346 | 1366260298 | 0 | log_date=2013-03-04 | 231666 | 41231 |
| 168361 | 1366260398 | 0 | log_date=2013-03-05 | 231681 | 41231 |
+
---------+-------------+------------------+---------------------+--------+--------+
PARTITION_KEY_VALS
|
1
2
3
4
5
6
7
|
mysql>
select
pk.PKEY_NAME,pk.PKEY_TYPE,pk.INTEGER_IDX,pkv.PART_KEY_VAL
from
PARTITION_KEYS pk,PARTITION_KEY_VALS pkv
where
pk.INTEGER_IDX=pkv.INTEGER_IDX
and
pk.TBL_ID=41231
and
pkv.PART_ID=168301;
+
-----------+-----------+-------------+--------------+
| PKEY_NAME | PKEY_TYPE | INTEGER_IDX | PART_KEY_VAL |
+
-----------+-----------+-------------+--------------+
| log_date | string | 0 | 2013-03-01 |
+
-----------+-----------+-------------+--------------+
|
1
2
3
4
5
6
7
8
|
mysql>
desc
BUCKETING_COLS;
+
-----------------+--------------+------+-----+---------+-------+
| Field | Type |
Null
|
Key
|
Default
| Extra |
+
-----------------+--------------+------+-----+---------+-------+
| SD_ID |
bigint
(20) |
NO
| PRI |
NULL
| |
| BUCKET_COL_NAME |
varchar
(256) | YES | |
NULL
| |
| INTEGER_IDX |
int
(11) |
NO
| PRI |
NULL
| |
+
-----------------+--------------+------+-----+---------+-------+
|