Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Adds a "tables" page because it's a bit strange launching immediately into the connection guides

Paul Copplestone51a29120b5e0
diff --git a/web/docs/guides/database/tables.mdx b/web/docs/guides/database/tables.mdx
new file mode 100644
index 00000000000..61f5a035e01
--- /dev/null
+++ b/web/docs/guides/database/tables.mdx
@@ -0,0 +1,122 @@
+---
+id: tables
+title: Tables
+description: Creating and using Postgres tables.
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+In PostgreSQL, data is stored in "tables".
+
+Tables are made of "columns" and "rows", similar to a spreadsheet. For example:
+
+| `id` | `name` | `description` |
+| ---- | ---- | ----------- |
+| 1 | Toy Story | When a new toy called "Forky" joins Woody and the gang, a road trip alongside old and new friends reveals how big the world can be for a toy. |
+| 2 | Monsters, Inc. | In order to power the city, monsters have to scare children so that they scream. However, the children are toxic to monsters. |
+| 3 | Finding Nemo | After his son is captured in the Great Barrier Reef and taken to Sydney, a timid clownfish sets out on a journey to bring him home. |
+| 4 | WALL-E | In the distant future, a small waste-collecting robot inadvertently embarks on a space journey that will ultimately decide the fate of mankind. |
+| 5 | Up | 78-year-old Carl Fredricksen travels to Paradise Falls in his house equipped with balloons, inadvertently taking a young stowaway. |
+
+This table has 3 "columns": `id`, `name`, and `description`, and 5 "rows" of data.
+
+## Designing tables
+
+Before you can store the data you need to "design" the table.
+This is different from NoSQL databases where you can immediately put any data in your database.
+
+There is a big benefit however: data integrity. PostgreSQL will guarantee that each table fits the rules that you specify.
+As you scale, this will become incredibly important.
+
+## Creating Tables
+
+Supabase gives you several options for creating tables. You can use the Table Editor or create them directly using SQL.
+
+<Tabs
+defaultValue="UI"
+values={[
+ {label: 'UI', value: 'UI'},
+ {label: 'SQL', value: 'SQL'},
+]}>
+<TabItem value="UI">
+
+```sh
+1. Go to the "Table editor" section.
+2. Click "New Table".
+3. Enter the table name "todos".
+4. Click "Save".
+5. Click "New Column".
+6. Enter the column name "task" and make the type "text".
+7. Click "Save".
+```
+
+<video width="99%" muted playsInline controls="true">
+<source src="/videos/api/api-create-table-sm.mp4" type="video/mp4" muted playsInline />
+</video>
+
+</TabItem>
+<TabItem value="SQL">
+
+```sql
+-- Create a table called "todos" with a column to store tasks.
+
+create table todos (
+ id bigint generated by default as identity primary key,
+ task text check (char_length(task) > 3)
+);
+```
+
+</TabItem>
+</Tabs>
+
+## Data types
+
+Every column is a predefined type. PostgreSQL provides many [default types](https://www.postgresql.org/docs/current/datatype.html), and you can even design your own (or use extensions)
+if the default types don't fit your needs.
+
+| `Name` | `Aliases` | `Description` |
+| ------------------------------------------- | -------------------- | ----------------------------------------------------------------- |
+| bigint | int8 | signed eight-byte integer |
+| bigserial | serial8 | autoincrementing eight-byte integer |
+| bit | | fixed-length bit string |
+| bit varying | varbit | variable-length bit string |
+| boolean | bool | logical Boolean (true/false) |
+| box | | rectangular box on a plane |
+| bytea | | binary data (“byte array”) |
+| character | char | fixed-length character string |
+| character varying | varchar | variable-length character string |
+| cidr | | IPv4 or IPv6 network address |
+| circle | | circle on a plane |
+| date | | calendar date (year, month, day) |
+| double precision | float8 | double precision floating-point number (8 bytes) |
+| inet | | IPv4 or IPv6 host address |
+| integer | int, int4 | signed four-byte integer |
+| interval \[ fields \] | | time span |
+| json | | textual JSON data |
+| jsonb | | binary JSON data, decomposed |
+| line | | infinite line on a plane |
+| lseg | | line segment on a plane |
+| macaddr | | MAC (Media Access Control) address |
+| macaddr8 | | MAC (Media Access Control) address (EUI-64 format) |
+| money | | currency amount |
+| numeric | decimal | exact numeric of selectable precision |
+| path | | geometric path on a plane |
+| pg\_lsn | | PostgreSQL Log Sequence Number |
+| pg\_snapshot | | user-level transaction ID snapshot |
+| point | | geometric point on a plane |
+| polygon | | closed geometric path on a plane |
+| real | float4 | single precision floating-point number (4 bytes) |
+| smallint | int2 | signed two-byte integer |
+| smallserial | serial2 | autoincrementing two-byte integer |
+| serial | serial4 | autoincrementing four-byte integer |
+| text | | variable-length character string |
+| time \[ without time zone \] | | time of day (no time zone) |
+| time with time zone | timetz | time of day, including time zone |
+| timestamp \[ without time zone \] | | date and time (no time zone) |
+| timestamp with time zone | timestamptz | date and time, including time zone |
+| tsquery | | text search query |
+| tsvector | | text search document |
+| txid\_snapshot | | user-level transaction ID snapshot (deprecated; see pg\_snapshot) |
+| uuid | | universally unique identifier |
+| xml | | XML data |
\ No newline at end of file