简体   繁体   English

oracle查询以查看数据类型列表

[英]oracle query to view list of data type

I try to show my table data type in datagridview vb.net. 我尝试在datagridview vb.net中显示我的表数据类型。 Here is the sample code : 这是示例代码:

        oradb = "Data Source=(DESCRIPTION=" _
      + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & txtServer1.Text & ")(PORT=" & port1.Value & ")))" _
      + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & txtSID.Text & ")));" _
      + "User Id=" & txtUsername1.Text & ";" _
      + "Password=" & txtPassword1.Text
        Dim connOracle As New OracleConnection(oradb)

        Try
            connOracle.Open()
            connOracle.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString())
        Finally
        End Try

        SQL = "desc hr.employees"
        myCommand1.Connection = connOracle
        myCommand1.CommandText = SQL
        myAdapter1.SelectCommand = myCommand1
        myAdapter1.Fill(myTablePreview)
        DataGridView1.DataSource = myTablePreview

I try login using username "system". 我尝试使用用户名“ system”登录。 When I run this code, I got error message "ORA-00900: invalid SQL statement" 运行此代码时,出现错误消息“ ORA-00900:无效的SQL语句”

is there any wrong with my query?? 我的查询有什么问题吗? pls helpme. 请帮助我。 thank's..... 谢谢.....

DESC is a SQL PLus command. DESC是SQL PLus命令。

you probably want to do an actual query, like 您可能想进行实际的查询,例如

select * 
from all_tab_cols
where table_name = 'EMP'

DESC (DESCRIBE) is a SQL*Plus command, not a SQL verb. DESC(DESCRIBE)是SQL * Plus命令,而不是SQL动词。 SQL*Plus is a front-end tool for SQL, so it adds some commands of its own, and this is one of those. SQL * Plus是用于SQL的前端工具,因此它添加了一些自己的命令,这就是其中之一。 You have to stick with SQL when using OLE DB. 使用OLE DB时必须坚持使用SQL。

If you want this data in a client program, you might want to try something like: 如果要在客户端程序中使用此数据,则可能需要尝试如下操作:

select * 
from all_tab_columns 
where table_name = '<your table name>'

or like this: 或像这样:

Select COLUMN_NAME 
from user_tab_columns 
where table_name='EMP'

This is pure (Oracle) SQL, which you can experiment with in SQL*Plus until you get the set of columns that you need. 这是纯(Oracle)SQL,您可以在SQL * Plus中进行试验,直到获得所需的列集为止。

Devian Yudha, Devian Yudha,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM