7.2. Building Tables
The core components of all relational databases are tables. A table consists of columns, which have certain data types. In this section you will learn how to create simple tables.
To create tables, the CREATE TABLE command must be used. CREATE TABLE is one of the most flexible and most powerful commands available. If you take a look at the syntax overview of the command, you will see that it provides many settings and attributes that can be assigned to a table:
phpbook=# \h CREATE TABLE Command: CREATE TABLE Description: define a new table Syntax: CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name ( { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ] | table_constraint } [, ... ] ) [ INHERITS ...
Get PHP and PostgreSQL: Advanced Web Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.