Computer languages have two broad families: declarative languages and procedural languages
Declarative languages are used to describe what should be done, whereas procedural languages like C + + and Java describe how things should be done.
SQL is declarative because users specify the result that they want instead of how to generate it. For example, the following statement queries records for employees whose last name is Zhang. The database retrieves the data and returns the retrieved data to users. As a declarative language, SQL allows you to process data at the logical level. You need to pay attention to the implementation details only when you manipulate the data.
SELECT last_name, first_name
WHERE last_name LIKE 'Zhang %' ORDER BY last_name, first_name;
The database retrieves all rows satisfying the condition, also called the predicate, that is specified by the WHERE clause. The database can pass these rows as a unit to the user, another SQL statement, or an application. The application does not need to process these rows one by one, nor does the developer need to know how these rows are physically stored or retrieved.
All SQL statements use the optimizer, a component of the database that determines the most efficient way to access the requested data. OceanBase Database also provides techniques that you can use to allow the optimizer to meet your diversified requirements.