SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top