Skip to content

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

Add data types table to docs site old and new, link to it from the Dashboard

Terry Sutton56da65fab8da
diff --git a/apps/temp-docs/docs/guides/database/tables.mdx b/apps/temp-docs/docs/guides/database/tables.mdx
index 89626dab66d..fbe8b1f9450 100644
--- a/apps/temp-docs/docs/guides/database/tables.mdx
+++ b/apps/temp-docs/docs/guides/database/tables.mdx
@@ -8,7 +8,7 @@ import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
-In Postgres, data is stored in "tables".
+In Postgres, data is stored in "tables".
Tables are similar to excel spreadsheets. They contain columns & rows of data. There are a few key differences from a spreadsheet however:
- Every column is a strict type of data. When you set up a column, you must define the "data type".
@@ -26,8 +26,8 @@ For example, this table has 3 "columns" (`id`, `name`, `description`) and 4 "row
## Creating Tables
-Supabase provides several options for creating tables. You can use the Table Editor or create them directly using SQL.
-We provide a SQL editor within the Dashboard, or you can [connect](/docs/guides/database/connecting/connecting-to-postgres) to your database
+Supabase provides several options for creating tables. You can use the Table Editor or create them directly using SQL.
+We provide a SQL editor within the Dashboard, or you can [connect](/docs/guides/database/connecting/connecting-to-postgres) to your database
and run the SQL queries yourself.
@@ -77,12 +77,37 @@ create table todos (
### 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)
+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.
+Here's a list of the data types that are available to use in the table editor in the Dashboard:
+
+| `Name` | `Description` | `Example` |
+| ------------------------------------------- | -------------------- | ----------------------------------------------------------------- |
+| int2 | Can contain numbers between -32,768 and 32,767 | For storing numbers like ages of people, distance between places or numbers you know will be fairly small. |
+| int4 | Can contain numbers between -2,147,483,648 and +2,147,483,648 | For storing numbers like the population of small towns or cities that you know will be less than about 2 billion. |
+| int8 | Can contain numbers between 9,223,372,036,854,775,808 and +9,223,372,036,854,775,808 | For storing numbers larger than roughly 2 billion. Like the number of people who live in the Northern vs Southern hemisphere or the total number of COVID-19 vaccinations administered. |
+| float4 | Can contain numbers with up to 6 decimal places | For storing things like temperature (22.5 degrees Celsius) or distance (10.25kms)|
+| float8 | Can contain numbers with up to 15 decimal places | For storing numbers with a high level of precision, like scientific or mathematical data. |
+| numeric | Can contain 131,072 digits before the decimal point and 16,383 digits after the decimal point. | For storing number that require very high precision. Use the numeric type when you need more precision than float4 or float8 offer. |
+| json | Can contain JSON data. | For storing data that logically belongs together, like a person's street address. Useful for when you want to store dynamic fields and not have every field represented as a column in your table. |
+| jsonb | The JSONB type stores your JSON input as a binary code instead of as an exact copy of the JSON data. JSONB is faster, more efficient and supports indexing. | If you are doing a lot of JSON manipulation in Postgres you should consider using JSONB for efficiency. Otherwise, if you are just doing typical data storing and fetching, JSON should be fine. |
+| text | Can contain strings of any length. | For storing any kind of textual data. Examples include text contents of recipes or blog posts. This is the general purpose data type for textual content. |
+| varchar | Can contain strings with a fixed length | For storing a string where you would want to limit the length to 160 characters. |
+| uuid | Can store a universal unique identifier. | For storing unique IDs, like when you need to store a reference to another table row. |
+| date | Can store a data value without time. | For storing dates like birthdays or holidays with a year, month and day. |
+| time | Can store the time of day | For storing things like when a process starts and stops at specific times in the day. The lights come on at 6:00:00 a.m. and go off at 10:00:00 p.m. |
+| timez | Can store the time of day, along with a timezone. | For storing things like event start times, like an Apple event starting at 10:00:00 a.m. Pacific Time. |
+| timestamp | Can store the date and time without a timezone. | For storing times like: May 1st, 2022 at 10 a.m. |
+| timestampz | Can store the date and time with a timezone. | For storing times like: May 1st, 2022 at 10 a.m, Pacific Time. |
+| bool | Can store boolean values | For storing things that will be true or false, like user_is_subscribed or show_homepage_ad. |
+
+
+Here's a complete list of all of the default data types provided by Postgres:
+
<details>
<summary>Show/Hide default data types</summary>
-
+
| `Name` | `Aliases` | `Description` |
| ------------------------------------------- | -------------------- | ----------------------------------------------------------------- |
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
index 0899f282991..11ba0519fc7 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
@@ -209,10 +209,9 @@ const ColumnEditor: FC<Props> = ({
<div className="text-sm grid md:grid-cols-12 md:gap-x-4 ">
<p className='text-scale-1100 col-span-7 col-start-5 -mt-4'>
- <a href="https://supabase.com/pricing" target="_blank" className="underline inline-block gap-1 p-2 rounded-sm">
+ <a href="https://supabase.com/docs/guides/database/tables#data-types" target="_blank" className="underline inline-block gap-1 p-2 rounded-sm">
Learn more about data types
</a>
-
</p>
</div>
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx
index 7bcda81f19c..46d7af3bd69 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx
@@ -319,20 +319,17 @@ const ColumnManagement: FC<Props> = ({
</div>
<div className="flex items-center justify-between">
- {!hasImportContent && (
- <Button type="default" onClick={() => onAddColumn()}>
- Add column
- </Button>
- )}
- <p className='text-sm text-scale-1100'>
- <a href="https://supabase.com/pricing" target="_blank" className="underline flex items-center gap-1">
- Learn more about data types
- </a>
- </p>
+ {!hasImportContent && (
+ <Button type="default" onClick={() => onAddColumn()}>
+ Add column
+ </Button>
+ )}
+ <p className='text-sm text-scale-1100'>
+ <a href="https://supabase.com/docs/guides/database/tables#data-types" target="_blank" className="underline flex items-center gap-1">
+ Learn more about data types
+ </a>
+ </p>
</div>
-
-
-
</div>
<ForeignKeySelector
tables={tables}
diff --git a/web/docs/guides/database/tables.mdx b/web/docs/guides/database/tables.mdx
index 75c77c70293..54b3236deda 100644
--- a/web/docs/guides/database/tables.mdx
+++ b/web/docs/guides/database/tables.mdx
@@ -85,30 +85,31 @@ You must define the "data type" when you create a column.
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.
-Here's a list of the data types that are available to use in the Dashboard.
+Here's a list of the data types that are available to use in the table editor in the Dashboard:
| `Name` | `Description` | `Example` |
| ------------------------------------------- | -------------------- | ----------------------------------------------------------------- |
| int2 | Can contain numbers between -32,768 and 32,767 | For storing numbers like ages of people, distance between places or numbers you know will be fairly small. |
| int4 | Can contain numbers between -2,147,483,648 and +2,147,483,648 | For storing numbers like the population of small towns or cities that you know will be less than about 2 billion. |
-| int8 | Can contain numbers between 9,223,372,036,854,775,808 and +9,223,372,036,854,775,808 | For storing numbers larger than about 2 billion. Like the number of people who live in the Northern vs Southern hemisphere or the total number of COVID-19 vaccinations administered. |
+| int8 | Can contain numbers between 9,223,372,036,854,775,808 and +9,223,372,036,854,775,808 | For storing numbers larger than roughly 2 billion. Like the number of people who live in the Northern vs Southern hemisphere or the total number of COVID-19 vaccinations administered. |
| float4 | Can contain numbers with up to 6 decimal places | For storing things like temperature (22.5 degrees Celsius) or distance (10.25kms)|
| float8 | Can contain numbers with up to 15 decimal places | For storing numbers with a high level of precision, like scientific or mathematical data. |
-| numeric | Can contain 131, 072 digits before the decimal point and 16, 383 digits after the decimal point. | For storing number that require very high precision. Use the numeric type when you need more precision than float4 or float8 offer. |
-| json | Can contain JSON data. | For storing data that logically belongs together, like a person’s street address. Useful for when you want to store dynamic fields and not have every field specified as a row in your table. |
-| jsonb | The JSONB type stores your JSON input as a binary code instead of as an exact copy of the JSON data. JSONB is faster, more efficient and supports indexing. | Not sure what the json vs jsonb recommendation should be. I think we should make one though. It’s really not clear from my reading. |
+| numeric | Can contain 131,072 digits before the decimal point and 16,383 digits after the decimal point. | For storing number that require very high precision. Use the numeric type when you need more precision than float4 or float8 offer. |
+| json | Can contain JSON data. | For storing data that logically belongs together, like a person's street address. Useful for when you want to store dynamic fields and not have every field represented as a column in your table. |
+| jsonb | The JSONB type stores your JSON input as a binary code instead of as an exact copy of the JSON data. JSONB is faster, more efficient and supports indexing. | If you are doing a lot of JSON manipulation in Postgres you should consider using JSONB for efficiency. Otherwise, if you are just doing typical data storing and fetching, JSON should be fine. |
| text | Can contain strings of any length. | For storing any kind of textual data. Examples include text contents of recipes or blog posts. This is the general purpose data type for textual content. |
-| varchar | Can contain strings with a fixed length | For storing a string where you would want to limit the length to 255 characters. |
+| varchar | Can contain strings with a fixed length | For storing a string where you would want to limit the length to 160 characters. |
| uuid | Can store a universal unique identifier. | For storing unique IDs, like when you need to store a reference to another table row. |
-| date | Can store a data value without time. | For storing dates like birthdays or holidays. |
-| time | Can store the time of day | For storing things like when a process starts and stops. |
-| timez | Can store the time of day, along with a timezone. | For storing things like event start times, like an Apple event starting at 10a.m. Pacific Time. |
-| timestamp | Can store the date and time without a timezone. | For storing times like: May 1st, 2022 at 10a.m. |
-| timestampz | Can store the date and time with a timezone. | For storing times like: May 1st, 2022 at 10a.m, Pacific Time. |
-| bool | Can store boolean values | For storing things like user_is_subscribed or show_homepage_ad. |
+| date | Can store a data value without time. | For storing dates like birthdays or holidays with a year, month and day. |
+| time | Can store the time of day | For storing things like when a process starts and stops at specific times in the day. The lights come on at 6:00:00 a.m. and go off at 10:00:00 p.m. |
+| timez | Can store the time of day, along with a timezone. | For storing things like event start times, like an Apple event starting at 10:00:00 a.m. Pacific Time. |
+| timestamp | Can store the date and time without a timezone. | For storing times like: May 1st, 2022 at 10 a.m. |
+| timestampz | Can store the date and time with a timezone. | For storing times like: May 1st, 2022 at 10 a.m, Pacific Time. |
+| bool | Can store boolean values | For storing things that will be true or false, like user_is_subscribed or show_homepage_ad. |
-Here's a complete list of all of the default data types provided by Postgres.
+Here's a complete list of all of the default data types provided by Postgres:
+
<details>
<summary>View all default data types</summary>