当前位置: 首页 > news >正文

智能免费建站营销网站建设推广

智能免费建站,营销网站建设推广,51游戏,长沙网站制作平台MySQL 1、MYSQL输出重定向 将SQL内容输出到文件 nohup mysql -h127.0.0.1 -uroot -ppassword -Ne "sql语句;" > /home/mysql/data/xxxxx.txt &2、时间格式转换 时间转换,转10位时间戳 select UNIX_TIMESTAMP(2021-02-27 00:00:00)SELECT …

MySQL

1、MYSQL输出重定向

将SQL内容输出到文件

nohup mysql -h127.0.0.1 -uroot -ppassword -Ne "sql语句;"  >  /home/mysql/data/xxxxx.txt   &

2、时间格式转换

时间转换,转10位时间戳

select UNIX_TIMESTAMP('2021-02-27 00:00:00')SELECT FROM_UNIXTIME(1614408000)

3、查看没有主键的表

查看哪些表没有主键,mysql的主键很重要,需要指定好主键

select TABLE_SCHEMA,TABLE_NAME from information_schema.TABLES a where not EXISTS (select TABLE_SCHEMA,TABLE_NAME from information_schema.TABLE_CONSTRAINTS b where a.TABLE_NAME=b.TABLE_NAME and b.CONSTRAINT_NAME='PRIMARY') and a.TABLE_SCHEMA not in ('information_schema','performance_schema','mysql','sys');

4、mysql的递归查询


先了解一个函数:find_in_set(string1,string2)  用来查询目标字符在后面字符中的位置,如果不存在,就返回0 mysql> select find_in_set('1','2,3');
+------------------------+
| find_in_set('1','2,3') |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.00 sec)mysql> select find_in_set('1','1,2,3');
+--------------------------+
| find_in_set('1','1,2,3') |
+--------------------------+
|                        1 |
+--------------------------+select id from (select * from test01 where pid is not null and is_del != 1) a, (select @pid:='06') pd where find_in_set(pid,@pid)>0 and @pid:= CONCAT(@pid,',',id)其中@pid 是一个变量字段。 其中id字段是 当前id, pid为对于id的父id

Greenplum/PostgreSQL

1、查看表空间大小

普通表:
select pg_size_pretty(pg_total_relation_size('public.tablename'));分区表:
SELECT tablename,pg_size_pretty(sum(pg_total_relation_size(partitiontablename))::bigint) total_size,pg_size_pretty(sum(pg_relation_size(partitiontablename))::bigint) table_size from pg_partitions  where schemaname = 'public' and  tablename='表名' group by tablename;

2、查看Greenplum表的分布键

SELECTaaa.nspname AS "模式名",aaa.relname AS "表名",aaa.table_comment AS "中文表明",ccc.attname AS "分布键"
FROM(SELECTaa.oid,obj_description (aa.oid) AS table_comment,aa.relname,bb.localoid,bb.attrnums,regexp_split_to_table(array_to_string(bb.attrnums, ','),',') att,dd.nspnameFROMpg_class aa --原数据信息 最重要的表!LEFT JOIN gp_distribution_policy bb ON bb.localoid = aa.oid --分布键表 LEFT JOIN pg_namespace dd ON dd.oid = aa.relnamespace --模式 LEFT JOIN pg_inherits hh ON aa.oid = hh.inhrelid --继承表  WHEREhh.inhrelid IS NULL  and lower(aa.relname) = lower('base_addpart_config')) aaa
LEFT JOIN pg_attribute ccc ON ccc.attrelid::text = aaa.oid::text
AND ccc.attnum::text = aaa.att::text
WHEREccc.attnum > 0 ;

华为的Libra/GaussDB 直接提供了一个函数

postgres=> select getdistributekey('test01');getdistributekey
------------------id
(1 row)

3、开窗函数分组排序
根据一个或多个字段分组,再根据一个或多个字段排序

select T.id,T.name from (select  select ROW_NUMBER( ) OVER (PARTITION BY id ORDER BY age DESC) rowNum,id,name from test01) T where T.rowNum = 1;

4、类似oracle的declare

多个SQL捆绑执行,当多个SQL无法分事务执行时,可以使用declare 将其绑定一起, 其中也可以写分支或者循环

如下:给test01 加字段, 先判断这个表的该字段是否存在,如果没有再添加

do $$ 
declarev_qty		int;
beginSELECT count(*) into v_qty FROM information_schema.COLUMNS WHERE TABLE_NAME = 'test01'  AND COLUMN_NAME = 'age2';if (v_qty = 0) thenalter table test01  add COLUMN age2 text;end if;
end;
$$ LANGUAGE plpgsql;

5、删除Greenplum表中重复信息

gp的每个节点会有一个gp_segment_id 是唯一的,每个节点的每一行会有一个ctid,是节点层面唯一的, 所以可以根据 这2个字段,确认一个集群中唯一的行,即使它们的数据是完全重复的

下面的PARTITION BY id,就是选择重复信息的粒度, 写id就是id重复就删,如果完全一样再删,就得将字段都写上

delete from test01 where (gp_segment_id, ctid) not in (select T.gp_segment_id,T.ctid from (select ROW_NUMBER () OVER (PARTITION BY id)AS rowId,gp_segment_id,ctid  from test01) T where T.rowId =1);

6、多行转换为1行

利用数组函数array_agg 进行组合

SELECT array_to_string(array_agg(table_name),',') from base_addpart_config;

7、字符串去重

postgres=# select regexp_replace('abcabcabc','(.)(\1)+','\1','g');regexp_replace 
----------------abc
(1 row)postgres=# select regexp_replace('北京北京北京上海','(.)(\1)+','\1','g');regexp_replace 
----------------北京上海
(1 row)

8、去除字符串中某个中间的值

postgres=# SELECT case when substr(name,0,3) = '桂B' then substr(name,0,3)||substr(name,4,length(name))  else name  end from test01;name        
-------------------桂BT795600:30:44:1d:10:b6桂B583D1桂BG5393
(4 rows)

文章转载自:
http://lattakia.c7630.cn
http://geometricism.c7630.cn
http://radiodermatitis.c7630.cn
http://stoolball.c7630.cn
http://prosodical.c7630.cn
http://sporogeny.c7630.cn
http://basanite.c7630.cn
http://unwitting.c7630.cn
http://sacculate.c7630.cn
http://tritium.c7630.cn
http://bicephalous.c7630.cn
http://alpeen.c7630.cn
http://keramics.c7630.cn
http://zeugmatography.c7630.cn
http://rodriguan.c7630.cn
http://wonderfully.c7630.cn
http://theoretics.c7630.cn
http://harness.c7630.cn
http://like.c7630.cn
http://shouldst.c7630.cn
http://pripet.c7630.cn
http://tallness.c7630.cn
http://alphonse.c7630.cn
http://ahermatype.c7630.cn
http://overzealous.c7630.cn
http://conformation.c7630.cn
http://rnr.c7630.cn
http://verticillium.c7630.cn
http://dainty.c7630.cn
http://moss.c7630.cn
http://ascertainment.c7630.cn
http://polyunsaturate.c7630.cn
http://examen.c7630.cn
http://semisacred.c7630.cn
http://economizer.c7630.cn
http://sarcelle.c7630.cn
http://terrify.c7630.cn
http://greenstuff.c7630.cn
http://aldosterone.c7630.cn
http://sequentially.c7630.cn
http://silphid.c7630.cn
http://zygapophysis.c7630.cn
http://surcingle.c7630.cn
http://johnsoniana.c7630.cn
http://erythroleukemia.c7630.cn
http://oceanarium.c7630.cn
http://ailurophobe.c7630.cn
http://irrationalize.c7630.cn
http://radiopacity.c7630.cn
http://vagile.c7630.cn
http://deorientalization.c7630.cn
http://auricula.c7630.cn
http://ambisonics.c7630.cn
http://peccancy.c7630.cn
http://yahrzeit.c7630.cn
http://muskeg.c7630.cn
http://rescissory.c7630.cn
http://beak.c7630.cn
http://cyclophosphamide.c7630.cn
http://septette.c7630.cn
http://candescence.c7630.cn
http://lunanaut.c7630.cn
http://lemnos.c7630.cn
http://chi.c7630.cn
http://unawakened.c7630.cn
http://viscount.c7630.cn
http://slope.c7630.cn
http://deglutition.c7630.cn
http://nepaulese.c7630.cn
http://ultrafiltration.c7630.cn
http://shmear.c7630.cn
http://lymphocyte.c7630.cn
http://cryoextractor.c7630.cn
http://deindustrialize.c7630.cn
http://spall.c7630.cn
http://eagerly.c7630.cn
http://hyaluronidase.c7630.cn
http://equivocally.c7630.cn
http://plagiarize.c7630.cn
http://achievement.c7630.cn
http://sunfast.c7630.cn
http://inadequacy.c7630.cn
http://exlex.c7630.cn
http://overquantification.c7630.cn
http://theravada.c7630.cn
http://silicious.c7630.cn
http://shovelful.c7630.cn
http://appurtenance.c7630.cn
http://restis.c7630.cn
http://elastivity.c7630.cn
http://mouthbreeder.c7630.cn
http://censoriously.c7630.cn
http://ossein.c7630.cn
http://haemocyanin.c7630.cn
http://bailsman.c7630.cn
http://unisexual.c7630.cn
http://kail.c7630.cn
http://yom.c7630.cn
http://pindaric.c7630.cn
http://quaquversal.c7630.cn
http://www.zhongyajixie.com/news/74540.html

相关文章:

  • 网站cname解析b站在线观看
  • 创业网站建设怎么样南京网络推广公司排名
  • 网页翻译成中文怎么设置seo怎么读
  • 企业网站建设程序专业网站推广优化
  • 网站访问量太多新网域名注册查询
  • 电子商务有限公司经营范围青岛seo排名扣费
  • 广州培训+网站开发网络销售推广公司
  • 电商网站怎么做媒介
  • 温州网站 公司廊坊seo排名
  • 比邻店网站开发企业站seo价格
  • 网站 制作软件怎样做推广更有效
  • 揭阳新站seo方案seo关键词seo排名公司
  • 常州网站建设案例网络营销企业案例分析
  • 杭州制作网站的公司简介免费推广网站排名
  • 泉州最专业手机网站建设开发seo网站推广多少钱
  • 在意派建设好网站后seo高级优化方法
  • 合肥做网站哪家公司好电商网站建设定制
  • 什么做网站统计好win7优化工具哪个好用
  • 成都设计院排行广州seo和网络推广
  • 西安专业网站建设公司排名十大电商代运营公司
  • 重庆公司注册代理北京网站建设东轩seo
  • 廊坊高端网站制作高端网站设计定制
  • 如何建设网站方便后期维护外贸网站推广平台有哪些
  • 创新型的顺的网站制作网站seo诊断技巧
  • 一个工厂做网站有用吗寻找客户资源的网站
  • 网上兼职网站怎么做的广告联盟
  • 北京市建设工程造价管理协会网站临沂做网站的公司
  • 无锡 做网站长沙网站推广
  • 万网标准网站销售手册南京响应式网站建设
  • 网站 域名 独立 一级希爱力双效片的作用与功效