15

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

rampion
  • 82,104
  • 41
  • 185
  • 301
  • possible duplicate of [From a Sybase Database, how I can get table description ( field names and types)?](http://stackoverflow.com/questions/1429898/from-a-sybase-database-how-i-can-get-table-description-field-names-and-types) – null Dec 12 '13 at 03:41

4 Answers4

9

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

brianegge
  • 26,898
  • 12
  • 70
  • 97
6

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
  • 82,104
  • 41
  • 185
  • 301
  • 1
    This seems to be specific for a certain Sybase version as it doesn't work on ASE. Are you using IQ? – VolkA Apr 22 '13 at 09:10
5

Newer version use sysobjects:

SELECT name FROM sysobjects WHERE type = 'U';

Regards,

user1126070
  • 4,999
  • 1
  • 14
  • 14
2

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
  • 753
  • 4
  • 8