Re: [SQL ] SQLite储存Base64 String建议的资料型别

楼主: shadowjohn (转角遇到爱)   2017-12-20 16:42:23
※ 引述《james999 (无伤大雅)》之铭言:
: 数据库名称:SQLite3
: 内容/问题描述:
: 本来是用SQL Server当数据库,但最近想换成SQLite就好,
: 其中Base64 String(Image)原先在SQL Server内资料型别是设成varchar(MAX),
: 不晓得在SQLite里面建议存成什么格式好?
: 谢谢大家:)
帮你试了一下 SQlite 的 text 形态
试塞了 512MB 的资料,似乎是没什么问题
1024MB 最后没有写入成功,应该是超过他的最大值了
以下是简单512mb的测试,多写了一个读写档案来确定资料大小给你参考
<?php
ini_set('memory_limit',-1);
$pdo = new PDO('sqlite:a.sqlite');
// $sql = "create table a(id integer,b text);";
// $sth = $pdo->prepare($sql);
// $sth->execute();
//
$fp = fopen('a.txt','w');
for($i=0;$i<512;$i++)
{
fwrite($fp,str_repeat('a',1024*1024));
}
fclose($fp);
$sql = "insert into a(`id`,`b`)values('1',?);";
$sth = $pdo->prepare($sql);
$sth->execute(array(file_get_contents('a.txt')));
//$pdo->close();
[[email protected] sqlite]# ls -lht
总计 1.4G
-rw-r

Links booklink

Contact Us: admin [ a t ] ucptt.com