title: "Postgresql存储二进制大数据文件"
date: 2021-02-02T20:46:31+08:00
draft: true
tags: ['postgres','binary']
author: "dadigang"
author_cn: "大地缸"
personal: " http://www.real007.cn "
http://www.real007.cn/about
如果想把整个文件或图片存储在数据表的一个字段内,该字段可以选择二进制基扒脊类型,然后将文件按二进制存储起来,文本文件也可以存在text字段内。
示例如下:
二进制类型bytea的 *** 作(在最大值内,有内存限制)
1、 创建表
2、 将文件放到coordinator目录下/mnt/postgresql/coord
通过pg_read_binary_file()函数,插入一张图片- 目录:/mnt/postgresql/coord/1.jpg
3、 也可以调用pg_read _file()将一个文本文件存储在一个text字段内
注意:函数pg_read_binary_file()和pg_read_file()中的路径必须是相对路径,默认路径是coordinator目录下此段,并且必须在coordinator目录下搏渗或者coordinator目录的子目录下。
Name
Return Type
Description
pg_read_file(filename text [, offset bigint, length bigint])
text
Return the contents of a text file
pg_read_binary_file(filename text [, offset bigint, length bigint])
bytea
Return the contents of a file
Form formPreview = new Form()public Leaf(string name) : base(name) { }
public override void Add(Component c)
{
Console.WriteLine("宽虚烂Cannot add to a leaf")
}
public override void Remove(Component c)
{
Console.WriteLine("Cannot remove to a leaf")
}
public override void Display(int depth)
{
Console.WriteLine(new string('慎漏-'誉衡,depth)+name)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)