Question

This is a very beginner question, but my google skills have failed me and I can't seem to find anything relevant in my notes.

I have this situation :
Database bdamr with table functie_amr and column denumire_functie(varchar2)
Database bdeur with table functie_eur and columns sal_min(number(5)), sal_max(number(5)).
I need to check that the denumire_funtie with value 'Director' has sal_min < 5000 .
The tables were result of vertical fragmentation.

In other words can a constraint compare values in a different table, and the other table can be in a different database ?

Amongst other I've tried this

 alter table functie_eur
   add constraint sal_min_dir 
   check (functie_amr@bdamr.denumire_funtie='Director' and salariu_minim>5000);

Thanks!

Was it helpful?

Solution

Have a look at this link CHECK CONSTRAINTS

You cannot compare values from other table using check constraint, whether the table is in same database or other database.

From oracle document:

The condition of a check constraint can refer to any column in the table, but it cannot refer to columns of other tables.

If you want to restrict column values insertion you can write triggers for that table

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top