From 76c8b832840f9f021cbea78639a4991da4d2afcd Mon Sep 17 00:00:00 2001 From: diant Date: Tue, 30 May 2023 18:18:48 +0800 Subject: [PATCH] =?UTF-8?q?oracle,=E8=BE=BE=E6=A2=A6=E5=B7=B2=E7=9F=A5sql?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D=20=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/db/mapper/dm/DmBaseMapper.xml | 22 +++++++++++++------ .../db/mapper/oracle/OracleBaseMapper.xml | 22 +++++++++++++------ .../db/service/database/DmServiceImpl.java | 16 +++++--------- .../service/database/OracleServiceImpl.java | 16 +++++--------- .../database/SqlserverServiceImpl.java | 9 +++++++- 5 files changed, 48 insertions(+), 37 deletions(-) diff --git a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/db/mapper/dm/DmBaseMapper.xml b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/db/mapper/dm/DmBaseMapper.xml index 08372dae..fee0d5ad 100644 --- a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/db/mapper/dm/DmBaseMapper.xml +++ b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/db/mapper/dm/DmBaseMapper.xml @@ -36,7 +36,8 @@ - select t.TABLE_NAME,t.COLUMN_NAME,t.DATA_TYPE,case t.NULLABLE when 'Y' then '1' when 'N' then '0' end NULLABLE, c.COMMENTS, - s.POSITION as primaryKey from all_tab_columns t - left join user_col_comments c on t.COLUMN_NAME = c.COLUMN_NAME and t.TABLE_NAME = c.TABLE_NAME - left join user_cons_columns s on t.COLUMN_NAME = s.COLUMN_NAME and t.TABLE_NAME = s.TABLE_NAME and s.POSITION = 1 + select t.TABLE_NAME,t.COLUMN_NAME,t.DATA_TYPE,case t.NULLABLE when 'Y' then '1' when 'N' then '0' end NULLABLE, + cons.POSITION as primaryKey,col_comments.comments from all_tab_columns t + left join ( + select s.owner, s.table_name, s.column_name,s.POSITION, cons.constraint_type from all_cons_columns s + join all_constraints cons on s.owner = cons.owner and + s.constraint_name = cons.constraint_name where cons.constraint_type in ('P', 'U', 'R') + )cons on t.owner = cons.owner and t.table_name = cons.table_name and t.column_name = cons.column_name + left join ( + select comments.owner, comments.table_name, comments.column_name, comments.comments + from all_col_comments comments) col_comments on t.owner = col_comments.owner and t.table_name = col_comments.table_name + and t.column_name = col_comments.column_name t.owner = #{dbName} and t.TABLE_NAME = #{tableName} @@ -59,7 +67,7 @@ @@ -67,7 +75,7 @@ - select t.OWNER as dbName,t.TABLE_NAME as tableName,c.COMMENTS as tableComment from all_tables t left join user_tab_comments c on t.TABLE_NAME = c.TABLE_NAME + select t.OWNER as dbName,t.TABLE_NAME as tableName,c.COMMENTS as tableComment from all_tables t + left join all_tab_comments c on t.TABLE_NAME = c.TABLE_NAME and t.OWNER = c.OWNER t.owner = #{dbName} @@ -45,10 +46,17 @@ select t.TABLE_NAME,t.COLUMN_NAME,t.DATA_TYPE,case t.NULLABLE when 'Y' then 1 when 'N' then 0 end NULLABLE, c.COMMENTS from all_tab_columns t - left join all_col_comments c on t.COLUMN_NAME = c.COLUMN_NAME and t.TABLE_NAME = c.TABLE_NAME + left join all_col_comments c on t.COLUMN_NAME = c.COLUMN_NAME and t.TABLE_NAME = c.TABLE_NAME and t.OWNER = c.OWNER where t.OWNER = #{dbName} AND (upper(t.COLUMN_NAME) like upper(#{searchText}) or upper(c.COMMENTS) like upper(#{searchText})) @@ -67,7 +75,7 @@