# How to write to a database

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2020-08-20
- **Format:** Video · 10 min watch · transcript available
- **Topics:** Data prep, Data engineering
- **Tools:** Snowflake; SQL; Tableau (prep)
- **Canonical:** https://just-tim.com/posts/write-to-database-prep-builder
- **Watch:** https://www.youtu.be/eXbAYhg9q_I

I walk through the new write-to-database capability introduced in Tableau Prep 2020.3, which lets you save flow output directly into a relational database rather than publishing to Tableau Server. Using the Superstore sample flow and a local Postgres database, I demonstrate the three write modes and the errors you can hit along the way.

## Key takeaways

- Tableau Prep 2020.3 lets you write flow output directly to a database via a new 'Database table' output option, alongside the existing 'Publish data source' option.
- Only certain relational databases are supported at launch: SQL Server, MySQL, Postgres, Amazon Redshift, Snowflake, Oracle and Teradata.
- You get three write modes — create table, append to table and replace data — each behaving exactly as named.
- Appending without an ID or timestamp key is risky, since you can't tell which rows arrived when; treat each write as a snapshot and add a time key to separate states.
- Writing to a database is preferable to publishing a data source in enterprise contexts because the data becomes available to other non-Tableau systems.

## Chapters

- 0:00 What's new in Tableau Prep 2020.3
- 0:56 Opening the Superstore sample flow
- 1:35 Choosing the database table output
- 2:50 Connecting to a Postgres database
- 3:59 Naming and creating a new table
- 5:07 The three write modes explained
- 6:26 Running the flow and checking Postgres
- 7:21 Append pitfalls and snapshot keys
- 9:03 Closing thoughts on the feature

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/write-to-database-prep-builder

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
