Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.

Description

Structured Query Language (SQL) is the most common language to use for interacting with relational databases. However, over the years, database vendors have implemented extensions of SQL to provide more functionality as well as simplify queries. Because most database systems are not fully compliant with the ANSI standards, and offer features not specified by ANSI, SQL is usually non-portable - syntax that works on one vendor does not necessarily work on another.

Tag Guidelines

This tag should be used for general SQL programming language questions. Be sure to also tag questions with for the specific database system(s) that you are using, so that reviews can use the appropriate SQL dialect and feature set. Database product tags include:

Question Guidelines

If you request a code review for an SQL query,

  • Provide some context about what your query is trying to accomplish.
    • Does it run as an offline batch job on a reporting database? Or does it run on your primary database, and the user expects an immediate response?
    • Does the code execute the query in one shot, or does it execute the query many times in a loop?
    • Are there any tables where the number of rows could be a concern?
  • Include sufficient information about your database schema (table definitions)
  • If query performance is a concern,
    • Ensure that indexes are in place, and mention them when describing the schema.
    • Include the output from executing the statement EXPLAIN SELECT.

Other Sites

SQL questions may also be appropriate on Database Administrators if they are not beginner questions. Questions about schema design would probably be best suited to Programmers SE.

history | excerpt history

Code Language (used for syntax highlighting): lang-sql