

Discover more from OpenLampTech
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!
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
;SHOW TABLES IN
database_name
;
(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.
SHOW TABLES
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 USE
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:
Executing 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:
Visit my blog Digital Owl’s Prose, where I write regularly on CodeIgniter, PHP, and SQL. I’m also active on Medium, LinkedIn, Twitter, and Instagram.
How can I help you?
Are you thinking of starting up a blog? I use WordPress for my blog, Digital Owl’s Prose. Let’s both save money on the plans offered. 💸
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.
Cover image credits: Image by Clker-Free-Vector-Images from Pixabay