6.6 basic MySQL user command 6.6.1
USE
Syntax
USE db_name
USE db_name
The statement tells MySQL to usedb_name
The database is the default database for future queries. The database is the current database, only until the session ends or anotherUSE
Statement 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 onUSE
Statement 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 accessdb1
In the databaseauthor
Table anddb2
In the databaseeditor
Table:
mysql> USE db1;mysql> SELECT author_name,editor_name FROM author,db2.editor -> WHERE author.editor_id = db2.editor.editor_id;
USE
The statement provides compatibility with Sybase.
6.6.2
DESCRIBE
Syntax (retrieve column information)
{DESCRIBE | DESC} tbl_name [col_name | wild]
DESCRIBE
YesSHOW COLUMNS FROM
. View section 4.5.6.1 to retrieve information about databases, tables, columns, and indexes.
DESCRIBE
Provides column information about a table.col_name
It 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 TABLE
The 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.
SHOW
Statements provide similar information. View chapter 4.5.6SHOW
Syntax.