티스토리 뷰

마리아 db에서 같은 테이블에서 업데이트를 치려고 하는데 table is specified twice 이런 에러가 났다.

흠.. 구글링을 해보니

 

The solutions involving SELECT ... FROM (SELECT * FROM table) AS tmp just dump the entire content of a table into a temporary table, which can then be used in any further outer queries, like for example an update query. This forces the order of operations to be: Select everything first into a temporary table and then use that data (instead of the data from the original table) to do the updates.

However if the table involved is large, then this temporary copying is going to be incredibly slow. No indexes will ever speed up SELECT * FROM table.

마리아 db에서 같은 테이블에서 업데이트를 치려고 하는데 table is specified twice 이런 에러가 났다.

흠.. 구글링을 해보니 stackoverflow에서

The solutions involving SELECT ... FROM (SELECT * FROM table) AS tmp just dump the entire content of a table into a temporary table, which can then be used in any further outer queries, like for example an update query. This forces the order of operations to be: Select everything first into a temporary table and then use that data (instead of the data from the original table) to do the updates.

However if the table involved is large, then this temporary copying is going to be incredibly slow. No indexes will ever speed up SELECT * FROM table.

https://stackoverflow.com/questions/44970574/table-is-specified-twice-both-as-a-target-for-update-and-as-a-separate-source

이런것을 봤다. 여기에 착안해서

create table test

as (select * from test2)

;

이런식으로 테스트 템프 테이블을 만들어서 템프테이블에서 값을 읽어와서 update를 치니 아주 잘되었다

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함