Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

USE

Focus mode
USE - Amazon Redshift

Changes the database on which queries run. SHOW USE points to the database that most recently is used with the USE command. RESET USE resets the used database. This means that if the database is not specified in the SQL, the objects are searched in the current database.

Syntax

USE database

Examples

Suppose there are two databases, dev and pdb. Let there be two tables t in the public schemas of each of the databases.

dev=# insert into dev.public.t values (1); INSERT 0 1 dev=# insert into pdb.public.t values (2); INSERT 0 1 -- USEd database is not set. dev=# show use; Use Database -------------- (1 row) dev=> show search_path; search_path --------------- $user, public (1 row) dev=# select * from t; c --- 1 (1 row) -- Set the USEd database to query the tables in it. dev=# use pdb; USE dev=# select * from t; id ---- 2 (1 row) dev=# select * from public.t; id ---- 2 (1 row) -- Reset the USEd database to again refer to objects in the connected database. dev=# RESET USE; RESET dev=# select * from t; c --- 1 (1 row)

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.