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




     
  • 相关阅读:
    前端js(一)
    前端CSS
    前端HTML
    视图等
    Navicat使用
    查询语句
    SpringBoot不能直接访问templates下的静态资源
    Mybatis什么时候用${}
    thymeleaf使用restul风格URL
    SpringBoot使用PageHelper
  • 原文地址:https://www.cnblogs.com/cjb1/p/12745272.html
Copyright © 2011-2022 走看看