473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is the difference in the update statements?

Hi all,
Here are the two update statement.

UPDATE stock SET status=NULL, quantity=0, price=0 WHERE type <> 'S'

UPDATE stock SET (status, quantity, price) = (NULL, 0, 0) WHERE type
<> 'S'

What is the difference between the above 2 update statement? Which
statement will yield good performance?

Thanks,
Thiru.
WantedToBeDBA.

Nov 12 '05 #1
5 1692
"Thiru" <Wa***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi all,
Here are the two update statement.

UPDATE stock SET status=NULL, quantity=0, price=0 WHERE type <> 'S'

UPDATE stock SET (status, quantity, price) = (NULL, 0, 0) WHERE type
<> 'S'

What is the difference between the above 2 update statement? Which
statement will yield good performance?

Thanks,
Thiru.
WantedToBeDBA.

No difference in performance.

The performance will depend on a number of factors such as:

1. Is there an index on TYPE?
2. Cardinality of rows not = 'S' and size of the rows.
3. Is table clustered on TYPE?
Nov 12 '05 #2
Hi,
If performance is not at an issue, then what is the need to have
two different statement??

Thiru.
WantedToBeDBA.

Nov 12 '05 #3
Thiru wrote:
Hi,
If performance is not at an issue, then what is the need to have
two different statement??


Some people like the first better than the second.

Similarly you could ask why subqueries are allowed in all situations, given
that you can write many queries using joins, or why BETWEEN exists, which
can be handled with two comparisons.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #4
Thiru wrote:
Hi,
If performance is not at an issue, then what is the need to have
two different statement??

Thiru.
WantedToBeDBA.

Point for row assignment
SET (x, y, z) = (SELECT SUM(a), AVG(b), MIN(c) FROM T)

Point for column assignment:
SET x = (SELECT a FROM T1),
y = (SELECT b FROM T2),
z = (SELECT c FROM T3)

Beyond that.. freedom of choice. Whatever you like netter.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5
"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:37*************@individual.net...
Thiru wrote:
Hi,
If performance is not at an issue, then what is the need to have
two different statement??

Thiru.
WantedToBeDBA.

The DB2 optimizer, among other things it does, is to perform query
optimization during which it converts your syntax to the most efficient DB2
syntax which is functionally equivalent to what you wrote.

You can see the optimized SQL when you do an explain.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: lkrubner | last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR, INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql? PostGre info would also be useful. I'm trying to...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
2
by: harry | last post by:
Using Oracle 8i, when I issue * (seems to be random number of times) number of update statements my app hangs while waiting to execute the next update statement. If I try then to drop any table...
4
by: Rustam Bogubaev | last post by:
Hi, I have a table with the following columns: ID INTEGEDR, Name VARCHAR(32), Surname VARCHAR(32), GroupID INTEGER, SubGroupOneID INTEGER, SubGroupTwoID...
3
by: Nipon | last post by:
Hi, I am using MS SQL Server 7.0 SP2 in Windows 2000 server SP4. I have one-to-many tables (TABLE_HEAD and TABLE_DETAILS)which I am going to update by using a stored procedure with UPDATE...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
2
by: technocrat | last post by:
HOW CAN THIS BE DONE IN JAVA??? THIS IS POSITIONED UPDATE EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM EMPLOYEE FOR UPDATE OF JOB; EXEC SQL OPEN C1;
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: Grey Alien | last post by:
I have created a SQL Server Express db in my ASP.Net website. I have a file that contains several SQL statements to create tables (100+) and stored procedures. I am guessing that there has to be a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.