Обсуждение: Name switch

Поиск
Список
Период
Сортировка

Name switch

От
"Adam Van Ornum"
Дата:
I had a really weird problem crop up a couple of days ago.  I just recently
installed PostgreSQL on FreeBSD 4.6.2 and have been playing around with it.
Most of my experience is with SQL Server 7 on the Windows platform (of
course) so there's lots of little things to play with.  Anyway, I created a
database called "media" and then created a couple of tables and added some
information to several of the tables.  From my Windows box I tried to access
the database through ODBC and it said that my table did not exist in the DB.
  I think got on my FreeBSD box and checked it out and found that apparently
there were no tables in my "media" db.  Eventually I found out that it
appears that my "media" db somehow switched with "template1".  Has anyone
else had this happen?  Did I do something majorly stupid?

Adam

_________________________________________________________________
Broadband?�Dial-up? Get reliable MSN Internet Access.
http://resourcecenter.msn.com/access/plans/default.asp


Re: Name switch

От
"Josh Berkus"
Дата:
Adam,

> I had a really weird problem crop up a couple of days ago.  I just
> recently installed PostgreSQL on FreeBSD 4.6.2 and have been playing
> around with it.  Most of my experience is with SQL Server 7 on the
> Windows platform (of course) so there's lots of little things to play
> with.  Anyway, I created a database called "media" and then created a
> couple of tables and added some information to several of the tables.
>  From my Windows box I tried to access the database through ODBC and
> it said that my table did not exist in the DB.
>  I think got on my FreeBSD box and checked it out and found that
> apparently
> there were no tables in my "media" db.  Eventually I found out that
> it appears that my "media" db somehow switched with "template1".  Has
> anyone else had this happen?  Did I do something majorly stupid?

No, you just forgot to switch to the "media" database after creating
it.  In a new DB system, "template1" is the only accessable database.

If you don't have anything worth saving, then the simplest way to clean
up "template1" is to delete the contents of the pgsql/data directory,
and re-run "initdb".   Then you can start over with a clean slate.

If you've spent a lot of time tinkering with "media", then:
1) DROP DATABASE media;
2) CREATE DATABASE media; --this will create the database with the same
tables and views you accidentally put in template1
3) Follow the rest of my instructions in my article on Techdocs on
cleaning the template1 database.

Also, there are several articles on moving from SQL Server to
PostgreSQL at techdocs:  http://techdocs.postgresql.org

-Josh Berkus