在 Oracle 查询中设置 FMTONLY ON
我想知道 SET FMTONLY ON
是否可以在 Oracle 查询中使用。当我这样使用时:
SET FMTONLY ON select * from department
我收到这样的消息:
第 1 行:跳过 SQLPLUS 命令:SET FMTONLY ON select * from Department
我正在 Oracle 中寻找一条语句,
该语句仅将元数据返回给客户端以测试响应的格式,而无需实际运行查询。
编辑
谢谢....我想要所有类型的查询通用的东西,如果查询包含任何“排序依据”,那么我们无法添加它。如果它是一个插入查询,它应该只验证查询,现在我正在做回滚以验证查询(然后在运行时执行它)SET FMTONLY 帮助我在 SQL 中实现它,在 Oracle 中类似? ??。
并“CREATE TABLE FormatTest AS (SELECT ...) 然后执行 DESCRIBE FormatTest。”我没有得到这个:(
任何帮助表示赞赏。
I'd like to know if SET FMTONLY ON
can be used within Oracle queries. When I'm using like this:
SET FMTONLY ON select * from department
I'm getting a message as such:
Line 1: SQLPLUS Command Skipped: SET FMTONLY ON select * from department
I'm looking for a statement in Oracle that
that returns only metadata to the client to test the format of the response without actually running the query.
EDIT
Thanks.... I want something generic for all types of queries, if the query contains any 'order by' then we cannot add this. If it is an insert query it should just validate the query, now I'm doing a roll back to just validate the query (and then execute it at run time) SET FMTONLY helps me achieve it in SQL, something similar in Oracle????.
And "CREATE TABLE FormatTest AS (SELECT ...) and then do a DESCRIBE FormatTest." I didn't get this one :(
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据此,设置 FMTONLY ON:
因此,我猜测结果是:(a) 语句成功,但什么也没有发生; (b) 语句失败,并引发异常。
因此,您可以通过运行
EXPLAIN PLAN FOR xxx
在Oracle中达到类似的效果,例如:如果语句成功,则可以假定该语句在语法上是有效的。
According to this, SET FMTONLY ON:
Therefore, I'm guessing the outcome is that either (a) the statement succeeds, and nothing happens; or (b) the statement fails, and an exception is raised.
Therefore, you could achieve a similar effect in Oracle by running
EXPLAIN PLAN FOR xxx
, e.g.:If the statement succeeds, then the statement can be assumed to be syntactically valid.
它并不完全相同,但您可以将
WHERE rownum<=1
添加到查询中。它允许您根据一行评估格式。这有点矫枉过正,但您可以执行
CREATE TABLE FormatTest AS (SELECT ...)
,然后执行DESCRIBE FormatTest
。编辑:
根据您最近的编辑,听起来您正在寻找语句验证而不是布局,在这种情况下,Janek Bogucki 或 Jeffrey Kemp 有更好的答案。
It is not quite the same, but you could add
WHERE rownum<=1
to your query. It would allow you to assess the format based on one row.Its a little overkill, but you could do
CREATE TABLE FormatTest AS (SELECT ...)
and then do aDESCRIBE FormatTest
.EDIT:
Based on your more recent edits it sounds like you are looking for statement validation rather than layout, in which case Janek Bogucki or Jeffrey Kemp have better answers.
查看DBMS_SQL.DESCRIBE_COLUMNS。这是将为每列返回的数据,
这将适用于任何选择语句,例如我通过修改 示例 8:描述列并且它起作用了,
Have a look at DBMS_SQL.DESCRIBE_COLUMNS. This is the data that will be returned for each column,
This will work with any select statement afaik, for example I tried this query by modifying Example 8: Describe Columns and it worked,