Reputation: 189
Is there any way to include XML datatype in MYSQl 5.1 or we have a newer version with XML datatype given?? like DB2 and MSSQL having XML datatype..
Upvotes: 0
Views: 818
Reputation: 76641
MySQL does not have an XML datatype.
In DB2 the XML
datatype is basically a TEXT blob encoded in UTF-8 that validates the XML upon input. You cannot store anything but valid XML in this container.
MySQL does not have this option, so you'll have to use the TEXT
datatype using a UTF-8 character set.
If you want to check the validness of the input into the field, you can do that in a trigger.
See here for validation code in a trigger (just general validation, not XML related): http://rpbouman.blogspot.com/2009/12/validating-mysql-data-entry-with_15.html
In order to do the XML checking you'll have to install a UDF for that.
http://www.mysqludf.org/lib_mysqludf_xql/
http://www.codeproject.com/KB/database/MySQL_Xml_UDF.aspx
As far as I can tell these libraries do not support XML validation.
If you're a C(++) or Delphi guru, you can write your own UDF, see: http://www.codeguru.com/cpp/data/mfc_database/misc/article.php/c12615
Upvotes: 1