PSQL convert/hash all values in a column

The equivalent of this pseudo-code:

for password in passwd:
    set password = crypt(password, my encryption method)

Is an update statement:

update t
    set password = crypt(password, . . .);

SQL is a set-based language. SQL queries do not have a looping mechanism because the language is operating on entire tables (or filtered subsets thereof).

You can add a where clause if you want to filter the rows so not all are updated.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top