Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

实用函数

  • 多个备选取第一个非空

    COALESCE(备选1,备选2...)
    
  • 四舍五入

    ROUND(x)
    
    • 返回对x进行四舍五入后的整数
    ROUND(x, y)
    
    • 结果保留y为小数,对y+1位进行四舍五入
    • 例子
      SELECT round(1.43222, 2)
      //结果是1.43
      
  • 禁用缓存

    • 往语句中加入NOW()RAND()等函数
  • 批量插入测试数据

    INSERT INTO test_a SELECT generate_series(1,100000),'francs';