Basic MySQL user commands

Source: Internet
Author: User
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.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.