The MySQL server, when installed, comes with certain default databases. One of those databases is mysql. In this recipe, we will learn to display all the table names that are available in the mysql database.
Displaying all the built-in tables in a default mysql database
How to do it...
- Create a MySQL object:
mysql_init(NULL);
- Establish a connection to the MySQL server running at the specified host. Also, connect to the desired database:
mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)
- Create an execute SQL statement, comprised of show tables:
mysql_query(conn, "show tables")
- Save the result of the executing SQL query (that is, the table information of the mysql database) into a resultset...