Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Simulate an update query in Postgres

Posted on 2007-11-16
4
1,123 Views
Last Modified: 2012-08-13
Is there a way I can simulate an update query so it will tell me a certain of number of rows would be updated but doesn't actually update them?
0
Comment
Question by:mock5c
4 Comments
 
LVL 3

Accepted Solution

by:
pmctrek earned 25 total points
ID: 20300451
Not sure if this will work raw or you may need pl\PgSQL installed on the database.

BEGIN
  UPDATE .....
ROLLBACK
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 25 total points
ID: 20300623
select count(*) from your_table
where (your-update-where-clause-here)
0
 
LVL 62

Expert Comment

by:gheist
ID: 20300741
rewrite your update into SELECT:
select count(*) from ... where ...
0
 
LVL 22

Expert Comment

by:earth man2
ID: 20304166
use transaction control and rollback your changes.
begin work;
update xxx...
rollback work;
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question