设为首页 加入收藏

TOP

Sybase查询表结构的方法(类似于Oracle的Desc)(一)
2015-07-24 11:22:52 来源: 作者: 【 】 浏览:17
Tags:Sybase 查询表 结构 方法 类似 Oracle Desc

经过我多次验证,终于找到了Sybase中查询数据库结构的方法了。
 

在此之前,我就很不解这Sybase数据库怎么就没有和Oracle、MySql一样简便的方法呢

desc 表名;

在网上查询之后,得到一个结果。

sp_help 表名;

但是这样查出了多个结果。虽然里面有我们想要的结果,但我们只取一个,而且还在中间。

怎么办呢?看存储过程源码,把我们想要的结果截取出来吧。

sp_help存储过程在sybsystemprocs库中,

源码:

/* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
/*	4.8	1.1	06/14/90	sproc/src/help */
/*
** Messages for "sp_help"               17570
**
** 17460, "Object must be in the current database."
** 17461, "Object does not exist in this database."
** 17570, "Operating System File"
** 17571, "---------------------"
** 17573, "Object is Remote/External"
** 17574, "-------------------------"
** 17575, "Object existed prior to Omni"
** 17576, "Lock scheme is Allpages" 
** 17577, "Lock scheme is Datapages"
** 17578, "Lock scheme is Datarows" 
** 17579, "Lock scheme Unknown or Corrupted" 
** 17581, "Trigger is disabled."
** 17582, "Trigger is enabled."
** 18571, "The attribute '%1!' is not applicable to tables with allpages lock scheme."
** 17589, "computed column"
** 19456, "Object is a computed column in table '%1!'."
** 19457, "Object is a function-based index key in table '%1!'."
*/

/*
** IMPORTANT NOTE:
** This stored procedure uses the built-in function object_id() in the
** where clause of a select query. If you intend to change this query
** or use the object_id() or db_id() builtin in this procedure, please read the
** READ.ME file in the $DBMS/generic/sproc directory to ensure that the rules
** pertaining to object-id's and db-id's outlined there, are followed.
*/

CREATE PROCEDURE dbo.sp_help
@objname varchar(767) = NULL			/* object name we're after */
as

declare @typeid int				/* type of object in systypes */
declare @basetypeid int				/* base type in systypes */
declare @lenfactor int				/* length factor */
declare @sysstat smallint			/* the type of the object */
declare @OS_file varchar(255)			/* physical file for ext tab */
declare @msg varchar(1024)
declare @sptlang	int
declare @len1 int, @len2 int, @len3 int, @len4 int, @len5 int, @len6 int, @sysstat2 int,
	@valstat2	int
declare @sqltext varchar(1024)			/* SQL to execute using execute
						** immediate. */
declare @and_access	int /* cache bits in OBJECT.sysstat2 */
declare @or_access	int /* cache bits in OBJECT.sysstat2 */

declare @sqlj_proc      int /* indicates a sqlj proc */
declare @opt_ind_status	int /* status of optimistic index lock */
declare @opt_ind_value	int /* user input value of optimistic index lock */
declare @opt_ind_lock	int /* Server constant for optimistic index lock */
declare @opt_text_dealloc int
declare @opt_text_value int
declare @opt_ind2_ascinserts int /* Server constant for ascinserts */
declare @encrypted_col	int /* indicates encrypted col */	
      , @decrypt_def    int /* indicates decrypt default col */
      , @inrowlob	int /* status2: whether column is LOB 'in row' */
      , @thiskey        varchar(30)		/* index key column of 
						** virtually hashed table. 
						*/ 
declare @notruncate	int /* indicates no truncation for varbinary columns */
declare @indid          int			
declare @new_char_value varchar(255)		/* hash factors of virtually 
						** hashed table. 
						*/
declare @num_keys       int			/* #index keys columns. */
declare @key_count      int,
	@msgnum		int,
	@valstat3	int,
	@sysstat3	int,
	@sep		varchar(2),
	@sysopt_name	varchar(100)
declare @tab_lob_cmplvl	tinyint			/* LOB compression level for table */
declare @objtype	char(2)			/* object type in sysobje
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇先打11.2.0.3.8这个PSU,后建库 下一篇oracle巡检脚本-部分

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)
·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)