Solved

Query in ISQL to export schema

Posted on 1999-01-13
4
1,416 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now