Gbase连接:
gccli -Dcrmdm -ugbase -p'2WsX3edc!@4rfv' -h10.10.4.183 -vvv < dm_custportrait_custval.sql
gccli -Dcrmdm -ugbase -p'2WsX3edc!@4rfv' -h10.10.4.183 -vvv <<!
drop table apple;
insert into a as select * from b;
!
建表+注释:
create table apple (
id int not null comment '序号',
colour varchar(10) comment '颜色'
) distributed by ('id');
给某列加索引:
create index index_name on table_name(column_name);
Mysql给某列加索引:
alter table table_name add index_name(column_name);
替换换行符:replace(replace(policy,char(10),''),char(13),'')
表加上注解:alter table table_name modify column_name datatype comment ‘啥啥啥’;
表添加列:alter table table_name add column_name datatype default 1 before age;
表删除列:alter table table_name drop column_name;
修改字段类型:alter table table_name modify column_name datatype;
装数:
csv文件到表:LOAD DATA INFILE 'file_list' INTO TABLE [dbname.]tbl_name [options]
(以下数据是用""包着的enclosed by不好用,可用sed将""去掉再装表)
load data infile 'sftp://用户名:密码@10.133.216.230//data2/aaa.csv' into table bdpmart.dm_dsj_renewproduct_firefly_xiamen CHARACTER SET charset_name DATA_FORMAT 3 NULL_VALUE '' FIELDS TERMINATED BY ',' ENCLOSED BY '"' DATETIME FORMAT '%Y-%m-%d %H:%i:%s'
卸数:
到本地:
rmt:select
* from crmdm.dm_custportrait_custval
into outfile '/home/zjk/khhx/dm_custportrait_custval.unl' character set utf8 fields terminated by '>|' NULL_VALUE '';
到HDFS:
set gbase_hdfs_protocol='rpc';
select
* from crmdm.dm_custportrait_custval
into outfile 'hdp://hdfs:07AUG*47xb@10.133.151.133:8020/khhx/20210223/dm_custportrait_custval.unl' character set utf8 fields terminated by '>|' NULL_VALUE '' outfilemode by hdfs FILECOUNT 1 writemode by overwrites;