如何在内连接中插入语句 [英] How to insert statement in an inner join

查看:122
本文介绍了如何在内连接中插入语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我加入D&表后,我需要在表D上插入声明C.



这个程序怎么样?



我试过了,



Hi,

I need to insert statement on table D after i have joined table D & C.

hows the procedure?

I tried,

INSERT INTO TABLE D( D.depot_id, D.city_id)VALUES( 45, 99);
SELECT C.city_id, D.city_id
FROM DEPOT D
INNER JOIN TABLE C
ON D.city_id = C.city_id







它出现错误,显示






it turned up error, displaying

INSERT INTO DEPOT D( D.depot_id, D.city_id)VALUES( 45, 99)
*
Error at line 1:
ORA-02291: integrity constraint (S100636395.SYS_C002144957) violated - parent key not found

ON D.city_id = C.city_id
               *
Error at line 4:
ORA-00904: "C"."CITY_ID": invalid identifier

推荐答案

我在这里看到三件事。 />


1)TABLE是保留关键字。虽然可以让Oracle接受它,但是有一个名为TABLE的表是不好的。



2)有一个名为S100636395.SYS_C002144957的约束要求表DEPOT中的字段是约束中定义的一组值之一。它可能是一个外键约束,通常意味着它必须是另一个表的主键。表结构中没有足够的信息供我进一步详细说明。



3)最后,无效标识符错误意味着它无法在TABLE中找到列CITY_ID,您将其别名为C(可能与注释#1相关)。
I see three things here.

1) TABLE is a reserved keyword. While it is possible to get Oracle to accept it, it is in bad form to have a table named TABLE.

2) There is a constraint named S100636395.SYS_C002144957 which requires a field in table DEPOT to be one of a set of values defined in the constraint. It is probably a foreign key constraint, usually meaning it has to be a primary key of another table. There is not sufficient information provided on the table structure for me to elaborate further.

3)Finally, the Invalid identifier error means it can not find column CITY_ID in TABLE, which you have aliased as C (perhaps related to note #1).


这篇关于如何在内连接中插入语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆