Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From a Sybase Database, how I can get table description ( field names and types)?

I have access to command line isql and I like to get Meta-Data of all the tables of a given database, possibly in a formatted file. How I can achieve that?

Thanks.

like image 763
aartist Avatar asked Sep 15 '09 22:09

aartist


People also ask

How can I get table column names and data types in Sybase?

You can use built-in procedure sp_columns. It will return all the table metadata including column name, data type, column length etc.

How do I Desc a table in Sybase?

Use DESCRIBE TABLE to list all the columns in the specified table or view. The DESCRIBE TABLE statement returns one row per table column, containing: Column The name of the column. Type The type of data in the column.

How do you get DDL of a table in Sybase?

In the Administration Console, expand IQ Servers > Schema Objects > Tables. Select Tables, Global Temporary Tables, or Proxy Tables. Select one or more tables from the right pane and either: Click the arrow to the right of the name and select Generate DDL, or.

What is description in database table?

So desc or describe command shows the structure of table which include name of the column, data-type of column and the nullability which means, that column can contain null values or not.


1 Answers

Check sysobjects and syscolumns tables.

Here is a diagram of Sybase system tables.

List of all user tables:

SELECT * FROM sysobjects WHERE type = 'U' 

You can change 'U' to other objects:

  • C – computed column
  • D – default
  • F – SQLJ function
  • L – log
  • N – partition condition
  • P – Transact-SQL or SQLJ procedure
  • PR – prepare objects (created by Dynamic SQL)
  • R – rule
  • RI – referential constraint
  • S – system table
  • TR – trigger
  • U – user table
  • V – view
  • XP – extended stored procedure

List of columns in a table:

SELECT sc.*  FROM syscolumns sc INNER JOIN sysobjects so ON sc.id = so.id WHERE so.name = 'my_table_name' 
like image 170
Lukasz Lysik Avatar answered Sep 22 '22 17:09

Lukasz Lysik