8

I am getting this error using oracle sql developer for the query below and can't really figure out what is wrong with it. "SQL command not properly ended"

select * from Table1 FETCH FIRST ROW ONLY

11
  • I am using this version 4.1.3.20
    – user6519393
    Jul 29, 2016 at 23:15
  • 1
    No, I mean ORACLE version.
    – user5683823
    Jul 29, 2016 at 23:15
  • Please run this statement and see what it tells you: SELECT * FROM v$version WHERE banner LIKE 'Oracle%';
    – user5683823
    Jul 29, 2016 at 23:16
  • Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    – user6519393
    Jul 29, 2016 at 23:17
  • 1
    SQL developer is not the database software, it is only the interface you use to interact with it. Every version of Oracle DB (including 12c) comes with its (upgraded) SQL Developer. I use SQL Developer perfectly fine, both with Oracle 11g (on my laptop) and with 12c (on my desktop) - all for learning, I am not an IT professional.
    – user5683823
    Jul 29, 2016 at 23:26

2 Answers 2

26

What version of Oracle are you using? FETCH (...) is only available in Oracle 12.

Please run this statement and see what it tells you:

SELECT * FROM v$version WHERE banner LIKE 'Oracle%'; 
1
  • I am using this version 4.1.3.20
    – user6519393
    Jul 29, 2016 at 23:15
5

After 5 years this question doesn't have a full answer except what is in the comments. Credit to @mathguy for the answer. You can do this

SELECT * from Table1 WHERE ROWNUM = 1

OR

SELECT * FROM Table1 WHERE ROWNUM < 10

These will give essentially random rows but generally this is just used for data exploration anyway, so not a big deal. If you want one specific row then use something like this:

WITH X AS (
  SELECT *, ROW_NUMBER() OVER (ORDER BY SomeField) FROM table1
)
SELECT * FROM X WHERE RN = 1`

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.