
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Different methods to check if a MySQL table exist?
Let us see some of the ways to check if a table exist in MySQL or not.
Using SHOW
The SHOW command displays all the tables.
SHOW tables;
Here is the output.
+--------------------------+ | Tables_in_business | +--------------------------+ | addcheckconstraintdemo | | addcolumntable | | addconstraintdemo | | alphademo | | autoincrement | | autoincrementtable | | backticksymbol | | bookindexes | | chardemo | | checkdemo | | clonestudent | | columnexistdemo | | columnvaluenulldemo | | commaseperatedemo | | dateadddemo | | deletedemo | | deleterecord | | demo | | demo1 | | demoascii | | demoauto | | demobcrypt | | demoemptyandnull | | demoint | | demoonreplace | | demoschema | | demowhere | | distinctdemo | | duplicatebookindexes | | duplicatefound | | employeetable | | escapedeom | | existsrowdemo | | findandreplacedemo | | firsttable | | foreigntable | | foreigntabledemo | | functiontriggersdemo | | groupdemo | | groupdemo1 | | ifelsedemo | | imagedemo | | incasesensdemo | | indexingdemo | | int1demo | | intdemo | | latandlangdemo | | limitoffsetdemo | | milliseconddemo | | modifycolumnnamedemo | | modifydatatype | | moneydemo | | moviecollection | | multipleindexdemo | | multiplerecordwithvalues | | mytable | | mytable1 | | nextpreviousdemo | | nonasciidemo | | nthrecorddemo | | nulldemo | | nullwithselect | | numbercolumndemo | | ondemo | | pasthistory | | presenthistory | | primarytable | | primarytable1 | | primarytabledemo | | qutesdemo | | rowcountdemo | | rownumberdemo | | rowstranspose | | rowstransposedemo | | secondtable | | sequencedemo | | smallintdemo | | sortingvarchardemo | | spacecolumn | | student | | tbldemotrail | | tblf | | tblfirst | | tblfunctiontrigger | | tblifdemo | | tblp | | tblselectdemo | | tblstudent | | tbluni | | tblupdatelimit | | textdemo | | texturl | | timestampdemo | | trailingandleadingdemo | | transcationdemo | | triggedemo | | trigger1 | | trigger2demo | | unsigneddemo | | updtable | | usernameandpassworddemo | | varchardemo | | varchardemo1 | | varchardemo2 | | varcharurl | | whereconditon | | xmldemo | +--------------------------+ 107 rows in set (0.15 sec)
Using LIKE to display a single table
Here is the syntax.
SHOW TABLES LIKE 'yourTableName';
Let us now implement the above syntax in the following query.
mysql> SHOW TABLES LIKE 'tblstudent';
Here is the output.
+---------------------------------+ | Tables_in_business (tblstudent) | +---------------------------------+ | tblstudent | +---------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- How to check if a column exist in a MySQL table?
- Check if table exist without using “select from” in MySQL?
- How to check if a table exists in MySQL and create if it does not already exist?
- MySQL query to check if multiple rows exist?
- How do I detect if a table exist in MySQL?
- How to check whether a stored procedure exist in MySQL?
- How to select from MySQL table A that does not exist in table B?
- Check if a value exists in a column in a MySQL table?
- MySQL SELECT from table A that does not exist in table B using JOINS?
- How to check if any value is Null in a MySQL table single row?
- Check if a table is empty or not in MySQL using EXISTS
- How to insert only those records that does not exist in a MySQL table?
- Check if given multiple keys exist in a dictionary in Python
- Create a table if it does not already exist and insert a record in the same query with MySQL
- How to check if a table already exists in the database with MySQL with INFORMATION_SCHEMA.TABLES.?

Advertisements