【发布时间】:2020-09-08 06:56:17
【问题描述】:
我正在尝试通过视图更新表,但我不断收到列未映射到键保留表的错误。有人可以解释为什么这些表没有保留密钥吗?
我得到的错误是:
SQL 错误:ORA-01779: não é possível modificar uma coluna que compatiblee a uma tabela que não é mantida por chaves 01779. 00000 - “不能修改映射到非键保留表的列” *原因:试图插入或更新连接视图的列 映射到非键保留表。 *Action:直接修改底层基表。
代码:
create table Pessoa
(
cartaoCidadao integer check(cartaoCidadao <= 99999999) not null,
nome VARCHAR(35) check(nome not like '%[0-9]%') not null,
email varchar(35) not null,
dataDeNascimento date not null,
genero varchar(9) check(genero in('Masculino','Feminino')) not null,
primary key(cartaoCidadao)
);
create table Membro
(
cartaoCidadao integer check(cartaoCidadao <= 99999999) not null ,
nivel varchar(8) not null,
primary key (cartaoCidadao),
foreign key (cartaoCidadao) references Pessoa(cartaoCidadao),
foreign key (nivel) references Escalao(nivel)
);
create table Escalao
(
nivel varchar(8) not null,
primary key(nivel)
);
create or replace view membroView
as
select cartaoCidadao, nome, email, dataDeNascimento, genero, nivel
from Pessoa
inner join Membro using(cartaoCidadao)
inner join telemoveis using (cartaoCidadao);
update membroView
set nome = 'Hello'
where cartaoCidadao = 123;
【问题讨论】:
-
请也发布错误详情。还有你的 Oracle 版本。
-
我添加了错误,但我不知道我使用的是哪个 oracle 版本,因为这是一项大学作业,我们只是使用提供给我们的任何我可以检查的方式吗?
-
据我所知,Oracle 的
LIKE不匹配像%[0-9]%这样的正则表达式。您需要使用正则表达式的函数。 -
这会影响被密钥保留的表吗?因为该检查按预期工作。
-
您的视图引用了一个额外的表
telemoveis,您没有提供该表的描述。