在beeline中使用hive并使用简单的select
查询时,我希望将列名中没有 表名的表 作为默认值返回。
简单表 (TutorialsPoint) :
的示例CREATE TABLE IF NOT EXISTS employee ( eid int, name String,
salary String, destination String)
COMMENT 'Employee details'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;
SELECT
查询返回:
SELECT * FROM employee;
+---------------+----------------+------------------+-----------------------+--+
| employee.eid | employee.name | employee.salary | employee.destination |
+---------------+----------------+------------------+-----------------------+--+
+---------------+----------------+------------------+-----------------------+--+
使用 AS
:
SELECT eid AS eid, name AS name, salary AS salary,
destination AS destination FROM employee;
+------+-------+---------+--------------+--+
| eid | name | salary | destination |
+------+-------+---------+--------------+--+
+------+-------+---------+--------------+--+
我希望每次运行AS
查询时都不要输入 select
,并将列名中没有表名的结果作为默认行为返回。
答案 0 :(得分:9)
set hive.resultset.use.unique.column.names=false
hive> create table t (i int,j int,k int);
hive> select * from t;
t.i t.j t.k
hive> set hive.resultset.use.unique.column.names=false;
hive> select * from t;
i j k