Sybase 常用命令介绍(chenyi)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1.1 常用命令介绍

1.1.1 数据库操纵命令

1.1.1.1 ISQL

语法举例:isql –Usa –P –SSYSMIS {> filename{< filename}}

说明:-U:用户名;-P:口令;-S:SERVER名。SERVER名必须在$HOME/interfaces中有定义,其作用相当于PC CLIENT端的sql.ini,其维护工具是$HOME/install/sybinit,相当于PC CLIENT端的sqledit.exe。注意在使用sybinit定义SERVER时,IP地址在/etc/hosts文件中须有定义(如“192.9.202.201 hb1”),否则在定义过程中会有警告信息,但不影响使用。

1.1.1.2 dbcc checkdb

作用:检查数据库状态。

语法举例:dbcc checkdb(DATABASE NAME)。

说明:一般情况下该命令与dbcc checkalloc、dbcc checktable 配合使用,以检查数据库的使用情况。根据命令显示结果进行维护操作,该命令的输出显示一般为以下文本:

……

Checking syslogs

The total number of data pages in this table is 225.

*** NOTICE: Space used on the log segment is 0.44 Mbytes, 0.88%.

*** NOTICE: Space free on the log segment is 49.56 Mbytes, 99.12%.

Table has 5168 data rows.

……

Checking csszh_csdj

The total number of data pages in this table is 1.

Table has 16 data rows.

……

DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.

若显示结果与上述有异,则结合其它dbcc命令确定具体是什么错误,报错时会显示Msg号,根据Msg号,采取相应的解决方法。(参见第错误!未定义书签。页“错误!未找到引用源。”。)

1.1.1.3 dbcc checkalloc

作用:检查数据库空间分配。

语法举例:dbcc checkalloc(DATABASE NAME{,fix})。

说明:一般情况下该命令与dbcc checkdb、dbcc checktable、dbcc tablealloc配合使用,以检查数据库的使用情况。根据命令显示结果进行维护操作,该命令的输出显示一般为以下文本:

TABLE: sysindexes OBJID = 2

INDID=1 FIRST=24 ROOT=32 SORT=0

Data level: 1. 26 Data pages allocated and 4 Extents allocated.

Indid : 1. 1 Index pages allocated and 1 Extents allocated. TOTAL # of extents = 5

*************************************************************** TABLE: sysobjects OBJID = 1

INDID=1 FIRST=1 ROOT=8 SORT=0

Data level: 1. 28 Data pages allocated and 4 Extents allocated.

Indid : 1. 1 Index pages allocated and 1 Extents allocated. INDID=2 FIRST=18 ROOT=16 SORT=0

Indid : 2. 9 Index pages allocated and 2 Extents allocated. TOTAL # of extents = 7

……

Processed 263 entries in the sysindexes for dbid 5.

Alloc page 0 (# of extent=32 used pages=109 ref pages=101)

Alloc page 256 (# of extent=32 used pages=91 ref pages=89)

Alloc page 512 (# of extent=32 used pages=95 ref pages=95)

Alloc page 768 (# of extent=32 used pages=118 ref pages=118)

Alloc page 1024 (# of extent=32 used pages=116 ref pages=116)

……

Total (# of extent=850 used pages=3040 ref pages=3014) in this database DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.

该命令的fix选项的作用是让数据库进行自动修复,但有一条件:必须将要修复的数据库状态设置为Single User(单用户模式),具体用法如下:

isql –Usa –P –SSYSMIS

1> sp_dboption pubdata,’single user’,true

2> go

1> use pubdata

2> go

1> checkpoint

2> go

1> dbcc checkalloc(pubdata,fix)

2> go

相关文档
最新文档