Skip to content

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

FInal fix.

Ramiro Nuñez Dosioe9983fe6dfe8
diff --git a/apps/www/_blog/2022-09-08-choosing-a-postgres-primary-key.mdx b/apps/www/_blog/2022-09-08-choosing-a-postgres-primary-key.mdx
index edc6f412497..ef7dc5487f6 100644
--- a/apps/www/_blog/2022-09-08-choosing-a-postgres-primary-key.mdx
+++ b/apps/www/_blog/2022-09-08-choosing-a-postgres-primary-key.mdx
@@ -63,15 +63,14 @@ After running that query, we can double check our results:
SELECT * FROM users;
```
-id |      email       |   name
-
-----+------------------+----------
-
-  1 | [email protected]  | new_user
-
-  2 | [email protected] | new_user
+| id | email | name |
+|----|------------------|----------|
+| 1 | [email protected] | new user |
+| 2 | [email protected] | new user |
+```sql
(2 rows)
+```
Using `COUNT(*)` in our query is not the most efficient (or even easiest) solution though, and hopefully it's clear why -- **counting a sequence of numbers for primary keys is a feature built in to Postgres**!
@@ -102,17 +101,20 @@ OK, now let's try inserting into it - we shouldn't have to specify `id`:
INSERT INTO users_serial (email, name) VALUES ('[email protected]', 'new user');
```
+```sql
SELECT * FROM users;
+```
- id |      email       |   name
-
-----+------------------+----------
-  1 | [email protected] | new user
+| id | email | name |
+|----|------------------|----------|
+| 1 | [email protected] | new user |
-(1 row)
+```sql
+(1 row)
INSERT 0 1
+```
It works, as you might expect - now the application doesn't have to *somehow magically know* the right ID to use when inserting.