diff --git a/sql/engines/oracle.py b/sql/engines/oracle.py index 6f25bbe71b..35d6f1bc67 100644 --- a/sql/engines/oracle.py +++ b/sql/engines/oracle.py @@ -590,10 +590,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False): conn = self.get_connection() cursor = conn.cursor() if db_name: - cursor.execute( - f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ", - {"db_name": db_name}, - ) + conn.conn.current_schema=db_name if re.match(r"^explain", sql, re.I): sql = sql else: @@ -669,10 +666,7 @@ def query( conn = self.get_connection() cursor = conn.cursor() if db_name: - cursor.execute( - f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ", - {"db_name": db_name}, - ) + conn.current_schema=db_name sql = sql.rstrip(";") # 支持oralce查询SQL执行计划语句 if re.match(r"^explain", sql, re.I):