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