Solved

Query in ISQL to export schema

Posted on 1999-01-13
4
1,431 Views
Last Modified: 2013-11-19
Looking for the equivalent sybase select statement for the oracle statement below: This statement uses metadata to export the Table name, column name, data type & length, description/definition and all other attributes

SELECT OWNER,TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID
FROM ALL_TAB_COLUMNS
where OWNER = 'ME'
0
Comment
Question by:rickwinterkorn
  • 2
4 Comments
 

Expert Comment

by:tgensler
ID: 1098546
This code was taken from simon walkers SQL workshop site on the internet.

/***************************************************************************

 sp__cols

 list columns in table without having to wade through sp_help's excess info

 Copyright 1992-1995 The SQL Workshop Ltd.      siwalker@cix.compulink.co.uk

 Who      When      Why
 ---------------------------------------------------------------------------
 npike      ???      created
 simon      5jul92      tidied up, add error handling
 simon      31jan96      update for release

****************************************************************************/

if exists(select * from master..sysdatabases where name = "sybsystemprocs")
      use sybsystemprocs
else
      use master
go

if exists(select * from sysobjects where name = "sp__cols" and type = "P")
      drop procedure sp__cols
go

create procedure sp__cols

      @objname      char(30)
as

/*
** This procedure copyright 1995 The SQL Workshop Ltd.
** The code is freely distributable, but please leave this comment intact.
** simon walker
** siwalker@cix.compulink.co.uk
*/

declare      @objid      int

select      @objid = id
from      sysobjects
where      name = @objname
and      type in ("U", "V", "S")

if @objid is NULL
begin
      print "Object is not a table or view in the current database."      
      return (1)
end

select      'column name'      = c.name,
      type            = t.name,
      length            = c.length,
      prec            = c.prec,
      scale            = c.scale,
      nulls            = convert(bit, (c.status & 8)),
      'default name'      = object_name(c.cdefault),
      'rule name'      = object_name(c.domain),
      ident            = convert(bit, (c.status & 0x80))
from      syscolumns c,
      systypes t
where      c.id = @objid
and      c.usertype *= t.usertype

return (0)

go

grant execute on sp__cols to public
go


0
 

Author Comment

by:rickwinterkorn
ID: 1098547
Thanks for the effort tgensler, however it didn't work.

0
 

Author Comment

by:rickwinterkorn
ID: 1098548
Answer - I wrote the following code and it works very well,
thought I'd share it.

select T.creator, C.tname, C.colno, C.cname, C.coltype,C.length,C.in_primary_key, C.nulls, C.remarks
from SYSCOLUMNS C, SYSTABLE T
where Trim(C.creator) = 'DBA'
and Trim(C.tname) = Trim(T.table_name);

output to c:\DirName\FileName.txt
format ascii;
0
 
LVL 2

Accepted Solution

by:
ajith_29 earned 50 total points
ID: 1098549
Hi rick,
This script will do the work for you

select Table_name = o.name ,
       Column_name= c.name,
          Data_type   = t.name,
             Length = c.length,
             Prec = c.prec,
             Scale = c.scale,
             Nulls = convert(bit, (c.status & 8))
            from syscolumns c, systypes t,sysobjects o
            where c.id <>0 and c.id = o.id and o.type = 'U'
                  and c.usertype *= t.usertype



Regards
Ajith
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
illegal characters in XML using UTF-8 8 39
sybase optimizer statistics 2 44
ColdFusion Rereplace 3 78
Limiting/Restricting CPU/Network/Memory usage of MS Access ODBC Query 11 45
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question