En PostgreSQL, ALTER TRIGGERALTER TRIGGER
ALTER TRIGGER trigger_name ON table_name RENAME TO new_name;
Analicemos la sintaxis anterior:
- RENOMBRAR A
,
CREATE TABLE staff( user_id serial PRIMARY KEY, username VARCHAR (50) UNIQUE NOT NULL, password VARCHAR (50) NOT NULL, email VARCHAR (355) UNIQUE NOT NULL, created_on TIMESTAMP NOT NULL, last_login TIMESTAMP );
CREATE FUNCTION check_staff_user() RETURNS TRIGGER AS $$ BEGIN IF length(NEW.username) < 8 OR NEW.username IS NULL THEN RAISE EXCEPTION 'The username cannot be less than 8 characters'; END IF; IF NEW.NAME IS NULL THEN RAISE EXCEPTION 'Username cannot be NULL'; END IF; RETURN NEW; END; $$ LANGUAGE plpgsql;
personal
CREATE TRIGGER username_check BEFORE INSERT OR UPDATE ON staff FOR EACH ROW EXECUTE PROCEDURE check_staff_user();
creado anteriormente
ALTER TRIGGER username_check ON staff RENAME TO check_username;
Publicación traducida automáticamente
Artículo escrito por RajuKumar19 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA