假设我有这个层次结构:
create or replace type tperson as object(
fname varchar2(20),
lname tprenom,
adress tadr,
phone_num varchar2(10),
email varchar2(50)
)not final;
create or replace type tuser under tperson(
username varchar2(20),
password varchar2(20)
);
create table agent(
id_ag int,
infos tuser not null
);
insert into agent values(1,tuser('name',tprenom('bilel','dani','lastname3')
,tadr(3,'ain delfa','miliana','hammama',20),
'2140547854','email@gmail.com','username','password'));
我如何从代理表中只选择、更新一个属性?
我试过那个sql,但它不起作用:
select infos.fname, infos.lname, infos.adress, infos.phone_num, infos.email,
infos.username, infos.password from agent where id_ag=1;
但我得到了这个错误:
无效标识符00904。00000-"%s:无效标识符">
我缺少什么?
感谢您的回复。
在where
之前有一个分号,它不应该在那里。
当涉及到访问用户定义的列时,请使用表前缀,这样就可以了。
以下是SELECT
查询的语法:
select
ag.infos.fname,
ag.infos.lname,
ag.infos.adress,
ag.infos.phone_num,
ag.infos.email,
ag.infos.username,
ag.infos.password
from agent ag
where ag.id_ag = 1;
如果您希望执行UPDATE
:
update agent ag
set ag.infos.fname = 'foo', ag.infos.lname = 'bar'
where ag.infos.id_ag = 1