![]() |
|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.6.1 USE Syntax | ||
6.6.2 DESCRIBE Syntax (Get Information About Columns) |
USE
Syntax USE db_name |
The USE db_name
statement tells MySQL to use the db_name
database as the default database for subsequent queries. The database remains
current until the end of the session or until another USE
statement
is issued:
mysql> USE db1; mysql> SELECT COUNT(*) FROM mytable; # selects from db1.mytable mysql> USE db2; mysql> SELECT COUNT(*) FROM mytable; # selects from db2.mytable |
Making a particular database current by means of the USE
statement
does not preclude you from accessing tables in other databases. The following example
accesses the author
table from the db1
database and 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 provided for Sybase compatibility.
DESCRIBE
Syntax (Get Information About Columns) {DESCRIBE | DESC} tbl_name [col_name | wild] |
DESCRIBE
is a shortcut for SHOW COLUMNS FROM
.
See section Retrieving information about Database, Tables, Columns, and Indexes.
DESCRIBE
provides information about a table's columns. col_name
may be a column name or a string containing the SQL `%' and `_'
wildcard characters to obtain output only for the columns with names matching
the string. There is no need to enclose the string in quotes.
If the column types are different from what you expect them to be based on a
CREATE TABLE
statement, note that MySQL sometimes
changes column types. See section Silent Column Specification Changes.
This statement is provided for Oracle compatibility.
The SHOW
statement provides similar information.
See section SHOW
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:45