
CREATE TABLE users (
  id serial not null,
  firstname varchar(100),
  middlename varchar(100),
  lastname varchar(100),
  email varchar(200),
  create_date timestamp default current_timestamp,
  last_update timestamp default current_timestamp
  )
;

CREATE LANGUAGE plpgsql ;

CREATE OR REPLACE FUNCTION update_modified_column()	
RETURNS TRIGGER AS $$
BEGIN
    NEW.last_update = now();
    RETURN NEW;	
END;
$$ language plpgsql ;

CREATE TRIGGER update_users BEFORE UPDATE ON users 
FOR EACH ROW EXECUTE PROCEDURE  update_modified_column();


insert into users (lastname ) values('Kamifuji');
insert into users (lastname ) values('Isihara');
insert into users (lastname ) values('Lin');

