Тут показані розбіжності між вибраною ревізією та поточною версією сторінки.
| Порівняння попередніх версій Попередня ревізія Наступна ревізія | Попередня ревізія | ||
|
programming:databases:postgresql:roles_example [2020/07/29 15:31] charon [New read-only user] |
programming:databases:postgresql:roles_example [2020/07/29 15:45] (поточний) charon [Grant usage for future tables, sequences, routines in schema for basic roles] |
||
|---|---|---|---|
| Рядок 16: | Рядок 16: | ||
| </ | </ | ||
| + | ---- | ||
| ===== Create basic roles: DO IT ONCE ===== | ===== Create basic roles: DO IT ONCE ===== | ||
| Рядок 28: | Рядок 29: | ||
| GRANT CONNECT ON DATABASE postgres TO experiment_admin, | GRANT CONNECT ON DATABASE postgres TO experiment_admin, | ||
| </ | </ | ||
| + | |||
| + | ---- | ||
| ===== Create new scheme ' | ===== Create new scheme ' | ||
| Рядок 40: | Рядок 43: | ||
| GRANT USAGE ON SCHEMA myschema TO experiment_read_write, | GRANT USAGE ON SCHEMA myschema TO experiment_read_write, | ||
| GRANT ALL PRIVILEGES ON SCHEMA myschema TO experiment_admin; | GRANT ALL PRIVILEGES ON SCHEMA myschema TO experiment_admin; | ||
| + | </ | ||
| + | |||
| + | All next commands in this section require that current user can administer roles // | ||
| + | <code postgresql> | ||
| + | GRANT experiment_admin, | ||
| + | </ | ||
| + | and | ||
| + | <code postgresql> | ||
| + | REVOKE experiment_admin, | ||
| </ | </ | ||
| Рядок 53: | Рядок 65: | ||
| ==== Grant usage for future tables, sequences, routines in schema for basic roles ==== | ==== Grant usage for future tables, sequences, routines in schema for basic roles ==== | ||
| <code postgresql> | <code postgresql> | ||
| - | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_write, | + | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_only, |
| - | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_write, | + | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_only, |
| - | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_write, | + | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_only, |
| - | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_write, | + | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_only, |
| - | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_write, | + | ALTER DEFAULT PRIVILEGES FOR ROLE experiment_read_only, |
| </ | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | These rules above will work only if user switches role (//SET ROLE experiment_admin// | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| ===== How to create new users ===== | ===== How to create new users ===== | ||