Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

i have 2 tables with the same unique id. i want to change table1 unique_id sequence from (1-100) to random 8 digit ids (43342359 - 83083224) and cascade that to table2.

what i have:

- table1
    id1 (primary)
    unique_id(index)
    option_id(index)
    value1
    value2

- table2
    id2 (primary)
    unique_id (index)
    other1
    other2

what i would like to achieve:

- table1
    unique_id (primary)
    option_id (index)
    value1
    value2

- table2
    id2 (primary)
    unique_id (index)(constraint cascade)- on table1 update/delete 
    other1
    other2

furthermore:

unique_ids are a range from 1 - 100 which interferes with another db with same unique_ids but different option_id. basicaly i would like to join 2 databases with the same scheme and create new unique_id primary on that, with cascade constraint as mentioned.

Update:

found a possible solution here https://gist.github.com/leenasn/875796

is there a simpler way?

share|improve this question
    
@PaulWhite is this less vague? i'm kinda new here and streetsmarts don't feel welcome. I also tried tons of different solutions provided here and there with my newbie mysql skills with no success. any thougths? –  joze novak Feb 18 '13 at 12:11
1  
Looks much better to me. I'm not a MySQL expert but no doubt one will be along shortly. –  Paul White Feb 18 '13 at 12:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.