Skip to content

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

Formats the JSON document

Paul Copplestonee79467cff16b
diff --git a/web/docs/guides/database/json.mdx b/web/docs/guides/database/json.mdx
index bdeb8e0d957..facdc9987d1 100644
--- a/web/docs/guides/database/json.mdx
+++ b/web/docs/guides/database/json.mdx
@@ -30,35 +30,43 @@ values={[
<TabItem value="SQL">
```sql
-CREATE TABLE books (
- id SERIAL PRIMARY KEY,
- title TEXT,
- author TEXT,
- metadata JSONB
+create table books (
+ id serial primary key,
+ title text,
+ author text,
+ metadata jsonb
);
```
</TabItem>
<TabItem value="UI">
-```bash
+```sh
+Create the table:
+
1. Go to the Table Editor
-- New Table
-- Create a new table named `books`
- - include primary key `id`, type `int8`, default value `Automatically generate as indentity`
- - Save the new table
- - `New Column`
- - Name the new column `title`
- - Make it type `text`
- - Save the new column
- - `New Column`
- - Name the new column `author`
- - Make it type `text`
- - Save the new column
- - `New Column`
- - Name the new column `metadata`
- - Make it type `jsonb`
- - Save the new column
+2. Click "New Table"
+3. Name the table "books"
+4. Include a primary key with the following properties:
+ - Name: "id"
+ - Type: "int8"
+ - Default value: "Automatically generate as indentity"
+5. Click "Save"
+
+
+Click "New Column" and 3 new columns with the following properties:
+
+1. title column:
+ - Name: "title"
+ - Type: "text"
+
+2. author column:
+ - Name: "author"
+ - Type: "text"
+
+3. metadata column:
+ - Name: "metadata"
+ - Type: "jsonb"
```
</TabItem>
@@ -88,22 +96,34 @@ values={[
<TabItem value="SQL">
```sql
-insert into books (title, author, metadata) values
-('The Poky Little Puppy',
- 'Janette Sebring Lowrey',
- '{"description":"Puppy is slower than other, bigger animals.","price":5.95,"ages":[3,6]}'),
-('The Tale of Peter Rabbit',
- 'Beatrix Potter',
- '{"description":"Rabbit eats some vegetables.","price":4.49,"ages":[2,5]}'),
-('Tootle',
- 'Gertrude Crampton',
- '{"description":"Little toy train has big dreams.","price":3.99,"ages":[2,5]}'),
-('Green Eggs and Ham',
- 'Dr. Seuss',
- '{"description":"Sam has changing food preferences and eats unusally colored food.","price":7.49,"ages":[4,8]}'),
-('Harry Potter and the Goblet of Fire',
- 'J.K. Rowling',
- '{"description":"Fourth year of school starts, big drama ensues.","price":24.95,"ages":[10,99]}');
+insert into books
+ (title, author, metadata)
+values
+ (
+ 'The Poky Little Puppy',
+ 'Janette Sebring Lowrey',
+ '{"description":"Puppy is slower than other, bigger animals.","price":5.95,"ages":[3,6]}'
+ ),
+ (
+ 'The Tale of Peter Rabbit',
+ 'Beatrix Potter',
+ '{"description":"Rabbit eats some vegetables.","price":4.49,"ages":[2,5]}'
+ ),
+ (
+ 'Tootle',
+ 'Gertrude Crampton',
+ '{"description":"Little toy train has big dreams.","price":3.99,"ages":[2,5]}'
+ ),
+ (
+ 'Green Eggs and Ham',
+ 'Dr. Seuss',
+ '{"description":"Sam has changing food preferences and eats unusally colored food.","price":7.49,"ages":[4,8]}'
+ ),
+ (
+ 'Harry Potter and the Goblet of Fire',
+ 'J.K. Rowling',
+ '{"description":"Fourth year of school starts, big drama ensues.","price":24.95,"ages":[10,99]}'
+ );
```
</TabItem>
@@ -189,7 +209,8 @@ values={[
<TabItem value="SQL">
```sql
-SELECT * FROM books;
+select *
+from books;
```
</TabItem>
@@ -234,12 +255,14 @@ values={[
<TabItem value="SQL">
```sql
-SELECT title,
+select
+ title,
metadata -> 'description' AS description,
metadata -> 'price' as price,
metadata -> 'ages' -> 0 as low_age,
metadata -> 'ages' -> 1 as high_age
-FROM books;
+from
+ books;
```
</TabItem>