1. 建表wkz
hive> create table wkz (id int,
> name string,
> age int,
> tel string)
> row format delimited
> fields terminated by '\t'
> ;
2. 本地當前路徑資料檔案wkz內容:
1 wkz
2 bug
3 cdd
3.建表b
hive> create table b (
> we string,ig int,id int,omg int,name string)
> row format delimited
> fields terminated by '\t'
> ;
4.匯入wkz檔案資料到wkz表:
hive> load data local inpath "wkz" into table wkz;
loading data to table default.wkz
table default.wkz stats: [numfiles=1, totalsize=18]
oktime taken: 1.932 seconds
5.把wkz前兩列插入b:
(1) > insert into table b select id,name from wkz;
failed: semanticexception [error 10044]: line 1:18 cannot insert into target table because column number/types are different 'b': table insclause-0 has 5 columns, but query has 2 columns.
直接報錯說b表有5列,但是只給了兩列
(2)其他列用id欄位代替插入成功:
hive> insert into table b select id,name,id ,id ,id from wkz;
query id = hadoop_20181229112929_df47ff39-c711-4a50-8ee9-a8d08a86e4ca
total jobs = 3
launching job 1 out of 3
number of reduce tasks is set to 0 since there's no reduce operator
...............
stage-stage-1: map: 1 cumulative cpu: 3.19 sec hdfs read: 3822 hdfs write: 98 success
total mapreduce cpu time spent: 3 seconds 190 msec
oktime taken: 13.973 seconds
6.總結:
(1)hive能夠從乙個表取資料插入到另乙個表,不過字段不足要自己填充
(2)hive不會自動對應欄位名去插入另乙個表,順序自己調整
將HBase中的表資料匯入到hive中
user friend 建立hb user friend外部表 create external table events.hb user friend row key string user id string friend id string stored by org.apache.hadoop...
將乙個表中的資料匯入到另一張表中
寫在前面的話 不管是 開發中還是應用程式開發中,我們都會經常遇到需要將資料從乙個表中匯入匯入到另乙個表中,甚至需要指定匯入字段。select into newtable from oldtable select into newtable from oldtable where 1 0 也就是讓wh...
把Sql2000中的表匯入到Mysql中的方法
前兩天得到了乙個成績的資料庫,可是是dbf的,因為想在mysql環境中做乙個成績分析,可是沒辦法匯入 於是先導入sqlsever2000中,想生成sql指令碼,然後再在mysql front中改入。sql檔案,可是發現匯出來的指令碼只有建立表的sql指令碼,沒有資料的指令碼,無奈,後來又想找個軟體試...