Template for adding a constraint.
Template to add a column. Make sure to change the name and type.
Update a column timestamp on every update.
Schedule PostgreSQL commands directly from the database.
Basic view template. Change according to your preference.
Basic table template. Change "table_name" to the name you prefer.
Template to create a simple function.
Template to create a function a function that return set of table.
Table with constraints example.
Table with foreign key (fk) template. Change "table_name" to the name you prefer.
Delete items in Storage using SQL
Template for dropping / removing constraint.
Template for dropping / removing function.
Template for dropping / removing row level security.
Template for dropping / removing trigger from table.
How to use full text search in PostgreSQL.
Generate YouTube-like short IDs as Postgres Primary Keys.
Update a field with incrementing value using stored procedure.
List all constraints and their tables.
List all foreign keys (FKs) and their columns.
List all the functions in (predefined/user-defined).
List all primary keys (PKs) and their columns.
List all table data size.
List all the triggers in (predefined/user-defined).
Row level security with advanced/complicated policies.
Row level security that requires table joins .
Row level security that make use of security definer functions .
Row level security for read access.
Row level security for restrict updates.
Row level security policies to implement TTL.
Row level security that verify email domains.
Template to rename any constraints you have.
Check your database version.
Starter template for the Next.js Stripe Subscriptions Starter.
Build a todo list with Row Level Security.
Template for updating a constraint.
List all the functions in (predefined/user-defined).
Get all the functions that user-defined in public
schema (by Default)
select n.nspname as schema_name,
p.proname as specific_name,
case p.prokind
when 'f' then 'FUNCTION'
when 'p' then 'PROCEDURE'
when 'a' then 'AGGREGATE'
when 'w' then 'WINDOW'
end as kind,
l.lanname as language,
case when l.lanname = 'internal' then p.prosrc
else pg_get_functiondef(p.oid)
end as definition,
pg_get_function_arguments(p.oid) as arguments,
t.typname as return_type
from pg_proc p
left join pg_namespace n on p.pronamespace = n.oid
left join pg_language l on p.prolang = l.oid
left join pg_type t on t.oid = p.prorettype
where n.nspname in ('public')
order by schema_name,
specific_name;
Get all the functions in the Database
select n.nspname as schema_name,
p.proname as specific_name,
case p.prokind
when 'f' then 'FUNCTION'
when 'p' then 'PROCEDURE'
when 'a' then 'AGGREGATE'
when 'w' then 'WINDOW'
end as kind,
l.lanname as language,
case when l.lanname = 'internal' then p.prosrc
else pg_get_functiondef(p.oid)
end as definition,
pg_get_function_arguments(p.oid) as arguments,
t.typname as return_type
from pg_proc p
left join pg_namespace n on p.pronamespace = n.oid
left join pg_language l on p.prolang = l.oid
left join pg_type t on t.oid = p.prorettype
where n.nspname not in ('pg_catalog', 'information_schema')
order by schema_name,
specific_name;