Created
May 22, 2015 04:18
-
-
Save siteshen/0a73a53030a84112e870 to your computer and use it in GitHub Desktop.
Example of update value of column with millions of rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| x=0 | |
| while [ $x -lt 5432 ]; do | |
| prev=$(expr $x \* 1000000) | |
| next=$(expr $(expr $x + 1) \* 1000000) | |
| echo $(date +'%Y-%m-%d %H:%M:%S'), $prev, $next | |
| x=$(expr $x + 1) | |
| psql -c "UPDATE followships SET is_deleted = false WHERE is_deleted IS NULL and id >= $prev and id <= $next;" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment