Reference and syntax for the USE DATABASE command.
USE DATABASE
statement in allows users to specify the database context for their queries within a session. This statement is crucial for operations within Firebolt where users interact with multiple databases, ensuring queries are executed against the intended database without the need to fully qualify object names in their SQL statements.
Parameter | Description |
---|---|
DATABASE | This is an optional keyword. |
<database_name> | The target database for session context. Essential for directing queries to the correct database without specifying the database name in each query. The database name must adhere to identifier rules supported by Firebolt, allowing for quoted or unquoted identifiers. An error is thrown if the database does not exist or the user lacks the necessary permissions. |
USE DATABASE
is designed to set the context at a session level, it plays a crucial role in the resolution of unqualified object names. All subsequent queries in the session resolve unqualified single-part names (like table or function names) based on the set database context, unless explicitly overridden by using fully qualified names or other USE statements is encountered.
USE DATABASE
with an engine’s URLUSE DATABASE
statement using an engine’s URL (see information_schema.engines), Firebolt returns the Firebolt-Update-Parameters
response header containing the new parameters that should be appended to the HTTP query string for subsequent statements to use the newly selected database.
USE DATABASE
command?USE DATABASE
command sets the current database context for the session, ensuring that all subsequent queries operate within the specified database unless another USE
command changes the context.
USE DATABASE
command affect the resolution of unqualified object names in queries?USE DATABASE
command is executed, all unqualified single-part names or two-part names, such as table or function names, in subsequent queries are resolved based on the set database context, simplifying queries by not requiring full names.
USE DATABASE
?USE DATABASE
command within the same session?USE DATABASE
command changes the session’s database context to the new database specified, affecting the resolution of unqualified object names in all subsequent queries.
USE DATABASE
command?USE DATABASE
command has set the desired database before executing unqualified queries.
USE DATABASE
within a transaction?