Now that we have learned how to create a table, let's look at the list of tables we have created in our database.
As you can see, "SHOW TABLES;" will print out a list of the tables that have been created in the current database. To view more detailed information about each table, use "DESCRIBE tablename;".
As you can see, all necessary table information is listed for reference when a table is described.
And last but not least, if you ever lose track of what database you are using, using SELECT DATABASE(); will show you the currently selected database.
mysql> SHOW TABLES;
+---------------------------------+
| Tables_in_YourDatabase |
+---------------------------------+
| pets |
+---------------------------------+
1 row in set (0.00 sec)
As you can see, "SHOW TABLES;" will print out a list of the tables that have been created in the current database. To view more detailed information about each table, use "DESCRIBE tablename;".
mysql> DESCRIBE pets;
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(75) | YES | | NULL | |
| breed | varchar(75) | YES | | NULL | |
| gender | varchar(7) | YES | | NULL | |
| dateofbirth | varchar(25) | YES | | NULL | |
| description | text | YES | | NULL | |
| pedigree | text | YES | | NULL | |
| medicalrecord | text | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)
As you can see, all necessary table information is listed for reference when a table is described.
And last but not least, if you ever lose track of what database you are using, using SELECT DATABASE(); will show you the currently selected database.
0 comments:
Post a Comment