
column
A column represents a single field or attribute in a database table or DataFrame that contains values of the same data type.
Definition
A column represents a single field or attribute in a database table or DataFrame that contains values of the same data type. Think of it like a vertical slice in a spreadsheet — every value in that slice represents the same kind of information, like names, dates, or numbers. In a customer database, for example, columns might include first_name, email, and signup_date. Each row is a record; each column is one attribute of every record.
Working with Columns in DuckDB
DuckDB provides powerful ways to work with columns through SQL. You can select specific columns:
SELECT first_name, email FROM customers
Or use wildcards with exclusions:
SELECT * EXCLUDE (password, api_key) FROM users
DuckDB also offers unique column operations not found in most databases, like selecting columns by pattern:
SELECT COLUMNS('order_*') FROM sales
Or applying functions across multiple columns:
SELECT MIN(COLUMNS(*)) FROM metrics
Data Types
Each column must have a consistent data type — for example, a date column can't contain arbitrary text strings. DuckDB supports standard SQL types like INTEGER, VARCHAR, and TIMESTAMP, but also modern types like JSON, MAP, and STRUCT for more complex data structures.
Best Practices
Column names should be descriptive and follow a consistent naming convention. While DuckDB is case-insensitive for column names, it's good practice to use lowercase with underscores (snake_case) for readability. Column names should avoid spaces or special characters, though DuckDB allows you to use them if you wrap the name in double quotes.
Related column concepts
The term "column" describes the logical field. Two closely related ideas are worth distinguishing:
- Columnar storage is the physical layout that stores each column's values together on disk. It is what makes analytical (OLAP) engines like DuckDB fast at scanning and aggregating a few columns across many rows — a different concept from the column itself.
- Generated columns are columns whose values are computed automatically from an expression over other columns, rather than being inserted directly.
Related terms
The SELECT statement is the workhorse of SQL, used to retrieve and transform data from tables, views, or other data sources.
DataFrame →A DataFrame is a two-dimensional data structure that organizes data into rows and columns, similar to a spreadsheet or database table.
Generated column →A generated column is a table column whose value is automatically computed from an expression involving other columns, rather than being stored directly by INSERT or UPDATE statements.
UNPIVOT →UNPIVOT reshapes wide data by turning multiple columns into rows, converting a set of columns into name/value pairs -- the inverse of PIVOT.
NATURAL JOIN →A NATURAL JOIN automatically joins two tables on all columns that share the same name, without an explicit ON or USING clause.
UNIQUE constraint →A UNIQUE constraint ensures that all values in a column, or combination of columns, are distinct across every row in a table.
FAQS
A column is a single field or attribute in a table (or DataFrame) that holds values of the same data type—like a vertical slice of a spreadsheet where every value represents the same kind of information.
Use SELECT col1, col2 FROM table. DuckDB also supports SELECT * EXCLUDE (col) to omit columns and SELECT COLUMNS('pattern') to select columns by pattern.
No. Each column has a single, consistent data type (e.g. INTEGER, VARCHAR, TIMESTAMP); a date column can't contain arbitrary text. DuckDB enforces the column's type.
