Difference between revisions of "SQL USE"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Class==
 
SQL Applications
 
 
 
 
==Purpose==
 
==Purpose==
 
Sets the specified database as the default database for subsequent queries
 
Sets the specified database as the default database for subsequent queries
Line 12: Line 8:
  
 
==See Also==
 
==See Also==
[[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[CREATE TABLE]], [[CREATE INDEX]], [[CREATE VIEW]], [[DB_DATADIR]], [[DROP DATABASE]], [[DROP INDEX]], [[DROP TABLE]], [[GETENV()]], [[SET AUTOCATALOG]], [[SET SQL]]
+
[[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[CLOSE DATABASES]], [[COPY DATABASE]], [[CREATE INDEX]], [[CREATE TABLE]], [[CREATE VIEW]], [[DB_DATADIR]], [[DISPLAY SCHEMAS]], [[DROP DATABASE]], [[DROP INDEX]], [[DROP TABLE]], [[GETENV()]], [[LIST SCHEMAS]], [[OPEN DATABASE]], [[SET AUTOCATALOG]], [[SET SQL]]
  
  
Line 37: Line 33:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL|USE]]
 
[[Category:SQL|USE]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
[[Category:Databases]]
 +
[[Category:Databases Commands]]

Latest revision as of 16:20, 25 November 2009

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, DB_DATADIR, 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.

Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database. Operating System file protection can be applied individually to the files for added security. The directories are sub-directories of the Recital data directory. The environment variable / symbol DB_DATADIR points to the current Recital data directory and can be queried using the GETENV() function. Files from other directories can be added to the database using the ADD TABLE command or via the database catalog and SET AUTOCATALOG functionality.

SQL must be set to MySQL before using the USE command in this way.


Example

Recital/SQL> set sql to mysql
Recital/SQL> USE hr;
Recital/SQL> SELECT staff_no, lastname from staff;
Recital/SQL> USE accounts;
Recital/SQL> SELECT salesid from customer;
Recital/SQL> USE hr;
Recital/SQL> SELECT staff_no, lastname, customerno from staff, accounts!customer
where staff.staff_no = accounts!customer.salesid;


Products

Recital Server, Recital