Hadoop eco-hive (six) Hive QL table

 

First, create a table

grammar:

create [temporary] [external] table [if not exists] [db_name.] table_name
[(col_name data_type [comment col_comment], ...)]
[comment table_comment]
[row format row_format]
[stored as file_format]

example: 

create table if not exists person ( 
id int, 
name string
)
comment 'human table'
row format delimited
fields terminated by '\t'
lines terminated by '\n'
stored as textfile;

 

Second, the structure of the table view

grammar;

desc[ribe] table_name;

example:

describe person;

 

Third, modify the table

grammar:

alter table name rename to new_name
alter table name add columns (col_spec[, col_spec ...])
alter table name change column_name new_name new_type
alter table name replace columns (col_spec[, col_spec ...])

 Modify the table name:

 alter table person rename to human;

Add columns:

 alter table human add columns (age int);

Delete Column:

 

Fourth, delete the table

grammar:

drop table [if exists] table_name;

example:

 drop table human;

 

Fifth, data insertion, query and delete

insert:

 insert into  human values(1,'pan',13);

Inquire:

select * from human;

delete:

truncate table table_name;
--  清空表,第二种方式
insert overwrite table table_name select * from table_name where 1=0; 

Published 354 original articles · won praise 522 · Views 1.28 million +

Guess you like

Origin blog.csdn.net/moakun/article/details/103101674