Object Query Language


Object Query Language is a query language standard for object-oriented databases modeled after SQL. OQL was developed by the Object Data Management Group. Because of its overall complexity nobody has ever fully implemented the complete OQL. OQL has influenced the design of some of the newer query languages like JDOQL and EJB QL, but they can't be considered as different flavors of OQL.

General rules

The following rules apply to OQL statements:

Simple query

The following example illustrates how one might retrieve the CPU-speed of all PCs with more than 64MB of RAM 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 on a PC, grouped by manufacturer:

SELECT manufacturer, AVG
FROM PCs pc
GROUP BY manufacturer: pc.manufacturer;

Note the use of the keyword partition, as opposed to aggregation in traditional SQL.