tags:

views:

436

answers:

3

How can I get sqsh to tell me which tables are available?

A: 

After some help from this site and some trial and error:

 select table_name from systable
 go

Painfully enough, sp_help doesn't exist in my version.

rampion
A: 

I am not familiar with systables. What flavor of Sybase are you running? ASA perhaps?

Please find appended a sqsh function (which you can put in your .sqshrc) which demonstrates some querying of the ASE (Adaptive Server Enterprise) catalog tables and the use of the Ed Barlow system stored procedure library http://www.edbarlow.com/gem/procs_only/index.htm to figure out what objects are in a database.

# Shorthand for sp__helptext or sp__revtable
\func -x ?
  IF EXISTS (SELECT * FROM sysobjects WHERE name = \\'${1}\\')
       BEGIN
       DECLARE @type VARCHAR(3)
       SELECT @type = type FROM sysobjects WHERE name = \\'${1}\\'
       IF @type IN (\\'U\\')
          exec sp__revtable ${1}
       ELSE
          exec sp__helptext ${1}
        END
   ELSE
       -- default to sp__ls (which can list partial matches) if an exact match wasn't found in sysobjects
       exec sp__ls ${1}
   go
\done

Paul Harrington
A: 

Does sp_tables work for you? Are you trying to get tab completion when creating a query?

brianegge