22 lines
989 B
SQL
22 lines
989 B
SQL
create schema test;
|
|
create table test.employees (
|
|
Id SERIAL NOT NULL PRIMARY KEY,
|
|
Name VARCHAR(50),
|
|
Location VARCHAR(50)
|
|
);
|
|
create table test.company (
|
|
cid SERIAL NOT NULL PRIMARY KEY,
|
|
Name VARCHAR(50)
|
|
);
|
|
create table test.employer (
|
|
eid SERIAL NOT NULL PRIMARY KEY,
|
|
Id INT,
|
|
cid INT
|
|
);
|
|
ALTER TABLE test.employer add constraint emp_fk foreign key(Id) REFERENCES test.employees(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
insert into test.employees (name,location) VALUES ('bob','kalamazoo');
|
|
create role test with login password 'test';
|
|
insert into test.employees (name,location) VALUES ('cheeks','magoo');
|
|
update test.employees set location = 'buttsville' where name = 'cheeks';
|
|
grant all privileges on schema test to test;
|