查询oracle数据库所有表数据量

  1. select t.table_name,t.num_rows from user_tables t ORDER BY t.num_rows desc

查询postgresql数据库所有表数据量

select table_schema || '.' || table_name as table_full_name,
pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) as size
from information_schema.tables
order by
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') desc

改变配置

  1. pg_ctl reload

分组取前几条:

https://blog.csdn.net/a258831020/article/details/48497929

  1. select t.* from (select serial_group_id, total,year, month, row_number() over(partition by serial_group_id ORDER BY year desc,month desc) as row from ap_serial_group_sales ORDER BY year desc) t where row<=1

相加:

  1. (coalesce(t.local_price,0)+coalesce(t.manu_price,0)+coalesce(t.country_price,0)) btotal

逗号合并:

  1. select array_to_string(ARRAY(SELECT unnest(array_agg(t.id)) ),',')
  2. from (
  3. select n.id
  4. from ap_group_photo_node n
  5. left join ap_group_photo_node_ex ex on ex.group_photo_node_id = n.id
  6. left join ap_photo p on n.id = p.group_photo_node_id
  7. where n.enabled = 1 and n.deleted = 0 and n.photo_amount > 0 and p.enabled=1
  8. group by n.id
  9. order by n.id
  10. limit 100
  11. ) t

相同id的合并值:

https://my.oschina.net/Kenyon/blog/86609

postgresql语句的更多相关文章

  1. Oracle,mysql,sqlserver,postgresql语句几点比較

    1.分页 Oracle: SELECT * FROM(SELECT A.*, ROWNUM RN FROM (select T.* from sj_receiptinfo t WHERE t.TAXN ...

  2. postgresql 基本语法

    postgresql数据库创建/修改/删除等写入类代码语法总结: 1,创建库 2,创建/删除表 2.1 创建表 create table myTableName 2.2 如果表不存在则创建表 crea ...

  3. 用postgreSQL做基于地理位置的app(zz)

    前言:项目中用到了postgreSQL中的earthdistance()函数功能计算地球上两点之间的距离,中文的资料太少了,我找到了一篇英文的.讲的很好的文章,特此翻译,希望能够帮助到以后用到eart ...

  4. POSTGRESQL 自动登录

    以前习惯使用MYSQL命令行登录,但是到POSTGRESQL不能实现,下面总结一下方法: 1.填写需要链接的postgresql语句,一般放在~/.bash_profile,例如: alias log ...

  5. Cube and EarthDistance

    前言:项目中用到了postgreSQL中的earthdistance()函数功能计算地球上两点之间的距离,中文的资料太少了,我找到了一篇英文的.讲的很好的文章 ,特此翻译,希望能够帮助到以后用到ear ...

  6. Odoo中的约束

    转载请注明原文地址:https://www.cnblogs.com/cnodoo/p/9280735.html 一:装饰器约束(字段约束) 装饰器参数指定了约束的字段,当涉及的字段中任一发生改变时触发 ...

  7. [TimLinux] django model关于QuerySet

    1. 获取执行过的sql命令 from django.db import connections connections['default'].queries 2. 获取QuerySet将执行的sql ...

  8. odoo10学习笔记四:onchange、唯一性约束

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/11189273.html 一:onchange机制[onchange=前端js函数!可以实现前端实时更新以及修 ...

  9. PostgreSQL--with子句

    在PostgreSQL中,WITH查询提供了一种编写辅助语句的方法,以便在更大的查询中使用.它有助于将复杂的大型查询分解为更简单的表单,便于阅读.这些语句通常称为公共表表达式(Common Table ...

随机推荐

  1. [Python][小知识][NO.5] 使用 Pyinstaller 打包成.exe文件

    1.安装 pyinstaller 插件 cmd命令:pip install PyInstaller PS . o.o 不知道 easy_install 的百度吧. 2.pyinstaller 简介 他 ...

  2. Hadoop3新特性

    1.添加Classpath isolation,防止不同版本的jar包出现冲突. 2.支持Shell重写. 3.支持HDFS中的擦除编码[Erasure Encoding],默认的EC策略可以节省50 ...

  3. cmd的变量总结

    转自:https://blog.csdn.net/flyoutsan/article/details/52811095 cmd变量通过set设置变量,通过可以使用set /?查看有关变量的帮助文档. ...

  4. LeetCode算法题-Kth Largest Element in a Stream(Java实现)

    这是悦乐书的第296次更新,第315篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第164题(顺位题号是703).设计一个类来查找流中第k个最大元素.请注意,它是排序顺序 ...

  5. Python爬虫 selenium

    库的安装 pip3 install selenium 声明浏览器对象 from selenium import webdriver browser = webdriver.Chrome() brows ...

  6. ZooKeeper学习总结 第一篇:ZooKeeper快速入门

    1. 概述 Zookeeper是Hadoop的一个子项目,它是分布式系统中的协调系统,可提供的服务主要有:配置服务.名字服务.分布式同步.组服务等. 它有如下的一些特点: 简单 Zookeeper的核 ...

  7. CentOS 7 minimal配置网络连接及net-tools安装

    在Virtual Box中安装好CentOS 7的minimal后,第一件事就是设置网络访问. 首先需要用 nmtui 命令进入 Network Manager,如下: 选择 Edit a conne ...

  8. 【vue】移动端demo资料

    http://imzjh.com/inew/#/(移动端demo) https://github.com/liangxiaojuan/eleme(饿了么git地址) https://github.co ...

  9. Luogu P1852 BZOJ 2144 [国家集训队]跳跳棋

    qwq 这题一看就不会,如果不是gg让做我是坚决不会做的 画图模拟,因为一次只能跳过一个棋子,所以对于一种情况只有三种移动方式: 中间向左跳 中间向右跳 左或右(距中间近的那个)向中间跳 发现,除了跳 ...

  10. MSIL学习------从HelloWorld开始

    我的博客即将搬运同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=3889z1y72b28 ...