¡Esta es una revisión vieja del documento!
psql -U postgres enter into console with user postgres.
\q exit.
create schema api;
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');
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;
ALTER USER user_name WITH PASSWORD 'new_password';
SELECT * FROM test;
a
---
1
2
3
SELECT a,
CASE WHEN a=1 THEN 'one'
WHEN a=2 THEN 'two'
ELSE 'other'
END
FROM test;
a | case
---+-------
1 | one
2 | two
3 | other
case when p.parent_id is null then false else true end as has_parent
</code>