Last active
August 29, 2015 14:04
-
-
Save lucasff/a432560f25bb3bd91784 to your computer and use it in GitHub Desktop.
Add a prefix on tables of a SQL dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Simple script for setting table prefixes in SQL-dump | |
if [ $# != 2 ]; then | |
cat >&2 << EOH | |
This is Drupal database prefixer. | |
Usage: | |
$0 prefix original_db.sql > prefixed_db.sql | |
- all tables will be prefixed with 'prefix' | |
EOH | |
exit 1; | |
fi | |
PRFX=$1; | |
sed "s/^CREATE TABLE /CREATE TABLE $PRFX/i; | |
s/^INSERT INTO /INSERT INTO $PRFX/i; | |
s/^REPLACE /REPLACE $PRFX/i; | |
s/^ALTER TABLE /ALTER TABLE $PRFX/i" $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment