O'Reilly logo

SQL in a Nutshell, 3rd Edition by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

CREATE/ALTER TABLE Statement

Manipulating tables is one of the most common activities that database administrators and programmers perform when working with database objects. This section details how to create and modify tables.

The ANSI standard represents a sort of least common denominator among the vendors. Although not all vendors offer every option of the ANSI-standard version of CREATE TABLE and ALTER TABLE, the ANSI standard does represent the basic form that can be used across all of the platforms. Conversely, the vendor platforms offer a variety of extensions and additions to the ANSI standards for CREATE and ALTER TABLE.

Tip

Typically, a great deal of consideration goes into the design and creation of a table. This discipline is known as database design. The discipline of analyzing the relationship of a table to its own data and to other tables within the database is known as normalization. We recommend that database programmers and administrators alike study both database design and normalization principles thoroughly before issuing CREATE TABLE commands.

Platform

Command

MySQL

Supported, with variations

Oracle

Supported, with variations

PostgreSQL

Supported, with variations

SQL Server

Supported, with variations

SQL2003 Syntax

The SQL2003 statement CREATE TABLE creates a permanent or temporary table within the database where the command is issued. The syntax is as follows:

CREATE [{LOCAL TEMPORARY| GLOBAL TEMPORARY}] TABLE table_name
   (column_name datatype attributes[, ...]) |
   [

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required