看板 Database 關於我們 聯絡資訊
※ 引述《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(); [root@3wa sqlite]# ls -lht 總計 1.4G -rw-r--r-- 1 root root 900M 12月 20 16:36 a.sqlite -rw-r--r-- 1 root root 512M 12月 20 16:34 a.txt -rw-r--r-- 1 root root 450 12月 20 16:34 a.php [root@3wa sqlite]# 900M 是因為測試 1MB 256mb xxmb 512mb ... 加一加就900 如果你是要用 base64 明碼存,text 應該是夠了,圖片? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.134.48.253 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1513759346.A.4DC.html