当前位置: 代码迷 >> Sybase >> 请教sysbase中 sp_extendsegment 和 alterbase 有什么不同
  详细解决方案

请教sysbase中 sp_extendsegment 和 alterbase 有什么不同

热度:3941   发布时间:2013-02-26 00:00:00.0
请问sysbase中 sp_extendsegment 和 alterbase 有什么不同?
我知道sp_extendsegment 是将某个段扩到设备上,但是alterdabse不也有这个功能吗,而其在sp_extendsegment之前还需要先执行alterdatabase。
两者的用法到底是什么呢,有什么不同呢?请指教,谢谢。

------解决方案--------------------------------------------------------
alter database是将设备上的空间分配给数据库使用。
sp_extendsegement是对分配过来的数据设备空间进行分段规划。

只有先分来空间,才能进行下一步的规划!
------解决方案--------------------------------------------------------
参考标准:


Function
Extends the range of a segment to another database device.
Syntax
sp_extendsegment segname, dbname, devname
Parameters
segname - is the name of the existing segment previously defined with sp_addsegment.
dbname - is the name of the database on which to extend the segment. dbname must be the name of the current database.
devname - is the name of the database device to be added to the current database device range already included in segname.
Examples
1.sp_extendsegment indexes, pubs2, dev2
This command extends the range of the segment indexes for the database pubs2 on the database device dev2.
Comments
·After defining a segment, you can use it in the create table and create index commands to place the table or index on the segment. If you create a table or index on a particular segment, subsequent data for the table or index is located on that segment.
·To associate a segment with a database device, create or alter the database with a reference to that device. A database device can have more than one segment associated with it.
·A segment can be extended over several database devices.
·When you extend the logsegment segment, Adaptive Server recalculates its last-chance threshold.
Messages
·Can't run sp_extendsegment from within a transaction.
sp_extendsegment updates system tables, so it cannot be run from within a transaction.
·Device 'devname' is now exclusively used by 'segname'.
sp_extendsegment succeeded.
·'devname' is reserved exclusively as a log device.
You cannot create a segment on a database device that is dedicated to the database log.
·No such device exists -- run sp_helpdb to list the devices for the current database.
The named device does not exist in master.dbo.sysdevices.
·Segment extended.
sp_extendsegment succeeded. The segment named segname now includes space on the database device devname.
·'segname' is not a valid identifier.
Segment names must conform to the rules for identifiers. They must begin with a letter, an underscore character ( _ ), or a pound sign (#). After the first character, identifiers can include letters, underscores, pound signs, or dollar signs ($).
·The specified device is not used by the database.
Although the device named as the devname parameter exists in master.dbo.sysdevices, it is not used by the specified database. Segments can be extended only on database devices used by the database. Use alter database to extend a database on a device listed in the master.dbo.sysdevices table.
·There is no such segment as 'segname'.