hive adds field modification comments

1. Add comments to ordinary table creation. To
create a table in Hive, you can use the following statements and add Chinese comments for easy identification.

– Create a temporary table
create table tb_test
(
id varchar(100), – user id
age varchar(100) – age
) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'STORED AS TEXTFILE;

– Add comment
create table tb_test
(
id varchar(100) comment ‘userid’, – userid
age varchar(100) comment ‘age’ – age
) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'STORED AS TEXTFILE;

– Query
select * from tb_test;
– View description
desc tb_test;
– Result
col_name data_type comment
id varchar(100) User id
age varchar(100) Age
2. Modify table comments
You can use the following statement to modify table comments:

– Modify table comments
alter table tb_test set tblproperties('comment' = 'Test table');

– View
desc formatted tb_test;
3. Modify field comments.
You can use the following statement to modify field comments:

– Modify field comment
alter table tb_test change column id id string comment 'user number';

– View
desc formatted tb_test;
4. Add fields
You can add fields through the following statement:

– Add fields
alter table tb_test add columns (gender string comment 'gender');

– Add multiple fields
alter table tb_test add columns
(
aa string comment 'aa',
bb string comment 'bb',
cc string comment 'cc'
);

– View
desc formatted tb_test

Guess you like

Origin blog.csdn.net/ZK_0705/article/details/126838525