創建table時,直接定義serdeproperties屬性,
create table wzhg( c0 string, c1 string, c2 string )row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' with serdeproperties ( 'input.regex' = 'bduid\\[(.*)\\]uid\\[(\\d+)\\]uname\\[(.*)\\]', 'output.format.string' = '%1$s\t%2$s' ) stored as textfile;
正則表達必須是java形式的。
添加字段時:
1、 更改serdeproperties的值
alter table table_name set serdeproperties (‘charset’ = ‘GBK’, ‘input.regex’=’ 'bduid\\[(.*)\\]uid\\[(\\d+)\\]’, ‘output.format.string’ = ‘’………………………)
2、 刪除\添加tablecolumns
alter table table_name add colums (id int);
如果創建表有問題的話,還需添加hive_contrib.jar
add $PATH/hive_contrib.jar
之后在進行建表等之類的工作
