The column or one of the columns to be updated. It must be the name of a column in the referenced table or view. You can retrieve the column values into variables or host variables, or into collections or host arrays. Viewed 1. Table 1: id name desc 1 a abc 2 b def 3 c adf Table 2: id name desc 1 x 2 y In oracle SQL, how do I run an sql update query that can update Table 1 with Table 2's name and desc using the same id?
So the end result I would get is Table 1: id name desc 1 x 2 y 3 c adf Question is taken from update one table with data from another , but specifically for oracle SQL. Laxmi 3, 22 22 silver badges 30 30 bronze badges. Muhd Muhd You need to go back to your other question, un-accept that answer, and state specifically that you need the Oracle PLSQL syntax.
Oh I see. So you copy-pasted the question body, but modified to include the Oracle bit. And this probably isn't the best example since "desc" is a reserved word, but oh well. Add a comment. Active Oldest Votes. Justin Cave Justin Cave k 22 22 gold badges silver badges bronze badges. Or do you use it only to speed up the query? Without it, every row in t1 will be updated and the values will be set to NULL if there is no matching row in t2.
FROM t2 must result in a unique row. This means that you have to select on all the fields which comprise a unique key -- a non-unique primary key is not sufficient.
Without uniqueness, you are reduced to something like PaulKarr's loop -- and if there is not a unique correlation, then more than one target row may be updated for each source row. Explanation on key-preserved requirement for updatable joins: asktom.
RachitSharma - That means that your subquery the query from table2 is returning multiple rows for one or more table1 values and Oracle doesn't know which one you want to use. You may also have a look at the following articles to learn more —.
Submit Next Question. By signing up, you agree to our Terms of Use and Privacy Policy. Forgot Password? This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy.
By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy. Oracle Update with Join. Popular Course in this category. The positioned update statement depends on the cursor and any tables the cursor references. You can compile a positioned update even if the cursor has not been opened yet.
0コメント