|
-
Jul 2nd, 2007, 11:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] Database tables where I don't know table names
Hi,
I am trying to figure out how, when I've connected to a database, I can collect all of the tables from that database, and put them into a TreeView, or ListView, or ListBox, or whatever I choose.
Ideally, I'd like to be able to list the table, and then list all fields within it, and then the field properties (i.e. string, numeric, length, etc. etc. etc.)
Can anybody point me in the right direction?
Thanks.
-
Jul 2nd, 2007, 11:08 AM
#2
Re: [2005] Database tables where I don't know table names
what type of database are you using? I know in SQL Server you can get the Table names by running this SQL
Code:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
As for access or other db's I am not exactly sure.
EDIT: This SQL will return you all the table, column name and datatype for all tables in the database but once again, this is for SQL server
Code:
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
OR for information of a specific table
Code:
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'YOUR_TABLE_NAME'
Last edited by bmahler; Jul 2nd, 2007 at 11:12 AM.
-
Jul 2nd, 2007, 11:17 AM
#3
Re: [2005] Database tables where I don't know table names
Well, also for access you can get the table list like so
Code:
SELECT Name FROM MSysObjects WHERE (Left([Name],1)<>"~") AND (Left([Name],4) <> "MSys") AND ([Type] In (1, 4, 6)) ORDER BY Name
-
Jul 6th, 2007, 10:18 AM
#4
Thread Starter
Addicted Member
Re: [2005] Database tables where I don't know table names
Thanks for your reply.
I'm using an Informix database, and I'm presuming that tables aren't identified as being TABLE_NAME - unless I'm doing something wrong - which is possible, I guess
-
Jul 6th, 2007, 10:20 AM
#5
Re: [2005] Database tables where I don't know table names
Information_Schema is unique to SQL Server only. The metadata for Informix is stored differently.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 6th, 2007, 10:31 AM
#6
Thread Starter
Addicted Member
Re: [2005] Database tables where I don't know table names
OK - thanks. I'll have to post something on an Informix forum - they must have come across this problem, surely?
-
Jul 6th, 2007, 10:33 AM
#7
Re: [2005] Database tables where I don't know table names
There is a method. I think you look in the catalog somewhere I just don't use Informix so I can't say where you would look.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 6th, 2007, 10:37 AM
#8
Frenzied Member
Re: [2005] Database tables where I don't know table names
Try "select * from systables". That works on our Informix database.
-
Jul 6th, 2007, 03:11 PM
#9
Thread Starter
Addicted Member
Re: [2005] Database tables where I don't know table names
Ahh - thanks guys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|