Results 1 to 18 of 18

Thread: [2005] getting the details of the table using Oracle

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    [2005] getting the details of the table using Oracle

    hi to all,
    i want to get the details of the table (column names and datatype). if i am using the Getschema(), it took lots of time. any other way is possible to get the details of the table in Oracle. if, possible plz help me.

    thank u

    with thanks and regards
    MMary

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: [2005] getting the details of the table using Oracle

    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [2005] getting the details of the table using Oracle

    Just colums and datatype you can use the describe command of SQL (for Oracle).

    desc tablename
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4
    Fanatic Member onlyGirl's Avatar
    Join Date
    Sep 2006
    Location
    Houston, TX
    Posts
    743

    Re: [2005] getting the details of the table using Oracle

    use describe tablename
    Using Visual Studio 2008

    Please mark your thread RESOLVED if you no longer need help.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    hi to all,
    thank u for ur kind reply. i have used "desc tablename". but it given the error "ORA-00900 Invalid SQL statement". my code is


    oledbcon = new OleDbConnection("Provider=OraOLEDB.Oracle;User Id=" + struname + ";Password=" + strpwd + "");
    oledbcon.Open();
    oledbcmd = new OleDbCommand("desc " + tablename, oledbcon);
    oledbreader = oledbcmd.ExecuteReader();
    while (oledbreader.Read())
    {
    cmbcolumns.Items.Add(oledbreader[0].ToString());
    }
    oledbreader.Close();
    oledbcon.Close();


    plz help me to solve the problem.

    With thanks and regards
    MMary

  6. #6
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: [2005] getting the details of the table using Oracle

    vb Code:
    1. exec sp_tables

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    hi,
    thank u for ur reply , exec sp_tables also giving the same error "Invalid SQL Statment". i gave the query like that "exec tablename". is it correct?
    and also , ple somebody help me to solve the problem.

    With thanks and regards
    mmary

  8. #8
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: [2005] getting the details of the table using Oracle


    Dim con1 As New OracleClient.OracleConnection("Connection string")
    con1.Open()
    Dim dt1 As New DataTable
    Dim da1 As New OracleClient.OracleDataAdapter("exec sp_tables", con1)
    ret = da1.Fill(dt1)
    If ret > 0 Then
    For i As Integer = 0 To ret - 1
    ComboBox1.Items.Add(dt1.Rows(i).Item("table_name"))
    Next
    End If

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    hi, thank u for ur kind reply.i need the table details(column name with data types". i think using ur code i can get the tables name. am i correct?. and also i am using the Oledb connection. i am not using the oracle connection.

    plz help me to solve the problem


    thank u

    with thanks and regards
    mmary.

  10. #10
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] getting the details of the table using Oracle

    Please mark you thread resolved using the Thread Tools as shown

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    hi to all,
    when i execute the "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =products", it also given the error "table or view does not exist". so,plz help me to solve th problem. i am using the oledb connection. in 2005 , there is no oracle connection. any other way is possible plz inform me. plz help me for that.

    thank u.

    with thanks and regards
    mmary

  12. #12
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] getting the details of the table using Oracle

    That means that you dont have a table called Products
    Please mark you thread resolved using the Thread Tools as shown

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    hi, thanks for ur reply. i am having the table like "Products". i was created one more table and i have used the same query it also, giving the same error. so. plz tell me how to rectify that?

    thank u.

    with thanks and regards
    mmary

  14. #14
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] getting the details of the table using Oracle

    can you give the screen shot for this command from the query analyzer
    vb Code:
    1. SELECT * FROM INFORMATION_SCHEMA.COLUMNS
    Please mark you thread resolved using the Thread Tools as shown

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    thank u for ur reply. it giving the error "ORA-00942: table or view does not exist".

    thank u
    with thanks and regards
    mmary

  16. #16
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] getting the details of the table using Oracle

    Oh You are using Oracle
    Please mark you thread resolved using the Thread Tools as shown

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: [2005] getting the details of the table using Oracle

    i am using oracle 10g.

    thank u
    with thanks and regards
    MMary

  18. #18
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [2005] getting the details of the table using Oracle

    OK I got the time at last to run this down. What I did was use the User_Tab_Columns View to get the information. Here is what I did:

    vb Code:
    1. '"Select COLUMN_NAME,DATA_TYPE,DATA_LENGTH,NULLABLE From User_tab_Columns Where Table_Name = 'CANDIDATE'"
    2.         Dim oDS As System.Data.DataSet
    3.         Dim strSQL As String = String.Empty
    4.         strSQL = "Select COLUMN_NAME,DATA_TYPE,DATA_LENGTH,NULLABLE From User_tab_Columns Where Table_Name = 'CANDIDATE'"
    5.         da = New clsDataAccess
    6.         oDS = da.Return_Oracle_DataSet(strSQL)
    7.         If Not oDS Is Nothing Then
    8.             Me.DataGridView1.DataSource = oDS.Tables(0)
    9.         End If
    10.         If mdlGeneral.errMessage.intErrNum <> 0 Then
    11.             MessageBox.Show(mdlGeneral.errMessage.strMess.Trim(), "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    12.         End If
    13.         da.Dispose()

    Now da is a class that I use to do things against the DB. Return_Oracle_DataSet is a function in the class that returns an Oracle Data Set. I placed a datagrid on a page and set the datagrids datasource to the returned datasets table o (the only table in the resultset).

    Now I did this as I said using the User_Tab_Columns View so that was a table owned by the user logged into the DB. (There own schema). If you want to use this to get someone elses schema then you use the DBA_Tab_Columns View and supply the table owner also.

    RaviIntegra sp_tables is used in MS SQL Server only not in Oracle DBs.
    danasegarne INFORMATION_SCHEMA is also used only in MS SQL Server.
    Last edited by GaryMazzone; Mar 23rd, 2007 at 08:13 AM.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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