on 2010 Jul 13 5:08 PM
I have to update a column in a very, very large table. So performance is a big issue.
The question is the same as this one, but only for Sybase. Is there a way to do it without a self join like in the top voted answer for Oracle?
This was my first attempt, but it is by orders to slow for the table it is intended for:
UPDATE table SET flag = 1
FROM table AS a1
LEFT OUTER JOIN table AS a2
ON (a1.other = a2.other AND a1.id < a2.id)
WHERE a2.ID IS NULL
and a1.name in ('x', 'y')
Request clarification before answering.
I'm frankly a bit confused, because the StackExchange post doesn't address updates at all.
However - as far as I can tell, virtually any of the SQL queries given in the answers of that StackExchange post will work in SQL Anywhere. SQL Anywhere supports (of course) subqueries and joins to derived tables. SQL Anywhere 9.0.1 and up supports WINDOW
functions, and you can use both MAX()
and ROW_NUMBER()
as window functions. Versions 10 and up supports the FIRST_VALUE()
window function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
39 | |
15 | |
9 | |
7 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.