Difference between revisions of "SQL USE"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision: SQL) |
Yvonne.milne (Talk | contribs) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Sets the specified database as the default database for subsequent queries | Sets the specified database as the default database for subsequent queries | ||
− | |||
==Syntax== | ==Syntax== | ||
USE <database name> | USE <database name> | ||
− | |||
==See Also== | ==See Also== | ||
− | [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[CLOSE DATABASES]], [[COPY DATABASE]], [[CREATE INDEX]], [[CREATE TABLE]], [[CREATE VIEW | + | [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[CLOSE DATABASES]], [[COPY DATABASE]], [[CREATE INDEX]], [[CREATE TABLE]], [[CREATE VIEW]], [[DISPLAY SCHEMAS]], [[DROP DATABASE]], [[DROP INDEX]], [[DROP TABLE]], [[GETENV()]], [[LIST SCHEMAS]], [[OPEN DATABASE]], [[SET AUTOCATALOG]], [[SET SQL]] |
− | + | ||
==Description== | ==Description== | ||
The USE command sets the specified 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. Tables from other databases can still be accessed, but must be indicated by including the database name in the table reference, database!table. | The USE command sets the specified 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. Tables from other databases can still be accessed, but must be indicated by including the database name in the table reference, database!table. | ||
− | |||
− | |||
SQL must be set to MySQL before using the USE command in this way. | SQL must be set to MySQL before using the USE command in this way. | ||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | set sql to mysql | |
− | + | USE hr; | |
− | + | SELECT staff_no, lastname from staff; | |
− | + | USE accounts; | |
− | + | SELECT salesid from customer; | |
− | + | USE hr; | |
− | + | SELECT staff_no, lastname, customerno from staff, accounts!customer | |
where staff.staff_no = accounts!customer.salesid; | where staff.staff_no = accounts!customer.salesid; | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL|USE]] | [[Category:SQL|USE]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
[[Category:Databases]] | [[Category:Databases]] | ||
− |
Latest revision as of 10:49, 4 February 2013
Contents
Purpose
Sets the specified database as the default database for subsequent queries
Syntax
USE <database name>
See Also
ADD TABLE, ALTER INDEX, ALTER TABLE, CLOSE DATABASES, COPY DATABASE, CREATE INDEX, CREATE TABLE, CREATE VIEW, DISPLAY SCHEMAS, DROP DATABASE, DROP INDEX, DROP TABLE, GETENV(), LIST SCHEMAS, OPEN DATABASE, SET AUTOCATALOG, SET SQL
Description
The USE command sets the specified 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. Tables from other databases can still be accessed, but must be indicated by including the database name in the table reference, database!table.
SQL must be set to MySQL before using the USE command in this way.
Example
set sql to mysql USE hr; SELECT staff_no, lastname from staff; USE accounts; SELECT salesid from customer; USE hr; SELECT staff_no, lastname, customerno from staff, accounts!customer where staff.staff_no = accounts!customer.salesid;