Related Documentation Download this Manual
PDF (US Ltr) - 40.4Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
USEdb_name TheUSE statement tells MySQL to use the named database as the default (current) database for subsequent statements. This statement requires some privilege for the database or some object within it.
The named database remains the default until the end of the session or anotherUSE statement is issued:
USE db1;SELECT COUNT(*) FROM mytable; # selects from db1.mytableUSE db2;SELECT COUNT(*) FROM mytable; # selects from db2.mytableThe database name must be specified on a single line. Newlines in database names are not supported.
Making a particular database the default by means of theUSE statement does not preclude accessing tables in other databases. The following example accesses theauthor table from thedb1 database and theeditor table from thedb2 database:
USE db1;SELECT author_name,editor_name FROM author,db2.editor WHERE author.editor_id = db2.editor.editor_id;Related Documentation Download this Manual
PDF (US Ltr) - 40.4Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb