DEV Community

Cover image for SQL Review - Useful queries for mySQL
Jo
Jo

Posted on

SQL Review - Useful queries for mySQL

This post will cover some useful mySQL queries that I am just now discovering and that would have been really helpful when I just started my journey of learning sql. Alas, we live and we learn.

Show databases

The

show databases;

command shows you a list of the databases available.

Use database_name

The

use database;

command allows you to switch between databases. I've found this one pretty helpful, pretty helpful I'd been double, triple, and quadrouple clicking a database name in mySQL in order to navigate among databases.

Show table

The

show table

command shows you the tables in a database (which could be especially useful after the use database command)

Desc table_name

The

DESC table_name;

command shows field, type, key, null value, and default values of a table. This is very helpful for troubleshooting.The extra column would hold something like "auto _increment" for a primary key.

Show Warnings

The

SHOW warnings

command shows what the warning message is if your query is not correct in some way.

Discussion (0)