Data Definition Language
The DDL is used to define the structure of data containers and objects
within the database. The most common of these containers and objects are
tables, indexes, and views. As you’ll see, most objects are defined with a
variation of the CREATE command, such as
CREATE TABLE or CREATE VIEW. The DROP command is used to delete an existing object (and all
of the data it might contain). Examples include DROP TABLE or DROP
INDEX. Because the command syntax is so different, statements like
CREATE TABLE or CREATE INDEX are usually considered to be
separate commands, and not variations of a single CREATE command.
In a sense, the DDL commands are similar to C/C++ header files. DDL commands are used to define the structure, names, and types of the data containers within a database, just as a header file typically defines type definitions, structures, classes, and other data structures. DDL commands are typically used to set up and configure a brand new database before data is entered.
Note
DDL commands define the basic structure of the database and are typically run when a new database is created.
DDL commands are often held in a script file, so that
the structure of the database can be easily recreated. Sometimes, especially
during development, you may need to recreate only part of the database. To
help support this, most CREATE commands
in SQLite have an optional IF NOT EXISTS
clause.
Normally, a CREATE statement will return an error if an object with the requested name ...