`

Sybase ASA (11及以后版本)中获取表定义的SQL语句及SP

 
阅读更多
ASA功能本来非常强大, 可是不理解为什么没有一个功能强大的描述一个表定义的简单的SQL语句。
像Oracle中:desc <table_name>
MySQL中:show create table <table_name>
都非常简单明了。

ASE里头,至少有个命令行:DDLGEN, 在$SYBASE/ASEP/bin 目录里头可以用。

可是到了ASA当中,用起来相当不顺利,至少很难一下子记住。

它要使用到 sa_get_table_definition存储过程,这还不够,不能直接显示结果,必须结合过程:sa_split_list一起才能达到效果。

请看下例:

select row_value from sa_split_list( sa_get_table_definition('DBA', 'djc_pc'), char(10));


查询一个结果集的各列属性,可以用:
select * from sa_describe_query('select * from djc_pc')
结果如下:

1 pc_cid 27 decimal decimal(20,0) 20 0 20 null null djc_pc 731 1 DBA djc_pc pc_cid 0 0 null null
2 pc_partition 9 varchar varchar(255) 255 0 255 null null djc_pc 731 2 DBA djc_pc pc_partition 0 0 null null
3 pc_cycle 2 int int 4 0 4 null null djc_pc 731 3 DBA djc_pc pc_cycle 1 0 null null
4 pc_owner 9 varchar varchar(255) 255 0 255 null null djc_pc 731 4 DBA djc_pc pc_owner 1 0 null null
5 pc_timeout 27 decimal decimal(20,0) 20 0 20 null null djc_pc 731 5 DBA djc_pc pc_timeout 1 0 null null




<script type="text/javascript"><!-- google_ad_client = "ca-pub-7104628658411459"; /* wide1 */ google_ad_slot = "8564482570"; google_ad_width = 728; google_ad_height = 90; //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics