Let's start by considering polynomials with all their roots, real and complex. This allows us to fully answer the question for first complex, and then real, polynomials and roots.
This approach will not only let us get all answers, but prove these are all answers, and the only answers.** It's also easy to see why that's so.
Fundamental principle: Over the complex numbers, all nonconstant polynomials can be uniquely factored into linear terms and a multiplier
See Wikipedia "Irreducible polynomial - over the complex numbers" and Fundamental theorem of algebra: any nonconstant polynomial can, in complex terms, be uniquely factored into something like
A.(x-B).(x-C).(x-D)... = 0
A <> 0 and B, C,D.. are the roots. B,C,D can of course be complex or real numbers. Also some of the B, C, D... may repeat, in which case we have one or more repeating roots, but the polynomial will still factorise this way.
We can rewrite this in terms of unique roots, as follows:
A. [(x-B)^P] . [(x-C)^Q] . [(x-D)^R] . [...] ... = 0
where A <> 0 and B,C,D... are now all unique complex numbers, and are the roots of the polynomial, and P,Q,R... are all integers >= 1 that account for any repeated roots.
The fundamental.theorem of algebra guarantees we can factor all polynomials this way, and that it will be unique for each polynomial. It's also evident from inspection that B,C,D are the roots, and all the roots, and no other roots exist.
Your answer, if complex roots are allowed
... Is now quite simple. Suppose 2 non-constant polynomials have identical roots. Then they must be identical other that possibly:
- a different non-zero multiplier (A is different between the polynomials, when factored)
- repeated roots (one or more of P, Q,R will differ between the polynomials, when factored)
What if we only allow real roots?
The polynomial can still only be factored one way as above. The only difference is, any B,C,D that isn't a real number won't ever equal a value of X we can choose, so it can't be a solution. So as well as the 2 types of change above, we can also change the powers for any existing complex linear factors to any integer >= 0, or multiply by new complex linear factors (to any integer power >0), and provided the factor we multiply/divide by has a complex parameter, it won't ever affect the real roots. We can't divide by new complex linear factors, though, because the result wouldn't be a polynomial.
This is easiest explained by example.
Example: suppose our equation is a polynomial that factors into a mix of real and complex linear factors, some repeated:
4 . (X - 7)^2 . (X + 4.5) . (X + 2i) . (X - 2i)= 0
Then any polynomial with identical real roots must be formed by some combination of these changes (I'll give an example of each):
(-6) . (X - 7)^2 . (X + 4.5) . (X + 2i) . (X - 2i) = 0
We have multiplied A by some real value <> 0 (in this case, -1.5).
4 . (X - 7)^8 . (X + 4.5) . (X + 2i) . (X - 2i)= 0
4 . (X - 7)^0 . (X + 4.5)^5 . (X + 2i) . (X - 2i)= 0
We have changed the powers for some of the repeated roots (up or down)
4 . (X - 7)^2 . (X + 4.5) . (X + 2i) . (X - 2i) . (X - [3+7i])^3 = 0
4 . (X - 7)^2 . (X + 4.5) . (X + 2i)^17 . (X - 2i) = 0
4 . (X - 7)^2 . (X + 4.5) . (X + 2i)= 0
4 . (X - 7)^2 . (X + 4.5) = 0
We have changed the powers for some of the complex roots (up or down), or removed them (equivalent to changing their power to 0), or introduced new complex linear factors.
Note that this last transformation might or might not change some of the coefficients in the equation from real to complex coefficients or vice-versa, depending what you do (see especially the last example where they don't). It may well change the complex roots of the polynomial. But it will not change, add or remove any real roots of the polynomial.
If you restrict yourself to changes of this kind that don't change any real coefficients to complex coefficients, you'll achieve all real coefficient polynomials with the same roots this way.
** Note - For quintics and higher, we may not be able to factorise to simple algebraically expressed roots, because not all 5th and higher order polynomials allow for neat expressions of their roots this way. But - even if inexpressible - the roots do exist, the limitation is in our ability to calculate them exactly, or write them concisely, not in their existence. The same method will work and be valid, and the same other types of polynomials will have identical complex (or real) roots. We just wouldn't be able to calculate or write the linear expressions, transformative equations, or roots, neatly, in the same way.