반응형
데이터베이스에서 연결을 끊고 PostgreSQL의 기본 데이터베이스로 돌아가는 방법은 무엇입니까?
PostgreSql 버전을 사용하고 있습니다.
postgres=# select version();
version
-------------------------------------------------------------
PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit
(1 row)
난에서 데이터베이스에 연결 한 postgres=#
에 newdb=#
지금은에이야 .... newdb=#
난을 분리하고 다시 가고 싶지 데이터베이스 postgres=#
데이터베이스 ....
어떻게하나요?
나는 시도했다 disconnect newdb;
그러나 그것의주는 erroe ::
postgres=# create database newdb;
CREATE DATABASE
postgres=# \c newdb;
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 "newdb" as user "postgres".
newdb=# disconnect newdb;
ERROR: syntax error at or near "disconnect"
LINE 1: disconnect newdb;
^
newdb=#
작동하지 않습니다.이 작업을 수행하는 다른 방법이 있거나 내가 잘못 했습니까!
간단합니다. 예를보세요.
-내 데이터베이스
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+---------------------------
francs | postgres | UTF8 | C | C | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | francs=C*T*c*/postgres +
| | | | | select_only=c/francs
postgres | postgres | UTF8 | C | C |
source_db | postgres | UTF8 | C | C | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | source_db=C*T*c*/postgres
template0 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
- 역할 프랑으로 db 프랑으로 전환
postgres=# \c francs francs
You are now connected to database "francs" as user "francs".
- 역할 postgres로 db postgres에 swith
francs=> \c postgres postgres
You are now connected to database "postgres" as user "postgres".
postgres=#
- DB 연결을 해제
postgres=# \q
psql에는 '연결 해제'가 없습니다. newdb 데이터베이스에서 연결을 끊는 대신 기본 postgres 데이터베이스에 연결합니다.
새 데이터베이스를 만들고 연결합니다.
postgres=# create database newdb;
CREATE DATABASE
postgres=# \c newdb
You are now connected to database "newdb" as user "postgres".
newdb=#
List the number of connections on newdb:
newdb=# select datname,numbackends from pg_stat_database where datname='newdb';
datname | numbackends
---------+-------------
newdb | 1
Now, instead of disconnecting, just connect with the default postgres database.
newdb=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=#
Now there are no connections on newdb:
postgres=# select datname,numbackends from pg_stat_database where datname='newdb';
datname | numbackends
---------+-------------
newdb | 0
반응형
'development' 카테고리의 다른 글
하위 도메인에서 허용되는 문자는 무엇입니까? (0) | 2020.11.24 |
---|---|
2D 배열의 차원에서 평균 계산 (0) | 2020.11.24 |
각도 쿠키 (0) | 2020.11.24 |
C # 코드에서 C ++ dll에 정의 된 클래스 사용 (0) | 2020.11.24 |
설치된 .NET 버전을 확인하는 명령 줄 명령이 있습니까? (0) | 2020.11.24 |