Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8912843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:18:44+00:00 2026-06-15T04:18:44+00:00

I have a table person in my PostgresSQL database, which contains data of different

  • 0

I have a table person in my PostgresSQL database, which contains data of different users.

I need to write a test case, which ensures that some routine does modify the data of user 1, and does not modify data of user 2.

For this purpose, I need to

a) calculate a hash code of all rows of user 1 and those of user 2,

b) then perform the operation under test,

c) calculate the hash code again and

d) compare hash codes from steps a) and c).

I found a way to calculate the hash code for a single row:

SELECT md5(CAST((f.*)AS text))
FROM person f;

In order to achieve my goal (find out whether rows of user 2 have been changed), I need to perform a query like this:

SELECT user_id, SOME_AGGREGATE_FUNCTION(md5(CAST((f.*)AS text)))
FROM person f
GROUP BY user_id;

What aggregate function can I use in order to calculate the hash code of a set of rows?

Note: I just want to know whether any rows of user 2 have been changed. I do not want to know, what exactly has changed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:18:45+00:00Added an answer on June 15, 2026 at 4:18 am

    The simplest way – just concat all the string form md5 with string_agg. But to use this aggregate correctly you must specify ORDER BY.

    Or use md5(string_agg(md5(CAST((f.*)AS text)),'')) with some ORDER BY – it will change if any field of f.* changes and it is cheap to compare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table Person which contains 2 fields.In my another database i have
Suppose I have table Person table Employee, which inherits Person. I want to get
I have a table called Person which I have already mapped in hibernate I
Say I have a person table in a database. Whenever a new person is
I have an ORM class called Person, which wraps around a person table: After
In my oracle database I have table called PERSON with columns code, surname, forename.
I have three table in SQL database such as table Person has relation one
I have a table called Person that contain a field called PersonAge. I need
I have a parent table (Person) with a child table (Address). I need to
Have a table called person. which has personid and contactid. if a person is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.