Tag Info

New answers tagged

1

The problem is that i'm not allowed to add a pk or uq constraint to "a.id_a" to reference the fk on b.id_a. If that column is intended to be unique then you have a management problem rather than a technical one. Any technical solution will be sub-optimal because you aren't allowed to use the methods that are designed to be optimal for this purpose. You ...


2

I do agree with Aaron, that not creating a PK (or unique constraint) is a very strange requirement But you could do something like this: insert into b (id_b, id_a) select 1, 2 where exists (select 1 from a where id_a = 2); or alternatively: insert into b (id_b, id_a) select 1, id_a from a where id_a = 2 If you want to insert multiple rows, you can ...



Top 50 recent answers are included