diff --git a/README.md b/README.md index 34f309c..1ef3d9b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_534 TILs and counting..._ +_535 TILs and counting..._ --- @@ -28,6 +28,7 @@ _534 TILs and counting..._ * [JavaScript](#javascript) * [Linux](#linux) * [Mac](#mac) +* [MySQL](#mysql) * [Phoenix](#phoenix) * [PostgreSQL](#postgresql) * [Rails](#rails) @@ -228,6 +229,10 @@ _534 TILs and counting..._ - [List All The Say Voices](mac/list-all-the-say-voices.md) - [Resizing Both Corners Of A Window](mac/resizing-both-corners-of-a-window.md) +### MySQL + +- [List Databases And Tables](mysql/list-databases-and-tables.md) + ### Phoenix - [Bypass Template Rendering](phoenix/bypass-template-rendering.md) diff --git a/mysql/list-databases-and-tables.md b/mysql/list-databases-and-tables.md new file mode 100644 index 0000000..b8fae92 --- /dev/null +++ b/mysql/list-databases-and-tables.md @@ -0,0 +1,42 @@ +# List Databases And Tables + +If you've started a [mysql](https://dev.mysql.com/) session, but haven't +connected to a particular database yet, you can list the available databases +like so: + +```sql +> show databases; ++-----------------------------+ +| Database | ++-----------------------------+ +| information_schema | +| my_app_dev | ++-----------------------------+ +``` + +If you are curious about the tables in a particular database, you can list +them by specifying the database's name: + +```sql +> show tables in my_app_dev ++------------------------------+ +| Tables_in_my_app_dev | ++------------------------------+ +| pokemons | +| trainers | ++------------------------------+ +``` + +Alternatively, you can connect to the database of interest and then there is +no need to specify the name of the database going forward. + +```sql +use my_app_dev; +show tables; ++------------------------------+ +| Tables_in_my_app_dev | ++------------------------------+ +| pokemons | +| trainers | ++------------------------------+ +```