Difference between revisions of "SQL USE"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
Line 29: | Line 29: | ||
[[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;