Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 17th, 2004, 02:31 AM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
Cool FireBird System Table Relations \ Metadata

Hi

I am trying to retreive the structure of a database via the firebird system tables. I don't want the ddl statements.

Is there anywhere where i can find what the relationships are between the system tables? Like a ERD or something?

I am having difficulties when trying to retreive the field types of a table as i can't seem to find the correct relationship between fields and types.

Thanks Wayne

Last edited by WayneB : May 17th, 2004 at 04:11 AM. Reason: Change wording

Reply With Quote
  #2  
Old May 18th, 2004, 02:40 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
Chapter 7 of the Language Reference manual lists all the systems tables and their fields. It is under the section called "System Tables and Views".

I had never really looked at these tables very closely but I was able to throw together the following query that showed me the tables I had created and the columns in those tables. Is this the type of query you're looking for? If it is, make sure you test it before you use it. I just glanced at the results to make sure they were "correct" but didn't spend much time analyzing them.
Code:
SELECT a.RDB$RELATION_NAME, b.RDB$FIELD_NAME, b.RDB$FIELD_ID, d.RDB$TYPE_NAME,
       c.RDB$FIELD_LENGTH, c.RDB$FIELD_SCALE
FROM   RDB$RELATIONS a
INNER JOIN RDB$RELATION_FIELDS b
ON     a.RDB$RELATION_NAME = b.RDB$RELATION_NAME
INNER JOIN RDB$FIELDS c
ON     b.RDB$FIELD_SOURCE = c.RDB$FIELD_NAME
INNER JOIN RDB$TYPES d
ON     c.RDB$FIELD_TYPE = d.RDB$TYPE
WHERE  a.RDB$SYSTEM_FLAG = 0
  AND  d.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
ORDER BY a.RDB$RELATION_NAME, b.RDB$FIELD_ID

Reply With Quote
  #3  
Old May 19th, 2004, 07:42 AM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
Yeah thanks.

This is the kind of thing that i was looking for. The linking of fields to field types and Sprocs to Data types is were my problems was.

I did not know that i had to hard code the Field type as string in the sql.

I found the SQL that i was looking for by using a SQL Monitor to monitor the SQL generated by the ERD tools.

Last edited by WayneB : May 19th, 2004 at 07:44 AM. Reason: Added more info

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > FireBird System Table Relations


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT