Prerequisite oralce, mybatis
Now there are multiple tables
I now need to count the amount of information in each table, that is, count(*)
My current method is to write multiple methods
For example, in mapper:
long selectCountA;
long selectCountB;
long selectCountC;
In this case, I have to check it three times in the database. Obtain 3 pieces of data respectively
I wonder if I can write a sql statement to directly obtain three values
Solution?
. Can you give me an oracle statement? It's all mysql. .
巴扎黑2017-05-18 10:47:06
select "a" name, count(1)
from tableA
union
select "b" name, count(1)
from tableB
union
select "C" name, count(1)
from tableC
Use multi-column writing method
with
temp_a as (select count(*) num from talbeA),
temp_b as (select count(*) num from tableB),
temp_c as (select count(*) num from tableC)
select temp_a.num, temp_b.num, temp_c.num from dual;
PHPz2017-05-18 10:47:06
select A.countA,B.countB from (select count(*) as countA from t_countA) as A ,(select count(*) as countB from t_countB) as B
Like this?
某草草2017-05-18 10:47:06
Mysqlselect table_rows from information_schema.TABLES where table_schema in ('schema1','schema2','scheman') and table_name in ('tableName1','tableName2','tableNameN')
I believe oralce also has a similar system table