1. 什么是存储过程?

存储过程是一些预编译的SQL语句

查询SQL执行顺序

  • FROM/JOIN and all the ON conditions
  • WHERE
  • GROUP BY
  • HAVING
  • SELECT (including window functions)
  • ORDER BY
  • LIMIT

    示例SQL

    根据国家面积列出各个州最大的国家

    1. SELECT continent, name, area FROM world x
    2. WHERE area >= ALL
    3. (SELECT area FROM world y
    4. WHERE y.continent=x.continent
    5. AND area>0)