How to delete records without a primary key in a stardard way (i.e. not using ctid)
0
votes
2
answers
6216
views
# Case of use
We have a log table without a PK with two columns (date, event);
You inserted a row. Then you want to undo the inserted record.
Is there a way to delete that row (without deleting other rows with the same data), that doesn't use postgres only capabilities?
I want a solution that works in another database (it doesn't need to be totally standard, it can be only in just one database: SqLite, Oracle, MySql or SQLServer).
## Example:
create table the_log(
date date,
event_id integer
);
insert into the_log(date, event_id) values ('2019-09-21',1),('2019-09-21',1);
select * from the_log;
My atempts:
delete from the_log where row_number() over ()=1;
delete from the_log limit 1;
with the_log_2 as (select *, row_number() over () as version from prueba_sin_clave)
delete from the_log_2 where version=1;
I supouse that the answer is **No**. I want to know if I am wrong or in what documentation I read that I am right.
Asked by Emilio Platzer
(465 rep)
Sep 21, 2018, 06:31 PM
Last activity: Nov 22, 2024, 11:04 PM
Last activity: Nov 22, 2024, 11:04 PM