Skip to content

Instantly share code, notes, and snippets.

@filipelenfers
Last active August 29, 2015 14:04
Show Gist options
  • Save filipelenfers/1ccb484e6829c1ce1812 to your computer and use it in GitHub Desktop.
Save filipelenfers/1ccb484e6829c1ce1812 to your computer and use it in GitHub Desktop.
Regex detect varchar fields replace bad chars
replace in varchars fields
find: ([a-zA-Z0-9_]*)\s*varchar\(\d{2,4}\)
replace: replace(replace(t.$1,'|','-'),'"','¬') $1
date format to YYYY/MM/DD HH:MM:SS
find: ([a-zA-Z0-9_]*)\s+(datetime|timestamp){1}
replace: TO_CHAR(t.$1,'YYYY/MM/DD HH24:MI:SS') $1
clean other types
find: ([a-zA-Z0-9_]*)\s+(integer|bigint){1}
replace: t.$1
Expected format of the text:
id integer,
fk_id bigint,
mydata1 varchar(256),
mydata2 varchar(256),
mydate3 varchar(256),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment