6.6 basic MySQL user command 6.6.1
USESyntax
USE db_name
USE db_nameThe statement tells MySQL to usedb_nameThe database is the default database for future queries. The database is the current database, only until the session ends or anotherUSEStatement issuing:
Mysql> Use db1; mysql> select count (*) from mytable; # select MySql> Use DB2 from db1.mytable; mysql> select count (*) from mytable; # select from db2.mytable
Rely onUSEStatement to set a specific database as the current database, which does not prevent you from accessing the table in another data. The following example shows how to accessdb1In the databaseauthorTable anddb2In the databaseeditorTable:
mysql> USE db1;mysql> SELECT author_name,editor_name FROM author,db2.editor -> WHERE author.editor_id = db2.editor.editor_id;
USEThe statement provides compatibility with Sybase.
6.6.2
DESCRIBESyntax (retrieve column information)
{DESCRIBE | DESC} tbl_name [col_name | wild]
DESCRIBEYesSHOW COLUMNS FROM. View section 4.5.6.1 to retrieve information about databases, tables, columns, and indexes.
DESCRIBEProvides column information about a table.col_nameIt can be a column name or an SQL wildcard character."%"And"_". There is no need to enclose strings in quotation marks.
If the column type is different from what you expectCREATE TABLEThe column created by the statement. Note that MySQL sometimes changes the column type. See section 6.5.3.1 implicit column definition changes.
This statement is compatible with Oracle.
SHOWStatements provide similar information. View chapter 4.5.6SHOWSyntax.