The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds some notes on data loading
Copple67e5898c630e
diff --git a/web/docs/guides/database/tables.mdx b/web/docs/guides/database/tables.mdxindex 353a5fff843..c88492f8a13 100644--- a/web/docs/guides/database/tables.mdx+++ b/web/docs/guides/database/tables.mdx@@ -1,6 +1,6 @@---id: tables-title: Tables, Columns and Rows+title: Tables and Datadescription: Creating and using Postgres tables.---@@ -172,6 +172,83 @@ create table movies ();```+## Loading data++There are several ways to load data in Supabase. You can load data directly into the database or using the [APIs](/docs/guides/api).+Use the "Bulk Loading" instructions if you are loading large data sets.++### Basic data loading++<Tabs+defaultValue="SQL"+values={[+ {label: 'SQL', value: 'SQL'},+ {label: 'JavaScript', value: 'JS'},+ {label: 'Dart', value: 'DART'},+]}>+<TabItem value="SQL">++```sql+insert into movies+ (name, description)+values+ ('The Empire Strikes Back', 'After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker begins Jedi training with Yoda.'),+ ('Return of the Jedi', 'After a daring mission to rescue Han Solo from Jabba the Hutt, the Rebels dispatch to Endor to destroy the second Death Star.');+```++</TabItem>+<TabItem value="JS">++```sql+const { data, error } = await supabase+ .from('movies')+ .insert([{+ name: 'The Empire Strikes Back',+ description: 'After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker begins Jedi training with Yoda.'+ }, {+ name: 'Return of the Jedi',+ description: 'After a daring mission to rescue Han Solo from Jabba the Hutt, the Rebels dispatch to Endor to destroy the second Death Star.'+ }])+```++</TabItem>+<TabItem value="DART">++```sql+final res = await supabase+ .from('movies')+ .insert([{+ name: 'The Empire Strikes Back',+ description: 'After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker begins Jedi training with Yoda.'+ }, {+ name: 'Return of the Jedi',+ description: 'After a daring mission to rescue Han Solo from Jabba the Hutt, the Rebels dispatch to Endor to destroy the second Death Star.'+ }]).execute();+```++</TabItem>+</Tabs>++### Bulk data loading++When inserting large data sets it's best to use PostgreSQL's [COPY](https://www.postgresql.org/docs/current/sql-copy.html) command.+This loads data directly from a file into a table. There are several file formats available for copying data: text, csv, binary, JSON, etc.++For example, if you wanted to load a CSV file into your movies table:++```csv title="./movies.csv"+"The Empire Strikes Back", "After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker begins Jedi training with Yoda."+"Return of the Jedi", "After a daring mission to rescue Han Solo from Jabba the Hutt, the Rebels dispatch to Endor to destroy the second Death Star."+```++You would [connect](/docs/guides/database/connecting-to-postgres#direct-connections) to your database directly and load the file with the COPY command:++```bash+psql -h DATABASE_URL -p 5432 postgres -U postgres \+ -c "COPY movies FROM './movies.csv';"+```++## Joining tables with Foreign KeysTables can be "joined" together using Foreign Keys.