mysql 库表整体相关查询
Posted sfth
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 库表整体相关查询相关的知识,希望对你有一定的参考价值。
select table_schema,table_name from information_schema.columns where column_name = '字段名';
- 查询某张表有几条记录
select count(*) FROM gasmis_shangxian.his_fuel_record;
- 查询某几张表一个有多少条记录
SELECT SUM(a) from(SELECT COUNT(*) a FROM gasmis_shangxian.his_fuel_record
UNION
SELECT COUNT(*)a FROM gasmis_shangxian.his_account_journal
UNION
SELECT COUNT(*) a FROM gasmis_shangxian.his_oilsys_fuel_record) as aa
- 查询某个字段属于哪个库
- > select table_schema,table_name from information_schema.columns where column_name = '字段名'
- 批量更新某个主键,使其值增1,直接
update
会主键冲突,使用order by (神奇的order by 用法)
UPDATE normalflow_list
SET flow_seqno = flow_seqno + 1
WHERE
flow_id = '010101'
AND flow_seqno > 2
ORDER BY
flow_seqno DESC;
获取某一列的最大值
select max(volumu) from table_name select max(flow_seqno) from normalflow_list where flow_id = '010101';
以上是关于mysql 库表整体相关查询的主要内容,如果未能解决你的问题,请参考以下文章