linkend="MELT93"> and .
- You should be aware that some language
- features are extensions to the standard.
+ You should be aware that some
PostgreSQL
+ language features are extensions to the standard.
The \i command reads in commands from the
specified file. The -s option puts you in
- single step mode which pauses before sending a query to the
+ single step mode which pauses before sending each query to the
server. The commands used in this section are in the file
basics.sql.
Each table is a named collection of rows.
- Each row has the same set of named columns,
+ Each row of a given table has the same set of named
+ columns,
and each column is of a specific data type. Whereas columns have
a fixed order in each row, it is important to remember that SQL
does not guarantee the order of the rows within the table in any
- way (unless they are explicitly sorted).
+ way (although they can be explicitly sorted for display).
INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
- Note that all data types use rather obvious input formats. The
+ Note that all data types use rather obvious input formats.
+ Constants that are not simple numeric values usually must be
+ surrounded by single quotes ('>), as in the example.
+ The
date column is actually quite flexible in what it
accepts, but for this tutorial we will stick to the unambiguous
format shown here.
VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29');
You can list the columns in a different order if you wish or
- even omit some columns, e.g., unknown precipitation:
+ even omit some columns, e.g., if the precipitation is unknown:
INSERT INTO weather (date, city, temp_hi, temp_lo)
VALUES ('1994-11-29', 'Hayward', 54, 37);
(2 rows)
- which gives us one output row per city. We can filter these grouped
+ which gives us one output row per city. Each aggregate result is
+ computed over the table rows matching that city.
+ We can filter these grouped
rows using HAVING:
(1 row)
- which gives us the same results for only the cities that have some
- below-forty readings. Finally, if we only care about cities whose
+ which gives us the same results for only the cities that have all
+ temp_lo> values below forty. Finally, if we only care about
+ cities whose
names begin with S
, we might do