既然我不确定我是否真的理解你问题的意图,我不知道这是否能解决问题。如果没有,也许你可以澄清你的内容。然后我 - 或者这个新闻组的其他人 - 可以再试一次。既然我不确定我是否真的理解你问题的意图,我不知道这是否能解决问题。如果没有,也许你可以澄清你的内容。然后我 - 或者这个新闻组的其他人 - 可以再试一次。 Rhino - Pierre Saint-Jacques - 回复:sesconsjunk at attglobaljunk dot com 重建地址:删除两个垃圾并用 代替它们的符号。 IBM DB2 Cerified Solutions Expert - 管理 SES顾问公司 been ruminating on the question (mostly in a 390/v7 context) ofwhether, and if so when, a row update becomes an insert/delete.i assume that there is a threshold on the number of columns ofthe table, or perhaps bytes, being updated where the engine justdecides, screw it, i''ll just make a new one.surfed this group and google, but couldn''t find anything.the context: we have some java folk who like to parametize/generalize/exersize into what they call Data Access Objects, andend up looping through a database result set based on columnmetadata (thus not having to write any table specific code),resetting all columns. makes for generatable code, but i for onedon''t like it.seems to be the worst possible performance scenario?? 解决方案I''m a Java developer but I''ve never used Data Access Objects so I may not bequalified to comment on this question.However, I would be quite astonished if "the engine" _EVER_ "just decides,screw it, I''ll just make a new one". (I assume that when you say "theengine" you mean the DB2 code itself, as opposed to some third party add-onto DB2.)Frankly, I''ve never heard so much as a whisper of a hint of a rumour of asuggestion that DB2 could transform an SQL Update statement to an Insertand/or a Delete and I''ve been working with DB2 in one capacity or anotherfor 20 years.As far as I know, an Update is always an Update, a Delete is always aDelete, and an Insert is always an Insert and none of these can change fromone to the other.Of course, I *could* be wrong....Having said that, an *application* which uses DB2 should be able to turn anupdate statement into a delete/insert. For instance, if a user submitted aquery like this through an interface that I wrote:update Employeeset salary = salary * 1.1where empno = ''000010''I could imagine converting that to:1) a delete that removed the current row for employee 0000102) an insert to create a new row for employee 000010 but with a 10% raise insalary.Of course, the code to do this would also need a select to determine thecurrent values of all of the other columns in the original row so that theycould be copied to the new row during the insert.However, there could easily be important side-issues with respect to relateddata. For instance, if the Employee table in the example had dependenttables, such as Employee_Health_Claims, doing the delete in the Employeetable could cause all rows of Employee_Health_Claims that relate to thatEmployee to be deleted if a DELETE CASCADE rule was in effect. (And rows intables dependent on Employee_Health_Claims might also be deleted if theDELETE CASCADE rule was in effect on this foreign keys.)By the same token, the delete in the Employee table would fail if there wasa DELETE RESTRICT rule between Employee and Employee_Health_Claims. Youwould have to consider Referential Integrity issues very carefully if youchose to convert an Update into a Delete/Insert combination.After all, you wouldn''t want an update in one table to cause all sorts ofdata to be deleted just because you thought you might get a slight advantageby turning one Update into a Delete followed by an Insert.Since I''m not sure if I really understood the intent of your question, Idon''t know if this answers it. If not, perhaps you can clarify what you areafter. Then I - or others on this newsgroup - could try again.Rhino I''m a Java developer but I''ve never used Data Access Objects so I may not be qualified to comment on this question. However, I would be quite astonished if "the engine" _EVER_ "just decides, screw it, I''ll just make a new one". (I assume that when you say "the engine" you mean the DB2 code itself, as opposed to some third party add-on to DB2.) Frankly, I''ve never heard so much as a whisper of a hint of a rumour of a suggestion that DB2 could transform an SQL Update statement to an Insert and/or a Delete and I''ve been working with DB2 in one capacity or another for 20 years. As far as I know, an Update is always an Update, a Delete is always a Delete, and an Insert is always an Insert and none of these can change from one to the other. Of course, I *could* be wrong.... Having said that, an *application* which uses DB2 should be able to turn an update statement into a delete/insert. For instance, if a user submitted a query like this through an interface that I wrote: update Employee set salary = salary * 1.1 where empno = ''000010'' I could imagine converting that to: 1) a delete that removed the current row for employee 000010 2) an insert to create a new row for employee 000010 but with a 10% raise in salary. Of course, the code to do this would also need a select to determine the current values of all of the other columns in the original row so that they could be copied to the new row during the insert. However, there could easily be important side-issues with respect to related data. For instance, if the Employee table in the example had dependent tables, such as Employee_Health_Claims, doing the delete in the Employee table could cause all rows of Employee_Health_Claims that relate to that Employee to be deleted if a DELETE CASCADE rule was in effect. (And rows in tables dependent on Employee_Health_Claims might also be deleted if the DELETE CASCADE rule was in effect on this foreign keys.) By the same token, the delete in the Employee table would fail if there was a DELETE RESTRICT rule between Employee and Employee_Health_Claims. You would have to consider Referential Integrity issues very carefully if you chose to convert an Update into a Delete/Insert combination. After all, you wouldn''t want an update in one table to cause all sorts of data to be deleted just because you thought you might get a slight advantage by turning one Update into a Delete followed by an Insert. Since I''m not sure if I really understood the intent of your question, I don''t know if this answers it. If not, perhaps you can clarify what you are after. Then I - or others on this newsgroup - could try again. Rhino--Pierre Saint-Jacques - Reply to: sesconsjunk at attglobaljunk dot comReconstruct address: Remove the two junk and replace at and dot bytheir symbols.IBM DB2 Cerified Solutions Expert - AdministrationSES Consultants Inc. I''m a Java developer but I''ve never used Data Access Objects so I may not be qualified to comment on this question. However, I would be quite astonished if "the engine" _EVER_ "just decides, screw it, I''ll just make a new one". (I assume that when you say "the engine" you mean the DB2 code itself, as opposed to some third party add-on to DB2.) Frankly, I''ve never heard so much as a whisper of a hint of a rumour of a suggestion that DB2 could transform an SQL Update statement to an Insert and/or a Delete and I''ve been working with DB2 in one capacity or another for 20 years. As far as I know, an Update is always an Update, a Delete is always a Delete, and an Insert is always an Insert and none of these can change from one to the other. Of course, I *could* be wrong.... Having said that, an *application* which uses DB2 should be able to turn an update statement into a delete/insert. For instance, if a user submitted a query like this through an interface that I wrote: update Employee set salary = salary * 1.1 where empno = ''000010'' I could imagine converting that to: 1) a delete that removed the current row for employee 000010 2) an insert to create a new row for employee 000010 but with a 10% raise in salary. Of course, the code to do this would also need a select to determine the current values of all of the other columns in the original row so that they could be copied to the new row during the insert. However, there could easily be important side-issues with respect to related data. For instance, if the Employee table in the example had dependent tables, such as Employee_Health_Claims, doing the delete in the Employee table could cause all rows of Employee_Health_Claims that relate to that Employee to be deleted if a DELETE CASCADE rule was in effect. (And rows in tables dependent on Employee_Health_Claims might also be deleted if the DELETE CASCADE rule was in effect on this foreign keys.) By the same token, the delete in the Employee table would fail if there was a DELETE RESTRICT rule between Employee and Employee_Health_Claims. You would have to consider Referential Integrity issues very carefully if you chose to convert an Update into a Delete/Insert combination. After all, you wouldn''t want an update in one table to cause all sorts of data to be deleted just because you thought you might get a slight advantage by turning one Update into a Delete followed by an Insert. Since I''m not sure if I really understood the intent of your question, I don''t know if this answers it. If not, perhaps you can clarify what you are after. Then I - or others on this newsgroup - could try again. Rhino--Pierre Saint-Jacques - Reply to: sesconsjunk at attglobaljunk dot comReconstruct address: Remove the two junk and replace at and dot bytheir symbols.IBM DB2 Cerified Solutions Expert - AdministrationSES Consultants Inc. 这篇关于更新transmogrifies插入/删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 08:53
查看更多