Re: Removing Database Names as Spaces?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Removing Database Names as Spaces?
Дата
Msg-id 6694.1092878970@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Removing Database Names as Spaces?  (Jonathon Batson <jonathon@octahedron.com.au>)
Ответы Re: Removing Database Names as Spaces?  (Jonathon Batson <jonathon@octahedron.com.au>)
Список pgsql-novice
Jonathon Batson <jonathon@octahedron.com.au> writes:
> I have a script that went haywire and created 2 databases with what
> looks like empty names OR names made up of spaces.

Judging by your lack of success and the funny formatting of the -l
output, they're not spaces.  Possibly carriage returns and other stuff.

One approach is to find out exactly what you got, instead of guessing.
Try "select datname,length(datname) from pg_database" then
"select datname,ascii(datname[N]) from pg_database" where N ranges
from 0 to one less than the length you just found out.  That will
give you the ASCII codes of the characters that are there.  After
that you can start thinking about how to type it ;-)

Also, there's always the brute-force way of renaming databases:

    select oid, datname from pg_database;
    update pg_database set datname = 'foo' where oid = <number from above>

This isn't ordinarily recommended but it seems safe enough, especially
if you're going to drop the database immediately after ...

            regards, tom lane

В списке pgsql-novice по дате отправления:

Предыдущее
От: Jonathon Batson
Дата:
Сообщение: Removing Database Names as Spaces?
Следующее
От: Keith Worthington
Дата:
Сообщение: New Installation