5
votes

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

2
I am using this version 4.1.3.20user6519393
No, I mean ORACLE version.mathguy
Please run this statement and see what it tells you: SELECT * FROM v$version WHERE banner LIKE 'Oracle%';mathguy
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Productionuser6519393
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.mathguy

2 Answers

19
votes

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
votes

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`