Sloan Digital Sky Survey
SkyServer DR15  
Not logged in Login Help
 

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

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 (or views) 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 a table (or view) name in the list below to launch a popup window showing the most commonly-searched data columns in that table/view.

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, you can get around the limit completely writing your query in CasJobs  (new window), 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.

Format HTML XML CSV

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