No, a serial number/product code will not be required. IF you had a recent OS on there, eg Sierra, you could have rebooted, holding down the option key which would have taken you to the startup manager, from there you could have picked the drive with the Recovery Partition, and from the Partition, after picking a language, use your mouse/trackpad to move the cursor to the top center of the screen and click. OS X Tools would show up, and from there, pick Disk Utility, and re-fomat. You'd also want to make sure that an Ethernet cable was plugged into it. After re-formatting, which should have been MacOS Extended (Master Boot drive) and GUID on, then quit disk Utility and go back to recovery partition. Choose to Re-install OS. You could maybe try Internet recovery by holding down Shift, Apple and R on reboot and it will try to get the most fitting OS for your 2009 iMac, which may be El Capitan
hope this helps
john b