Switch database in PostgreSQL

To switch database in Sybase, we run command:

use database_name go

To switch database in SQL Serve, MySQL or Oracle, we run command:

use database_name;

But, when comes to PostgreSQL, we use \connect database_name; or \c database_name;

Examples:

To connect to database name ‘company’ run the below command:

postgres=# \connect company;

WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page “Notes for Windows users” for details.
You are now connected to database “company” as user “postgres”.
company=#

To switch from company database to postgres

company=# \c postgres;

WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page “Notes for Windows users” for details.
You are now connected to database “postgres” as user “postgres”.
postgres=#

CheapSexCams
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: