Tutorial > WBEM > CIM Query Language
CIM Query Language
This tutorial describes the basic syntax and features of the DMTF CIM Query Language (CQL), which can be very complex. For detailed information on CQL refer to the CIM Query Language Specification, defined in
DSP0202. This specificiation is preliminary and currently available for public review.
The DMTF CIM Query Language
(CQL) provides the capability to select properties from sets of CIM
instances. CQL support is subdivided into a number of independent features:
- Basic Query
- Simple Join
- Complex Join
- Result Set Operations
- Extended Select List
- Embedded Properties
- Regular Expression Like
- Array Range
- Satisfies Array
- Foreign Namespace Support
- Arithmetic Expression
CQL features are advertised
through a property in an instance of CIM_QueryCapabilities.
CQL queries are expressed as a
statement in the following form:
SELECT <items> FROM
<this> [ WHERE <conditions> ] [ ORDERED BY <sort
SELECT defines the columns of
the table that results from the SELECT
in its basic form (for example, the properties of the CIM Instance
data to be returned as part of the result set).
FROM specifies the CIM Element
from which to retrieve the data. For example,
FROM could specify the name of one CIM class. All instances
of this class and and its subclasses are candidates for inclusion
in the information that is returned as part of the result set.
WHERE acts as a filter. The result set
will not include items that do not match the set of conditions.
ORDERED BY sorts the results in the specified order.
The following examples describe some of the ways in which CQL can be used.
- Get all StorageExtent and MediaAccessDevice instances.
Note that the projection is limited to instances that are
either CIM_StorageExtent or CIM_MediaAccessDevice, however only
properties of CIM_LogicalDevice and its superclasses are returned.
Required feature: Basic Query
SELECT * FROM CIM_LogicalDevice WHERE CIM_LogicalDevice ISA
CIM_StorageExtent OR CIM_LogicalDevice ISA CIM_MediaAccessDevice
- Get the object path, ElementName and Caption for all StorageExtents
Required features: Basic Query, Extended Select List
SELECT OBJECTPATH(CIM_StorageExtent) AS Path, ElementName, Caption
A set of instances would be returned, each containing the object path
that identify the name of the instance, the ElementName and Caption properties.
- Select all LogicalDevices on a particular ComputerSystem that
have an OperationalStatus not equal to “OK” (value
= 2), and return their object paths and OperationalStatus.
Required features: Basic Query, Extended Select List, Complex Join,
SELECT OBJECTPATH(CIM_LogicalDevice) AS Path,
CIM_LogicalDevice.OperationalStatus[*] FROM CIM_LogicalDevice,
CIM_ComputerSystem, CIM_SystemDevice WHERE CIM_ComputerSystem.ElementName =
AND CIM_SystemDevice.GroupComponent =
AND CIM_ SystemDevice.PartComponent =
AND ANY CIM_LogicalDevice.OperationalStatus[*] <> 2)
A set of instances would be returned, each containing the object
path identifying the name of the instance of CIM_LogicalDevice on
the specified CIM_ComputerSystem and the OperationalStatus property.
- List all ComputerSystems and the object paths of any instances
dependent on the system as described by the Dependency association.
Required Features: Basic Query, Extended Select List, Complex Join
SELECT CIM_ComputerSystem.*, OBJECTPATH(CIM_ManagedElement) AS
MEObjectName FROM CIM_ComputerSystem, CIM_ManagedElement,
WHERE CIM_Dependency.Antecedent = OBJECTPATH(CIM_ComputerSystem)
AND CIM_Dependency.Dependent = OBJECTPATH(CIM_ManagedElement)
This query returns a set of instances that are defined by the references of the
Dependency association's instances. The instances that are returned
contain all the properties of CIM_ComputerSystem and a string
representing the associated ManagedElement's object path.