Created
April 14, 2015 16:23
-
-
Save disciplezero/93bcb7bc069633f89e0d to your computer and use it in GitHub Desktop.
Get Primary MySQL Key
This file contains hidden or 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/bash | |
HOST=$1 | |
USER=$2 | |
PASS=$3 | |
DATABASE=$4 | |
TABLE=$5 | |
# head/tail to get the second line. The first column is the table, so we delete everything afterwards. | |
mysql -h $HOST -u $USER --password=$PASS $DATABASE -e 'show columns from '"$TABLE"' where `Key`="Pri";'| head -2 |tail -1|sed "s/\t.*//g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment