Saturday, December 23, 2017

Hive Primitive Data Type in one Example

create table hivedatatypedemo(
t_boolean       boolean             comment 'TRUE/FALSE',
t_tinyint       tinyint             comment '-128 to 127',
t_smallint      smallint            comment '-32768 to 32767',
t_int           int                 comment '-2(15) to 2(15)-1',
t_bigint        bigint              comment '-2(63) to 2(63)-1',
t_float         float               comment '4-byte single precision floating point number',
t_double        double              comment '8-byte double precision floating point number',
t_decimal1      decimal(5,2)        comment '-999,99 to 999,99',
t_decimal2      decimal(5)          comment '-99999 to 99999',
t_char          char(10)            comment 'fixed lenth char, max size 255',
t_varchar       varchar(5000)       comment 'varable lenth char, max size 65535',
t_string        string              comment 'default to varchar(32762)',
t_timestamp     timestamp           comment 'Traditional UNIX timestamp + Java Format',
t_date          date                comment 'In the form YYYY-­MM-­DD'
)


0: jdbc:hive2://cdh-vm.dbaglobe.com:10000/def> desc hivedatatypedemo;
+--------------+----------------+------------------------------------------------+--+
|   col_name   |   data_type    |                    comment                     |
+--------------+----------------+------------------------------------------------+--+
| t_boolean    | boolean        | TRUE/FALSE                                     |
| t_tinyint    | tinyint        | -128 to 127                                    |
| t_smallint   | smallint       | -32768 to 32767                                |
| t_int        | int            | -2(15) to 2(15)-1                              |
| t_bigint     | bigint         | -2(63) to 2(63)-1                              |
| t_float      | float          | 4-byte single precision floating point number  |
| t_double     | double         | 8-byte double precision floating point number  |
| t_decimal1   | decimal(5,2)   | -999,99 to 999,99                              |
| t_decimal2   | decimal(5,0)   | -99999 to 99999                                |
| t_char       | char(10)       | fixed lenth char, max size 255                 |
| t_varchar    | varchar(5000)  | varable lenth char, max size 65535             |
| t_string     | string         | default to varchar(32762)                      |
| t_timestamp  | timestamp      | Traditional UNIX timestamp + Java Format       |
| t_date       | date           | In the form YYYY-­MM-­DD                         |
+--------------+----------------+------------------------------------------------+--+
14 rows selected (0.066 seconds)

No comments:

Post a Comment