Posts
416
Comments
233
Trackbacks
42
What Is INET_ATON And Why Is It In A Database

While converting some MySql databases to SQL Server I ran across this function.  Confused by the lack of hints to its purpose in the name I did what any red-blooded IT person would do…  look it up.  It turns out that this function turns the string representation of an IP address into a long integer.  What good that does I am still not sure, but here is the jist of the operation.

(octet1 * 256^3) + (octet2 * 256^2) + (octet3 * 256) + octet4

Simple enough, right?  Now for the real question.  What the heck is this function doing in the database?  My only thought is that it is faster to search an integer than a string, but to my way of thought this function has nothing to do with normal database operations and doesn’t belong.  A value like this should be converted to an integer by your business logic and passed into the database.  Your DBMS should not be concerned with IP infrastructure.  Of course that is jus my opinion and I would love to hear what others think.

del.icio.us Tags: ,,,,
posted on Tuesday, March 22, 2011 12:18 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Comment *  
Verification

Tim Murphy

Tim is a Solutions Architect for PSC Group, LLC. He has been an IT consultant since 1999 specializing in Microsoft technologies. Along with running the Chicago Information Technology Architects Group and speaking on Microsoft and architecture topics he was also contributing author on "The Definitive Guide to the Microsoft Enterprise Library".



I review for the O'Reilly Blogger Review Program



Technorati Profile

www.flickr.com
Tag Cloud