I have found some information about switch MAC table here: How does a switch learn a switch table? . There is explained how switch learns MAC addresses but what happens when I manipulate cables? What happens when I disconnect one cable? What happens when I disconnect one cable and I will connect it to another port?
The entry in the switch mac table has a timestamp and all records have a lifetime. (300 seconds is a common value but it can be another value, and it may be configurable, depending on the switch vendor / model / software version).
So when you disconnect a device, the entry will be removed after some times.
Additionally some switches will immediately remove all entries listing a port if this port goes down.
A switch will keep a single entry for a given mac address, and if needed update it. So if you move a device from one port to another, when the device will sent a frame, the switch will update the mac table with the new port.
Things become more complex when you have many switches interconnected.