sybase中生成所有建表语句的过程

sybase中生成所有建表语句的过程

ID:9945379

大小:121.50 KB

页数:0页

时间:2018-05-16

sybase中生成所有建表语句的过程_第页
预览图正在加载中,预计需要20秒,请耐心等待
资源描述:

《sybase中生成所有建表语句的过程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、SYBASE中生成所有建表语句的过程Sql代码: 1.if exists(select 1 from sysobjects where name = 'sp_gent' and type = 'P')  2.  drop procedure sp_gent  3.go  4.  5.create procedure sp_gent    6.@tblname varchar(30) = null,    7.@prechar varchar(4) = null,   --$:no print    8.@tabl

2、e_dll varchar(16384) = null out,    9.@dbname varchar(32) = null,    10.@droptg char(1) = '1',    11.@prxytx varchar(255) = null,    12.@replace varchar(20) = null,    13.@tabtype varchar(1) = 'A', --A:所有表;P:代理表;U:用户表    14.@indextg varchar(3) = 'TPI',  --T:纯

3、表;P:主键;I:纯索引;J:除主键外的纯索引(和TP使用与I相同,和I同时使用I失效)    15.@table_seg varchar(32) = null,    16.@index_seg varchar(32) = null    17.as    18.begin    19.     set nocount on     20.    21.    if @tblname is null begin    22.        declare @c_tblname varchar(30)    23

4、.        declare cur_1 cursor for    24.        select name from sysobjects where type = 'U' order by name    25.        open cur_1    26.        fetch cur_1 into @c_tblname    27.        while @@sqlstatus = 0 begin    28.            exec sp_gent     29.     

5、           @tblname = @c_tblname,    30.                @prechar = @prechar,    31.                @dbname  = @dbname ,    32.                @droptg  = @droptg ,    33.                @prxytx  =  @prxytx ,    34.                @replace = @replace,    35.   

6、             @tabtype = @tabtype, --A:所有表;P:代理表;U:用户表    36.                @indextg = @indextg, --A:表和索引;T:纯表;I:纯索引    37.                @table_seg = @table_seg,    1.                @index_seg = @index_seg    2.            fetch cur_1 into @c_tblname    3.

7、        end    4.        close cur_1    5.        deallocate cursor cur_1    6.        return    7.    end    8.    9.    declare @obj_id int    10.    declare @sysstat2 int    11.    declare @username varchar(30)    12.    13.     select @obj_id = id, @sysst

8、at2 = sysstat2 ,@username  = user_name(uid)    14.        from sysobjects where name = @tblname and type = 'U'    15.    if @@rowcount <> 1    16.    begin    17.        print 'table %1! 

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。