cfahlgren1's picture
cfahlgren1 HF staff
add duplicate checker
e6091f8
---
id: "duckdb-table-info"
title: "Table Info"
slug: "duckdb-table-info-query"
description: "Get detailed information about a table's structure"
code: |
with nested as
(
select unnest(reasoning_chains) as reasoning_chains
from train limit 100
)
select reasoning_chains.* from nested;
---
# 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](https://huggingface.co/datasets/NousResearch/hermes-function-calling-v1?sql_console=true&sql=pragma+table_info%28%27func_calling_singleturn%27%29)
```sql
-- 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](https://duckdb.org/docs/sql/query_syntax/unnest.html).
# Example Usage
<iframe
src="https://huggingface.co/datasets/SkunkworksAI/reasoning-0.01/embed/viewer/default/train?sql_console=true&sql=with+nested+as+%0A++%28%0A++select+unnest%28reasoning_chains%29+as+reasoning_chains%0A++from+train+limit+100%0A%29%0A%0Aselect+reasoning_chains.*+from+nested%3B"
frameborder="0"
width="100%"
height="560px"
></iframe>