pgm/sql/localDB.sql
2020-10-24 23:12:10 -05:00

22 lines
756 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;