SQL Data Definition Language

SQL's Data Definition Language (DDL) is for working with tables and indexes. A table defines a set of columns for different fields of data and is similar to a class in Python. Columns are like class properties or variables; rows are like class instances.

DDL has five statements, which we'll look at in turn in the following sections.

Create Table

The CREATE TABLE statement defines the table. It has the following form:

CREATE TABLE table
(field_name sql_type [(size)] [NOT NULL] [index1] , ...)

where

  • field_name is the name of the field being defined

  • sql_type is a valid SQL type

  • size is the size of the field

  • NOT NULL specifies that the column can't be empty or equal to None

The brackets in the statement denote optional ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython 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.