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;