I have this table that does not have a primary key.
I am going to insert some records into a new table to analyze them, and I am thinking of creating a new primary key with values ββfrom all available columns.
If it were a programming language such as Java, I would:
int hash = column1 * 31 + column2 * 31 + column3*31
Or something like that. But this is SQL.
How to create a primary key from the values ββof available columns? I cannot just mark all the columns as PK, since I need to compare them with data from another DB table.
My table has 3 numbers and a date.
EDIT What's my problem
I think a little more background is needed. I apologize for not providing it before.
I have a database (dm) that is updated every day from another db (source). He has records for the last two years.
Last month (July), the update process was disrupted, and for a month the data was not updated in dm.
I manually create a table with the same structure in my Oracle XE, and I copy the records from the original source to my db (myxe). I copied only the entries from July to create the report needed by the end of the month.
Finally, in August 8, the update process was fixed, and the records that were waiting for the transfer of this automatic process were copied to the database (from source to dm).
This process cleans the original data source after copying it (in dm).
Everything looks great, but we just realize that the number of records is lost (about 25% of July)
So what I want to do is use my backup (myxe) and paste all these records into the database (dm).
The problem is here:
- They do not have a clearly defined PC.
- They are in different databases.
So, I thought that if I could create a unique pk from both tables that gave the same number, I could say that they were missing and insert them.
EDIT 2
So, I did the following in my local environment:
select a.* from the_table@PRODUCTION a , the_table b where a.idle = b.idle and a.activity = b.activity and a.finishdate = b.finishdate
Which returns all rows that are present in both databases (join ...?) I have 2000 records.
What will I do next, delete them all from the target db, and then just paste them all from my db into the target table.
I hope I donβt get into something worse: - S: -S