Jelajahi Sumber

修改获取表名SQL

wanggaokun 1 tahun lalu
induk
melakukan
dc4c63db52

+ 14 - 4
PHM-admin/phm-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -72,14 +72,24 @@
                LOWER(sc.TYPE$)                                          column_type
         from SYS.SYSCOLUMNS sc
                  left join SYS.SYSOBJECTS so on sc.ID = so.ID
-                 left join SYS.SYSCOLUMNCOMMENTS SCC on sc.NAME = scc.COLNAME and scc.TABLE_TYPE = 'TABLE' and
-                                                        scc.SCHNAME = (select CURR_SCH from V$SESSIONS LIMIT 1) and
-                                                        scc.TVNAME = so.NAME
+                 left join SYS.SYSCOLUMNCOMMENTS SCC
+                           on sc.NAME = scc.COLNAME and scc.TABLE_TYPE = 'TABLE' and
+                              scc.SCHNAME = (select CURR_SCH
+                                             from V$SESSIONS
+                                             WHERE CURR_SCH = 'PHM'
+                                             LIMIT 1) and
+                              scc.TVNAME = so.NAME
         where so.TYPE$ = 'SCHOBJ'
           and so.SUBTYPE$ = 'UTAB'
           and so.PID = -1
           and so.SCHID =
-              (select ID from SYS.SYSOBJECTS where TYPE$ = 'SCH' and NAME = (select CURR_SCH from V$SESSIONS LIMIT 1))
+              (select ID
+               from SYS.SYSOBJECTS
+               where TYPE$ = 'SCH'
+                 and NAME = (select CURR_SCH
+                             from V$SESSIONS
+                             WHERE CURR_SCH = 'PHM'
+                             LIMIT 1))
           and so.NAME = #{tableName}
         order by sc.COLID
     </select>

+ 6 - 4
PHM-admin/phm-generator/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -98,9 +98,10 @@
     <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
         select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join
         SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH
-        from V$SESSIONS LIMIT 1)
+        from V$SESSIONS WHERE CURR_SCH = 'PHM' LIMIT 1)
         where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID =
-        (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH from V$SESSIONS LIMIT 1)) and
+        (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH
+        from V$SESSIONS WHERE CURR_SCH = 'PHM' LIMIT 1)) and
         so.NAME NOT LIKE 'QRTZ_%' AND so.NAME NOT LIKE 'gen_%'
         and so.NAME NOT IN (select table_name from gen_table)
         <if test="tableName != null and tableName != ''">
@@ -116,9 +117,10 @@
     <select id="selectDbTableListByNames" resultMap="GenTableResult">
         select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join
         SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH
-        from V$SESSIONS LIMIT 1)
+        from V$SESSIONS WHERE CURR_SCH = 'PHM' LIMIT 1)
         where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID =
-        (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH from V$SESSIONS LIMIT 1)) and
+        (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH
+        from V$SESSIONS WHERE CURR_SCH = 'PHM' LIMIT 1)) and
         so.NAME NOT LIKE 'qrtz_%' and so.NAME NOT LIKE 'gen_%'
         and so.NAME in
         <foreach collection="array" item="name" open="(" separator="," close=")">