Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # in DataGrip, dump rows as SQL INSERT
  4. # then produce more compact and readable file
  5.  
  6. (
  7. # leave only one INSERT INTO ... VALUES
  8. head -1 $1 | sed -r 's/(INSERT INTO \S+) (.+) (VALUES) .+$/\1\n\2\n\3/' ;
  9. # remove repeating INSERTs, leave only tuples separated by comma and newline
  10. sed -r 's/INSERT INTO \S+ \(.+\) VALUES //' $1 | sed -r 's/;$/,/'
  11. ) | head -c-1
  12. # and remove trailing comma
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement