“use database_name” command in PostgreSQL

后端 未结 5 950
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 07:23

I am beginner to PostgreSQL.

I want to connect to another database from the query editor of Postgres - like the USE command of MySQL or MS SQL Server. <

5条回答
  •  再見小時候
    2020-12-07 07:57

    The basic problem while migrating from MySQL I faced was, I thought of the term database to be same in PostgreSQL also, but it is not. So if we are going to switch the database from our application or pgAdmin, the result would not be as expected. As in my case, we have separate schemas (Considering PostgreSQL terminology here.) for each customer and separate admin schema. So in application, I have to switch between schemas.

    For this, we can use the SET search_path command. This does switch the current schema to the specified schema name for the current session.

    example:

    SET search_path = different_schema_name;
    

    This changes the current_schema to the specified schema for the session. To change it permanently, we have to make changes in postgresql.conf file.

提交回复
热议问题