Unix Technical Forum

data model

This is a discussion on data model within the Informix forums, part of the Database Server Software category; --> How would I use the system tables to generate an excel spreadsheet for each database in an informix instance? ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 11:23 AM
Rob
 
Posts: n/a
Default data model

How would I use the system tables to generate an excel spreadsheet for each
database in an informix instance?
I need the table name, number of rows, Raw size and lock mode

Thank you in advance.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 11:23 AM
Obnoxio The Clown
 
Posts: n/a
Default Re: data model


Rob said:
>
> How would I use the system tables to generate an excel spreadsheet for
> each
> database in an informix instance?
> I need the table name, number of rows, Raw size and lock mode


Set up an ODBC connection. Use the query tool to generate the select
statement. Execute.

--
Bye now,
Obnoxio

"C'est pas parce qu'on n'a rien à dire qu'il faut fermer sa gueule"
- Coluche

did i mention i like nulls? heck, i even go so far as to say that all
columns in a table except the primary key could/should be nullable. this
has certain advantages, for example, if you need to insert a child record
and you don't have a parent row for it, just do an insert into the parent
table with the primary key value (everything else null), and voila,
relational integrity is preserved. but this is, admittedly, a bit
controversial among modellers.

--r937, dbforums.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 11:23 AM
scottishpoet
 
Posts: n/a
Default Re: data model

IBM Informix online manuals are pretty good! Check out :

http://publib.boulder.ibm.com/infoce...htm?resultof=%

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2008, 11:23 AM
vomaringo@yahoo.com
 
Posts: n/a
Default Re: data model

with perl and 2 modules

use DBI;
use Spreadsheet::WriteExcel;

my $db="test";
my $dbh = DBI->connect("DBI:Informix:".$db);
my $sth = $dbh->prepare("SELECT tabname, nrows,rowsize FROM systables
WHERE tabid>99") or die;
$sth->execute();
my @cols = ( \$tabname, \$nrows, \$rowsize );
$sth->bind_columns(undef, @cols);

my $wk = Spreadsheet::WriteExcel->new($db.".xls");
my $ws = $wk->add_worksheet("database ".$db);
my $format = $wk->add_format();
$format->set_align('left');
my $row=0;
while ( $sth->fetch() ) {
print $tabname, $nrows, $rowsize,"\n";
$ws->write($row,0, $tabname);
$ws->write($row,1, $nrows);
$ws->write($row,2, $rowsize);
$row++;
}

regards,

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-20-2008, 11:24 AM
scottishpoet
 
Posts: n/a
Default Re: data model

in dbaccess :

unload to "<dbname>.xls"
select * from systables


then open the file excel , remember to change the delimiter in excel to
"|"

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-20-2008, 11:24 AM
Doug Lawry
 
Posts: n/a
Default Re: data model

"Rob" <nospam@blueyonder.co.uk> wrote in message
news:drncdd$6u2$1$8300dec7@news.demon.co.uk...
> How would I use the system tables to generate an excel spreadsheet
> for each database in an informix instance?
> I need the table name, number of rows, Raw size and lock mode
> Thank you in advance.


In Excel, select "Data / Import External Data / New Database Query".
If this is greyed out, install Microsoft Query from the Office CD.
Uncheck "Use the Query Wizard to create/edit queries".
Choose "<New Data Source>" unless you have an existing one.
In "Add Tables", click Options and enable "System Tables".
Add the "systables" table and close "Add Tables".
Make sure "Tables" and "Criteria" are enabled under "View".
Double click "tabname", "nrows", "rowsize" and "locklevel".
Add criteria "tabid > 99" (excludes system tables).
Add criteria "tabtype = 'T'" (excludes views).
Select "Records / Sort" from the menu and add "tabname".
If you press the SQL button, you should now see:

SELECT systables.tabname, systables.nrows,
systables.rowsize, systables.locklevel
FROM informix.systables systables
WHERE (systables.tabid>99) AND (systables.tabtype='T')
ORDER BY systables.tabname

Select "File / Return Data to Microsoft Excel".

Note that, for "nrows" to be accurate, you will need to run the
SQL statement "update statistics" using "dbaccess" beforehand.

--
Regards,
Doug Lawry
www.douglawry.webhop.org


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-20-2008, 11:24 AM
Rob
 
Posts: n/a
Default Re: data model

Thanks for all your help guys sorted now.



"Rob" <nospam@blueyonder.co.uk> wrote in message
news:drncdd$6u2$1$8300dec7@news.demon.co.uk...
> How would I use the system tables to generate an excel spreadsheet for

each
> database in an informix instance?
> I need the table name, number of rows, Raw size and lock mode
>
> Thank you in advance.
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:56 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com