SHOW DATABASES
We will try to display a drop down list box with all database names as options. We will use PHP & PDO with database connection to display list of databases.
Here is the code.
<?Php
require "config.php"; // Database Connection
$result = $dbo->query("SHOW DATABASES");
echo "<select name=d1>";
while ($row = $result->fetch(PDO::FETCH_NUM)) {
echo "<option value='$row[0]'>$row[0]</option>";
}
echo "</select>";
?>
<?Php
require "config.php"; // Database Connection
$result = $dbo->query("SHOW TABLES");
while ($row = $result->fetch(PDO::FETCH_NUM)) {
echo $row[0]."<br>";
}
?>
show tables where Tables_in_sql_tutorial like 'analytics_%'
this will display all tables ( names ) starting with analytics_ inside the database sql_tutorial
SHOW TABLES like 'analytics_%'
SELECT table_name FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'sql_tutorial'
ORDER BY table_name ASC
SQL ReferencesPrimary Key constraint
Create Table
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.