Discover more from OpenLampTech
MySQL SHOW TABLES - 2 variations
Learn two variations of the MySQL SHOW TABLES command
This post is an excerpt from one of my premium MySQL Beginner blog posts and content.
If you are new to MySQL and want to learn how to use the database and get the data you need from it, I am making these premium posts and content for you!
Thanks for reading OpenLampTech! Subscribe to the free weekly newsletter for all the great original and curated PHP/MySQL content I share in the publication.
SHOW TABLES Command
In order to
SELECT any data, we have to know what table we want to see the data from. Therefore, we need to know the table name.
We can use the
SHOW TABLES command and retrieve a result set containing the tables which are present in a database. There are 2 variations of
SHOW TABLES, both of which return the same information:
SHOW TABLES IN
;(where database_name is the name of the database)
Let's see an example of each so we are familiar with them both and can use either seamlessly if needed.
In MySQL Workbench, on the first line of the .sql script we are using to execute the MySQL commands, we simply write
USE sakila; as shown in this screenshot:
When you execute
database_name, you're instructing MySQL that the subsequent queries should be run against the named database. We can use
SHOW TABLES; on the next line:
SHOW TABLES; returns a result set with all of the table names for the tables that are part of the sakila database that an authenticated user has permission to see:
Do you need to learn MySQL? Just starting and confused about how to query a table and get the data you need? I am creating premium MySQL Beginners content for this specific reason. To help those who want to learn the basics of MySQL but don't know where to start. Learn more about my premium MySQL blog posts and content as I develop and release them.
SHOW TABLES IN database_name
In the event that you haven't issued the
USE statement, you can specify the named database when you execute the
SHOW TABLES command:
Executing this form of
SHOW TABLES has the same effect, returning a result set of table names in the named database:
How can I help you?
Grab a Gmail HTML Email Signature template from my Etsy shop and make your emails pop and stand out. ✉️
Need hosting for your next web application or WordPress site? I use and highly recommend Hostinger. They have great pricing and service.
I enjoy reading Refind: The essence of the web, every morning in your inbox. Subscribe for free. Help me get a premium subscription by signing up yourself with my referral link.
Grab a free pack of mobile Creator wallpapers with my referral link.
Just getting started or wanting to learn MySQL? Find out about my premium blog posts and MySQL Beginner Series here.
Want to support this newsletter and my work? Drop some spare change in my Tip Jar.💰
Disclosure: Some of the services and products links in this email are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.