-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.sql
More file actions
42 lines (28 loc) · 927 Bytes
/
task2.sql
File metadata and controls
42 lines (28 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#Задание №1
drop user if exists 'shop'@'localhost';
drop user if exists 'shop_read'@'localhost';
CREATE USER 'shop'@'localhost' IDENTIFIED WITH sha256_password BY 'pass';
CREATE USER 'shop_read'@'localhost' IDENTIFIED WITH sha256_password BY 'pass';
GRANT ALL ON shop.* TO 'shop'@'localhost';
GRANT SELECT ON shop.* TO 'shop_read'@'localhost';
#Задание №2
use shop;
drop table if exists accounts;
CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
`password` VARCHAR(255)
) ;
INSERT INTO accounts
(name, `password`)
VALUES
('alex', 'pass1'),
('john', 'pass2'),
('ivan', 'pass3');
drop view if exists accounts_view;
CREATE VIEW accounts_view AS
select *
from accounts;
drop user if exists 'user_read'@'localhost';
CREATE USER 'user_read'@'localhost' IDENTIFIED WITH sha256_password BY 'pass';
GRANT select ON shop.accounts_view TO 'user_read'@'localhost';