Table aliasing not working in raw Oracle SQL queri

2019-07-28 07:03发布

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条回答
手持菜刀,她持情操
2楼-- · 2019-07-28 07:11

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!

查看更多
登录 后发表回答