• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

SQL Question - Querying the DB objects

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    SQL Question - Querying the DB objects

    Did a quick google and came up with little so I thought I'd ask you lot seeing as you all love showing off your skills

    How can I find a table/view that contains a column that I know the name of?

    e.g. I know the name of a column is "ISBN", how can I find, using a query, the table "Book"?

    Know what I mean?

    If possible, I would like to be able to do this across the whole DBMS, not just one database within it.

    Over to you gurus
    "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


    Thomas Jefferson

    #2
    select o.name, c.id, c.name
    from syscolumns c, sysobjects o
    where c.id=o.id
    and c.name = "ISBN"

    Comment


      #3
      Give us a clue - what kind of database are you working with??????

      Code:
      SELECT table_name
      FROM   dba_tab_columns
      WHERE  column_name = 'ISBN'
      will do it in Oracle for you.
      Best Forum Advisor 2014
      Work in the public sector? You can read my FAQ here
      Click here to get 15% off your first year's IPSE membership

      Comment


        #4
        Probably should have mentioned that! Sybase.
        "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


        Thomas Jefferson

        Comment


          #5
          Originally posted by BrilloPad View Post
          select o.name, c.id, c.name
          from syscolumns c, sysobjects o
          where c.id=o.id
          and c.name = "ISBN"
          That's the ticket. Thanks BP.
          "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


          Thomas Jefferson

          Comment


            #6
            Originally posted by Ruprect View Post
            Probably should have mentioned that! Sybase.
            Sorry, I thought you said it was a database....
            Best Forum Advisor 2014
            Work in the public sector? You can read my FAQ here
            Click here to get 15% off your first year's IPSE membership

            Comment


              #7
              Originally posted by TheFaQQer View Post
              Sorry, I thought you said it was a database....

              Comment


                #8
                Off the top of my head its the syscolumns and sysobjects tables you need to join and query. The command sp_tables will list the tables you can view including system OR if your using Rapid SQL just use the 'Search DB option' under 'Tools'.

                Sybase is sh*t, current gig is Sybase 6 months and just got another 6 months but Im seriously considering looking else soley because 12 months Sybase in line of work and not Oracle will make getting a new contract very hard.
                Last edited by Bumfluff; 28 March 2008, 10:59.

                Comment


                  #9
                  Originally posted by TheFaQQer View Post
                  Sorry, I thought you said it was a database....

                  an RDBMS

                  Comment


                    #10
                    Originally posted by TheFaQQer View Post
                    Sorry, I thought you said it was a database....
                    lol, well, I could have said SQL Server...
                    "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


                    Thomas Jefferson

                    Comment

                    Working...
                    X