最近被sql语句中什么时候先+table再+tbname,什么时候直接 +tbname(表名) 搞到疯掉
来个实验
create table tbuser
(id int ,name string)
row format delimited
fields terminated by ‘,’
collection items terminated by ‘-’
map keys terminated by ‘:’
lines terminated by ‘\n’
stored as textfile;
//注意表名不能用user 会报错
from tb_userx
insert into tbuser
select 1, ‘zhangsan’ limit 2;
from tb_userx
insert overwrite table tbuser
select 2,‘lisi’ limit1;
//以上步骤 tbuser 拿到了id1 id2 两条数据
你可以从中发现
insert into tbname 直接+表名 是插入数据
insert into +table+ tbname 也是一样可以成功的
insert overwrite +table+tbname 是覆盖数据
注意:
mysql中验证了一下
insert into tbname values (); 成功
insert into table tbname values (); 失败
以后可能还会遇到一些
很多跟以前习惯不一样的sql命令
到了再说 ,再过来总结,先记住最基础的
LOAD DATA LOCAL INPATH ‘/opt/data/cdr_summ_imei_cell_info.csv’ OVERWRITE INTO TABLE cell_monitor;
LOAD DATA LOCAL INPATH ‘/opt/data/cdr_summ_imei_cell_info.csv’ INTO TABLE cell_monitor;