2

Is it possible to create custom domain / data type and associate some trigger with it, for example hash password?

I will have for example password domain and if I set some value to this column, it will automatically hash that, so I don't have to create trigger for each table with password column

asked Nov 20, 2012 at 13:03

1 Answer 1

2

You cannot do that.

As the documentation says:

CREATE TRIGGER creates a new trigger. The trigger will be associated with the specified table or view

This clearly excludes types and domains. (Very logically: triggers are normally fired upon changing something - here you want to change a column, not the type.)

You should instead use a stored procedure to take care of your password column(s). And personally I think the less places password are stored at, the better.

answered Nov 20, 2012 at 13:14
1
  • I agree. in fact, storing a password at all is a very dangerous pasttime. Better to store only the salted hash of the password since it is almost impossible to reverse engineer a salted hash. Commented Nov 20, 2012 at 18:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.