zoukankan      html  css  js  c++  java
  • pgsql 记录

    查询 pgsql可使用的内存

    SHOW work_mem;

    ALTER SYSTEM SET work_mem= 2097151; 

    pgsql查询两张表的百分比

    SELECT
    CAST (
    (
    COUNT (DISTINCT s.userid) / CAST (
    COUNT (DISTINCT u.userid) AS DECIMAL
    )
    ) * 100 AS INT
    )
    FROM
    portal.system_record s,
    portal.sys_user 

     pgsql查询时间  

    当前时间向前推一天

    SELECT current_timestamp - interval '1 day'

    求出最近7天的数据
    select * from 表名 where date between (SELECT current_timestamp - interval '7 day') and current_timestamp

    当前时间向前推进一个月
    SELECT current_timestamp - interval '1 month'

    当前时间向前推进一年

    SELECT current_timestamp - interval '1 year'
    当前时间向前推一小时:
    SELECT current_timestamp - interval '1 hour'
    当前时间向前推一分钟:
    SELECT current_timestamp - interval '1 min'
    当前时间向前推60秒:
    SELECT current_timestamp - interval '60 second'





    select * from task where to_date(deadline, 'yyyymm')<to_date('201909', 'yyyymmdd')//查询指定月份之前

     select * from task where to_date(deadline, 'yyyymmdd')<now()   //查询当前日期之前   

    id自增

    创建一个序列
    CREATE SEQUENCE upms_log_id_seq START 10;

    然后 

    nextval(' upms_log_id_seq')

    从一张表插入到另一张表

    INSERT INTO "portal"."system_log_analysis" ("userid", "anchor_point_1", "anchor_point_2","action", "time")
    select s.userid,s.moudle,s.sub_module,s."action",s."time" from system_record s




     
  • 相关阅读:
    nginx 正向代理 反向代理 负载均衡
    nginx配置文件常用基本配置指令
    92)http 和https协议入门
    tp6--nginx下pathinfo配置
    tp6省略url里的index.php
    echarts鼠标移上去显示数据
    composer 下载thinkphp6失败
    tp5写入cookie失效
    4.15 Spring Cloud理论基础
    4.14 SpringBoot理论基础
  • 原文地址:https://www.cnblogs.com/cjb1/p/12745272.html
Copyright © 2011-2022 走看看