Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I validate SQL query syntax in oracle database?

set NOEXEC ON;
Select * from emp;
Set NOEXEC OFF;

This validation is working in SQL Server. But It's not working in oracle.

Is there any syntax to check the query is valid or not in Oracle.

like image 357
Srinivas Ch Avatar asked Jun 09 '15 05:06

Srinivas Ch


People also ask

How do you validate a SQL query?

To validate the syntax of the statements, right-click in the editor, and then select a validation option. To validate the syntax of the statements for the connection that is selected in the Configuration tab, select the Validate statement syntax for current configuration option.

What checks the query syntax?

When a user executes any query, for generating the internal form of the query, the parser in the system checks the syntax of the query, verifies the name of the relation in the database, the tuple, and finally the required attribute value. The parser creates a tree of the query, known as 'parse-tree.

How can I test a SQL script without executing?

A solution for this is the noexec parameter. By default it is set to off but it can be enabled, if you want to test a script without executing it. The parameter tells SQL Server to parse the script and that is it, no execution.


1 Answers

Using EXPLAIN PLAN

EXPLAIN PLAN FOR SELECT FROM emp;

ERROR at line 1: ORA-00936: missing expression

EXPLAIN PLAN FOR SELECT * FROM emp;

Explained

like image 160
sqluser Avatar answered Oct 20 '22 00:10

sqluser