Обсуждение: How to access tables using a superuser

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

How to access tables using a superuser

От
Siva Palanisamy
Дата:

Hi All,

 

I have few tables being created using an ordinary user account. When I login into the postgresql using the super-user, I can’t access my tables!

It says, ERROR:  relation "tablename" does not exist.

 

As I need to perform some operations using super-user, I want the tables to be accessed/mapped to the super-user account. Any clue on this part?

 

Thanks and Regards,

Siva.

 



::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

Re: How to access tables using a superuser

От
John R Pierce
Дата:
On 08/17/11 11:58 PM, Siva Palanisamy wrote:
>
> Hi All,
>
> I have few tables being created using an ordinary user account. When I
> login into the postgresql using the super-user, I can’t access my tables!
>
> It says, ERROR: relation "tablename" does not exist.
>
> As I need to perform some operations using super-user, I want the
> tables to be accessed/mapped to the super-user account. Any clue on
> this part?
>
>


are you logged into the same database ? are these tables in a schema
other than public?


--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



Re: How to access tables using a superuser

От
Siva Palanisamy
Дата:
Hi John,

I logged into the same database. I can say the commands, and you can correct me if I'm wrong.

Ordinary User: psql -h localhost -d db -U ordinaryusername
Select * from contacts
Now, I can access the tables. I also do have the .SQL file where it states the table schema as follows:
CREATE USER sa;
GRANT ALL ON DATABASE db TO sa;
\c db sa
CREATE SCHEMA AUTHORIZATION sa;
ALTER USER sa SET search_path TO sa,public;
CREATE TABLE sa.contacts (
        contact_id      SERIAL PRIMARY KEY,
        contact_type    INTEGER DEFAULT 0,
        display_name    TEXT NOT NULL DEFAULT '',
        UNIQUE(display_name)
    ) WITHOUT OIDS;

I logged into the database as a super-user: psql -h localhost -d db -U postgres
Select * from contacts;
ERROR: relation "contacts" does not exist.

Could you please guide me on this part? I wish to access the table using the super-user.

Thanks and Regards,
Siva.


-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of John R Pierce
Sent: Thursday, August 18, 2011 12:40 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to access tables using a superuser

On 08/17/11 11:58 PM, Siva Palanisamy wrote:
>
> Hi All,
>
> I have few tables being created using an ordinary user account. When I
> login into the postgresql using the super-user, I can't access my tables!
>
> It says, ERROR: relation "tablename" does not exist.
>
> As I need to perform some operations using super-user, I want the
> tables to be accessed/mapped to the super-user account. Any clue on
> this part?
>
>


are you logged into the same database ? are these tables in a schema
other than public?


--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

Re: How to access tables using a superuser

От
Guillaume Lelarge
Дата:
On Thu, 2011-08-18 at 12:48 +0530, Siva Palanisamy wrote:
> Hi John,
>
> I logged into the same database. I can say the commands, and you can correct me if I'm wrong.
>
> Ordinary User: psql -h localhost -d db -U ordinaryusername
> Select * from contacts
> Now, I can access the tables. I also do have the .SQL file where it states the table schema as follows:
> CREATE USER sa;
> GRANT ALL ON DATABASE db TO sa;
> \c db sa
> CREATE SCHEMA AUTHORIZATION sa;
> ALTER USER sa SET search_path TO sa,public;

This statement changed the search_path of user sa.

> CREATE TABLE sa.contacts (
>         contact_id      SERIAL PRIMARY KEY,
>         contact_type    INTEGER DEFAULT 0,
>         display_name    TEXT NOT NULL DEFAULT '',
>         UNIQUE(display_name)
>     ) WITHOUT OIDS;
>

Here you created the table contacts in the schema sa.

> I logged into the database as a super-user: psql -h localhost -d db -U postgres
> Select * from contacts;
> ERROR: relation "contacts" does not exist.
>

SELECT * FROM sa.contacts
would work.

Or

SET search_patch TO sa, public;
SELECT * FROM contacts
would work too.

And, please, don't top-post.


--
Guillaume
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com