Object Query Language

Object Query Language (OQL) is a query language standard for object-oriented databases modeled after SQL. OQL was developed by the Object Data Management Group (ODMG). 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:

  • 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 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(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.

gollark: If your factory is told to make 100K units of winter clothing of any kind they will probably just go for the simplest/easiest one, even if it isn't very useful to have 100K winter coats (extra small) (plain white). Now, you could say "but in capitalism they'll just make the cheapest one", but companies are directly subservient to what consumers actually want and can't get away with that.
gollark: That is why we have the "legal system"./
gollark: With a government.
gollark: Sure they can. Just apply penalties/taxes if you pollute stuff.
gollark: > Tell factories to produce 100K units of winter clothing and give them free choice of a variety of different accepted models.But then you don't know how much stuff each factory will need.

See also


This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.