15

I just downloaded the developer edition of SQL Anywhere. How can I get a list of tables in the database I'm connected to?. Also for a particular table, how do I get the meta-data for that table (column names, types, etc)?

George Stocker
  • 57,289
  • 29
  • 176
  • 237
virtualmic
  • 3,173
  • 6
  • 26
  • 34
  • I got answer to part of my question regarding table details here: http://stackoverflow.com/questions/100504/what-is-the-sql-command-to-return-the-field-names-of-a-table But still I don't know how to find the list of tables. I have got an idea though, let me try :) – virtualmic Feb 25 '09 at 09:54

11 Answers11

14

I have not used SQL-Anywhere for many years however the following statement should work

select c.column_name
from systabcol c 
   key join systab t on t.table_id=c.table_id 
   where t.table_name='tablename'

This was cribbed directly from an earlier question

Community
  • 1
  • 1
Steve Weet
  • 28,126
  • 11
  • 70
  • 86
9
select * from systable  // lists all tables
select * from syscolumn // lists all tables columns
Zote
  • 5,343
  • 5
  • 41
  • 43
4

For a particular table:

describe TableName

will return the table's columns, with an indication of the column's type, whether it's nullable and a primary key

Vincent Buck
  • 16,462
  • 2
  • 21
  • 21
1

Use this view: http://dcx.sybase.com/1001/en/dbrfen10/rf-syvcol.html

Try

select * from sys.syscolumns

or just tables which you created:

select * from sys.syscolumns where creator=(select current user)
MWik
  • 103
  • 5
1
SELECT b.name + '.' + a.name
  FROM sysobjects a, sysusers b
 WHERE a.type IN ('U', 'S')
   AND a.uid = b.uid
 ORDER BY b.name, a.name

This will yield a list of tables and users that have access to them.

CoolBeans
  • 20,654
  • 10
  • 86
  • 101
Dansk
  • 11
  • 1
1

Assuming Windows: start - All Programs - SQL Anywhere 11 - Sybase Central

Then Connections - Connect with SQL Anywhere 11...

Select "ODBC Data Source name" and pick "SQL Anywhere 11 Demo"

Press OK to see a tree view of the various objects in the database (tables etcetera).

Breck Carter
  • 351
  • 2
  • 5
  • 18
0

To get the list of all tables used in the database :

select * from systable //without 's'

To get the list of all columns :

select * from syscolumn //without 's'
idir.dah
  • 1
  • 1
0

select t.table_name, c.column_name, c.base_type_str, c.nulls from systabcol c key join systab t on t.table_id = c.table_id

http://dcx.sap.com/1200/en/dbreference_en12/syscolumn345.html

CredoV
  • 1
  • 1
0

System proc, sa_describe_query is quite useful

SELECT * FROM sa_describe_query('select * from TableName')

Zilog
  • 468
  • 3
  • 7
-1

To select one table details

select * from Table_Name;

To select two different table and Map with id

select * from Table_1 t1,Table2 t2 where t2.id=ti.id;
-1

select * from user_tables;

desc tablename;