Adding a comma separated table to Hive

前端 未结 4 1959
傲寒
傲寒 2021-01-26 08:38

I have a very basic question which is: How can I add a very simple table to Hive. My table is saved in a text file (.txt) which is saved in HDFS. I have tried to create an exter

4条回答
  •  灰色年华
    2021-01-26 09:23

        create external table Data (
            dummy INT,
            account_number INT, 
            balance INT, 
            firstname STRING, 
            lastname STRING, 
            age INT, 
            gender CHAR(1), 
            address STRING, 
            employer STRING, 
            email STRING,
            city STRING, 
            state CHAR(2)
        )
        row format delimited    
        FIELDS TERMINATED BY ‘,’
        stored as textfile
        LOCATION 'Your hdfs location for external table';
    

    If data in HDFS then use :

    LOAD DATA INPATH 'hdfs_file_or_directory_path' INTO TABLE tablename
    

    The use select * from table_name

提交回复
热议问题