问题
Considering the following Raw SQL query made in Django 1.5 to an Oracle backend that is actually working
cursor.execute("SELECT EGW.TF_BSC_CELTCHH.BSC FROM EGW.TF_BSC_CELTCHH WHERE ROWNUM <= 5")
But if I try to use an alias for the table name like this:
cursor.execute("SELECT TCHH.BSC FROM EGW.TF_BSC_CELTCHH AS TCHH WHERE ROWNUM <= 5")
I get the following error:
ORA-00933: SQL command not properly ended
Why table aliasing is causing such trouble in Oracle?
回答1:
Don't use AS
, just type ...
cursor.execute("SELECT TCHH.BSC FROM EGW.TF_BSC_CELTCHH TCHH WHERE ROWNUM <= 5")
That way it should work.
Cheers!
来源:https://stackoverflow.com/questions/16406140/table-aliasing-not-working-in-raw-oracle-sql-queries-inside-django