Thread: Re: pls Help us... (sql question)

Re: pls Help us... (sql question)

From
"Ross J. Reedstrom"
Date:
Best to ask your questions on the list, so others may find them,
with (hopefully) helpful answers in the archives in the future.

so, you've got a table with indistinguishable rows. I'm afraid you've
got to use an non ANSI extension. Every DB I've ever used has something
equivelant. In PostgreSQL, it's the 'oid', so in your case, you'd do:

SELECT oid,Name from tablename;

and see something like:
oid       Name 
-------  -------
102453   ibrahim      first row
102455   ibrahim      second row
103756   ibrahim      third row


Then, you can delete, comparing on the oid:

DELETE FROM tablename WHERE oid=102455;

Ross

On Tue, Jul 03, 2001 at 03:23:42AM -0700, ibrahim cobanoglu wrote:
> Hi. my name is ibrahim 
> 
> i have one problem with multiple rows..
> 
> i have a table named record and this table consist one
> field (name)
> 
> in this field there are 3 values such as
> Name 
> -------
> ibrahim      first row
> ibrahim      second row
> ibrahim      third row
> 
> i want to delete only the second row. ( with  Ansi 
> SQL (no cursor, trigger, rowid, rownum,....etc.) use
> select, count, .... (whats required!) )
> 
> but i dont know How to delete..
> 
> its really improtant for me.
> 
> i will glad....
> 
> 
> 
>  
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/


Re: Re: pls Help us... (sql question)

From
"Richard Huxton"
Date:
From: "Ross J. Reedstrom" <reedstrm@rice.edu>

> Best to ask your questions on the list, so others may find them,
> with (hopefully) helpful answers in the archives in the future.
>
> so, you've got a table with indistinguishable rows. I'm afraid you've
> got to use an non ANSI extension. Every DB I've ever used has something
> equivelant. In PostgreSQL, it's the 'oid', so in your case, you'd do:
>
> SELECT oid,Name from tablename;
>
> and see something like:
> oid       Name
> -------  -------
> 102453   ibrahim      first row
> 102455   ibrahim      second row
> 103756   ibrahim      third row
>
>
> Then, you can delete, comparing on the oid:
>
> DELETE FROM tablename WHERE oid=102455;

Ibrahim - if you want to prevent any more duplicate entries you can make the
"name" column unique - see the CREATE TABLE docs but it would be something
like:

CREATE TABLE tablename ( "Name" varchar(64) UNIQUE;
);

Then PG will fail any attempt to insert a duplicate value (it is the same as
creating a UNIQUE index basically).

- Richard Huxton



While Using COPY COMMAND ...

From
Bhuvan A
Date:
hello sirs,,

I am using PSQL client. I can able to copy the contents of a
table to '/tmp/' directory. But Why can't i able to copy
contents of a table to my home directory?

But, i can redirect the output of a command (\o) to a file
in my home directory..  How it gets succeed while the prev.
doesn't????

For your clarifications, here is the workflow.


bhuvan=# copy f_addr_phones with oids to
'/home/bhuvan/fap-table';
ERROR:  COPY command, running in backend with effective uid
1015, could not open file '/home/bhuvan/fap-table' for
writing.  Errno = Permission denied (13).
bhuvan=# copy f_addr_phones with oids to '/tmp/fap-table';
COPY
bhuvan=# 

------






Re: While Using COPY COMMAND ...

From
"Richard Huxton"
Date:
From: "Bhuvan A" <bhuvanbk@yahoo.com>

> hello sirs,,
>
> I am using PSQL client. I can able to copy the contents of a
> table to '/tmp/' directory. But Why can't i able to copy
> contents of a table to my home directory?
>
> But, i can redirect the output of a command (\o) to a file
> in my home directory..  How it gets succeed while the prev.
> doesn't????
>
> For your clarifications, here is the workflow.
>
>
> bhuvan=# copy f_addr_phones with oids to
> '/home/bhuvan/fap-table';
> ERROR:  COPY command, running in backend with effective uid
> 1015, could not open file '/home/bhuvan/fap-table' for

The "copy" command runs in the backend as user postgres (uid 1015) who quite
rightly doesn't have access to your home directory

Look into \copy instead - that acts from the client, so has your
permissions.

HTH

- Richard Huxton



Re: While Using COPY COMMAND ...

From
Peter Eisentraut
Date:
Bhuvan A writes:

> bhuvan=# copy f_addr_phones with oids to
> '/home/bhuvan/fap-table';
> ERROR:  COPY command, running in backend with effective uid
> 1015, could not open file '/home/bhuvan/fap-table' for
> writing.  Errno = Permission denied (13).

The server is probably running under a different user id (postgres?).

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter