Writing PSQL DB Queries
Contents: Description, Procedure, Functions Used, Related Functions
Description The purpose of this page is provide a very quick tutorial on composing a PSQL query statement to obtain image meta-data from the MSFF Mars PSQL database. More complex queries than those shown here can be used with the themis3db interface; see appropriate online documentation for SQL grammar and syntax. The instructions provided here assume that you are primarily accessing the database through the Davinci-PSQLQueryTool interface. See the themis3db function page and/or the PSQL QueryTool Glossary procedure page for examples on how to execute the full series of commands in Davinci.
Procedure
select [WHAT] from [TABLE] where [CONDITIONS] [[GROUP] having [GRP_CONDITIONS]] [ORDER];
Basic Query Examples using the irfrmsci table: dv> query="select file_id, framelet_id, bright_temp9 from irfrmsci where file_id='I01001001' order by framelet_id;" dv> query="select irfrmsci.* from irfrmsci where file_id='I01001001' order by framelet_id;" dv> query="select file_id, framelet_id, mola_avg, mola_min as molamin, mola_max as mola_max \ from irqubsci where file_id='I01001001' and framelet_id=0 order by framelet_id;" dv> query="select file_id, framelet_id, mola_avg from irfrmsci where file_id in ('I01001001','I01002002') \ and framelet_id > 0 and mola_avg > 0;" dv> query="select file_id, avg(tes_emiss3) from irfrmsci where file_id='I01001001' group by file_id;" dv> query="select file_id, avg(tes_emiss3) as avg_tes3 from irfrmsci where file_id like 'I010%' \ group by file_id having avg(tes_emiss3) between 0.9 and 1.0 order by 2 desc;"
select [WHAT] from [TABLES] where [JOIN] and [CONDITIONS] [[GROUP] having [GRP_CONDITIONS]] [ORDER];
Multi-Table Query Examples ... (warning: these queries are SLOW!) dv> query="select irfrmsci.file_id, irfrmsci.framelet_id, bright_temp9 from \ irfrmsci, frmgeom where irfrmsci.file_id=frmgeom.file_id and \ irfrmsci.framelet_id=frmgeom.framelet_id and point_id='CT' \ and band_idx=1 and lat between -5.0 and 5.0 and lon between 30 \ and 60 order by irfrmsci.framelet_id;" dv> query="select sci.file_id, avg(tes_emiss3), lat, lon from irfrmsci as sci, \ frmgeom as geom, thm3_quality qual where sci.file_id=geom.file_id and \ sci.file_id=qual.file_id and point_id='CT' and band_idx=1 and calibration=0 \ group by sci.file_id, lat, lon;"
|
DavinciWiki Mini-Nav Bar Contents
Contact Developers
All other topics
Functions Used
Related Procedures |