提交 | 用户 | 时间
|
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 TableFieldListSql extends AbstractSql { |
|
13 |
|
|
14 |
@Override |
|
15 |
protected String mysql() { |
|
16 |
return "select COLUMN_NAME as columnName,COLUMN_COMMENT as columnComment from information_schema.COLUMNS where table_name = ? and table_schema = ?"; |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
protected String sqlServer() { |
|
21 |
return "SELECT A.name as columnName,\n" + |
|
22 |
" CONVERT(varchar(200), isnull(G.[value], '')) as columnComment\n" + |
|
23 |
" FROM syscolumns A\n" + |
|
24 |
" Left Join systypes B On A.xusertype= B.xusertype\n" + |
|
25 |
" Inner Join sysobjects D On A.id= D.id\n" + |
|
26 |
" and D.xtype= 'U'\n" + |
|
27 |
" and D.name<> 'dtproperties'\n" + |
|
28 |
" Left Join syscomments E on A.cdefault= E.id\n" + |
|
29 |
" Left Join sys.extended_properties G on A.id= G.major_id\n" + |
|
30 |
" and A.colid= G.minor_id\n" + |
|
31 |
" Left Join sys.extended_properties F On D.id= F.major_id\n" + |
|
32 |
" and F.minor_id= 0\n" + |
|
33 |
" where d.name= ? \n" + |
|
34 |
" Order By A.id,\n" + |
|
35 |
" A.colorder"; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
protected String pgSql() { |
|
40 |
return "SELECT a.attname as \"columnName\" , col_description(a.attrelid,a.attnum) as \"columnComment\"\n" + |
|
41 |
"FROM pg_class as c,pg_attribute as a " + |
|
42 |
"where c.relname = ? and a.attrelid = c.oid and a.attnum>0"; |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected String oracle() { |
|
47 |
return "select column_name as columnName, comments as columnComment from user_col_comments where Table_Name= ?"; |
|
48 |
} |
|
49 |
} |