首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Sybase >

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

2012-03-08 
请问sysbase中 sp_extendsegment 和 alterbase 有什么不同?我知道sp_extendsegment 是将某个段扩到设备上,

请问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'.


The segment you tried to extend does not exist. Run sp_helpsegment to list the segments for a database.
·This command has been ignored. Extending the log segment on device 'devname' would leave no space for creating objects in database 'database_name'.
devname is the only or last database device with space available for the database database_name.
·You must execute this procedure from the database in which you wish to add a segment. Please execute 'use database_name' and try again.
sp_extendsegment can extend segments only in the database from which it is run. Qualify sp_extendsegment with the database name or issue the use database_name command to open the database in which you want to extend a segment. Then run sp_extendsegment again.
Permissions
Only the Database Owner or a System Administrator can execute sp_extendsegment.
Tables Used
master.dbo.sysdatabases, sysdevices, master.dbo.sysusages, sysobjects, syssegments
See Also
Commands
alter database, create index, create table
System procedures
sp_addsegment, sp_dropsegment, sp_helpdb, sp_helpdevice, sp_helpsegment, sp_placeobject
[解决办法]

探讨
还是不太明白啊,比如
use master
alter database K_CS
log on Data03=10


sp_extendsegment log, K_CS, Data03

这两句 不都是将log 这个段扩到Data03上吗,既然都用了alterdatabase 还用sp_extendsegment干什么



引用 1 楼 andkylee 的回复……

热点排行