提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.base.db.dao.sqls; |
懒 |
2 |
|
|
3 |
import lombok.Getter; |
|
4 |
|
|
5 |
/** |
|
6 |
* 获取所有表的sql |
|
7 |
* |
|
8 |
* @author fengshuonan |
|
9 |
* @date 2019-07-16-13:06 |
|
10 |
*/ |
|
11 |
@Getter |
|
12 |
public class TableListSql extends AbstractSql { |
|
13 |
|
|
14 |
@Override |
|
15 |
protected String mysql() { |
|
16 |
return "select TABLE_NAME as tableName,TABLE_COMMENT as tableComment from information_schema.`TABLES` where TABLE_SCHEMA = ?"; |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
protected String sqlServer() { |
|
21 |
return "SELECT DISTINCT\n" + |
|
22 |
"d.name as tableName,\n" + |
|
23 |
"CONVERT(varchar(200), f.value) as tableComment\n" + |
|
24 |
"FROM\n" + |
|
25 |
"syscolumns a\n" + |
|
26 |
"LEFT JOIN systypes b ON a.xusertype= b.xusertype\n" + |
|
27 |
"INNER JOIN sysobjects d ON a.id= d.id\n" + |
|
28 |
"AND d.xtype= 'U'\n" + |
|
29 |
"AND d.name<> 'dtproperties'\n" + |
|
30 |
"LEFT JOIN syscomments e ON a.cdefault= e.id\n" + |
|
31 |
"LEFT JOIN sys.extended_properties g ON a.id= G.major_id\n" + |
|
32 |
"AND a.colid= g.minor_id\n" + |
|
33 |
"LEFT JOIN sys.extended_properties f ON d.id= f.major_id\n" + |
|
34 |
"AND f.minor_id= 0"; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
protected String pgSql() { |
|
39 |
return "select " + |
|
40 |
"relname as \"tableName\"," + |
|
41 |
"cast(obj_description(relfilenode,'pg_class') as varchar) as \"tableComment\" " + |
|
42 |
"from pg_class c \n" + |
|
43 |
"where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' order by relname"; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected String oracle() { |
|
48 |
return "select ut.table_name as tableName, co.comments as tableComment from user_tables ut\n" + |
|
49 |
"left join user_tab_comments co on ut.table_name = co.table_name\n" + |
|
50 |
"where tablespace_name is not null and user= ?"; |
|
51 |
} |
|
52 |
} |