SQL Tutorial: Commonly Searched Columns
SQL Tutorial
SQL Tutorial
 Back to Help
 1. Introduction
 2. A Simple Query
 3. Common Searches
 4. More Samples
 5. Multiple Tables
 6. Aggregate Fcns.
 7. Group By
 8. Order By
 10. Functions
 11. Conclusion

Commonly Searched Columns

The Schema Browser contains complete documentation on every table in the SkyServer database. But, most of the queries you will write will search through only a small subset of those tables. And even the commonly used tables contain many technical, esoteric items - most users will search for only a few columns.

Below is a list of some of the most commonly used tables and a short description of them. Click on any of the table names to be taken to a list of the most commonly used columns in that table. Take some time to understand what these columns mean, because you will use them over and over again in your queries. Click on the table name to see some of the most common data entries in that table (links open in new windows).

PhotoObj - stores information about the images of every object, including run, rerun, camcol, field, ra, dec, magnitudes and object flags.

PlateX - stores information on the aluminum plates that the SDSS uses to take spectra, including their exposure times and reddening information. You will need to find the Plate and MJD in this table to look up an object's spectrum in the Get Spectra tool.

SpecObj - stores information on objects' spectra, including redshifts and spectroscopic classifications.

In addition, SkyServer contains several subsets of the PhotoObj table. PhotoPrimary contains only the "best" measurements of each object. Generally, it's better to use PhotoPrimary rather than PhotoObj, which contains both good and bad data. Star contains only data for stars, Galaxy contains only data for galaxies, and Unknown contains only data for objects classified as "unknown." These subsets are actually views rather than tables; you will learn the difference later in the tutorial.


Two Other Tips

First, SkyServer's Query tool is limited to 90 seconds of search time and 100,000 results. If you want to write queries that return more than 100,000 objects, you have to be clever: split your query into multiple pieces. For example, if you are looking for stars between ra = 0 and ra = 3, you could write two queries, one from ra = 0 to ra = 1.5 and one from ra = 1.5 to ra = 3. Save all the results of the queries until you have all the results you want.

Or, if you have enough computer savvy, you can get around the limit completely by downloading and installing the SDSS Query Analyzer (sdssQA). Or you could use CasJobs, which has no limits on search time or number of results.

If you want the query to return fewer results, you can add the statement "top n" to the select block, where n is some integer from 1 to 1,000. For example, when you're testing to see if a query returns reasonable results, you might not want to have to wade through 1,000 records. You might want to have the query return 10 records instead; use "select top 10".

Second, SQL is not case-sensitive, meaning capital and lowercase letters are the same. The commands "select," "Select," "SELECT" will all do the same thing. But, it's a good idea to use capitalization and spacing to make your queries as easy as possible for other people to understand.

Click Next to learn more about how to write SQL queries.


Enter your SQL query in the text box. The query is limited to 90 seconds and 100,000 rows.