1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.landtool.lanbase.modules.sys.dao.SysGeneratorDao">
 
    <select id="queryList" resultType="map">
        SELECT *
        FROM(
            SELECT ROW_NUMBER() OVER(ORDER BY B.tableName) AS rownumber,B.*
            FROM (
 
                SELECT A.name AS tableName,cast(G.value as varchar(100)) AS tableComment FROM SYS.tables A
                LEFT JOIN SYS.extended_properties G ON (A.object_id = G.major_id AND G.minor_id = 0)
                WHERE A.name != 'sysdiagrams'
                <if test="tableName != null and tableName != ''">
                    and  A.name like ('%' || #{tableName} || '%')
                </if>
 
            ) B
        ) A
        WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
    </select>
    
    <select id="queryTotal" resultType="int">
        SELECT count(*) FROM sysobjects WHERE xtype='U' AND name != 'sysdiagrams'
        <where>
            <if test="tableName != null and tableName != ''">
                and name like ('%' || #{tableName} || '%')
            </if>
        </where>
    </select> 
    
    <select id="queryTable" resultType="map">
 
        SELECT A.name AS tableName,cast(G.value as varchar(100)) AS tableComment,A.create_date AS createTime FROM SYS.tables A
        LEFT JOIN SYS.extended_properties G ON (A.object_id = G.major_id AND G.minor_id = 0)
        WHERE  A.name = #{tableName}
 
 
        <!--    select t.table_name "tableName",f.comments "tableComment", k.column_name "keyColumnName",o.CREATED "createTime"
            from user_tables t
             inner join user_tab_comments f on t.table_name = f.table_name
             inner join dba_objects o on t.TABLE_NAME = o.OBJECT_NAME
            left join (
                select a.table_name, a.constraint_name,  a.column_name 
                     from user_cons_columns a, user_constraints b 
                     where a.constraint_name = b.constraint_name and b.constraint_type = 'P' and a.table_name = 'SYS_MENU'
                )k on k.table_name = t.TABLE_NAME
            where t.table_name =  #{tableName} -->
 
        <!-- select t.table_name "tableName",f.comments "tableComment",o.CREATED "createTime" 
            from user_tables t
             inner join user_tab_comments f on t.table_name = f.table_name
             inner join dba_objects o on t.TABLE_NAME = o.OBJECT_NAME
             where t.table_name = #{tableName} -->
    </select> 
    
    <select id="queryColumns" resultType="map">
 
        SELECT
            B.name as columnName,D.data_type AS dataType,cast(C.value as varchar(100)) AS columnComment
        FROM SYS.tables A
        INNER JOIN SYS.columns B ON B.object_id = A.object_id
        LEFT JOIN SYS.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id
        LEFT JOIN(
            SELECT table_name,column_name,data_type FROM INFORMATION_SCHEMA.COLUMNS
        )D ON D.column_name = B.name and D.TABLE_NAME = A.name
        WHERE  A.name = #{tableName}
 
        <!--select c.COLUMN_NAME "columnName",c.DATA_TYPE "dataType",f.comments "columnComment"
            from user_tab_columns c
              inner join user_col_comments f on c.COLUMN_NAME = f.COLUMN_NAME and  f.TABLE_NAME = #{tableName}
               where c.TABLE_NAME = #{tableName}
        order by c.COLUMN_ID-->
    </select>
 
</mapper>