mysql_select_db - Online Linux Manual PageSection : 3
Updated :
Source : Version 3.2.2
Note : MariaDB Connector/C

Namemysql_select_db − selects a database as default

Synopsis #include <mysql.h> int mysql_select_db(MYSQL * mysql, const char * db);

DescriptionSelects a database as default. Returns zero on success, non−zero on failure

Parameters• mysql is a connection identifier, which was previously allocated by mysql_init(3) and connected by mysql_real_connect(3). • db − the default database name

Notes• To retrieve the name of the default database either execute the SQL command SELECT DATABASE() or retrieve the value via mariadb_get_infov(3) API function. • The default database can also be set by the db parameter in mysql_real_connect(3).

Examples

SQL # switch to default database test USE test; # check default database SELECT DATABASE(); +−−−−−−−−−−−−+ | database() | +−−−−−−−−−−−−+ | test | +−−−−−−−−−−−−+

MariadDB Connector/C static int set_default_db(MYSQL *mysql) { int rc; char *default_db; /* change default database to test */ rc= mysql_select_db(mysql, "test"); if (rc) return rc; /* Error */ /* get the default database */ rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_SCHEMA, &default_db); if (rc) return rc; /* Error */ if (strcmp("test", default_db) != NULL) { printf("Wrong default database\n"); return 1; } printf("Default database: %s", default_db); return 0; }

See alsomysql_real_connect(3)
0
Johanes Gumabo
Data Size   :   7,802 byte
man-mysql_select_db.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   3 / 182,357
Visitor ID   :     :  
Visitor IP   :   3.17.181.112   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.