virtualmic
virtualmic

Reputation: 3213

Table Details in SQL Anywhere?

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)?

Upvotes: 15

Views: 30869

Answers (11)

CredoV
CredoV

Reputation: 11

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

Upvotes: 0

Ayaskanta Mishra
Ayaskanta Mishra

Reputation: 1

select * from user_tables;

desc tablename;

Upvotes: -1

user4161594
user4161594

Reputation: 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;

Upvotes: -1

Steve Weet
Steve Weet

Reputation: 28392

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

Upvotes: 14

MWik
MWik

Reputation: 103

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)

Upvotes: 1

idir.dah
idir.dah

Reputation: 1

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'

Upvotes: 0

Zilog
Zilog

Reputation: 476

System proc, sa_describe_query is quite useful

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

Upvotes: 0

Dansk
Dansk

Reputation: 11

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.

Upvotes: 1

Vincent Buck
Vincent Buck

Reputation: 17132

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

Upvotes: 4

Zote
Zote

Reputation: 5379

select * from systable  // lists all tables
select * from syscolumn // lists all tables columns

Upvotes: 9

Breck Carter
Breck Carter

Reputation: 351

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).

Upvotes: 1

Related Questions