1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter2.The SQL Language</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="tutorial.html" title="PartI.Tutorial">
<link rel="prev" href="tutorial-accessdb.html" title="1.4.Accessing a Database">
<link rel="next" href="tutorial-concepts.html" title="2.2.Concepts">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="tutorial-sql">
<div class="titlepage"><div><div><h2 class="title">
<a name="tutorial-sql"></a>Chapter2.The <acronym class="acronym">SQL</acronym> Language</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="tutorial-sql.html#tutorial-sql-intro">2.1. Introduction</a></span></dt>
<dt><span class="sect1"><a href="tutorial-concepts.html">2.2. Concepts</a></span></dt>
<dt><span class="sect1"><a href="tutorial-table.html">2.3. Creating a New Table</a></span></dt>
<dt><span class="sect1"><a href="tutorial-populate.html">2.4. Populating a Table With Rows</a></span></dt>
<dt><span class="sect1"><a href="tutorial-select.html">2.5. Querying a Table</a></span></dt>
<dt><span class="sect1"><a href="tutorial-join.html">2.6. Joins Between Tables</a></span></dt>
<dt><span class="sect1"><a href="tutorial-agg.html">2.7. Aggregate Functions</a></span></dt>
<dt><span class="sect1"><a href="tutorial-update.html">2.8. Updates</a></span></dt>
<dt><span class="sect1"><a href="tutorial-delete.html">2.9. Deletions</a></span></dt>
</dl>
</div>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="tutorial-sql-intro"></a>2.1.Introduction</h2></div></div></div>
<p> This chapter provides an overview of how to use
<acronym class="acronym">SQL</acronym> to perform simple operations. This
tutorial is only intended to give you an introduction and is in no
way a complete tutorial on <acronym class="acronym">SQL</acronym>. Numerous books
have been written on <acronym class="acronym">SQL</acronym>, including [<a href="biblio.html#melt93" title="[melt93]">melt93</a>] and [<a href="biblio.html#date97" title="[date97]">date97</a>].
You should be aware that some <span class="productname">PostgreSQL</span>
language features are extensions to the standard.
</p>
<p> In the examples that follow, we assume that you have created a
database named <code class="literal">mydb</code>, as described in the previous
chapter, and have started <span class="application">psql</span>.
</p>
<p> Examples in this manual can also be found in the
<span class="productname">PostgreSQL</span> source distribution
in the directory <code class="filename">src/tutorial/</code>. To use those
files, first change to that directory and run <span class="application">make</span>:
</p>
<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd <em class="replaceable"><code>....</code></em>/src/tutorial</code></strong>
<code class="prompt">$</code> <strong class="userinput"><code>make</code></strong></pre>
<p>
This creates the scripts and compiles the C files containing user-defined
functions and types. (You must use GNU make for this [mdash ] it may be named
something different on your system, often <span class="application">gmake</span>.)
Then, to start the tutorial, do the following:
</p>
<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd <em class="replaceable"><code>....</code></em>/src/tutorial</code></strong>
<code class="prompt">$</code> <strong class="userinput"><code>psql -s mydb</code></strong>
<code class="computeroutput">...</code>
<code class="prompt">mydb=></code> <strong class="userinput"><code>\i basics.sql</code></strong></pre>
<p>
The <code class="literal">\i</code> command reads in commands from the
specified file. The <code class="literal">-s</code> option puts you in
single step mode which pauses before sending each statement to the
server. The commands used in this section are in the file
<code class="filename">basics.sql</code>.
</p>
</div>
</div></body>
</html>
|