Herramientas de usuario

Herramientas del sitio


wiki2:postgresql

¡Esta es una revisión vieja del documento!


PostgreSQL

Basics

psql -U postgres enter into console with user postgres.

\q exit.

Create schema

create schema api;

Create table and insert

create table api.todos (
  id serial primary key,
  done boolean not null default false,
  task text not null,
  due timestamptz
);

insert into api.todos (task) values
  ('finish tutorial 0'), ('pat self on back');

Make a role

create role web_anon nologin;
grant web_anon to postgres;

grant usage on schema api to web_anon;
grant select on api.todos to web_anon;

The web_anon role has permission to access things in the api schema, and to read rows in the todos table.

… Other:

create role todo_user nologin;
grant todo_user to postgres;

grant usage on schema api to todo_user;
grant all on api.todos to todo_user;
grant usage, select on sequence api.todos_id_seq to todo_user;
wiki2/postgresql.1523629357.txt.gz · Última modificación: 2020/05/09 09:25 (editor externo)