CREATE TYPE
CREATE TYPE is a SQL statement in the DDL Statements category. Creates a user-defined type (UDT) — a structured type with attributes. PostgreSQL composite type, SQL Server UDDT. The syntax is CREATE TYPE type_name AS (attr1 type1, attr2 type2);. It returns user-defined type. A typical example: -- PostgreSQL: CREATE TYPE address AS (street TEXT, city TEXT, zip TEXT); CREATE TABLE customers (name TEXT, home address); -- SQL Server: CREATE TYPE dbo.phone FROM VARCHAR(20) NOT NULL; CREATE TABLE contacts (name VARCHAR(100), phone dbo.phone); A close relative is CREATE TABLE, which creates a new table in the database with specified columns, data types, and constraints. A close relative is ALTER TABLE, which modifies an existing table: add/drop columns, modify data types, rename, add/drop constraints. A close relative is DROP TABLE, which permanently removes a table and all its data from the database. Cannot be undone. More about this category: Data Definition Language — CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE, CREATE INDEX.