Next Previous Up Contents
Next: Cone Search
Up: Load Window
Previous: Table Searches

### A.6.4 SQL Query

SQL Query Dialogue

If you want to read a table from an SQL database, you can use a specialised dialogue to specify the SQL query by selecting SQL Query button from the Load Window's toolbar () or DataSources menu.

This provides you with a list of fields to fill in which make up the query, as follows:

Protocol
  The name of the appropriate JDBC sub-protocol. This is defined by the JDBC driver that you are using, and is for instance "`mysql`" for MySQL's Connector/J driver or "`postgresql`" for PostgreSQL's JDBC driver.
Host
  The hostname of the machine on which the database resides (may be "`localhost`" if the database is local).
Database name
  The name of the database.
User name
  The username under which you wish to access the database. This is not strictly necessary if there is no access control for the database in question.
Password
  The password for the given username. Again, whether this is necessary depends on the access policy of the database.
SQL Query
  The text of the query which will define the resulting table. If you want to look at a table named XXX as it exists in the database, you can write something like "`SELECT * from XXX`". In principle any SQL query on the database can be used here, but the details of what SQL syntax is permitted may be restricted by the JDBC driver you are using.

There are a number of criteria which must be satisfied for SQL access to work within TOPCAT (installation of appropriate drivers and so on) - see Section 10.3. If you don't take these steps, this dialogue may be inaccessible.

The way that this dialogue contacts the database makes some assumptions about how the JDBC driver works which are not always true, so for some databases and drivers it may not be possible to get it to work. It may be improved in the future; if you have particular problems, please contact the author or the mailing list.

Next Previous Up Contents
Next: Cone Search
Up: Load Window
Previous: Table Searches

TOPCAT - Tool for OPerations on Catalogues And Tables
Starlink User Note253
TOPCAT web page: http://www.starlink.ac.uk/topcat/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@bristol.ac.uk