Name
mysql_list_dbs( )
Synopsis
MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)
This 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.
... 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, NULL would be
replaced with "%work%
“. As with all results sets,
release the resources with mysql_free_result( )
when finished.
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.