如何在 where 子句中包含 USER_VIEWS.TEXT 列
这似乎应该是一件很容易弄清楚的事情,但我正在努力寻找任何答案。
我希望能够查询 Oracle 中的 USER_VIEWS 表以查找使用特定表的其他视图。
像这样的东西:
从用户视图中选择视图名称、文本 WHERE 文本 LIKE'%MY_TABLE%'
我收到错误: ORA-00932:数据类型不一致:预期的 NUMBER 为 LONG
TEXT 的数据类型为 LONG,在 TOAD 中显示为 WIDEMEMO。
我尝试过将其转换为 to_char 并连接。我尝试创建另一个仅包含 TEXT 数据的表,结果出现 ORA-00997:非法使用 LONG 数据类型。
有什么想法吗?
谢谢!
This seems like it should have been an easy thing to figure out but I am struggling to find any answers.
I want to be able to query against the USER_VIEWS table in Oracle to find other views that are using a particular table.
Something like:
SELECT view_name, text FROM user_views
WHERE text LIKE'%MY_TABLE%'
I get the error:
ORA-00932: inconsistent datatypes: expected NUMBER got LONG
The datatype for TEXT is LONG and in TOAD it shows WIDEMEMO.
I have tried casting it, to_char and concatenating. I tried creating another table with just the TEXT data and I get ORA-00997: illegal use of LONG datatype.
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从技术上讲,您可以使用 DBMS_METADATA 包获取 CLOB 中视图的 DDL,然后解析它以查找对表的引用。但还有比查看视图定义更简单的解决方案。
Oracle 在
USER_DEPENDENCIES
视图(或ALL_DEPENDENCIES
或DBA_DEPENDENCIES
)中维护有关对象依赖关系的信息,具体取决于您的权限级别以及是否尝试跟踪依赖关系跨模式)。使用这些视图效果会更好。如果您使用
USER_DEPENDENCIES
视图,您还可以使用依赖对象树执行更复杂的操作。如果我创建依赖于第一个视图的第二个视图,我可以很容易地看到两个视图最终都使用基表。Technically, you could use the
DBMS_METADATA
package to get the DDL for the view in a CLOB and then parse that looking for a reference to your table. But there are far easier solutions than looking at the view definition.Oracle maintains information about object dependencies in the
USER_DEPENDENCIES
view (orALL_DEPENDENCIES
orDBA_DEPENDENCIES
depending on your privilege levels and whether you're trying to track dependencies across schemas). You're far better off using those viewsIf you're using the
USER_DEPENDENCIES
view, you can also do more sophisticated things with the tree of dependent objects. If I create a second view that depends on the first, I can easily see that both views eventually use the base table.您不能将 LIKE 与 LONG 列一起使用。不过,您可以编写自己的自定义函数来执行搜索 - 请参阅 http://www. techonthenet.com/oracle/questions/long_value.php
您还可以创建一个表并将 LONG 列转换为 CLOB 列:
另请参阅 http:// /www.dba-oracle.com/oracle_news/2005_5_9_converting_long_lob_data_types.htm
You cannot use LIKE with LONG columns. You could write your own custom function to perform the search, though - see http://www.techonthenet.com/oracle/questions/long_value.php
You could also create a table and convert the LONG column to a CLOB column:
see also http://www.dba-oracle.com/oracle_news/2005_5_9_converting_long_lob_data_types.htm
如果您只想在 TOAD 的数据网格中查看它,那么您可以打开预览:
View =>蟾蜍选项=>数据网格 =>数据=> [x] 预览 CLOB 和 LONG 数据
我正在使用 TOAD 10.5.1.3
If you just want to see it in TOAD's datagrid then you can turn on the preview:
View => Toad Options => Data Grids => Data => [x] Preview CLOB and LONG data
I'm using TOAD 10.5.1.3