A column in relational databases is a named attribute of a table that stores one kind of value for every row, with a declared data type and optional rules that restrict what may be stored. In database fundamentals, the column is also called a field or, in relational theory, an attribute, and it defines the vertical dimension of a table while rows define the horizontal one.
Every value in a table sits at the intersection of exactly one row and one column. The set of columns, together with their types and constraints, forms the core of a table’s schema, so designing columns well is one of the earliest and most consequential decisions in data modeling.
What a column defines in a table
A column defines the meaning, type and rules for a single property that all rows of a table share. Its definition is written in the CREATE TABLE statement and stored in the system catalog, the metadata that the database management system consults on every query.
A column definition is built from several parts. The table below lists the main components and their effect on stored data.
| Component | Example | Effect |
|---|---|---|
| Name | order_date | Identifies the column in queries |
| Data type | DATE, VARCHAR(100) | Limits values and sets storage format |
| Nullability | NOT NULL | Decides whether a value may be missing |
| Default value | DEFAULT CURRENT_DATE | Supplies a value when none is given |
| Constraint | CHECK (price >= 0) | Rejects values that break a rule |
| Collation | Case-insensitive collation | Controls text comparison and sorting |
In relational theory, each attribute draws its values from a domain, the set of permitted values. SQL approximates domains through data types and constraints. Because the order of columns carries no meaning in the relational model, well-written queries name columns explicitly rather than relying on their position.
Column data types and storage
The data type of a column determines which values are valid, how much space they use and how they compare. Choosing the narrowest type that safely covers the real range saves disk space, memory and index size, and it also catches invalid input early.
| Type family | Typical types | Storage and notes |
|---|---|---|
| Integer | SMALLINT, INTEGER, BIGINT | 2, 4 or 8 bytes; exact whole numbers |
| Exact decimal | NUMERIC(p,s), DECIMAL | Variable size; required for money |
| Floating point | REAL, DOUBLE PRECISION | 4 or 8 bytes; approximate values |
| Character | CHAR(n), VARCHAR(n), TEXT | Length depends on content and encoding |
| Temporal | DATE, TIMESTAMP, INTERVAL | Fixed size; supports date arithmetic |
| Boolean | BOOLEAN | Usually 1 byte; true, false or NULL |
| Semi-structured | JSON, JSONB, XML | Flexible content; weaker type checking |
Exact names and limits vary between systems, so a design should be checked against the specific product. A frequent and costly error is storing currency in floating-point columns, which introduces rounding differences; financial amounts belong in exact decimal types or in integer minor units such as cents.
Column compared with row, field and key
A column describes one property across all records, whereas a row describes one record across all properties. The terminology overlaps between communities, which is why the same idea appears under several names.
| Term | Meaning | Relation to a column |
|---|---|---|
| Column | Named, typed property of a table | The concept itself |
| Attribute | Relational theory name for a column | Formal synonym |
| Field | Column, or a single value in one record | Synonym; meaning depends on context |
| Row | One record holding a value per column | Crosses every column once |
| Primary key | Column or columns that identify each row | Built from one or more columns |
| Foreign key | Column referencing another table’s key | A column with a referential rule |
| Index | Structure that speeds lookups on columns | Defined over one or more columns |
A column becomes a key not by its type but by the constraint declared on it. A single column can serve as a primary key, a composite key can span several columns, and a foreign key column enforces referential integrity by allowing only values that exist in the referenced table.
Designing and changing columns
Good column design follows the principle of atomic values, which is the core of first normal form: each column holds one indivisible fact. A column that stores a comma-separated list of tags or a full address in one string makes filtering, validation and indexing difficult.
- Use consistent naming, such as lowercase words separated by underscores, and avoid reserved words like
orderoruser. - Declare NOT NULL by default and allow NULL only where a missing value has a clear meaning.
- Add CHECK and UNIQUE constraints so the database, not only the application, protects data quality.
- Avoid repeating groups such as
phone1,phone2,phone3; move them into a related table instead.
Columns change over a system’s lifetime through ALTER TABLE. The cost of a change depends heavily on the operation and the product, as the following table shows in general terms.
| Change | Usual impact | Precaution |
|---|---|---|
| Add a nullable column | Often a fast metadata change | Backfill data in small batches |
| Add a column with a default | Fast in many modern systems | Check the product version |
| Change the data type | May rewrite the whole table | Use a new column and migrate |
| Rename a column | Fast, but breaks dependent code | Update views, procedures and ORM mappings |
| Drop a column | Fast or deferred cleanup | Confirm no query still reads it |
Row stores and column stores
The column also shapes physical storage. A row-oriented store keeps all columns of a record together on disk, which suits OLTP workloads that read or write whole records. A column-oriented store keeps the values of each column together, which suits analytics that scan a few columns across millions of rows.
Columnar layout compresses well because neighboring values share a type and often repeat, and queries read only the columns they need. The trade-off is slower single-record inserts and updates, which is why many organizations keep transactional data in a row store and copy it to a columnar warehouse for reporting.
The idea in brief
Think of a spreadsheet of customers. Each column has a heading, such as Name, Email or Birth date, and holds the same kind of information for every person in the list. A database column works the same way, but it is stricter.
The database knows what kind of data each column accepts. A date column will refuse the word hello, and a price column can be told never to accept a negative number. These rules keep the information clean and trustworthy, so reports and applications built on top of it give correct results.
A practical scenario
A small online bookstore stores its orders in a table whose total column was originally declared as a floating-point type. After a year, the monthly revenue report differs from the payment provider’s statement by a few cents, and accountants spend hours reconciling the gap.
A database administrator adds a new column total_amount of type NUMERIC(10,2) with a CHECK (total_amount >= 0) constraint, copies the values in batches of 10,000 rows, switches the application to the new column and finally drops the old one. A NOT NULL constraint is added once the backfill is complete.
The migration runs without downtime because each step is small. From the next month on, the report matches the payment statements to the cent, and an attempted import of a negative order total is now rejected by the database itself instead of reaching the books.