File size: 1,985 Bytes
e6091f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
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>