Solved

Query in ISQL to export schema

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

920 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

12 Experts available now in Live!

Get 1:1 Help Now