第一范文网 - 专业文章范例文档资料分享平台

unix 数据库 学习 笔记

来源:用户分享 时间:2025/5/23 3:54:21 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

数据库备份与恢复

onconfig 参数

TAPEDEV 设置成STDIO.

备份:

ontape -s -L 0 -t STDIO -F|gzip -f > /databk/ontape0.gz 恢复:

gunzip -c /databk/ontape0.gz|ontape -r -t STDIO

onmode –mGo to multi-user on-line

设置informix环境变量

? FORCE_DDL_EXEC

开启:SET ENVIRONMENT FORCE_DDL_EXEC \关闭:SET ENVIRONMENT FORCE_DDL_EXEC off

强制执行alter fragment 语句,所有其他正在使用该表的事物将会回滚。

如何注册外部存储过程

强制锁表

LOCK TABLE table-name IN MODE table-name:表名称。

SHARE:允许读表中数据,但不允许作任何修改

EXCLUSIVE:禁止其他任何形式访问表

每次只能对表琐定一次;事务处理过程中,BEGIN WORK后立即执行LOCK TABLE以取代记录级加锁,COMMIT WORK和 ROLLBACK WORK语句取消所有对表的加锁;若没有事务处理,锁将保持到用户退出或执行UNLOCK为止。

例:lock table tabname in exclusive mode;

next extent size allocation

The number of kilobytes that the database server allocates for a next extent is, in general, equal to the size of a next extent, as specified in the SQL statement CREATE TABLE. However, the actual size of the next-extent allocation might deviate from the specified size because the allocation procedure takes into account the following three factors: ? ? ?

Number of existing extents for this tblspace

Availability of contiguous space in the chunk and dbspace Location of existing tblspace extents

Extent Size Doubling: extent size自动翻倍

如果一张静态表或者用户自定义的临时表已经有16个extent,后续的extent大小会自动加倍。 例如创建表时设置的next size为20K,那么数据库分配的前16个extent大小为20K,第17到第32个extent大小为40k,第33到第48个extent大小为80K等等。

Lack of Contiguous Space:没有足够的连续空间

如果数据库在第一个chunk中找不到连续的next extent大小的空间,会继续在下一个chunk中寻找,但是注意extent不能跨chunk。

如果数据库在所有的chunk中都找不到足够的连续空间,那么就分配最大可用的连续空间为next extent(最小分配单位为4KB,默认8KB)。

Merge of Extents for the Same Table:同一张表的extent合并

如果数据库要分配的下一个extent和已分配给同张表的空间连续,那么数据库并不会把这次分配当做一个新的分配,而是扩充已存在的extent。我们看到的extent的个数并不是分配次数,而是extent的物理个数。

查看某张表所占空间大小

select a.dbspace,a.npused,

a.npused* b.pagesize / 1024/1024/1024 as AggUsedGB from sysfragments a, niosdb:systables b where a.tabid = b.tabid and a.fragtype = 'T' and b.tabname = 'tpa_pm_subject_serv_gsm

?

分片查看

select

st.dbsname databasename,st.tabname,sd.name dbs_name, ti_nextns extents,

sin.ti_nrows,sin.ti_pagesize, sin.ti_rowsize,

sin.ti_nptotal nptotal, format_units(sin.ti_nptotal,sd.pagesize) total_size, sin.ti_npused npused, format_units(sin.ti_npused,sd.pagesize) used_size, sin.ti_nptotal-sin.ti_npused

npfree,format_units(sin.ti_nptotal-sin.ti_npused,sd.pagesize) free_size, sin.ti_nextsiz nextsize

from sysmaster:systabnames st, sysmaster:sysdbspaces sd,sysmaster:systabinfo sin,niosdb:systables dt

where sd.dbsnum = trunc(st.partnum/1048576) and dt.tabid>99

and dt.tabname=st.tabname and st.partnum=sin.ti_partnum and st.dbsname='niosdb' and dt.tabname not like 'tmp%' order by 10 desc; ?

合并查看

select

st.dbsname databasename, st.tabname, dt.fextsize ext_size, dt.nextsize nxt_size, sum(ti_nextns) extents,

sum(sin.ti_nrows) nrows,max(sin.ti_pagesize) pagesize, sum(sin.ti_nptotal) total_size, sum(sin.ti_npused) used_size,

sum(sin.ti_nptotal)-sum(sin.ti_npused) npfree,

format_units(sum(sin.ti_nptotal)-sum(sin.ti_npused),max(sd.pagesize)) free_size from sysmaster:systabnames st, sysmaster:sysdbspaces sd,sysmaster:systabinfo sin,niosdb:systables dt

where sd.dbsnum = trunc(st.partnum/1048576)

npused,

format_units(sum(sin.ti_npused),max(sd.pagesize))

nptotal,

format_units(sum(sin.ti_nptotal),max(sd.pagesize))

and dt.tabid>99

and dt.tabname=st.tabname and st.partnum=sin.ti_partnum and st.dbsname='niosdb' and st.tabname not like 'tmp%' group by 1,2,3,4 order by 12 desc; ?

带时间分片查询

select

st.dbsname databasename,st.tabname,sd.name dbs_name, ti_nextns extents,

sin.ti_nrows,sin.ti_pagesize, sin.ti_rowsize,

sin.ti_nptotal nptotal, format_units(sin.ti_nptotal,sd.pagesize) total_size, sin.ti_npused npused, format_units(sin.ti_npused,sd.pagesize) used_size, sin.ti_nptotal-sin.ti_npused

npfree,format_units(sin.ti_nptotal-sin.ti_npused,sd.pagesize) free_size, sin.ti_nextsiz nextsize,frg.begin_time,frg.end_time

from sysmaster:systabnames st, sysmaster:sysdbspaces sd,sysmaster:systabinfo sin,niosdb:systables dt,niosdb:tac_frag_manager frg where sd.dbsnum = trunc(st.partnum/1048576) and dt.tabid>99 and

dt.tabname=st.tabname

and

dt.tabname=frg.table_name

and

sd.name=frg.tablespace_name and frg.del_flag=0 and st.partnum=sin.ti_partnum and st.dbsname='niosdb' and dt.tabname not like 'tmp%' order by 10 desc;

表压缩处理

现场有时会遇到如下情况

1、 数据库空间不够用,有很多表碎片较多,想重用这部分空间 2、 部分表不是很经常使用,可以压缩处理,节省空间

3、 部分表的部分分片方法量很小(比如很久以前的历史数据),可以压缩存放,以节省空

针对以上需求可以使用如下方法,注:使用到informix 11.5及以上的特性

搜索更多关于: unix 数据库 学习 笔记 的文档
unix 数据库 学习 笔记.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6saio6ky9d4zk8m0i2aj_7.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top