Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Last active March 20, 2019 07:48
Show Gist options
  • Save yyoshiki41/8dfe9807e55ce9ef2c2621bfedd76ca9 to your computer and use it in GitHub Desktop.
Save yyoshiki41/8dfe9807e55ce9ef2c2621bfedd76ca9 to your computer and use it in GitHub Desktop.
#!/bin/bash
output="./output.txt"
db="db_name"
user="root"
tables=$(mysql -uroot ${db} -e "SHOW TABLES;")
for table in ${tables}
do
if [ "${table}" == "Tables_in_dev_foo" ]; then
continue
fi
mysqlshow -u${user} ${db} "${table//_/\_}" >> "${output}"
echo "" >> "${output}"
done
@yyoshiki41
Copy link
Author

output

Database: db_name  Table: alembic_version
+-------------+-------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| Field       | Type        | Collation          | Null | Key | Default | Extra | Privileges                      | Comment |
+-------------+-------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| version_num | varchar(32) | utf8mb4_general_ci | NO   | PRI |         |       | select,insert,update,references |         |
+-------------+-------------+--------------------+------+-----+---------+-------+---------------------------------+---------+

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment