LINUX.ORG.RU
решено ФорумAdmin

Не могу удалить БД из кластера, заглавная буква в названии

 


0

2
root@accounting20:/home/maintainer#  psql -U dbadmin -d postgres -p 5433 -h localhost -l
                                     Список баз данных
       Имя       | Владелец | Кодировка | LC_COLLATE  |  LC_CTYPE   |     Права доступа
-----------------+----------+-----------+-------------+-------------+-----------------------
 Accounting20_01 | dbadmin  | UTF8      | ru_RU.UTF-8 | ru_RU.UTF-8 |
 accounting20_01 | dbadmin  | UTF8      | ru_RU.UTF-8 | ru_RU.UTF-8 |
 accounting20_02 | dbadmin  | UTF8      | ru_RU.UTF-8 | ru_RU.UTF-8 |
 accounting20_03 | dbadmin  | UTF8      | ru_RU.UTF-8 | ru_RU.UTF-8 |
 accounting20_04 | dbadmin  | UTF8      | ru_RU.UTF-8 | ru_RU.UTF-8 |

Пытается удалять другую базу

root@accounting20:/home/maintainer#  psql -U dbadmin -d postgres -p 5433 -h localhost -w -c "drop database Accounting20_01;"

ОШИБКА:  база данных "accounting20_01" занята другими пользователями


Ответ на: комментарий от ii343hbka
root@accounting20:/home/maintainer#  psql -U dbadmin -d postgres -p 5433 -h localhost -w -c "drop database ""Accounting20_01"";"
ОШИБКА:  база данных "accounting20_01" занята другими пользователями
ПОДРОБНОСТИ:  Эта база данных используется ещё в 1 сеансе.

Shulman
() автор топика
Ответ на: комментарий от Shulman
postgres=# create database "A1";
CREATE DATABASE
postgres=# create database "a1";
CREATE DATABASE
postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 A1        | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 a1        | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(5 rows)

postgres=# \q
root@c41977e25bc0:/# psql -U postgres -c "drop database \"a1\"";
DROP DATABASE
root@c41977e25bc0:/# psql -U postgres -c "\l";
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 A1        | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(4 rows)

root@c41977e25bc0:/# psql -U postgres -c "drop database \"A1\"";
DROP DATABASE
root@c41977e25bc0:/# psql -U postgres -c "\l";
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(3 rows)

root@c41977e25bc0:/# 
ii343hbka ★★★
()
Последнее исправление: ii343hbka (всего исправлений: 1)
Ответ на: комментарий от kravzo

Я бы ' попробовал.

вы бы попробовали читать документацию. Для названия базы нужны двойные кавычки (если там есть заглавные буквы или специальные символы). У автора темы две разных базы, названия которых различаются только регистром первой буквы. Он хочет удалить ту, которая начинается с большой буквы, но двойных кавычек не пишет. PostgreSQL пытается удалить другую базу, но это не получается.

Partisan ★★★★
()
Ответ на: комментарий от crutch_master

Я особо не заморачивался, эти базы учебные

Shulman
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.