Search CTRL + K

Query Language

查询语言数据库管理系统 提供给用户和 数据库 交互的工具。

有两种“纯”数据库语言,它们简短、正式,一般作为其他数据库语言的基础:

查询语言 可以归纳为三类:命令式、函数式和声明式。

三类查询语言并不是边界分明

实践中的 查询语言,比如 SQL,会同时包含多种 查询语言 的特性。[1]

命令式(Imperative)

用户控制系统一步步执行操作,计算、获取数据。在计算过程中包含了可变的状态变量。

程序式(Functional)

用户调用一系列函数链式执行计算、获取数据。在计算过程中不包含状态变量,无副作用。

声明式(Non-Procedural/Declarative)

用户只声明需要的数据,由 数据库管理系统 实现计算过程并返回数据。


Database System Concepts

A query language is a language in which a user requests information from the database. Query languages can be categorized as imperative, functional, or declarative.[2]

Database System Concepts

In an imperative query language, the user instructs the system to perform a specific sequence of operations on the database to compute the desired result; such languages usually have a notion of state variables, which are updated in the course of the computation.[2:1]

Database System Concepts

In a functional query language, the computation is expressed as the evaluation of functions that may operate on data in the database or on the results of other functions; functions are side-effect free, and they do not update the program state.[2:2]

Database System Concepts

In a declarative query language, the user describes the desired information without giving a specific sequence of steps or function calls for obtaining that information; the desired information is typically described using some form of mathematical logic. It is the job of the database system to figure out how to obtain the desired information.[2:3]


  1. https://en.wikipedia.org/wiki/SQL ↩︎

  2. Abraham Silberschatz, Henry F. Korth, and S. Sudarshan, Database System Concepts, Seventh edition (New York, NY: McGraw-Hill, 2020). P47 ↩︎ ↩︎ ↩︎ ↩︎