<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >The SQL Language</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 8.0.11 Documentation" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Conclusion" HREF="tutorial-conclusion.html"><LINK REL="NEXT" TITLE="SQL Syntax" HREF="sql-syntax.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2007-02-02T03:57:22"></HEAD ><BODY CLASS="PART" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" >PostgreSQL 8.0.11 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="tutorial-conclusion.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="tutorial.html" >Fast Backward</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="admin.html" >Fast Forward</A ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="sql-syntax.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="PART" ><A NAME="SQL" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="TITLE" >II. The SQL Language</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN1055" ></A ><P > This part describes the use of the <ACRONYM CLASS="ACRONYM" >SQL</ACRONYM > language in <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN >. We start with describing the general syntax of <ACRONYM CLASS="ACRONYM" >SQL</ACRONYM >, then explain how to create the structures to hold data, how to populate the database, and how to query it. The middle part lists the available data types and functions for use in <ACRONYM CLASS="ACRONYM" >SQL</ACRONYM > commands. The rest treats several aspects that are important for tuning a database for optimal performance. </P ><P > The information in this part is arranged so that a novice user can follow it start to end to gain a full understanding of the topics without having to refer forward too many times. The chapters are intended to be self-contained, so that advanced users can read the chapters individually as they choose. The information in this part is presented in a narrative fashion in topical units. Readers looking for a complete description of a particular command should look into <A HREF="reference.html" >Part VI</A >. </P ><P > Readers of this part should know how to connect to a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > database and issue <ACRONYM CLASS="ACRONYM" >SQL</ACRONYM > commands. Readers that are unfamiliar with these issues are encouraged to read <A HREF="tutorial.html" >Part I</A > first. <ACRONYM CLASS="ACRONYM" >SQL</ACRONYM > commands are typically entered using the <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > interactive terminal <SPAN CLASS="APPLICATION" >psql</SPAN >, but other programs that have similar functionality can be used as well. </P ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT >4. <A HREF="sql-syntax.html" >SQL Syntax</A ></DT ><DD ><DL ><DT >4.1. <A HREF="sql-syntax.html#SQL-SYNTAX-LEXICAL" >Lexical Structure</A ></DT ><DT >4.2. <A HREF="sql-expressions.html" >Value Expressions</A ></DT ></DL ></DD ><DT >5. <A HREF="ddl.html" >Data Definition</A ></DT ><DD ><DL ><DT >5.1. <A HREF="ddl.html#DDL-BASICS" >Table Basics</A ></DT ><DT >5.2. <A HREF="ddl-default.html" >Default Values</A ></DT ><DT >5.3. <A HREF="ddl-constraints.html" >Constraints</A ></DT ><DT >5.4. <A HREF="ddl-system-columns.html" >System Columns</A ></DT ><DT >5.5. <A HREF="ddl-inherit.html" >Inheritance</A ></DT ><DT >5.6. <A HREF="ddl-alter.html" >Modifying Tables</A ></DT ><DT >5.7. <A HREF="ddl-priv.html" >Privileges</A ></DT ><DT >5.8. <A HREF="ddl-schemas.html" >Schemas</A ></DT ><DT >5.9. <A HREF="ddl-others.html" >Other Database Objects</A ></DT ><DT >5.10. <A HREF="ddl-depend.html" >Dependency Tracking</A ></DT ></DL ></DD ><DT >6. <A HREF="dml.html" >Data Manipulation</A ></DT ><DD ><DL ><DT >6.1. <A HREF="dml.html#DML-INSERT" >Inserting Data</A ></DT ><DT >6.2. <A HREF="dml-update.html" >Updating Data</A ></DT ><DT >6.3. <A HREF="dml-delete.html" >Deleting Data</A ></DT ></DL ></DD ><DT >7. <A HREF="queries.html" >Queries</A ></DT ><DD ><DL ><DT >7.1. <A HREF="queries.html#QUERIES-OVERVIEW" >Overview</A ></DT ><DT >7.2. <A HREF="queries-table-expressions.html" >Table Expressions</A ></DT ><DT >7.3. <A HREF="queries-select-lists.html" >Select Lists</A ></DT ><DT >7.4. <A HREF="queries-union.html" >Combining Queries</A ></DT ><DT >7.5. <A HREF="queries-order.html" >Sorting Rows</A ></DT ><DT >7.6. <A HREF="queries-limit.html" ><TT CLASS="LITERAL" >LIMIT</TT > and <TT CLASS="LITERAL" >OFFSET</TT ></A ></DT ></DL ></DD ><DT >8. <A HREF="datatype.html" >Data Types</A ></DT ><DD ><DL ><DT >8.1. <A HREF="datatype.html#DATATYPE-NUMERIC" >Numeric Types</A ></DT ><DT >8.2. <A HREF="datatype-money.html" >Monetary Types</A ></DT ><DT >8.3. <A HREF="datatype-character.html" >Character Types</A ></DT ><DT >8.4. <A HREF="datatype-binary.html" >Binary Data Types</A ></DT ><DT >8.5. <A HREF="datatype-datetime.html" >Date/Time Types</A ></DT ><DT >8.6. <A HREF="datatype-boolean.html" >Boolean Type</A ></DT ><DT >8.7. <A HREF="datatype-geometric.html" >Geometric Types</A ></DT ><DT >8.8. <A HREF="datatype-net-types.html" >Network Address Types</A ></DT ><DT >8.9. <A HREF="datatype-bit.html" >Bit String Types</A ></DT ><DT >8.10. <A HREF="arrays.html" >Arrays</A ></DT ><DT >8.11. <A HREF="rowtypes.html" >Composite Types</A ></DT ><DT >8.12. <A HREF="datatype-oid.html" >Object Identifier Types</A ></DT ><DT >8.13. <A HREF="datatype-pseudo.html" >Pseudo-Types</A ></DT ></DL ></DD ><DT >9. <A HREF="functions.html" >Functions and Operators</A ></DT ><DD ><DL ><DT >9.1. <A HREF="functions.html#FUNCTIONS-LOGICAL" >Logical Operators</A ></DT ><DT >9.2. <A HREF="functions-comparison.html" >Comparison Operators</A ></DT ><DT >9.3. <A HREF="functions-math.html" >Mathematical Functions and Operators</A ></DT ><DT >9.4. <A HREF="functions-string.html" >String Functions and Operators</A ></DT ><DT >9.5. <A HREF="functions-binarystring.html" >Binary String Functions and Operators</A ></DT ><DT >9.6. <A HREF="functions-bitstring.html" >Bit String Functions and Operators</A ></DT ><DT >9.7. <A HREF="functions-matching.html" >Pattern Matching</A ></DT ><DT >9.8. <A HREF="functions-formatting.html" >Data Type Formatting Functions</A ></DT ><DT >9.9. <A HREF="functions-datetime.html" >Date/Time Functions and Operators</A ></DT ><DT >9.10. <A HREF="functions-geometry.html" >Geometric Functions and Operators</A ></DT ><DT >9.11. <A HREF="functions-net.html" >Network Address Functions and Operators</A ></DT ><DT >9.12. <A HREF="functions-sequence.html" >Sequence Manipulation Functions</A ></DT ><DT >9.13. <A HREF="functions-conditional.html" >Conditional Expressions</A ></DT ><DT >9.14. <A HREF="functions-array.html" >Array Functions and Operators</A ></DT ><DT >9.15. <A HREF="functions-aggregate.html" >Aggregate Functions</A ></DT ><DT >9.16. <A HREF="functions-subquery.html" >Subquery Expressions</A ></DT ><DT >9.17. <A HREF="functions-comparisons.html" >Row and Array Comparisons</A ></DT ><DT >9.18. <A HREF="functions-srf.html" >Set Returning Functions</A ></DT ><DT >9.19. <A HREF="functions-info.html" >System Information Functions</A ></DT ><DT >9.20. <A HREF="functions-admin.html" >System Administration Functions</A ></DT ></DL ></DD ><DT >10. <A HREF="typeconv.html" >Type Conversion</A ></DT ><DD ><DL ><DT >10.1. <A HREF="typeconv.html#TYPECONV-OVERVIEW" >Overview</A ></DT ><DT >10.2. <A HREF="typeconv-oper.html" >Operators</A ></DT ><DT >10.3. <A HREF="typeconv-func.html" >Functions</A ></DT ><DT >10.4. <A HREF="typeconv-query.html" >Value Storage</A ></DT ><DT >10.5. <A HREF="typeconv-union-case.html" ><TT CLASS="LITERAL" >UNION</TT >, <TT CLASS="LITERAL" >CASE</TT >, and <TT CLASS="LITERAL" >ARRAY</TT > Constructs</A ></DT ></DL ></DD ><DT >11. <A HREF="indexes.html" >Indexes</A ></DT ><DD ><DL ><DT >11.1. <A HREF="indexes.html#INDEXES-INTRO" >Introduction</A ></DT ><DT >11.2. <A HREF="indexes-types.html" >Index Types</A ></DT ><DT >11.3. <A HREF="indexes-multicolumn.html" >Multicolumn Indexes</A ></DT ><DT >11.4. <A HREF="indexes-unique.html" >Unique Indexes</A ></DT ><DT >11.5. <A HREF="indexes-expressional.html" >Indexes on Expressions</A ></DT ><DT >11.6. <A HREF="indexes-opclass.html" >Operator Classes</A ></DT ><DT >11.7. <A HREF="indexes-partial.html" >Partial Indexes</A ></DT ><DT >11.8. <A HREF="indexes-examine.html" >Examining Index Usage</A ></DT ></DL ></DD ><DT >12. <A HREF="mvcc.html" >Concurrency Control</A ></DT ><DD ><DL ><DT >12.1. <A HREF="mvcc.html#MVCC-INTRO" >Introduction</A ></DT ><DT >12.2. <A HREF="transaction-iso.html" >Transaction Isolation</A ></DT ><DT >12.3. <A HREF="explicit-locking.html" >Explicit Locking</A ></DT ><DT >12.4. <A HREF="applevel-consistency.html" >Data Consistency Checks at the Application Level</A ></DT ><DT >12.5. <A HREF="locking-indexes.html" >Locking and Indexes</A ></DT ></DL ></DD ><DT >13. <A HREF="performance-tips.html" >Performance Tips</A ></DT ><DD ><DL ><DT >13.1. <A HREF="performance-tips.html#USING-EXPLAIN" >Using <TT CLASS="COMMAND" >EXPLAIN</TT ></A ></DT ><DT >13.2. <A HREF="planner-stats.html" >Statistics Used by the Planner</A ></DT ><DT >13.3. <A HREF="explicit-joins.html" >Controlling the Planner with Explicit <TT CLASS="LITERAL" >JOIN</TT > Clauses</A ></DT ><DT >13.4. <A HREF="populate.html" >Populating a Database</A ></DT ></DL ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="tutorial-conclusion.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="sql-syntax.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Conclusion</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >SQL Syntax</TD ></TR ></TABLE ></DIV ></BODY ></HTML >