ADQL means Astronomical Data Query Language. This language is used by the
IVOA to represent astronomy queries posted to VO services.
It is based on SQL (Structured Query Language) and enriched with geometrical functions such as
But contrary to SQL, ADQL is only designed to interrogate a database !
All information about ADQL are available at this IVOA Document. This page gathers minimal ADQL features required to interrogate Simbad-TAP. These features are explained through query examples on the following Simbad tables:
1. Minimal queries
SELECT * FROM basic;
Select all information about all astronomical objects.
SELECT main_id, ra, dec, coo_err_maj, coo_err_min, coo_err_angle FROM basic;
Select the position (and one id) of all astronomical objects.
2. Labeling columns
In the output of a query execution, columns are identified by their name in the database (i.e.
However, these output names can be changed while writing the query:
SELECT ra, dec, main_id AS "Usual ID" FROM basic;
=> Output column names will be:
3. Rows limit
Select the 50 first rows of the table
SELECT TOP 50 * FROM basic;
4. Ordering rows
Order by column name
SELECT TOP 50 * FROM ident ORDER BY id;
Order by column label
SELECT TOP 50 oidref, id AS ObjectName FROM ident ORDER BY ObjectName;
Order by column index
SELECT TOP 50 * FROM ident ORDER BY 2;
Order by descending column name
SELECT TOP 50 * FROM ident ORDER BY id DESC;
5. Filtering rows
SELECT ids FROM ids WHERE oidref = 2894585;
Select all names of an object.
SELECT oid, main_id, nbref FROM basic WHERE nbref >= 3000 ORDER BY nbref;
Select all objects which are referenced more than 3000 times.
Select all object identifiers from catalogue ACO (name starting with 'ACO' string).
SELECT id FROM ident WHERE id like 'ACO%';
Select the 50 first objects whose right ascension and declineason are not null.
SELECT TOP 50 oid, main_id, ra, dec FROM basic WHERE ra IS NOT NULL AND dec IS NOT NULL;
SELECT main_id as child, membership from h_link JOIN ident as p on p.oidref=parent JOIN basic on oid=child WHERE p.id = 'Pleiades Moving Group' and (membership >=95 or membership is null);
Select children names of an object.
6. Geometrical functions
ADQL also allows interrogation on position like Search Cone.
-- All objects around M13 with a radius of 0.1° SELECT TOP 50 oid, main_id, ra, dec FROM basic WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', 250.423475, 36.4613194444444, 0.1)) = 1 AND ra IS NOT NULL AND dec IS NOT NULL;
--is a comment, and so will be ignored at the query execution.
In this example only two types of regions have been used:
- POINT(coord_sys, right_ascension, declineason)
- CIRCLE(coord_sys, ra_center, dec_center, radius_in_degree)
But the following regions also exist:
- BOX(coord_sys, ra_center, dec_center, width_in_degrees, height_in_degrees)
- POLYGON(coord_sys, ra_vertice1, dec_vertice1, ra_vertice2, dec_vertice2, ra_vertice3, dec_vertice3 [, ...])
- REGION(stc_region) (not implemented in Simbad-TAP)
The two main geometrical functions of ADQL are:
- CONTAINS(region1, region2)
- INTERSECTS(region1, region2)
These functions return 1 if region1 contains/intersects region2, 0 otherwise.
ADQL also provides functions to compute distance, area, ...
- DISTANCE(POINT1, POINT2)
- COORDSYS(region) (not implemented in Simbad-TAP)
- CENTROID(region) (not implemented in Simbad-TAP)
7. Using several tables
SELECT oid, main_id, ra, dec, nbRef FROM basic JOIN ident ON oid = oidref WHERE id = 'smc';
Get all information about SMC
Get all identifiers of SMC
SELECT ident1.id AS "SMC Identifiers" FROM ident AS ident1 JOIN ident AS ident2 USING(oidref) WHERE ident2.id = 'smc';
USINGcan be used only if the given column exists in both tables with exactly the same name.
AS. But contrary to the columns, this label is actually an alias and MUST always be used to reference the corresponding table. These table alias are particularly usefull when columns with the same name come from different tables.
Multi Ordered Coverage output
-- Young Stellar objects SELECT hpx FROM basic WHERE otype='YSO'
8. Upload tables
In TAP, you can upload VOTables and interrogate them as tables in an ADQL query.
When uploading a VOTable, a table name must be provided.
This name prefixed by
TAP_UPLOAD must be used to reference the table in the ADQL query
SELECT * FROM TAP_UPLOAD.foo;
9. Object and spectral types in Simbad
Spectral type: You can find this information in the column
sptypeof the table
basic. You can filter objects by their spectral type with the following operators:
BETWEEN '..' AND '..',
SELECT TOP 100 oid, main_id, sp_type FROM basic WHERE sp_type BETWEEN 'F3' AND 'F5';
Object type: This information is available in the columns
otype, otype_txtof the table
basic. You can filter objects by their type with the following operators:
NOT IN. Since object types can be more or less precise (for instance: AGN are particular types of Galaxy), you can specify if you search for a precise type of object or for its descendants by adding 2 points (
'..') at the end of the type name:
If you want to search for all objects labelled exactly
SELECT TOP 100 oid, main_id, otype_txt FROM basic WHERE otype = 'Galaxy';
If you want to search for all galaxies:
SELECT TOP 100 oid, main_id, otype_txt FROM basic WHERE otype = 'Galaxy..';
- If you want to search for all objects labelled exactly
10. ADQL traps & tricks
- By default ADQL is not case-sensitive. So you can write:
- The column and table names (and their aliases) are also not case-sensitive except if surrounded with double-quotes.
- Tables and columns of Simbad are always in lower case except for uploaded tables.
- String literals must always be surrounded by simple-quotes.
- Right ascensions, declineasons and radius must be given in degrees.
- The coordinate system of ADQL regions is not interpreted in Simbad-TAP and is supposed to be ICRS.
- Don't forget to compare the functions
INTERSECTSwith 1 or 0.
- An uploaded table name must always be prefixed by