在Sybase Central中,当我右键单击存储过程并选择"生成DDL"时,我会看到存储过程的定义,但也会看到例如授予。
如何使用isql在命令行中执行此操作?
最佳/推荐的方法是ddlgen实用程序;这将为proc的文本、sp_procxmode
设置和权限生成DDL。ddlgen
是逆向工程Sybase ASE
DDL的"首选"工具。
样品运行:
$ ddlgen -SASE400 -Ppassword -Usa -TP -Nsybsystemprocs.dbo.sp_helptext
-----------------------------------------------------------------------------
-- DDL for Stored Procedure 'sybsystemprocs.dbo.sp_helptext'
-----------------------------------------------------------------------------
print '<<<<< CREATING Stored Procedure - "sybsystemprocs.dbo.sp_helptext" >>>>>'
go
use sybsystemprocs
go
IF EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'sp_helptext' AND u.name = 'dbo' AND o.type = 'P')
BEGIN
setuser 'dbo'
drop procedure sp_helptext
END
go
IF (@@error != 0)
BEGIN
PRINT 'Error dropping Stored Procedure sybsystemprocs.dbo.sp_helptext'
SELECT syb_quit()
END
go
setuser 'dbo'
go
/*
** sp_helptext
**
... snip ...
*/
create or replace procedure sp_helptext(
@objname varchar(325) = NULL
, @grouping_num int = NULL
, @numlines int = NULL
, @printopts varchar(256) = NULL
, @trace int = 0
) as
... snip ...
return (0)
end
go
Grant Execute on dbo.sp_helptext to public Granted by dbo
go
sp_procxmode 'sp_helptext', anymode
go
setuser
go
其他选项包括:
- 用于proc文本的defncopy实用程序
- sp_helptext获取进程的文本
- sp_helprotect获取权限(不过您需要分析输出以生成必要的
grant/revoke
命令(