About Auto Clear the Register IPaddr

I use Mysql Database to save my users’ information.That table names sip_buddies.After the gateway registered to the Asterisk Server,I break the physical connection. The problem is users’ ipaddr in the sip_buddies doesn’t clear.I need it to be auto cleared.How can I do that ?
ps:
If a gateway disconnected to the Asterisk Server,whether the Asterisk Server can feel it or not ?Or Maybe use some method to make it feel the break.

Thanks for your help.