Rahul Kumar (@rahul)
Let's assume that you forgot the name of a database or table, or what the structure of a given table is (for example, what its columns are called)? MySQL addresses this problem through several statements that provide information about the databases and tables it supports. Let's learn this quickly..
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| college |
| university |
+------------+
You have previously seen SHOW DATABASES
, which lists the databases managed by the server. To find out which database is currently selected, use the DATABASE()
function:
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| college |
+------------+
If you have not yet selected any database, the result is
.NULL
To find out what tables the default database contains (for example, when you are not sure about the name of a table), use this statement:
mysql> SHOW TABLES;
+---------------------+
| Tables_in_college |
+---------------------+
| student |
| course |
+---------------------+
If you want to find more information about the table and its structure then you can use the following key
mysql> DESCRIBE pet;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| owner | varchar(20) | YES | | NULL | |
| species | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
| death | date | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
Add a thoughtful comment...
✨ Explore more tech insights and coding wonders with @dsabyte! Your journey in innovation has just begun. Keep learning, keep sharing, and let's continue to code a brighter future together. Happy exploring! 🚀❤️
Join the "News Later" community by entering your email. It's quick, it's easy, and it's your key to unlocking future tech revelations.
Weekly Updates
Every week, we curate and deliver a collection of articles, blogs and chapters directly to your inbox. Stay informed, stay inspired, and stay ahead in the fast-paced world of technology.
No spam
Rest assured, we won't clutter your inbox with unnecessary emails. No spam, only meaningful insights, and valuable content designed to elevate your tech experience.