渗透经验
数据库利用
Mysql
Mssql
Oracle
PostgreSQL
Redis
查询关键字段记录数量
-
+
首页
查询关键字段记录数量
目标:<span style="font-family:楷体">==根据系统视图联合查询包含phone字段的列名、数据量大于阈值、表名、schema、数据库名,并按数据量排序。==</span> 返回数据格式:schema-table-column-rows mssql ```sql SELECT t.TABLE_SCHEMA as 'TABLE_SCHEMA',a.name as 'TABLE_NAME', c.COLUMN_NAME, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id INNER JOIN information_schema.columns c on a.name = c.TABLE_NAME INNER JOIN information_schema.tables t on a.name = t.TABLE_NAME WHERE (a.type = 'u') AND (b.indid IN (0, 1)) and (c.COLUMN_NAME like '%phone%') and (b.rows > 100) ORDER BY b.rows DESC ``` mysql ```sql SELECT t.table_schema AS 'schema', t.table_name AS 'table', c.COLUMN_NAME AS 'column', t.table_rows AS 'rows' FROM information_schema.TABLES t left join information_schema.COLUMNS c on c.table_name = t.table_name WHERE c.COLUMN_NAME like '%phone%' and t.table_rows > 100 group by t.table_schema, t.table_name, c.COLUMN_NAME, t.table_rows order by t.table_rows desc ``` oracle ```sql select s.username "schema",t.table_name "table",c.column_name "column_name",t.num_rows "num_rows" from sys.dba_users s right join sys.dba_tables t on s.username=t.owner right join all_tab_columns c on c.table_name=t.table_name where t.num_rows > 100 and c.column_name like '%PHONE%' group by s.username,t.table_name,c.column_name,t.num_rows order by 4 desc ``` postgres ```sql SELECT c.table_schema,c.table_name,c.column_name,t.n_live_tup FROM pg_stat_user_tables as t inner join information_schema.columns as c on c.table_name = t.relname where c.column_name like '%PHONE%' and t.n_live_tup >100 ORDER BY t.n_live_tup DESC ``` # References - https://mp.weixin.qq.com/s/rpmrFOlHyRcTw4FctRxqFg
admin
2022年3月13日 20:16
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 睿文
如果睿文给你带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护文档,感谢你的捐助!
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码