Postgres Views
Jump to navigation
Jump to search
SECURITY INVOKER indicates that the function is to be executed with the privileges of the user that calls it. That is the default. SECURITY DEFINER specifies that the function is to be executed with the privileges of the user that created it.
https://hevodata.com/learn/postgresql-stored-procedures/
Copy Table
CREATE TABLE users.chat as SELECT * FROM api.chat;
Create View
CREATE VIEW api.chat AS SELECT id, name, user_id, created_at FROM users.chat WHERE (user_id = ( SELECT users.id FROM public.users WHERE ((users.username)::text = CURRENT_USER)));
int to uuid
ALTER TABLE public.items ALTER COLUMN user_id SET DATA TYPE UUID USING (gen_random_uuid());
GRANT VIEW DEFINITION TO [user]; will allow the user to see the definitions of structures in the database, including tables, views, stored procedures, etc. You'll need to do that for every database on the instance. There is no server-wide equivalent, out of the box, that limits permissions to just the database level. If you need to limit it to just a single schema, then you'd do: GRANT VIEW DEFINITION ON schema::[name_of_schema] TO [user];
https://dba.stackexchange.com/questions/128229/execute-system-commands-in-postgresql