SQL USE

From Recital Documentation Wiki
Jump to: navigation, search

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