Data Definition Language (DDL) is a subset of SQL (Structured Query Language) used to define and modify database schema and structure. It includes commands for creating, altering, and deleting database objects like tables, indexes, and views.
The basic queries used in DDL are:
There are also a couple of SQLite specific queries that you might use:
Usually used to create a new table.
CREATE TABLE tablename ( column1 datatype, column2 datatype );
CREATE TABLE Employees (
EmployeeID int,
FirstName varchar(255),
LastName varchar(255),
BirthDate date
);
Used to modify existing database objects.
ALTER TABLE tablename
ADD column_name datatype;
ALTER TABLE Employees
ADD Email varchar(255);
Used to delete objects from the database.
DROP TABLE tablename;
DROP TABLE Employees;
Used to delete all data inside a table, but not the table itself.
TRUNCATE TABLE tablename;
TRUNCATE TABLE Employees;
The .table command in SQLite is used to list all tables in the current database. It's a part of the SQLite command line shell's special commands, which are not standard SQL queries but are specific to the SQLite CLI.
.table
The PRAGMA table_info statement in SQLite is used to retrieve information about the columns in a specified table. It is particularly useful for understanding the structure of a table, including the names of columns, their data types, whether they can be NULL, and other properties.
PRAGMA table_info(table_name);