select * from sm_pub_filesystem where filepath = '1001A3100000000GO1I0' or filepath like '1001A3100000000GO1I0/%' order by ts desc select pk, filepath, creator, isfolder, lasttime, filelength, isdoc, pk_doc, modifier, filedesc, scantimes, modifytime, filetype from sm_pub_filesystem where filepath = '1001A3100000000GO1I0' or filepath like '1001A3100000000GO1I0/%' order by ts desc
select smfile.pk_doc,header.name,fbody.storepath 实际存储路径,smfile.filepath,smfile.*, header.*, fbody.* from sm_pub_filesystem smfile left join bap_fs_header header on smfile.pk_doc = header.path left join bap_fs_body fbody on header.guid = fbody.headid where smfile.ISFOLDER ='n' and smfile.filepath like '1001A3100000000GO1I0%'; -- 替换为实际的单据主键 and smfile.pk_doc='';
select smfile.pk_doc,header.name,fbody.storepath 实际存储路径,smfile.filepath,smfile.*, header.*, fbody.* from sm_pub_filesystem smfile left join bap_fs_header header on smfile.pk_doc = header.path left join bap_fs_body fbody on header.guid = fbody.headid where smfile.ISFOLDER ='n' and smfile.filepath like '1001A3100000000GO1I0%'; -- 替换为实际的单据主键
select * from sm_pub_filesystem where pk_doc = 'b1eb7727-0bc9-48c9-ba4e-79edfba3dca5';
select storepath,name,filepath from sm_pub_filesystem smfile left join bap_fs_header header on smfile.pk_doc = header.path left join bap_fs_body fbody on header.guid = fbody.headid where smfile.filepath like '%842btdub1oavk930jteitcodacc2r43h/0003b03e-9860-4f31-a90f-4d4d0143f9a1sanlingLOGO1_20230815165903.jpg%'
select storepath,name,header.* from bap_fs_header header left join bap_fs_body fbody on header.guid = fbody.headid where header.guid='b1eb7727-0bc9-48c9-ba4e-79edfba3dca5';
-- 单据相关的附件 select header.name,fbody.storepath 实际存储路径,smfile.filepath from sm_pub_filesystem smfile left join bap_fs_header header on smfile.pk_doc = header.path left join bap_fs_body fbody on header.guid = fbody.headid where smfile.ISFOLDER ='n' and smfile.pk_doc= 'b1eb7727-0bc9-48c9-ba4e-79edfba3dca5'
select * from bap_fs_body where storepath like '%银行电子回单%'
--备份表
create table bap_fs_body_bak_at_20250523 as select * from bap_fs_body
--更新表数据
UPDATE bap_fs_body SET storepath=replace(storepath,'/root/ufs/nccdatabase','/data/ufs/yonbip')
2 个回复
nccloud
背景
采用磁盘存储的文件服务器,因原有路径规划调整或变化,需要改变文件存储绝对路径。
方案
采用磁盘存储的附件,主要在sysconfig中的文件服务器配置处修改新增附件的所属数据源和文件存储路径,同时在数据库中有保存附件的绝对地址,所以需要同步修改。
1、调整文件存储路径和实际附件地址,以原有附件保存在/data/fs ,想要迁移到/data/ufs为例。
首先/data/fs下,一般存在uapattachroot riamsgattachfiles 等文件夹,需要将全部的内容复制或转移到/data/ufs下。
2、如果前后数据源名称有变化的,需要查看/data/fs下如果有以数据源名称命名的文件夹,需要同步更名
3、修改数据库的附件表,执行SQL
--备份表
create table bap_fs_body_bak_at_202109301300 as select * from bap_fs_body
--更新表数据
UPDATE bap_fs_body SET storepath=replace(storepath,'/data/fs','/data/ufs')
至此,重启服务器后即可完成。
注意:本调整操作期间,尽量保持系统关闭或无附件新增修改及删除等动作,避免数据出现不一致的情况。
nccloud
select * from sm_pub_filesystem where filepath = '1001A3100000000GO1I0' or filepath like '1001A3100000000GO1I0/%' order by ts desc
select pk, filepath, creator, isfolder, lasttime, filelength, isdoc, pk_doc, modifier, filedesc, scantimes, modifytime, filetype from sm_pub_filesystem where filepath = '1001A3100000000GO1I0' or filepath like '1001A3100000000GO1I0/%' order by ts desc
select smfile.pk_doc,header.name,fbody.storepath 实际存储路径,smfile.filepath,smfile.*, header.*, fbody.*
from sm_pub_filesystem smfile
left join bap_fs_header header on smfile.pk_doc = header.path
left join bap_fs_body fbody on header.guid = fbody.headid
where smfile.ISFOLDER ='n'
and smfile.filepath like '1001A3100000000GO1I0%'; -- 替换为实际的单据主键
and smfile.pk_doc='';
select smfile.pk_doc,header.name,fbody.storepath 实际存储路径,smfile.filepath,smfile.*, header.*, fbody.*
from sm_pub_filesystem smfile
left join bap_fs_header header on smfile.pk_doc = header.path
left join bap_fs_body fbody on header.guid = fbody.headid
where smfile.ISFOLDER ='n'
and smfile.filepath like '1001A3100000000GO1I0%'; -- 替换为实际的单据主键
select * from sm_pub_filesystem where pk_doc = 'b1eb7727-0bc9-48c9-ba4e-79edfba3dca5';
select storepath,name,filepath from sm_pub_filesystem smfile left join bap_fs_header header on smfile.pk_doc = header.path left join bap_fs_body fbody on header.guid = fbody.headid where smfile.filepath like '%842btdub1oavk930jteitcodacc2r43h/0003b03e-9860-4f31-a90f-4d4d0143f9a1sanlingLOGO1_20230815165903.jpg%'
select storepath,name,header.*
from bap_fs_header header
left join bap_fs_body fbody on header.guid = fbody.headid where header.guid='b1eb7727-0bc9-48c9-ba4e-79edfba3dca5';
-- 单据相关的附件
select header.name,fbody.storepath 实际存储路径,smfile.filepath
from sm_pub_filesystem smfile
left join bap_fs_header header on smfile.pk_doc = header.path
left join bap_fs_body fbody on header.guid = fbody.headid
where smfile.ISFOLDER ='n'
and smfile.pk_doc= 'b1eb7727-0bc9-48c9-ba4e-79edfba3dca5'
select * from bap_fs_body where storepath like '%银行电子回单%'
--备份表
create table bap_fs_body_bak_at_20250523 as select * from bap_fs_body
--更新表数据
UPDATE bap_fs_body SET storepath=replace(storepath,'/root/ufs/nccdatabase','/data/ufs/yonbip')