sql修改表名,数据库名,添加分区

#修改表名
ALTER TABLE employee RENAME TO emp;


#更新数据库的某个字段
set sql_safe_updates=0;
update shenbi.good_out set good_out.season = '春' where good_out.season = 'Q1'




#修改数据库名
CREATE DATABASE new_db;
RENAME TABLE old_db.table1 TO new_db.table1,
old_db.table2 TO new_db.table2;

DROP DATABASE old_db;


#添加分区字段


insert into table bi_bala_ec_category_like_top10 partition(stat_date)
SELECT
         category_like,
        '淘宝' as platform,
        '巴拉' as brand,
        '巴拉巴拉官方旗舰' as store_neme,
         count(1) category_like_total,
        '${hivevar:biz_date}' as stat_date
FROM  stat_bala_ec_process.stat_bala_ec_sm
where stat_date = '${hivevar:biz_date}'
group by
category_like
order by category_like_total desc
limit 10

猜你喜欢

转载自blog.csdn.net/gameovertryagain/article/details/80701785