I bought a sport demo and there were no key codes when they delivered it. Ford dealership I got it from said the code was the last 6? digits of the VIN. Is that true?
I would think so however, check with your local Mazda dealer as that is a good way to get into their door for service since you did not buy it from them
Key code is needed only if you lose your key.
Other codes (stereo, navigation, etc. - not sure CX9 has them - my old Odyssey had them) might be needed if you disconnect the battery. You will need to enter the codes to unlock them.
In all cases, the dealer's computer can access those codes based on your VIN.
However, if you don't do services there, your dealer might charge you for such lookup.