经过我多次验证,终于找到了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