Extensions
Usage
#### Generating Data {#docs:extensions:tpch::generating-data}  
To generate data for scale factor 1, use:  
```sql
CALL dbgen(sf = 1);
```  
Calling `dbgen` does not clean up existing TPC-H tables.
To clean up existing tables, use `DROP TABLE` before running `dbgen`:  
```sql
DROP TABLE IF EXISTS customer;
DROP TABLE IF EXISTS lineitem;
DROP TABLE IF EXISTS nation;
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS partsupp;
DROP TABLE IF EXISTS region;
DROP TABLE IF EXISTS supplier;
```  
#### Running a Query {#docs:extensions:tpch::running-a-query}  
To run a query, e.g., query 4, use:  
```sql
PRAGMA tpch(4);
```  
| o_orderpriority | order_count |
|-----------------|------------:|
| 1-URGENT        | 10594       |
| 2-HIGH          | 10476       |
| 3-MEDIUM        | 10410       |
| 4-NOT SPECIFIED | 10556       |
| 5-LOW           | 10487       |  
#### Listing Queries {#docs:extensions:tpch::listing-queries}  
To list all 22 queries, run:  
```sql
FROM tpch_queries();
```  
This function returns a table with columns `query_nr` and `query`.  
#### Listing Expected Answers {#docs:extensions:tpch::listing-expected-answers}  
To produced the expected results for all queries on scale factors 0.01, 0.1, and 1, run:  
```sql
FROM tpch_answers();
```  
This function returns a table with columns `query_nr`, `scale_factor`, and `answer`.