Object Query Language (OQL) is a
query language
A query language, also known as data query language or database query language (DQL), is a computer language used to make queries in databases and information systems. In database systems, query languages rely on strict theory to retrieve informa ...
standard for
object-oriented databases modeled after
SQL
Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel")
is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
and developed by the
Object Data Management Group The Object Data Management Group (ODMG) was conceived in the summer of 1991 at a breakfast with object database vendors that was organized by Rick Cattell of Sun Microsystems. In 1998, the ODMG changed its name from the Object Database Management Gr ...
(ODMG). Because of its overall complexity the complete OQL standard has not yet been fully implemented in any software. The OQL standard influenced the design of later query languages such as
JDOQL and
EJB QL
EJB QL or EJB-QL is a portable database query language for Enterprise Java Beans. It was used in Java EE applications. Compared to SQL
Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel")
is a domain-spe ...
, though none are considered to be any version of OQL.
General rules
The following rules apply to OQL statements:
* All complete statements must be terminated by a semi-colon.
* A list of entries in OQL is usually separated by commas but not terminated by a comma(,).
* Strings of text are enclosed by matching quotation marks.
Examples
Simple query
The following example illustrates how one might retrieve the
CPU-speed of all PCs with more than 64MB of
RAM
Ram, ram, or RAM most commonly refers to:
* A male sheep
* Random-access memory, computer memory
* Ram Trucks, US, since 2009
** List of vehicles named Dodge Ram, trucks and vans
** Ram Pickup, produced by Ram Trucks
Ram, ram, or RAM may also ref ...
from a fictional
PC database:
SELECT pc.cpuspeed
FROM PCs pc
WHERE pc.ram > 64;
Query with grouping and aggregation
The following example illustrates how one might retrieve the average amount of
RAM
Ram, ram, or RAM most commonly refers to:
* A male sheep
* Random-access memory, computer memory
* Ram Trucks, US, since 2009
** List of vehicles named Dodge Ram, trucks and vans
** Ram Pickup, produced by Ram Trucks
Ram, ram, or RAM may also ref ...
on a
PC, grouped by manufacturer:
SELECT manufacturer, AVG(SELECT part.pc.ram FROM partition part)
FROM PCs pc
GROUP BY manufacturer: pc.manufacturer;
Note the use of the keyword
partition
, as opposed to aggregation in traditional SQL.
References
*
*
See also
*
Object Data Management Group The Object Data Management Group (ODMG) was conceived in the summer of 1991 at a breakfast with object database vendors that was organized by Rick Cattell of Sun Microsystems. In 1998, the ODMG changed its name from the Object Database Management Gr ...
(ODMG)
* Object Definition Language
References
Query languages
{{Compu-lang-stub