Search code examples
sqloracletable-alias

Why do I get an Error when I try to rename a table after FROM?


When I simply try to retrieve all of the rows in my table EMPLOYEE like this:

SELECT *
FROM EMPLOYEE AS emp;

I get the following error:

ORA-00933: SQL command not properly ended 
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action: 
Error at Line: 14 Column: 11

If I remove the AS emp it works just perfectly fine, but I want to rename my table here. Am I missing something totally obvious?


Solution

  • I believe that is a problem with your database engine. From the error i gather you are using Oracle. Oracle alias for tables is: table_name alias_name (https://www.techonthenet.com/oracle/alias.php)

    So change the query to:

    SELECT *
    FROM EMPLOYEE emp;