The Use command allows us to work with the database.
Use command format: Use < database name >;
For example, if the XHKDB database exists, try to access it:
mysql> use XHKDB;
screen tip: Database changed
1) The USE statement can advertise that MySQL uses the Db_name database as the default (current) database for subsequent statements. The database remains as the default database until the end of the segment, or until the next different use statement appears:
mysql> use DB1;
mysql> SELECT COUNT (*) from mytable; # selects from Db1.mytable
mysql> use DB2;
mysql> SELECT COUNT (*) from mytable; # selects from Db2.mytable
2) Using the USE statement to mark a particular current database does not prevent you from accessing tables in other databases. The following example accesses the author table from the DB1 database and accesses the editor table from the DB2 database:
mysql> use DB1;
mysql> SELECT author_name,editor_name from Author,db2.editor
WHERE author.editor_id = db2.editor.editor_id;
The USE statement is set up to be compatible with Sybase.
Some netizens asked, how to quit after the connection. In fact, you do not have to quit, use the database, using show databases can query all the database, if you want to jump to another database, with
Use other database names
you can do it.
Notes MySQL command use: Using the database