Skip to content

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

docs: use the standard run snippet for run-this-query steps (#51974)

Miranda Limonczenkof5b00a523715
diff --git a/apps/docs/content/guides/ai/automatic-embeddings.mdx b/apps/docs/content/guides/ai/automatic-embeddings.mdx
index 7d4b375f5e2..5a9411a2d94 100644
--- a/apps/docs/content/guides/ai/automatic-embeddings.mdx
+++ b/apps/docs/content/guides/ai/automatic-embeddings.mdx
@@ -183,7 +183,7 @@ select
vault.create_secret('http://api.supabase.internal:8000', 'project_url');
```
-When deploying to the cloud platform, open the [SQL editor](/dashboard/project/_/sql/new) and run the following, replacing `<project-url>` with your [project's API URL](/dashboard/project/_/settings/api):
+When deploying to the cloud platform, replace `<project-url>` with your [project's API URL](/dashboard/project/_/settings/api). Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
select
diff --git a/apps/docs/content/guides/database/connecting-to-postgres/pooling-and-limits.mdx b/apps/docs/content/guides/database/connecting-to-postgres/pooling-and-limits.mdx
index 2bb4fe24b57..48e93635a53 100644
--- a/apps/docs/content/guides/database/connecting-to-postgres/pooling-and-limits.mdx
+++ b/apps/docs/content/guides/database/connecting-to-postgres/pooling-and-limits.mdx
@@ -84,7 +84,7 @@ Track connection usage in the [Observability](/dashboard/project/_/observability
- **Dedicated Pooler Client Connections:** active client connections to PgBouncer.
- **Shared Pooler (Supavisor) Client Connections:** active client connections to Supavisor.
-These reports are not real-time. They show the connection count from the last refresh. For up-to-the-second data, query `pg_stat_activity` in the SQL Editor:
+These reports are not real-time. They show the connection count from the last refresh. For up-to-the-second data, query `pg_stat_activity`. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
-- Count connections by application and user name
diff --git a/apps/docs/content/guides/database/extensions/pg_net.mdx b/apps/docs/content/guides/database/extensions/pg_net.mdx
index ffef8232c98..8d6ad94758e 100644
--- a/apps/docs/content/guides/database/extensions/pg_net.mdx
+++ b/apps/docs/content/guides/database/extensions/pg_net.mdx
@@ -456,7 +456,7 @@ Dropping `pg_net` removes its extension-owned objects, including `net.http_reque
</Admonition>
-Run the following commands in the [SQL Editor](/dashboard/project/_/sql/new):
+Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
-- Ensure the target schema exists
diff --git a/apps/docs/content/guides/database/postgres/dropping-all-tables-in-schema.mdx b/apps/docs/content/guides/database/postgres/dropping-all-tables-in-schema.mdx
index bfacb3be120..cdc85ee8929 100644
--- a/apps/docs/content/guides/database/postgres/dropping-all-tables-in-schema.mdx
+++ b/apps/docs/content/guides/database/postgres/dropping-all-tables-in-schema.mdx
@@ -4,7 +4,7 @@ description: 'Useful snippet for deleting all tables in a given schema'
footerHelpType: 'postgres'
---
-Execute the following query to drop all tables in a given schema.
+This query drops all tables in a given schema.
Replace `my-schema-name` with the name of your schema. In Supabase, the default schema is `public`.
<Admonition type="caution">
@@ -13,6 +13,8 @@ This deletes all tables and their associated data. Ensure you have a recent [bac
</Admonition>
+Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
+
```sql
do $$ declare
r record;
@@ -24,5 +26,3 @@ end $$;
```
This query works by listing out all the tables in the given schema and then executing a `drop table` for each (hence the `for... loop`).
-
-You can run this query using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard, or via `psql` if you're [connecting directly to the database](/docs/guides/database/connecting-to-postgres#direct-connection).
diff --git a/apps/docs/content/guides/database/postgres/first-row-in-group.mdx b/apps/docs/content/guides/database/postgres/first-row-in-group.mdx
index 12333740ef6..df20a3f9fdc 100644
--- a/apps/docs/content/guides/database/postgres/first-row-in-group.mdx
+++ b/apps/docs/content/guides/database/postgres/first-row-in-group.mdx
@@ -23,7 +23,7 @@ The expected output we want is:
| 3 | Brighton | 34 |
| 2 | Liverpool | 84 |
-From the [SQL Editor](/dashboard/project/_/sql), you can run a query like:
+Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
select distinct
@@ -41,5 +41,3 @@ The important bits here are:
- The `desc` keyword to order the `points` from highest to lowest.
- The `distinct` keyword that tells Postgres to only return a single row per team.
-
-This query can also be executed via `psql` or any other query editor if you prefer to [connect directly to the database](/docs/guides/database/connecting-to-postgres#direct-connection).
diff --git a/apps/docs/content/guides/database/postgres/row-level-security.mdx b/apps/docs/content/guides/database/postgres/row-level-security.mdx
index 7e1f717331c..fe383b0174c 100644
--- a/apps/docs/content/guides/database/postgres/row-level-security.mdx
+++ b/apps/docs/content/guides/database/postgres/row-level-security.mdx
@@ -113,7 +113,7 @@ Until the suite passes, you don't know whether the policies do what you intended
### Enable RLS and set the grants
-Run these statements in the [SQL Editor](/dashboard/project/_/sql/new) for a one-off change, or in a [migration](/docs/guides/deployment/database-migrations) to keep the change reproducible across environments. Grants and RLS belong in the same migration.
+Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection). To keep the change reproducible across environments, put the statements in a [migration](/docs/guides/deployment/database-migrations) instead. Grants and RLS belong in the same migration.
Enable RLS, then set the grants to match what each role does in your app:
diff --git a/apps/docs/content/guides/database/postgres/which-version-of-postgres.mdx b/apps/docs/content/guides/database/postgres/which-version-of-postgres.mdx
index c5655e0e563..dee20577dcf 100644
--- a/apps/docs/content/guides/database/postgres/which-version-of-postgres.mdx
+++ b/apps/docs/content/guides/database/postgres/which-version-of-postgres.mdx
@@ -6,7 +6,7 @@ footerHelpType: 'postgres'
It's important to know which version of Postgres you are running as each major version has different features and may cause breaking changes. You may also need to update your schema when [upgrading](https://www.postgresql.org/docs/current/pgupgrade.html) or downgrading to a major Postgres version.
-Run the following query using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard:
+Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
show server_version;
@@ -17,5 +17,3 @@ Which should return something like:
```
15.1
```
-
-This query can also be executed via `psql` or any other query editor if you prefer to [connect directly to the database](/docs/guides/database/connecting-to-postgres#direct-connection).
diff --git a/apps/docs/content/guides/deployment/managing-environments.mdx b/apps/docs/content/guides/deployment/managing-environments.mdx
index 5ef90de4319..c9ecafb560b 100644
--- a/apps/docs/content/guides/deployment/managing-environments.mdx
+++ b/apps/docs/content/guides/deployment/managing-environments.mdx
@@ -355,7 +355,7 @@ Error: Error running pg_dump on remote database: pg_dump: error: query failed: E
pg_dump: error: query was: LOCK TABLE "graphql"."_type" IN ACCESS SHARE MODE
```
-To resolve this error, you need to grant `postgres` role permissions to `graphql` schema. You can do that by running the following query from Supabase dashboard's SQL Editor.
+To resolve this error, you need to grant `postgres` role permissions to `graphql` schema. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
grant all on all tables in schema graphql to postgres, anon, authenticated, service_role;
diff --git a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx b/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
index 91b07ad6eb0..73a34fe17c0 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/hono.mdx
@@ -48,7 +48,7 @@ Update the values with your Supabase project URL and publishable key, which you
This app signs users in anonymously, so [enable anonymous sign-ins](/dashboard/project/_/auth/providers) in the Auth settings.
-Anonymous sign-ins use the `authenticated` role, but the database setup in step 2 grants read access to the `anon` role only. Without the privilege and a matching policy for `authenticated`, the instruments query returns no rows. Run the following in the [SQL Editor](/dashboard/project/_/sql/new) to grant the privilege and add the policy:
+Anonymous sign-ins use the `authenticated` role, but the database setup in step 2 grants read access to the `anon` role only. Without the privilege and a matching policy for `authenticated`, the instruments query returns no rows. Grant the privilege and add the policy. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql SQL_EDITOR
grant select on public.instruments to authenticated;
diff --git a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx b/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
index 0d9d6d1f293..f3060abe91f 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/refine.mdx
@@ -165,7 +165,7 @@ export default App
The scaffolded pages create and edit instruments, but the database setup in step 2 grants read access only. Without write privileges and matching policies, the create and edit pages fail with `permission denied for table instruments`.
-Run the following in the [SQL Editor](/dashboard/project/_/sql/new) to grant the privileges and add the policies:
+Grant the privileges and add the policies. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql SQL_EDITOR
grant insert, update, delete on public.instruments to anon;
diff --git a/apps/docs/content/guides/getting-started/quickstarts/spring-boot.mdx b/apps/docs/content/guides/getting-started/quickstarts/spring-boot.mdx
index 84e57cdec81..379d59dd171 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/spring-boot.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/spring-boot.mdx
@@ -69,7 +69,7 @@ If the app fails to start with `Unable to determine Dialect without JDBC metadat
By default Hibernate creates tables in the `public` schema. We recommend changing this as Supabase exposes the `public` schema as a [data API](/docs/guides/api).
-Create the `app` schema before you start the app. Hibernate creates tables in that schema on startup, but it does not create the schema itself. Run the following in the [SQL Editor](/dashboard/project/_/sql/new):
+Create the `app` schema before you start the app. Hibernate creates tables in that schema on startup, but it does not create the schema itself. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql SQL_EDITOR
create schema if not exists app;
diff --git a/apps/docs/content/guides/platform/database-size.mdx b/apps/docs/content/guides/platform/database-size.mdx
index 65466517d3e..6307a2d8ec1 100644
--- a/apps/docs/content/guides/platform/database-size.mdx
+++ b/apps/docs/content/guides/platform/database-size.mdx
@@ -58,7 +58,7 @@ npx supabase link
npx supabase inspect db bloat --linked
```
-If you find a table you would like to immediately clean, you can run the following in the [SQL Editor](/dashboard/project/_/sql/new):
+If you find a table you would like to immediately clean, run `vacuum full` on it. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
vacuum full <table name>;
@@ -145,7 +145,7 @@ limit 50;
### Disabling read-only mode
-You manually override read-only mode to reduce disk size. To do this, run the following in the [SQL Editor](/dashboard/project/_/sql):
+You manually override read-only mode to reduce disk size. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
First, change the [transaction access mode](https://www.postgresql.org/docs/current/sql-set-transaction.html):
diff --git a/apps/docs/content/guides/platform/postgres-connection-logging.mdx b/apps/docs/content/guides/platform/postgres-connection-logging.mdx
index e823658b455..705748238e6 100644
--- a/apps/docs/content/guides/platform/postgres-connection-logging.mdx
+++ b/apps/docs/content/guides/platform/postgres-connection-logging.mdx
@@ -72,7 +72,7 @@ curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/config/database/p
}'
```
-To verify the setting, use the SQL Editor:
+Verify the setting. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
show log_connections;
diff --git a/apps/docs/content/guides/platform/upgrading.mdx b/apps/docs/content/guides/platform/upgrading.mdx
index a98606b0c8e..4fb3d4ca321 100644
--- a/apps/docs/content/guides/platform/upgrading.mdx
+++ b/apps/docs/content/guides/platform/upgrading.mdx
@@ -170,7 +170,7 @@ This affects tools that rely on introspection:
Regular data queries (e.g. `accountCollection`, `insertIntoAccountCollection`) are not affected.
-To re-enable introspection on a schema, run the following SQL in the SQL editor:
+Re-enable introspection on a schema. Run the following SQL using the [SQL Editor](/dashboard/project/_/sql) in the Supabase Dashboard or with `psql` over a direct connection. To connect with `psql`, see [Direct connection](/docs/guides/database/connecting-to-postgres#direct-connection).
```sql
comment on schema public is e'@graphql({"introspection": true})';