sql-snippets / src /snippets /table_info.md
cfahlgren1's picture
cfahlgren1 HF staff
add more examples
15917f6
metadata
id: duckdb-table-info
title: Table Info
slug: duckdb-table-info-query
description: Get detailed information about a table's structure
code: |
  -- Returns detailed information about a table's structure
  -- Use this to get the column names, types, and other details
  PRAGMA table_info('table_name');

DuckDB Table Info Query

This snippet demonstrates how to use the PRAGMA table_info function in DuckDB to get detailedinformation about a specific table's structure.

Try out this query here

-- Returns detailed information about a table's structure
-- Use this to get the column names, types, and other details
PRAGMA table_info('table_name');

Example Output

cid name type notnull dflt_value pk
0 id VARCHAR false null false
1 conversations STRUCT("from" VARCHAR, "value" VARCHAR)[] false null false
2 category VARCHAR false null false
3 subcategory VARCHAR false null false
4 task VARCHAR false null false

You can read more about this here.