<bdo id='uM0jJ'></bdo><ul id='uM0jJ'></ul>

<legend id='uM0jJ'><style id='uM0jJ'><dir id='uM0jJ'><q id='uM0jJ'></q></dir></style></legend>
<tfoot id='uM0jJ'></tfoot>
    1. <small id='uM0jJ'></small><noframes id='uM0jJ'>

      1. <i id='uM0jJ'><tr id='uM0jJ'><dt id='uM0jJ'><q id='uM0jJ'><span id='uM0jJ'><b id='uM0jJ'><form id='uM0jJ'><ins id='uM0jJ'></ins><ul id='uM0jJ'></ul><sub id='uM0jJ'></sub></form><legend id='uM0jJ'></legend><bdo id='uM0jJ'><pre id='uM0jJ'><center id='uM0jJ'></center></pre></bdo></b><th id='uM0jJ'></th></span></q></dt></tr></i><div id='uM0jJ'><tfoot id='uM0jJ'></tfoot><dl id='uM0jJ'><fieldset id='uM0jJ'></fieldset></dl></div>

        Oracle 查询以获取列名

        时间:2023-09-19

          <tbody id='icbCM'></tbody>
      2. <legend id='icbCM'><style id='icbCM'><dir id='icbCM'><q id='icbCM'></q></dir></style></legend>

      3. <tfoot id='icbCM'></tfoot>
        • <bdo id='icbCM'></bdo><ul id='icbCM'></ul>
          <i id='icbCM'><tr id='icbCM'><dt id='icbCM'><q id='icbCM'><span id='icbCM'><b id='icbCM'><form id='icbCM'><ins id='icbCM'></ins><ul id='icbCM'></ul><sub id='icbCM'></sub></form><legend id='icbCM'></legend><bdo id='icbCM'><pre id='icbCM'><center id='icbCM'></center></pre></bdo></b><th id='icbCM'></th></span></q></dt></tr></i><div id='icbCM'><tfoot id='icbCM'></tfoot><dl id='icbCM'><fieldset id='icbCM'></fieldset></dl></div>

            <small id='icbCM'></small><noframes id='icbCM'>

                • 本文介绍了Oracle 查询以获取列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 mySQL 查询来从这样的表中获取列:

                  I have a mySQL query to get columns from a table like this:

                  String sqlStr="select column_name 
                  from information_schema.COLUMNS 
                  where table_name='users' 
                  and table_schema='"+_db+"' 
                  and column_name not in ('password','version','id')"
                  

                  如何在 Oracle 11g 数据库中更改上述查询?我需要获取列名称作为表用户"的结果集,不包括某些列,指定模式.现在我的新表空间中有所有表,那么我是否指定表空间名称代替模式名称?

                  How do I change the above query in Oracle 11g database? I need to get columns names as a resultset for table 'users' excluding certain columns, specifying a schema. Right now I have all tables in my new tablespace, so do I specify tablespace name in place of schema name?

                  还有一个通用的 HQL 吗?在我的新 Oracle 数据库中(我是 Oracle 的新手),我只有表空间名称,所以这相当于模式名称(逻辑上?)

                  Also is there a generic HQL for this? In my new Oracle database (I am new to Oracle), I only have tablespace name, so is that equivalent to schema name (logically?)

                  推荐答案

                  information_schema.COLUMNS 的 Oracle 等价物是 USER_TAB_COLS 对于当前用户拥有的表,ALL_TAB_COLSDBA_TAB_COLS 适用于所有用户拥有的表.

                  The Oracle equivalent for information_schema.COLUMNS is USER_TAB_COLS for tables owned by the current user, ALL_TAB_COLS or DBA_TAB_COLS for tables owned by all users.

                  表空间不等同于模式,您也不必提供表空间名称.

                  Tablespace is not equivalent to a schema, neither do you have to provide the tablespace name.

                  如果您想查询 ALL_TAB_COLSDBA_TAB_COLS 以获取特定用户拥有的 OF 表列,则提供架构/用户名将很有用.在你的情况下,我想查询看起来像:

                  Providing the schema/username would be of use if you want to query ALL_TAB_COLS or DBA_TAB_COLS for columns OF tables owned by a specific user. in your case, I'd imagine the query would look something like:

                  String sqlStr= "
                  SELECT column_name
                    FROM all_tab_cols
                   WHERE table_name = 'USERS'
                     AND owner = '" +_db+ "'
                     AND column_name NOT IN ( 'PASSWORD', 'VERSION', 'ID' )"
                  

                  请注意,使用这种方法,您可能会面临 SQL 注入的风险.

                  Note that with this approach, you risk SQL injection.

                  大写表名和列名,因为它们在 Oracle 中通常是大写的;如果用双引号将它们括起来,它们只能是小写或混合大小写.

                  Uppercased the table- and column names as these are typically uppercase in Oracle; they are only lower- or mixed case if created with double quotes around them.

                  这篇关于Oracle 查询以获取列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:列数据类型中 BYTE 和 CHAR 之间的区别 下一篇:SQL 生成从 1 到 100 的数字列表

                  相关文章

                    <small id='oz16P'></small><noframes id='oz16P'>

                  1. <tfoot id='oz16P'></tfoot>
                  2. <i id='oz16P'><tr id='oz16P'><dt id='oz16P'><q id='oz16P'><span id='oz16P'><b id='oz16P'><form id='oz16P'><ins id='oz16P'></ins><ul id='oz16P'></ul><sub id='oz16P'></sub></form><legend id='oz16P'></legend><bdo id='oz16P'><pre id='oz16P'><center id='oz16P'></center></pre></bdo></b><th id='oz16P'></th></span></q></dt></tr></i><div id='oz16P'><tfoot id='oz16P'></tfoot><dl id='oz16P'><fieldset id='oz16P'></fieldset></dl></div>

                      <legend id='oz16P'><style id='oz16P'><dir id='oz16P'><q id='oz16P'></q></dir></style></legend>
                        <bdo id='oz16P'></bdo><ul id='oz16P'></ul>