postgresql创建trigger和函数

---创建函数----
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
   NEW.updated_at = now(); 
   RETURN NEW;
END;
$$ language 'plpgsql';

---移除trigger----
DROP TRIGGER IF EXISTS update_feature_updated_at ON public.feature;
DROP TRIGGER IF EXISTS update_feature_table_updated_at ON public.feature_table;

----创建trigger----
CREATE TRIGGER update_feature_updated_at BEFORE UPDATE ON public.feature FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
CREATE TRIGGER update_feature_table_updated_at BEFORE UPDATE ON public.feature_table FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();