system.columns
Read-only metadata for columns across registered server databases. Use it to discover a table's declared schema rather than inferring a schema from its current values.
Columns
| Name | Meaning |
|---|---|
| database | Managed database name. |
| table | Table or view name; quote this identifier in SQL. |
| name | Column name. |
| type | Declared type text. |
| position | One-based column position. |
| default_kind | Kind of declared default or generated value. |
| default_expression | SQL expression defining that value. |
| is_in_primary_key | Whether the column is part of the primary key. |
| is_nullable | Whether the column permits a top-level NULL. |
| primary_key_position | Position in the declared key, or zero when absent. |
| schema_name | Connection namespace, such as main or temp. |
| is_temporary | Whether the object belongs to the observing temporary namespace. |
Example
sql
CREATE TABLE documented_columns(id UInt32, label String);sql
SELECT name, type, position
FROM system.columns
WHERE "table" = 'documented_columns' AND schema_name = 'main'
ORDER BY position
FORMAT csv;text
"id","UInt32",1
"label","String",2Always use the system qualifier. This service relation is provided by the server, rather than a standalone embedded connection. See system.tables for object-level metadata.