mysql 中 for xml_什么是“ FOR XML AUTO”?在MySQL中? (用于具有表示行的XML字符串)...

bd96500e110b49cbb3cd949968f18be7.png

In SQL Server I frequently use "FOR XML AUTO", which allows something like "SELECT id FROM car FOR XML AUTO" to return "12". Is there a way to do this in MySQL?

What I want is to be able to store this XML in another table so I can have complete log of changes made in the database. The history table will be populated by triggers, and each row will be a denormalized representation of the row that changed; storing XML seems like a great way to change the definition of a table and not worry about messing up the log history. So what I need is a simple and straightforward way to have an string that can be inserted as a data value, and this is string must be the XML description of the row.

Thank you very much!

Regards,

Pedro

解决方案

See http://www.mysqludf.org/lib_mysqludf_xql/index.php for the lib_mysqludf_xql library from the MySQL UDF Repository.

The library provides a set of functions that generate XML output similar to SQL/XML as seen in Oracle/SQL Server. There are download/build/install instructions on the page along with a description of the library and the various functions it provides.

These should be sufficient to be used from within a trigger as you were planning.

-Dipin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值