如何在MySQL中插入BLOB和CLOB文件? [英] How to insert BLOB and CLOB files in MySQL?
本文介绍了如何在MySQL中插入BLOB和CLOB文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用软件的前端存储图像和.docx/.doc,.pptx/.ppt,.pdf文件.我不明白如何实现此目标以及如何将BLOB和CLOB文件插入表中.请帮忙.
I want to store images and .docx/.doc, .pptx/.ppt, .pdf files using the front end of my software. I don't understand how to implement this and how to insert the BLOB and CLOB files into the table. Please help.
我正在使用Kubuntu 11.04,MySQL5,Qt 4.7.3.
I am using Kubuntu 11.04, MySQL5, Qt 4.7.3.
推荐答案
两种方式:
1-使用 LOAD_FILE 函数->
1 - Use a LOAD_FILE function -
INSERT INTO table1 VALUES(1, LOAD_FILE('data.png'));
2-以十六进制字符串形式插入文件,例如-
2 - Insert file as hex string, e.g. -
INSERT INTO table1 VALUES
(1, x'89504E470D0A1A0A0000000D494844520000001000000010080200000090916836000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000097048597300000EC300000EC301C76FA8640000001E49444154384F6350DAE843126220493550F1A80662426C349406472801006AC91F1040F796BD0000000049454E44AE426082');
这篇关于如何在MySQL中插入BLOB和CLOB文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文