MySQL 4.1.0 Chinese reference manual---6.6 basic mysql user utility commands

Source: Internet
Author: User
Tags count db2 manual mysql reference
mysql| Reference | Reference manual | Chinese MySQL 4.1.0 chinese reference manual---dog (heart sail) Translate MySQL Reference Manual for version 4.1.0-alpha.

6.6 Basic MySQL User Practical commands 6.6.1 use syntax


Use Db_name

The use Db_name statement tells MySQL that the Db_name database is used as the default database for future queries. The database remains in the current database, only to the end of the session or another USE statement is issued:

mysql> use db1;mysql> SELECT COUNT (*) from mytable; # from the db1.mytable select mysql> use db2;mysql> Select COUNT (*) from mytable; # Choose from Db2.mytable.

Depending on the use statement, setting a specific database as the current database does not prevent you from accessing the table in another data. The following example accesses the editor table in the author table and in the DB2 database in the DB1 database:

mysql> use db1;mysql> SELECT author_name,editor_name from author,db2.editor-> WHERE author.editor_id = Db2.edit or.editor_id;

The USE statement provides a compatibility with Sybase.
6.6.2 DESCRIBE syntax (access to column information)


{DESCRIBE | DESC} tbl_name [Col_name | wild]

DESCRIBE is the abbreviation for show COLUMNS from. View Chapter 4.5.6.1 retrieves information about databases, tables, columns, and indexes.

DESCRIBE provides column information about a table. Col_name can be a column name or a string that contains the SQL wildcard character "%" and "_". It is not necessary to enclose the string in quotation marks.

If the column type is different from what you expect based on a CREATE TABLE statement, note that MySQL sometimes changes the column type. View Chapter 6.5.3.1 implicit column definition changes.

This statement is provided to Oracle-compatible.

The show statement provides similar information. View Chapter 4.5.6 Show syntax.


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.