Skip to content

Instantly share code, notes, and snippets.

@jaymzcd
Created February 15, 2011 17:22
Show Gist options
  • Select an option

  • Save jaymzcd/827841 to your computer and use it in GitHub Desktop.

Select an option

Save jaymzcd/827841 to your computer and use it in GitHub Desktop.
Makes a throwaway table from a flat file with lists of field names (all nullable varchars)
#!/usr/bin/env sh
echo "CREATE TABLE `basename ${1,,} ${1: -4}` ("
echo " id INTEGER AUTO_INCREMENT,"
while read line
do
no_space=${line/ /_}
field_name=${no_space,,}
echo -e " $field_name VARCHAR(50) default NULL,"
done < $1
echo " PRIMARY KEY(id)"
echo ") TYPE=innodb;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment