存档

‘Sybase ASE’ 分类的存档,文章数:183

今天下午在solaris10 ASE15.0.3平台上批量创建非聚簇索引时,报下面的错误:

Msg 1526, Level 17, State 5: Server 'SYB_NFJD_TEST', Procedure 'sp_helpdb', Line 674: Sort failure. The configure size for data cache (default data cache) is not sufficient to handle the sort buffers (128) requested. Please reconfigure the data cache or sort buffers and try the command again. (return status = -7)

用命令:sp_helpcache "default data cache",发现高速数据缓冲大小为:8M,此为默认值。

执行命令将default data cache扩充至100M,sp_cacheconfig "default data cache","100m"

然后再重新执行一遍非聚簇索引的创建过程,成功完成了!

在error message & troubleshooting 中没有找到错误号1526的解释以及解决办法。

目前暂时没有想明白,为什么在创建非聚簇索引的时候需要用default data cache,而且默认数据缓存不足还会出错。难道default data cache要缓存某一层次的索引的页数据?

------------------------------------------------------------------------------------------------

以下关联一篇网上搜索的也是关于error:1526的信息

The failure is most likely happening on the remote server where the actual
physical table lives. It's certainly possible to create indexes on proxy
tables, but what really happens is that the physical index is created on the
remote server. Try logging in to the remote server where the actual table
resides. Check the memory settings on the remote server.

> Hi,
> I am trying to create a non clustered index on an "existing
> table"(proxy table). But it keeps failing with the error,
>
> Sort failure. The configure size for data cache (default
> data cache) is not
> sufficient to handle the sort buffers (30008) requested.
> Please reconfigure the
> data cache or sort buffers and try the command again.
>
> The data cache is configured 2 Gig, 800MB for 8K pool
> I have this configuration enough for most of the things.
>
> How can I make the non clustered index.

总结一下: 在建立非聚簇索引的时候,都涉及到default data cache数据缓存的使用。不管是在基本表还是在代理表上创建非聚簇索引,都会在物理表所在的ASE服务器上使用数据缓存。如果数据缓存不足,则会报 1526的错误信息。解决办法为用过程sp_cacheconfig增加default data cache即可。

————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:nonclustered index default data cache insufficient 1526 

                      数据缓存不足 非聚簇索引
————————————————————————————————-

ASE15.0之前的版本中利用bcp这个实用程序只能够导出整表或视图的数据。要想利用bcp有条件得导出表内数据,只能根据条件建立视图,然后 再导出该视图的数据;或者根据条件建立临时表,再导出临时表的数据。但是,都必须在执行bcp命令之前到数据库内部去创建对象(视图或者临时表),然后再 执行bcp命令导出视图或者临时表数据。显然,不是太方便。而其它的数据库管理系统,比如sqlserver早在sqlserver2000就实现了根据 条件queryout数据的功能。利用sybase ASE的第三方工具按条件导出数据也是一种办法。

在ASE 15.0及以后版本中,sybase终于提供了按照条件导出表内数据的办法,虽然实现起来还稍微有一点点小麻烦,但是终究是有这个功能了。参数:--initstring 就是为实现这个功能而加的。

关于参数:--initstring的注意事项有:

1.  参数--initstring之后的SQL语句会在数据导出之前被发送到ASE引擎;

2.  参数--initstring之后的SQL语句被当做会话级别的SQL语句一样处理;

3.  参数--initstring之后的SQL语句在整个bcp导出数据会话期间始终有效;

4.  真正导出的数据是关键字bcp和out之间的表的数据,而不是参数--initstring中select列表的数据。

下面开始举几个例子:

问题描述:

在Sybase Central中查看数据库时,在数据库目录下没有找到某个用户数据库(名字:andkylee),但是用isql连上数据库执行sp_helpdb能够 查询到andkylee的确存在。在Sybase Central中找了一会儿,竟然在代理数据库目录下找到了数据库andkylee。很是奇怪,怎么跑到代理数据库里面了。数据库andkylee就是一 个普通的用户数据库而已。

继续,依次展开代理数据库里面的andkylee库的目录,却找不到任何的用户表。代理表目录空空的,也没有用户表目录(真正的代理数据库中没有用户表)。纳闷了,andkylee库里的用户表都跑到哪里去了?

不过,用其它的数据库客户端工具是能够查询到andkylee库里面的用户表数据的。比如:用isql连上数据库,进入到andkylee库里。 sp_help可以查看到所有的对象名称。发现用户表都在,执行select能够查看到表的数据。其它的比 如:powerbuilder,dbartisan里面都能够在tables目录下面找到andkylee库里的所有表。看来,用户数据库 andkylee没多少异常。是普通库而不是代理数据库。

分析原因:

一开始,我以为是andkylee库里的用户没有关联上登陆账号引起的。这个情况是比较常见的。

在master库中执行:select suid ,name from syslogins where name='escourt4'

1> select suid ,name from syslogins where name='escourt4'
2> go
 suid        name
 ----------- ------------------------------
           5 escourt4
(1 row affected)

登录escourt4对应的suid为:5。

在进入到用户库andkylee里面。

1> use andkylee
2> go
1> select suid,uid,name from sysusers where name='escourt4'
2> go
 suid        uid         name
 ----------- ----------- ------------------------------
           5           3 escourt4
(1 row affected)

可以看出库andkylee里面的用户escourt4的uid为:3,它的suid为:5,正是对应的登录escourt4的suid。这没有问题,是正常的!

在测试load tran with until_time 的时候出现了错误。

先执行:dump tran andkylee to "d:\andkylee_tran2.dmp" with no_truncate 然后,进行数据库的恢复。

先进行全库恢复,接着进行下面的日志恢复,并恢复到指定的时间点。

但是报下面的错误:

1> load tran andkylee from "d:\andkylee_tran2.dmp" with until_time='Jun 28 2010 5:24:10 PM'
2> go
Backup Server session id is:  111.  Use this value when executing the
'sp_volchanged' system stored procedure after fulfilling any volume change
request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'ndkylee101790F554' section number 1
mounted on disk file 'd:\andkylee_tran2.dmp'
Backup Server: 4.58.1.1: Database andkylee: 75548 kilobytes LOADed.
Msg 623, Level 21, State 1:
Server 'TEST', Line 1:
Adaptive Server failed to retrieve a row via its RID in database 'andkylee'
because the target page is not a data page. Rid pageid = 0x16381; row num = 0x0.

Page pointer = 0x240FA000, pageno = 0, status = 0x300, ptnid = 99, indexid = 0,
level = 0.

用dbcc page查看pageid = 0x16381 的页面内容,发现此页面为日志页。页面号0x16381为十六进制,转化成十进制为:91009

今天试验了一下不同ASE版本跨平台远程备份数据库的操作。

环境:

源数据端:solaris 10 SPARC 64bit,ASE 12.5.4,称为:server1

目的数据端:windows xp x86,ASE15.0.3,称为:server2

 

任务:

测试将源数据端solaris上的ASE数据库服务器里面的andkylee库远程备份到目的windows-xp机子上。


第一步:在server1的interfaces文件中添加远程服务器条目

在server2的连接接口配置文件%SYBASE%\ini\sql.ini中,备份服务器的名称为:TEST_BS.

在server1的 /db/sybase/ase1254/interfaces中添加:

TEST_BS
        master tcp ether 192.168.2.173 5001
        query tcp ether 192.168.2.173 5001

 

注意:添加到server1的远程备份服务器名称务必和server2中的备份服务器名称保持一致。

 

第二步:连接上server1的ASE服务器,添加远程备份服务器的条目

isql -Usa -P -Sase1254

sp_addserver TEST_BS

这一步不是必须的!

第三步:在server1的ASE中执行远程备份命令

dump database andkylee to "d:\andkylee_remote.dmp" at TEST_BS

可以使用stripe on进行远程备份文件分片,最大分片数为32。

如果想压缩远程备份文件的话,必须使用with compression=[0-9]选项;兼容选项compress::只支持本地备份。

最后检查,在远程服务器server2上D盘发现有远程备份生成的文件:andkylee_remote.dmp。 远程备份数据库操作完成!

 

————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:ase cross-platform dump load solaris windows 跨平台 远程 备份恢复
————————————————————————————————-

在ASE12.5.x平台中没有替换字符串的函数,也就是说没有类似replace的函数。对于replace这个词,我想有编程经验的肯定一看字 面意思就知道是将某一字符串中指定的字符串替换为另外的字符串。可惜的是这么简单的功能在ase12.5.x中没有相应的函数,只有一个可怜的stuff 函数。

stuff函数仅仅能够替换某一个字符串中某一个位置处的字符串为另外的字符串,如果这个字符串中有多处需要被替换呢?抱歉,stuff歇菜了。

一个简单的类似replace的功能还得需要写个过程或者函数来实现。 写起来效率低执行起来效率更低, so pooor.

谁要是实现了用简单的一两条sql语句顶替replace的功能,麻烦告诉我一声。谢谢!

幸运的是,ASE15.0版本中引入了类似replace的函数,但是人家的名字叫str_replace,不知道为啥?replace这个词和那个关键字冲突吗? 不解ZZZZZZZ~~~

str_replace函数的语法很简单:

                     st_replace("string_expression1", "string_expression2", "string_expression3")

就是:将字符串1中所包含的所有 的字符串2都用字符串3统统替换。

一个简单的例子:

1> select str_replace('This is Andkylee!My nAme is andkylee!','A','a')
2> go
 -------------------------------------
 This is andkylee!My name is andkylee!
(1 row affected)

 

但是, 网上有人发帖说str_replace不能替换字符串中的空格为“(也就是说删除字符串中的所有空格)。不看官方文档,想当然的就写出来这样的语句:select str_replace('123 456 ',' ','')

但是很可惜,执行失败。

1> select len('123 456 '),str_replace('123 456 ',' ','') ,len(str_replace('123 456 ',' ',''))
2> go
 ----------- -------- -----------
           8 123 456            8
(1 row affected)

 

如上可以看到select str_replace('123 456 ',' ','')并没有替换其中的空格为空(亦即删除其中的所有空格),用函数str_replace执行前后的字符串是相同的。

通过查阅官方文档中关于str_replace的介绍,有下面的两点需要注意:

1. Adaptive Server 将空字符串常量自动转换为 1 个空格的字符串,以便将该字符串与 NULL 值区分开。

2. str_replace 在第三个参数中接受 NULL,将其视为尝试用 NULL 替换 string_expression2,有效地将 str_replace 转换成“字符串切除”
操作。

这两条的意思是说:在函数str_replace中""相当于" ", NULL 相当于“”(空字符)。

 ""相当于" "

示例:

1> select str_replace("cde fghi ","","_")
2> go
 ---------
 cde_fghi_
(1 row affected)
1> select str_replace("cde fghi "," ","_")
2> go
 ---------
 cde_fghi_
(1 row affected)

 

两个空格还是2个空格意思:

1> select str_replace("cde fghi ","  ","_")
2> go

 ---------
 cde fghi

(1 row affected)

NULL 相当于“”(空字符)

示例如下:

1> select str_replace("cde fghi "," ",null),len(str_replace("cde fghi "," ",null))
2> go
 --------- -----------
 cdefghi             7
(1 row affected)
1> select str_replace("cde fghi ","",null),len(str_replace("cde fghi "," ",null))
2> go
 --------- -----------
 cdefghi             7
(1 row affected)

 

总结:

在函数str_replace中NULL 相当于“”(空字符),""相当于" " 。其它都是正常的。

通过本文中的例子,可以看出Sybase ASE中存在一些不太符合常规习惯的地方。

————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:str_replace 15.0 null 空格 替换
————————————————————————————————-

一、添加镜像

为master设备添加镜像设备:

1> disk mirror
2> name='master',
3> mirror='D:\sybase\data\master_mirr.dat'
4> go
Msg 5155, Level 16, State 1:
Server 'TEST', Line 1:
The command 'DISK MIRROR' cannot be executed since disk mirroring has been
disabled. In order to enable disk mirroring, use: sp_configure 'disable disk
mirroring',0 and restart the server.

 

ASE默认是关闭设备镜像功能的,需要配置参数启用。disable disk mirroring 这是一个静态参数,配置完之后需要重启ASE服务器。

1> sp_configure "disable disk mirroring",0
2> go
 Parameter Name                 Default     Memory Used Config Value
         Run Value    Unit                 Type
 ------------------------------ ----------- ----------- ------------
         ------------ -------------------- ----------
 disable disk mirroring                   1           0            0
                    1 switch               static
(1 row affected)
Configuration option changed. Since the option is static, Adaptive Server must
be rebooted in order for the change to take effect.
Changing the value of 'disable disk mirroring' to '0' reduces the amount of
memory ASE uses by 18636 K. The reduced memory may be reused when this configure
value changes, but will not be released until ASE restarts.
(return status = 0)

 

重启ASE服务器之后。

执行命令镜像master设备

1> disk mirror
2> name='master',
3> mirror='D:\sybase\data\master_mirr.dat'
4> go
Creating the physical file for the mirror...
Starting Dynamic Mirroring of 20480 pages for logical device 'master'.
         512 pages mirrored...
        1024 pages mirrored...
        1536 pages mirrored...
        2048 pages mirrored...
        2560 pages mirrored...
        3072 pages mirrored...
        3584 pages mirrored...
        4096 pages mirrored...
        4608 pages mirrored...
        5120 pages mirrored...
        5632 pages mirrored...
        6144 pages mirrored...
        6656 pages mirrored...
        7168 pages mirrored...
        7680 pages mirrored...
        8192 pages mirrored...
        8704 pages mirrored...
        9216 pages mirrored...
        9728 pages mirrored...
The remaining 10752 pages are currently unallocated and will be mirrored as they
are allocated.
1>

 

成功完成!

利用过程sp_helpdevice查看master设备目前的状态。

1> sp_helpdevice master
2> go
 device_name physical_name
         description
         status cntrltype vdevno vpn_low vpn_high
 ----------- -------------------------
         -------------------------------------------------------------------------
         ------ --------- ------ ------- --------
 master      D:\sybase\data\master.dat
         file system device, special, MIRROR ENABLED, mirror = 'D:\sybase\data\m
         aster_mirr.dat',
serial writes, dsync on, directio off, reads mirrored,
          default disk, physical disk, 80.00 MB, Free: 42.00 MB
            739         0      0       0    40959
(1 row affected)
 dbname      size          allocated           vstart lstart
 ----------- ------------- ------------------- ------ ------
 master           26.00 MB Dec  2 2009  6:58PM      4      0
 model             6.00 MB Dec  2 2009  6:58PM  13316      0
 sybsystemdb       6.00 MB Dec  2 2009  6:58PM  19460      0
(1 row affected)
(return status = 0)

 

下面来解析一下被镜像后master设备的状态字段。

master设备被镜像后,在sysdevices系统表中并没有增加记录行;仅仅是更新了master设备对应的记录行中的status和mirrorname两个字段的内容。

1> select * from sysdevices
2> where name='master'
3> go
 low         high        status cntrltype name                           phyname                                                                                                                         mirrorname                                                                                                                      vdevno      crdate                     resizedate                 status2
 ----------- ----------- ------ --------- ------------------------------ ------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------- ----------- -------------------------- -------------------------- -----------
           0       40959    739         0 master                         D:\sybase\data\master.dat                                                                                                       D:\sybase\data\master_mirr.dat                                                                                                            0        Dec  2 2009  6:58PM        Mar 27 2010  4:32PM           0
(1 row affected)
1>
 

从上面可以看出master设备对应的status变成了739。status字段用bit位来表示各个状态的信息。

739 = 1 + 2 + 32 + 64 + 128 + 512

其中:

1:缺省磁盘; 

2:物理磁盘 

32:串行写 

64:设备已镜像 

128: 读已镜像

512:已允许镜像

这几个状态和sp_helpdevice master 中查看到的相一致。 呵呵, 要是看过sp_helpdevice的源代码的话,自然很好理解。

 

二、取消镜像

unmirror分两种情况:user-initiated 和 system-initiated 。 在镜像设备上如果出现了IO错误会导致系统自动取消该设备的镜像。

用户手动取消镜像的语法为:

 disk unmirror

name="logical_device_name"

[,side={"primary"|secondary}]

[,mode={retain|remove}]

其中side和mode两个选项是可选的。side的默认值为:secondary,意思是取消哪一边的镜像设备(有主设备和镜像设备两个)。 mode的默认值是retain,意思是本次取消是临时的(retain,下次还可以激活设备以再次用来镜像)还是永久的(remove,删除设备了)。

下面测试临时取消master设备的镜像功能!

1> disk unmirror
2> name='master',side=secondary,mode=retain
3> go
1>

 

执行完,没有任何提示信息。在errlog文件中看到有这么一条信息:00:00000:00030:2010/06/07 13:20:59.59 kernel  Closing the secondary device for virtual device master

现在再来看看master设备的状态信息:

1> sp_helpdevice master
2> go
 device_name physical_name             description                                                                                                                                                                                           status cntrltype vdevno vpn_low vpn_high
 ----------- ------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ --------- ------ ------- --------
 master      D:\sybase\data\master.dat file system device, special, MIRROR DISABLED, mirror = 'D:\sybase\data\master_mirr.dat', serial writes, dsync on, directio off, reads mirrored, default disk, physical disk, 80.00 MB, Free: 42.00 MB   2275         0      0       0    40959
(1 row affected)
 dbname      size          allocated           vstart lstart
 ----------- ------------- ------------------- ------ ------
 master           26.00 MB Dec  2 2009  6:58PM      4      0
 model             6.00 MB Dec  2 2009  6:58PM  13316      0
 sybsystemdb       6.00 MB Dec  2 2009  6:58PM  19460      0
(1 row affected)
(return status = 0)
1> select * from sysdevices where name='master'
2> go
 low         high        status cntrltype name                           phyname                                                                                                                         mirrorname                                                                                                                      vdevno      crdate                     resizedate                 status2
 ----------- ----------- ------ --------- ------------------------------ ------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------- ----------- -------------------------- -------------------------- -----------
           0       40959   2275         0 master                         D:\sybase\data\master.dat                                                                                                       D:\sybase\data\master_mirr.dat                                                                                                            0        Dec  2 2009  6:58PM        Mar 27 2010  4:32PM           0
(1 row affected)
1>
 

sp_helpdevice显示master设备已被MIRROR DISABLED。 sysdevices系统表中master对应的status列为:2275 = 2048 + 128 + 64 + 32 + 2 + 1 。状态为2048表示镜像已禁用(内部使用)。


三、重新激活镜像

语法:disk remirror name="logical_device_name"

在设备的镜像功能因为用户或者系统的缘故而被中止时,可以利用此命令恢复设备上的镜像功能。发出该命令后,ASE服务器会将镜像主设备上的数据拷贝到镜像次设备上面去。

恢复本文上面暂时取消的master上的镜像。

1> disk remirror
2> name='master'
3> go
Starting Dynamic Mirroring of 20480 pages for logical device 'master'.
         512 pages mirrored...
        1024 pages mirrored...
        1536 pages mirrored...
        2048 pages mirrored...
        2560 pages mirrored...
        3072 pages mirrored...
        3584 pages mirrored...
        4096 pages mirrored...
        4608 pages mirrored...
        5120 pages mirrored...
        5632 pages mirrored...
        6144 pages mirrored...
        6656 pages mirrored...
        7168 pages mirrored...
        7680 pages mirrored...
        8192 pages mirrored...
        8704 pages mirrored...
        9216 pages mirrored...
        9728 pages mirrored...
The remaining 10752 pages are currently unallocated and will be mirrored as they are allocated.
1>
 

在errorlog文件中有下面的日志内容:00:00000:00030:2010/06/07 13:31:03.26 kernel  mirror for virtual device 0 started using asynchronous (with DIRECTIO) I/O

再次查看status状态信息,

1> select name,status,phyname,mirrorname from sysdevices where name='master'
2> go
 name                           status phyname                                                                                                                         mirrorname
 ------------------------------ ------ ------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------
 master                            739 D:\sybase\data\master.dat                                                                                                       D:\sybase\data\master_mirr.dat
(1 row affected)

 

可以看到重新恢复镜像后,master设备的status状态信息和刚开始添加镜像时相同。个人感觉重新激活镜像(remirror)和新添加镜像 已经是一样的。只是不用告诉系统镜像到什么位置了而已;还有初次镜像的时候secondary设备文件必须不存在而激活镜像则相反。

 

四、利用镜像功能来移动设备的物理位置

可以利用镜像功能将数据库设备移动到其它物理位置。比如设备A原来在C盘,要是将其移动到D盘。 需要两个步骤:

1.将设备A镜像到D盘的设备文件上;

2.取消设备A在C盘的主镜像文件。

下面演示将tempdb的设备文件由D:\sybase\data\tempdbdev.dat移动到D:\syb_data\tempdbdev.dat

1> disk mirror
2> name='tempdbdev',
3> mirror='d:\syb_data\tempdbdev.dat'
4> go
Creating the physical file for the mirror...
Starting Dynamic Mirroring of 51200 pages for logical device 'tempdbdev'.
         512 pages mirrored...
        1024 pages mirrored...
        1536 pages mirrored...
        2048 pages mirrored...
        2560 pages mirrored...
        3072 pages mirrored...
        3584 pages mirrored...
        4096 pages mirrored...
        4608 pages mirrored...
        5120 pages mirrored...
        5632 pages mirrored...
        6144 pages mirrored...
        6656 pages mirrored...
        7168 pages mirrored...
        7680 pages mirrored...
        8192 pages mirrored...
        8704 pages mirrored...
        9216 pages mirrored...
        9728 pages mirrored...
       10240 pages mirrored...
       10752 pages mirrored...
       11264 pages mirrored...
       11776 pages mirrored...
       12288 pages mirrored...
       12800 pages mirrored...
       13312 pages mirrored...
       13824 pages mirrored...
       14336 pages mirrored...
       14848 pages mirrored...
       15360 pages mirrored...
       15872 pages mirrored...
       16384 pages mirrored...
       16896 pages mirrored...
       17408 pages mirrored...
       17920 pages mirrored...
       18432 pages mirrored...
       18944 pages mirrored...
       19456 pages mirrored...
       19968 pages mirrored...
       20480 pages mirrored...
       20992 pages mirrored...
       21504 pages mirrored...
       22016 pages mirrored...
       22528 pages mirrored...
       23040 pages mirrored...
       23552 pages mirrored...
       24064 pages mirrored...
       24576 pages mirrored...
       25088 pages mirrored...
       25600 pages mirrored...
       26112 pages mirrored...
       26624 pages mirrored...
       27136 pages mirrored...
       27648 pages mirrored...
       28160 pages mirrored...
       28672 pages mirrored...
       29184 pages mirrored...
       29696 pages mirrored...
       30208 pages mirrored...
       30720 pages mirrored...
       31232 pages mirrored...
       31744 pages mirrored...
       32256 pages mirrored...
       32768 pages mirrored...
       33280 pages mirrored...
       33792 pages mirrored...
       34304 pages mirrored...
       34816 pages mirrored...
       35328 pages mirrored...
       35840 pages mirrored...
       36352 pages mirrored...
       36864 pages mirrored...
       37376 pages mirrored...
       37888 pages mirrored...
       38400 pages mirrored...
       38912 pages mirrored...
       39424 pages mirrored...
       39936 pages mirrored...
       40448 pages mirrored...
       40960 pages mirrored...
       41472 pages mirrored...
       41984 pages mirrored...
       42496 pages mirrored...
       43008 pages mirrored...
       43520 pages mirrored...
       44032 pages mirrored...
       44544 pages mirrored...
       45056 pages mirrored...
       45568 pages mirrored...
       46080 pages mirrored...
       46592 pages mirrored...
       47104 pages mirrored...
       47616 pages mirrored...
       48128 pages mirrored...
       48640 pages mirrored...
       49152 pages mirrored...
       49664 pages mirrored...
       50176 pages mirrored...
       50688 pages mirrored...
       51200 pages mirrored...
1> disk unmirror
2> name='tempdbdev',
3> side='primary',
4> mode=remove
5> go
1> sp_helpdevice tempdbdev
2> go
 device_name physical_name             description                                                                                  status cntrltype vdevno vpn_low vpn_high
 ----------- ------------------------- -------------------------------------------------------------------------------------------- ------ --------- ------ ------- --------
 tempdbdev   d:\syb_data\tempdbdev.dat file system device, special, dsync on, directio off, physical disk, 200.00 MB, Free: 0.00 MB  16386         0      2       0   102399
(1 row affected)
 dbname size          allocated           vstart lstart
 ------ ------------- ------------------- ------ ------
 tempdb     100.00 MB Dec  2 2009  7:01PM      0      0
 tempdb      50.00 MB Dec  8 2009 11:16AM  51200  25600
 tempdb      50.00 MB Dec  8 2009 11:16AM  76800  38400
(1 row affected)
(return status = 0)
1> select name,status,phyname,mirrorname from sysdevices where name='tempdbdev'
2> go
 name                           status phyname                                                                                                                         mirrorname
 ------------------------------ ------ ------------------------------------------------------------------------------------------------------------------------------- -------------
 tempdbdev                       16386 d:\syb_data\tempdbdev.dat                                                                                                       NULL
(1 row affected)
1>
 

对应于errorlog中的信息为: 00:00000:00030:2010/06/07 13:45:33.34 kernel  mirror for virtual device 2 started using asynchronous I/O
00:00000:00030:2010/06/07 13:46:56.00 kernel  Closing the primary device for virtual device tempdbdev
00:00000:00030:2010/06/07 13:46:56.00 kernel  The new primary device is now d:\syb_data\tempdbdev.dat

其中status:16386 = 16384 + 2 这是一个普通的物理设备文件。

 

五、对master设备进行镜像的另外一种方法

对master设备镜像还有一种方法,就是直接利用命令参数。 windows下sqlsrvr.exe的参数中有个是: -r mirror_file          - master device's mirror device name

可以修改RUN_SEVERNAME文件来加入-r这个参数来镜像master设备。

如改为:

D:\sybase\ASE-15_0\bin\sqlsrvr.exe  -dD:\sybase\data\master.dat -sTEST -eD:\sybase\ASE-15_0\install\TEST.log -iD:\sybase\ini -MD:\sybase\ASE-15_0 -rd:\syb_data\master_mirr.dat

 

在windows下的ASE还需要修改注册表中的配置信息, 才能用系统工具中的服务正常启动数据。 不过你要是习惯每次都用RUN_SERVERNAME这个命令行来启动数据库的话, 也不用改注册表了。至于如何改注册表, 本篇暂时不介绍。

好了,关于ASE中的mirror就介绍这么多吧。

 

————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:mirror unmirror remirror 镜像  移动设备
————————————————————————————————-

在论坛中看到有人寻找从sybase数据 库中提取表结构的方法。用 dbartisan8.6.1这个第三方工具可以很轻松的实现,我自己也用pb编写过函数能够提取表结构和索引创建语法。
像sybase自带的sybase central也能从中导出ddl。我感觉从sybase central中导出语法时可能利用的就是ddlgen这个工具,原因我认为sybase central和ddlgen都基于java 编写。
先将整理的ddlgen说明以及使用方法贴在下面。

ddlgen

Description

A Java-based tool that generates definitions for server- and database-level objects in Adaptive Server. ddlgen supports Adaptive Server version 11.9.2 and later.

The command-line version of ddlgen is located in $SYBASE/ASEP/bin ( %SYBASE%\ASEP\bin in Windows ).

Syntax

ddlgen

-Ulogin

-Ppassword

-S[server | host_name : port_number ]

[-I interfaces_file ]

[-Tobject_type ]

[-Nobject_name ]

[-Ddbname ]

[-Xextended_object_type ]

[-Ooutput_file ]

[-Eerror_file ]

[-Lprogress_log_file ]

[-Jclient_charset ]

-F[ % | SGM | GRP | USR | R | D | UDD | U | V |
P | XP | I | RI | KC | TR | PC ]

Parameters

-U login

specifies a login name, and is case-sensitive.

-P password

specifies your password.

-S [server | host _ name : port _ number ]

specifies the name of the Adaptive Server. ddlgen looks this name up in the interfaces file or LDAP configuration file. If you specify:

·
-S [host _ name :port _ number ] –
ddlgen uses the host _ name and port _ number provided, and neither interfaces nor LDAP configuration files are read or parsed.

·
-S[server ] -I ddlgen parses the interfaces file specified at the user location for the server name (see the -I parameter description for more information).

·
-S[server ] – without specifying an interfaces file, ddlgen does the following:

a.
ddlgen first tries to read the LDAP configuration file from the standard location

b.
If the LDAP file does not exist, or exists but does not contain an Adaptive Server entry, then the interfaces file is parsed at its standard location for the server name

c.
If the LDAP file exists, then ddlgen uses it to search the server name. The interfaces file is not parsed, and the LDAP configuration file is parsed.

You must use the -S option because ddlgen does not connect to a default server.

-I

specifies the interfaces file name, and corresponds to $SYBASE/interfaces for UNIX , and %SYBASE%\ini\sql.ini for Windows. Use this optional parameter with -S .

-Tobject _ type

specifies the type of object you are creating. If you do not use -T , ddlgen generates DDL for the default database of login. The object types for -T are:

 

Object type  Description 
C  cache
D  default
DB  database
DBD  database device
DPD  dump device
EC  execution class
EG  engine group
EK  encrypted keys
GRP  group
I  index
KC  key constraints
L  login
LK  logical key
P  stored procedure
R  rule
RI  referential integrity
RO  role
RS  remote server
SGM  segment
TR  trigger
U  table
UDD  user-defined datatype
USR  user
V  view
WS  user-defined Web service
WSC  Web service consumer
XP  extended stored procedure

 

-Nobject _ name

specifies the fully qualified name of the object you are creating, such as -Ndb _ name .owner _ name .table _ name .object _ name . The -N option:

·
is required if you specify any object _ type other than DB (database) in the -T parameter.

·
accepts wildcards with the use of % .

·
generates DDL for all items of a specific object type on your server.

·
enforces strict order in which it parses the names in the -Ndb _ name .owner _ name .table _ name .object _ name format. If you only provide three arguments, ddlgen assumes they are owner _ name , table _ name , and object _ name , in that order. Alternatively, you can also use -Nowner _ name .table _ name -Ddb _ name . ddlgen does not impose this restriction if object _ name is an index (I ).

-Ddbname

specifies the name of the database for the object you specify in the -N option. The default is the user’s default database.

-Xextended _ object _ type

differentiates the following:


user tables (OU ) from proxy tables (OD ) when you specify a table as your object type (-TU )
temporary databases (OD ) from nontemporary databases (OU ) when you specify database as your object type (-TDB )
SQLJ procedures (OD ) from stored procedures (OU ) when you specify procedure as your object type (-TP ).

If object _ type (-T ) is U (table) and -X is not specified, ddlgen generates DDL for both user tables and proxy tables. To generate DDL only for:


user tables – use the OU extended object type with the -X option.
proxy tables – use the OD extended object type with the -X option.

ddlgen does not support schema generation for system tables.

 

-Ooutput _ file

specifies an output file for the generated DDL. If you do not specify -O , the DDL you create appears in a console window.

-Eerror _ file

specifies a log file for recording errors. If you do not specify -E , the generated errors appear in a console window.

-Lprogress _ log _ file

specifies a log file for recording the progress of ddlgen . If you do not specify -L , the progress is not recorded.

-Jclient _charset

specifies the character set to use on the client. -Jclient _charset requests that Adaptive Server convert to and from client _charset , the character set used on the client. A filter converts input between client _charset and the Adaptive Server character set.

Omitting -J sets the character set to a default for the platform. The default may not necessarily be the character set that the client is using.

HP platforms – You must use -Jiso_1 to specify the correct character set.

-F

filters out indexes, triggers, and constraints out of table and database definitions in the DDL of table- and database-level objects. The valid filters are:


For tables [ % | I | RI | KC | TR | PC ]


For databases [ % | SGM | GRP | USR | R | D | UDD | U | V | P | XP | I | RI | KC | TR]

The filter options are:

 

 

Filter option  Filters out: 
%  Everything, and retrieves the schema-only definition of a database or table.
SGM  Segments
GRP  Groups
USR  Users
R  Rules
D  Defaults
UDD  Uer-defined datatypes
U  User tables
V  Views
P  Stored procedures
PC  Partition condition
XP  Extended stored procedures
I  Indexes
RI  Referential integrity constraints
KC  Primary- and unique-key constraints
TR  Triggers

 

-v

displays the version and copyright message of ddlgen and returns to the operating system.

 

Examples

Example 1

Caches – Generates DDL for a cache called default data cache on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TC -N"default data cache"

To generate DDL for all caches:

ddlgen -Ulogin -Ppassword -Sserver :port -TC -N%

Example 2

Defaults – Generates DDL for a default called “phondflt” owned by jones in the pubs2 database on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TD -Njones.phonedflt -Dpubs2

Alternatively, because ddlgen allows you to use a fully qualified name in the -N flag, you can omit the -Ddbname and include the database name in the -N option:

ddlgen -Ulogin -Ppassword -Sserver :port -TD -Ndbname .owner .defaultname

To generate DDL for all defaults in a database owned by “owner”:

ddlgen -Ulogin -Ppassword -Sserver :port -TD -Nowner .% -Ddbname

Example 3

Databases – Generates DDL for a database called pubs2 on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TDB -Npubs2

If you do not specify a dbname , ddlgen generates DDL for the default database of login :

ddlgen -Ulogin -Ppassword -Sserver :port

If you do not use the -T parameter, ddlgen generates DDL for a default-type database:

ddlgen -Ulogin -Ppassword -Sserver :port -Ndbname

To generate DDL for all databases:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -N%

Example 4

Database device – Generates DDL for a database device called master running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TDBD -Nmaster

To generate DDL for all database devices:

ddlgen -Ulogin -Ppassword -Sserver :port -TDBD -N%

Example 5

Temporary databases – Generates DDL for all databases, including tempdb :

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -N%

To generate DDL for all temporary databases, use the OD extended database type:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -XOD -N%

Although you can use the OD extended type in Adaptive Server versions 12.5.0.3 and later, versions earlier than 12.5.0.3 issue warning messages. You can safely ignore this message; ddlgen continues processing the command.

To generate DDL for all databases except temporary databases, use the OU extended type:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -XOU -N%

The following generates DDL for a temporary database named tempdb1 :

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -Ntempdb1

The output includes the following:

·
A create temporary database statement


create temporary database tempdb1 on master = 4,asdas = 2
go


An sp_tempdb bind statement where the isql application is bound to tempdb1 :


sp_tempdb 'bind','ap', 'isql', 'DB', 'tempdb1'
go

 

DDL for objects such as views, stored procedures, and tables is not generated along with DDL for a temporary database because these objects are temporary, and are re-created when the server restarts.

When you use the -F parameter to filter a table while generating DDL for a database object, then indexes, referential integrity, key constraints and triggers automatically get filtered, as they are a subset of the table object.

Example 6

Dump device – generates DDL for a dump device called tapedump1 running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TDPD -Ntapedump1

To generate DDL for all dump devices:

ddlgen -Ulogin -Ppassword -Sserver :port -TDPD -N%

Example 7

Execution class – generates DDL for an execution class called EC2 running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TEC -NEC2

To generate DDL for all execution classes:

ddlgen -Ulogin -Ppassword -Sserver :port -TEC -N%

Example 8

Engine groups – generates DDL for an engine group called LASTONLINE running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TEG -NLASTONLINE

To generate DDL for all engine groups:

ddlgen -Ulogin -Ppassword -Sserver :port -TEG -N%

Example 9

Extended stored procedures – generates DDL for the xp_cmdshell extended stored procedure in the pubs2 database, owned by Jones and running on a machine named HARBOR using port 1955, by using the fully qualified dbname .owner .extendedstoredprocedure format with the -N option:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TXP -Npubs2.jones.xp_cmdshell

Alternatively, you can use the -D option instead of using the fully qualified name:

ddlgen -Ulogin -Ppassword -Sserver :port -TXP

    -Nowner .extendedstoredprocedure -Ddbname

To generate DDL for all extended stored procedures:

ddlgen -Ulogin -Ppassword -Sserver :port -TXP -Ndbname .owner .%

Example 10

Filters – Generates DDL for the authors table in the pubs2 database, filtering for all indexes (I ), and referential integrity constraints (RI ), primary and unique key constraints (KC ), triggers (TR ), and partition condition (PC ) from the DDL of a table:

ddlgen -Uroy -Proy123 -TU -Nauthors -Dpubs2 -F%

Alternatively, you can specify each of the filters individually:

ddlgen -Ulogin -Ppassword -TU -Ndbname .owner .table

    -FI,RI,KC,TR

The following generates the definition of table _ name while filtering out foreign keys and primary-unique keys:

ddlgen -Ulogin -Ppassword -TU -Ntable_name -Ddbname

    -FRI,KC

Both of these generate foreign keys for a specified user in the entire database:

ddlgen -Ulogin -Ppassword -TRI -N%.%.% -Ddbname

Or:

ddlgen -Ulogin -Ppassword -TRI -Ndbname %.%.%

Both of these generate DDL for the primary and unique keys of all the tables in a database that begin with “PK”:

ddlgen -Ulogin -Ppassword -TKC -Ndbname .%.%.PK%

Or:

ddlgen -Ulogin -Ppassword -TKC -N%.%.PK% -Ddbname

The following generates schema-only definition of a database:

ddlgen -Ulogin -Ppassword -Sserver :port -TF -Ndbname -F%

Alternatively, you can specify each of the filters individually:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -Ndbname

    -FSGM,GRP,USR,R,D,UDD,V,P,XP,I,RI,KC,TR

The following generates the database DDL skipping the compiled object:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -Ndbname -FTR,D,XP,V,R

The following generates database definition without a table definition:

ddlgen -Ulogin -Ppassword -Sserver :port -TDB -Ndbname

    -FU

Example 11

Groups – Generates DDL for a group called “public” in the pubs2 database, running on a machine named HARBOR using port 1955, by using the fully qualified dbname .groupname format in the -N option:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TGRP -Npubs2.public

Alternatively, you can use the -D option to specify the dbname :

ddlgen -Ulogin -Ppassword -Sserver :port -TGRP -Ngroupname -Ddbname

To generate DDL for all groups:

ddlgen -Ulogin -Ppassword -Sserver :port -TGRP -Ndbname .%

Example 12

Indexes – Generates DDL for an index called au_lname for the table authors owned by dbo, in the pubs2 database:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TI -Ndbo.authors.au_lname -Dpubs2

Alternatively, because ddlgen allows you to use a fully qualified name in the -N flag, you can omit the -Ddbname and include the database name in the -N option:

ddlgen -Ulogin -Ppassword -Sserver :port

    -TI -Ndbname .owner .tablename .indexname

If you use a fully qualified name, you may omit the -D option.

To generate DDL for all indexes for a single table:

ddlgen -Ulogin -Ppassword -Sserver :port -TI

    -Ndbname .owner .tablename .%

To generate DDL for all indexes of all tables in a database:

ddlgen -Ulogin -Ppassword -Sserver :port -TI

    -Ndbname .%.%.%

For example, this generates DDL for all indexes for all tables in the pubs2 database:

ddlgen -Usa -P -SHARBOR:1955 -TI -Npubs2.%.%.%

 

ddlgen -Usa -P -SHARBOR:1955 -TI -Npubs2.%.%.%

Example 13

Keys – Both of these generate DDL for the primary and unique keys of all the tables in a database that begin with “PK”:

ddlgen -Usa -P -TKC -Ndbname .%.%.PK%

Or:

ddlgen -Usa -P -TKC -N%.%.PK% -Ddbname

Example 14

Logical keys LK generates logical keys of table defined by sp_primarykey , sp_commonkey , sp_foreignkey statements. Since these keys do not have a name, the name of the object in this case would be the name of the table. This example generate a DDL for logical keys of table authors in database pubs2 running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TLK -Npubs2.dbo.authors

To generate DDL for all logical keys in database pub2 use:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TLK -Npubs2.%.%

To filter out logical keys definition from DDL of table authors use LK in -F argument, use:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TLK -Npubs2.dbo.authors -FLK

Example 15

Logins – Generates DDL for all logins on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TL -N%

The password in the DDL generated for all logins is “password”.

Alternatively, you can specify an individual login by using -Nusername instead of -N% :

ddlgen -Ulogin -Ppassword -Sserver :port -TL -Nusername

Example 16

Remote Servers – Generates DDL for a remote server called ORANGE on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TRS -NORANGE

To generate DDL for all remote servers:

ddlgen -Ulogin -Ppassword -Sserver :port -TRS -N%

Example 17

Roles – Generates DDL for the sa _ role on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TRO -Nsa_role

To generate DDL for all roles:

ddlgen -Ulogin -Ppassword -Sserver :port -TRO -N%

The password in the DDL generated for all roles is “password”.

Example 18

Rules – Generates DDL for all rules associated with authors on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TR -Nauthors.dbo.%

The % symbol tells ddlgen to create DDLs for all rules that exist on the server.

You can also give the fully qualified name of the rule:

ddlgen -Ulogin -Ppassword -Sserver :port -TR -Ndbname .owner .rulename

Alternatively, you can also use the -D parameter:

ddlgen -Ulogin -Ppassword -Sserver :port -TR -Nowner .rulename -Ddbname

Example 19

Segments – Generates DDL using the fully qualified dbname .segmentname format in the -N option for a segment called logsegment for the pubs2 database, on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TSGM -Npubs2.logsegment

Alternatively, you can use specify the dbname using the -D option:

ddlgen -Ulogin -Ppassword -Sserver :port -TSGM -Nsegmentname -Ddbname

To generate DDL for all segments:

ddlgen -Ulogin -Ppassword -Sserver :port -TSGM -Ndbname .%

Example 20

SQLJ functions – Generates DDL for a SQLJ function named region _ of owned by dbo in database master :

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TF –Nmaster.dbo.region_of

Alternatively you can also use the -D parameter:

ddlgen -Ulogin -Ppassword -Sserver :port -TF –Ndbo.region_of –Dmaster

To generate DDL for all SQLJ functions in a database, use object type F :

ddlgen -Ulogin -Ppassword -Sserver :port -TF –Ndbname .owner .%

Example 21

SQLJ procedures – are a kind of stored procedure. You generate DDL for SQL procedures along with DDL for stored procedures. The following generates DDL for all stored procedures—including SQLJ procedures—owned by dbo in the master database:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TP –Nmaster.dbo.%

To generate DDL for all SQLJ procedures that are only owned by dbo in the master database, use the following, where the extended type OD refers to SQLJ procedures:

ddlgen -Ulogin -Ppassword -Sserver :port -TP –Nmaster.dbo.% -XOD

To generate DDL for all procedures except SQLJ procedures owned by dbo in the master database, use the following, where the extended type OU refers to all stored procedures except SQLJ procedures:

ddlgen -Ulogin -Ppassword -Sserver :port -TP –Nmaster.dbo.% -XOU

Example 22

Stored procedures – Generates DDL for the sp_monitor stored procedure for the pubs2 database on a machine named HARBOR using port 1955, using the fully qualified dbname .owner .procedure _ name format for the -N option:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TP -Npubs2.dbo.sp_monitor

Alternatively, you can use specify the dbname using the -D option:

ddlgen -Ulogin -Ppassword -Sserver :port -TP -Nowner .procedurename -Ddbname

To generate DDL for all stored procedures:

ddlgen -Ulogin -Ppassword -Sserver :port -TP -Ndbname .owner .%

Example 23

Tables – Generates DDL for all user tables in the pubs2 database owned by “dbo” and running on a machine named HARBOR using port 1955:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TU -Ndbo.% -Dpubs2

You can also use the -N parameter to give the fully qualified name of the table:

ddlgen -Ulogin -Ppassword -Sserver :port -TU

    -Ndbname .tableowner .tablename

Alternatively, you can also use the -D parameter to specify the database:

ddlgen -Ulogin -Ppassword -Sserver :port -TU

    -Ntableowner .tablename -Ddbname

To generate DDL for all proxy tables, which uses the value OD , use -XOD instead, where X is the extended type, and OD denotes proxy tables:

ddlgen -Ulogin -Ppassword -Sserver :port -TU

    -Ntableowner .% -Ddbname -XOD

To generate DDL for all user tables, which uses the value OU , use -XOU instead, where X is the extended type, and OU denotes user tables:

ddlgen -Ulogin -Ppassword -Sserver :port -TU

    -Ntableowner .% -Ddbname -XOU

To generate DDL for all tables, including user tables and proxy tables:

ddlgen -Ulogin -Ppassword -Sserver :port -TU -Ndbname .tableowner .%

Example 24

Triggers – Generates DDL for the trigger checksum for the pubs2 database on a machine named HARBOR using port 1955, using the fully qualified dbname .owner .trigger _ name format for the -N option:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TTR -Npubs2.dbo.checksum

Alternatively, you can use specify the database _ name using the -D option:

ddlgen -Ulogin -Ppassword -Sserver :port -TTR

    -Nowner .triggername -Ddbname

To generate DDL for all triggers:

ddlgen -Ulogin -Ppassword -Sserver :port -TTR -Ndbname .owner .%

 

Example 25

User-defined datatypes – Generates DDL for the user-defined datatype “Identype” for the pubs2 database on a machine named HARBOR using port 1955 using the fully qualified dbname .userdefined _ datatype format for the -N option:

ddlgen -Uroy -Proy123 -SHARBOR:1955 -TUDD -Npubs2.Identype

Alternatively, you can use the -D option to specify the dbname :

ddlgen -Ulogin -Ppassword -Sserver :port -TUDD

    -Nuserdefined_datatype -Ddbname

To generate DDL for all user-defined datatypes:

ddlgen -Ulogin -Ppassword -Sserver :port -TUDD -Nbname .%

For example, this generates DDL for all indexes for all tables in the pubs2 database Usage


ddlgen does not identify existing sequences within views, stored procedures or triggers. For this reason, when generating DDL for a database, you must first run ddlgen on those views, stored procedures and triggers that are independent, before running ddlgen on those with dependencies. For example, if view B depends on view A, you must first run ddlgen on view A, before running it on view B.


The default information for ddlgen is:

 

 

Option  Parameter  Required  Default 
-U  username  Yes None
-P  password  Yes None
-S  host _ name :port _ number  Yes None
-T  object _ type  No Database
       
  See the -T parameter description for a list of valid object types    
-N  object _ name  Yes, if object _ type for -T is not DB (database) Default database name of username , if -Tobject _ type is db or if -T is not specified
-D  database _ name  No Default database of username 
-X  extended _ object _ type  No; use only when the object _ type for -T is U (user table), P (procedure), DB (database) None
       
  Options are:    
       
  o    
  OU – for user tables, user databases (excluding temporary databases), and stored procedures (excluding SQLJ procedures).    
       
  o    
  OD – for proxy tables, temporary databases, and SQLJ procedures.    
-O  output _ file _ name  No Standard out
-E  error _ file _ name  No Standard out
-L  log _ file _ name  No None
-V  version _ number of ddlgen  No None

 

 

At the command line, invoke ddlgen using the ddlgen shell script file ( ddlgen.bat for Windows), included in your Adaptive Server installation. The main class in DDLGen.jar is com.sybase.ddlgen.DDLGenerator .


To start ddlgen in the Sybase Central plug-in for Adaptive Server:

a.Right-click on the object for which you want to generate DDL.

b.Select Generate DDL .


In the output DDL of create table , bind statements are generated as independent DLL instead of dependent DLL.

 

Filters

If you use an invalid filter parameter, ddlgen generates a warning, ignores that parameter, and continues with the rest of the valid parameters you specify.

If you specify % along with other filter parameters, ddlgen ignores all other filterable parameters, and only shows schema-only definitions. ddlgen then continues to evaluate the dependencies within the subset of the applied as the filterable parameters for the database.

Permissions

Since ddlgen needs to obtain data from system catalogs, users must either be logged in as “dbo” or have select permissions on syscatalogs .

————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:ddlgen 表结构
————————————————————————————————-