Column (database)
In relational databases, a column is a set of data values of a particular simple data type, one value for each row of the table. A column represents an attribute or characteristic of the entity modeled by the table. It is also referred to as a field.
Each column in a table has a name (the column heading) that uniquely identifies it within that table. The name should ideally be descriptive of the data it contains. All values within a column must conform to the column's defined data type, which specifies the kind of values that can be stored, such as integer, text (string), date, or boolean. The data type also imposes constraints on the possible operations that can be performed on the values.
Columns are defined when a table is created using a Data Definition Language (DDL) statement, such as CREATE TABLE
. The definition includes the column's name, data type, and any constraints like NOT NULL
(requiring a value to be present) or UNIQUE
(ensuring that each value in the column is distinct).
Columns are fundamental to the structure and organization of relational databases, enabling efficient storage, retrieval, and manipulation of data. Queries, often expressed in SQL (Structured Query Language), commonly specify which columns to select and how to filter rows based on column values. The choice of appropriate column names and data types is crucial for designing effective and maintainable database schemas.