Skip to content

Instantly share code, notes, and snippets.

@sevaine
Created June 7, 2017 00:28
Show Gist options
  • Save sevaine/4e3356af93f016ecef2ba9ecf370047e to your computer and use it in GitHub Desktop.
Save sevaine/4e3356af93f016ecef2ba9ecf370047e to your computer and use it in GitHub Desktop.
SQL Select update http url
#
# This should update the url to NEW_IP and NEW_PORT ( UNTESTED )
#
DEFINE NEW_IP = '10.10.10.10'
DEFINE NEW_PORT = '443'
UPDATE DB_NAME.TABLE_NAME
SET field_name=REGEXP_REPLACE(field_name, '(http?://)(.*):(.*)/(.*)', '\1&NEW_IP:&NEW_PORT/\4')
WHERE field_name LIKE 'http%'
AND field_name NOT LIKE '%uri/path%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment