Condividi tramite


SET DATABASE Command

Sets an open database as the current database or sets no current database.

SET DATABASE TO [DatabaseName]

Parameters

  • [ DatabaseName]
    Specifies the name of an open database to set as the current database. Omitting DatabaseName or specifying an empty string sets the current database to no database.

Remarks

SET DATABASE is scoped to the current data session. Though you can have many databases open at the same time, you can set only one as the current database. Commands and functions that operate on a database operate on the current database.

For more information, see How to: Set the Current Database and How to: Open Databases.

Example

The following example creates two databases named mydbc1 and mydbc2, and a table named table1. SET DATABASE is used to make mydbc1 the current database, and table1 is added to mydbc1 when it is created. The table is then closed and removed from mydbc1. SET DATABASE is used to make mydbc1 the current database, and ADD TABLE is then used to add the table to mydbc2. RENAME TABLE is used to change the name of the table from table1 to table2.

CREATE DATABASE mydbc1
CREATE DATABASE mydbc2
SET DATABASE TO mydbc1
CREATE TABLE table1 (cField1 C(10), n N(10))  && Adds table to mydbc1
CLOSE TABLES     
REMOVE TABLE table1
SET DATABASE TO mydbc2
ADD TABLE table1
RENAME TABLE table1 TO table2

For more information, see CREATE DATABASE Command, CREATE TABLE - SQL Command, CLOSE DATABASES Command, REMOVE TABLE Command, ADD TABLE Command, and RENAME TABLE Command.

See Also

Reference

DELETE DATABASE Command

MODIFY DATABASE Command

SET DATASESSION Command

SET Command Overview

Other Resources

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)