Results 1 to 2 of 2

Thread: detecting database structure

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    detecting database structure

    Hi there.

    I am very new to this, and we are kind of going to start doing this for a project.

    I need to know, is it possible to detect the structure of a table in a specified database in SQL?

    if so - how would you do that? what is brought back from sql when requested?


    The other thing is....

    when it comes to populating a database, how do you populate the database by record? I mean, lets say if table A has 5 fields, and table B has 9 fields, how do you populate the tables (auto detecting) for all fields in the table?

    Thank-you

  2. #2
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Detecting the structure of a table is a database dependent thing, that is, the answer varies depending on which database you are using. For example, MS SQL Server, if you had a table called "Procedures" here's how you would get information about it:

    Code:
    SELECT * 
    FROM syscolumns c, sysobjects t
    WHERE t.name = 'Procedures' AND
    t.id = c.id
    ORDER BY c.colorder
    Most other databases have some similar set of "system" tables that allow you to map your table structure.

    Given the above, you should be able to dynamically craft an insert statement to populate any of your existing tables.

    cudabean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width