对SharePoint 2007数据库中一些数据表的使用
来源:互联网 发布:小型企业网络搭建 编辑:程序博客网 时间:2024/05/19 12:27
转:http://blog.csdn.net/ma_jiang/article/details/6553392
在工作中接触了一些SharePoint的数据库中的一些表。在此做个总结。
一位高手告诉我了与Content Database相关的三个表:
AllUserData AllDocs AllDocStreams
我就是从这三个表开始研究的。而且在研究中发现 AllLists 表也很重要,但遗憾的是没在msdn上找到对这个表的说明。
表中每列的含义我就不多说了,在msdn上都有。 我在此举几个例子来介绍一下这些表的使用。
1. 得到用户上传的文档的数目:
select count(*) as DocNumber from dbo.AllDocs
where [ExtensionForFile] <> '' and [DoclibRowId] > 0 and [ListId] in
(select [tp_ID] from dbo.AllLists where [tp_ServerTemplate] = 101 and [tp_ItemCount] > 0)
注:AllLists列表中记录着所有列表的信息,此处所说的列表指的是所有SPList对象。
2. 得到每个文档的平均大小:
--declare variables
declare @file_size int
set @file_size = 0
set @file_size = (select sum(Cast([Size] as bigint)) as DocSize from dbo.AllDocs
where [ExtensionForFile] <> '' and [DoclibRowId] > 0 and [ListId] in
(select [tp_ID] from dbo.AllLists where [tp_ServerTemplate] = 101 and [tp_ItemCount] > 0))
set @file_size = @file_size / 1024
print(@file_size);
注:[Size]字段是以Byte为单位的,所以要将其变为bigint类型。
3. 得到文档库中文档的格式及相应的数目:
select [ExtensionForFile], count(*) as FileCount from dbo.AllDocs
where [ExtensionForFile] <> '' and [DoclibRowId] > 0 and [ListId] in
(select [tp_ID] from dbo.AllLists where [tp_ServerTemplate] = 101 and [tp_ItemCount] > 0)
group by [ExtensionForFile] order by [FileCount] desc
1. 得到文档库的大小
dbo.Webs 记录了每个 SPWeb对象的 FullUrl和 Guid.
dbo.Sites 记录了每个 SPSite对象的 GUID,可以与 dbo.Webs、 dbo.AllDocs对象联合起来使用。
select [ListId] as [LibId], [tp_Title] as [LibTitle],dbo.Webs.[FullUrl], (sum(Cast([Size] as bigint)) / (1024)) as [LibSize (KB)]
from dbo.AllDocs, dbo.AllLists, dbo.Webs
where [ExtensionForFile] <> '' and [DoclibRowId] > 0 and [ListId] = [tp_ID] and
[tp_ServerTemplate] in (101,109,111,113,114,115,116,119) and [tp_ItemCount] > 0 and dbo.AllDocs.[SiteId]=
(select dbo.Sites.[Id] from dbo.Sites, dbo.Webs
where dbo.Webs.[SiteId] = dbo.Sites.Id and dbo.Webs.[FullUrl] = '')
and dbo.AllDocs.[WebId] = dbo.Webs.[Id]
Group By [ListId], dbo.Webs.[FullUrl], [tp_Title] order by [LibSize (KB)] desc
注: dbo.Webs.[FullUrl] 列存储了每个 SPWeb 对象的 url 地址 ( 例如: Teams/Test0223PM0400) ,当此 SPWeb 对象是根站点的 web 对象时,此处值为空字符串。
2. 得到在某段时间内更新的文档数
--declare variables
declare @start_time datetime, @end_time datetime
--set UTC DateTime
set @start_time = cast('2010-12-27 08:08:33' as datetime)
set @end_time = cast('2010-12-28 02:35:21' as datetime)
select count(*) from dbo.AllDocs
where [ExtensionForFile] <> '' and [DoclibRowId] > 0 and [ListId] in
(select [tp_ID] from dbo.AllLists where [tp_ServerTemplate] = 101 and [tp_ItemCount] > 0)
and ([MetaInfoTimeLastModified] between @start_time and @end_time)
注:dbo.AllDocs表中的[TimeCreated], [TimeLastModified], [NextToLastTimeModified], [MetaInfoTimeLastModified],以及[TimeLastWritten] 列都使用 UTC 时间。
3.得到最常使用的文档格式及数目
select [ExtensionForFile], count(*) as 'AttachmentCount' from AllDocs
where DoclibRowId is null and [DeleteTransactionId] = 0x and [Type] = 0
and [HasStream] = 1 and ListId in
(select tp_ID from dbo.AllLists where [tp_ServerTemplate] in (100,107,108,150,1100) and [tp_ItemCount] > 0)
group by [ExtensionForFile] order by [AttachmentCount] desc
注: [DeleteTransactionId] 指示该listitem是否已被删除,未删除则值应为0x。
[HasStream] 指示此item是否含有文件流,1表示含有。
[Type] 指示此文档的‘Document Store Type’, 0表示文件,1表示文件夹。
4. 从站点集的Url地址得到所在数据库的名字
此处需要用到SharePoint的配置数据库(默认名称为:SharePoint_Config)
select dbo.objects.[name] from dbo.objects, dbo.sitemap
where dbo.objects.[ID] = dbo.sitemap.[databaseID] and dbo.sitemap.[path] = '/AK/StrategicIndustries'
注:dbo.objects.[name] –> 数据库的名称存在于此列。
dbo.sitemap.[path] –> 记录着站点集的路径。
- 对SharePoint 2007数据库中一些数据表的使用
- 对SharePoint 2007数据库中一些数据表的使用
- 查询SQL数据库中各数据表的空间使用情况
- Oracle数据库--对数据表结构的操作
- java对数据库中数据表的增删改查(基于MySQL数据库)
- sharepoint 关于 在数据表中编辑 share point server 2003 在数据表中编辑 未安装与 Windows SharePoint Services 兼容的数据表组件。
- 使用PHP代码对Mysql数据库的数据表显示实例代码
- sharepoint中列表的使用
- 取得Access数据库中数据表的信息
- 一种描述数据库中数据表的数据结构
- 遍历数据库中两个数据表的方法
- 读取SqlServe中不同数据库的数据表
- MyBatis对数据库的CRUD(一些标签的使用)
- 查找数据库中数据表。。。
- 数据库中对表的一些基本操作
- ORACLE 数据库对数据表的基本管理语句
- 客户端出错:无法在数据表视图中显示该列表: 没有安装与 Windows SharePoint Services 兼容的数据表组件。
- sharepoint的一些资源
- Sharepoint数据库存储过程
- android 广播在4.0+系统上无法接受的问题
- knockout事件范围父类属性
- Gradle android 插件现况
- 各式各样的极品程序员,你属于哪一种
- 对SharePoint 2007数据库中一些数据表的使用
- SharePoint对象模型性能考量
- 排序小结之插入排序及其升级版
- MYSQL中replace into的用法
- 初始化domain model
- Wpf TreeView 延时加载实现
- [转载] Windows 平台下 CodeBlocks 连接 MySQL 数据库
- uva-350
- mysql merge表介绍