mysql_list_dbs()
MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)
This function returns a results set containing a list of
databases found for the current connection. An expression may be given
to select databases whose names match a certain pattern. The
% or _ characters may be used as
wildcards. If NULL is given for the second argument, the names of all
databases on the server will be selected in the results set. Here is
an example:
...
MYSQL_RES *result;
MYSQL_ROW row;
...
result = mysql_list_dbs(mysql, NULL);
while((row = mysql_fetch_row(result)) != NULL)
{ printf("%s \n", row[0]); }
mysql_free_result(result);
...This excerpt extracts a list of databases from the server using
the mysql_list_dbs() function and stores the
results. Using the mysql_fetch_row()
function, each row of the results set is stored temporarily for
printing. To extract a list of databases with “work” in the name,
replace NULL with "%work%“. As with all results
sets, release the resources with
mysql_free_result() when finished.