MySQL dump to tables

A very small GAWK script that splits a mysql text dump to separate table dump files.

#!/bin/sh
# GPLv2 by Erno Rigo <mcree_AT_tricon_DOT_hu>
 
gawk '
 BEGIN { FS=" "; dest="/dev/null" }
 /^(USE)/ { dir=gensub(";","","g",$2) ; dir=gensub("`","","g",dir) ; system("mkdir "dir) }
 /^(CREATE|USE|DROP)/ { fflush(dest); dest="/dev/null" }
 /^CREATE TABLE/ { file=gensub("`","","g",$3) ; fflush(dest); dest=dir"/"file".sql" }
 { print >> dest }
'

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:mysql_dump_to_tables
en/blog/mysql_dump_to_tables.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0