MySQL常用查询

1.查询数据库下所有表名、描述、大小

SELECT 
TABLE_NAME 表名,
TABLE_COMMENT 表注释,
TABLE_ROWS 数据量,
CONCAT(ROUND(data_length/1024/1024, 2), ' MB') AS '表大小 (MB)',
engine 存储引擎
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'demo' 
ORDER BY TABLE_NAME;

2.创建临时表

CREATE TEMPORARY TABLE temp_product
(
    code VARCHAR(50)
);

insert into temp_product
values ('3bd9d6fc-1da5-4bac-ada8-7cbdcd514e98'),
       ('5d9dcc7b-1920-469f-9593-0b36f4ca40ea'),
       ('5d9dcc7b-1920-469f-9593-0b');


select tp.code,sp.src_product_ref,entity_name FROM  temp_product tp
left join src_product sp
on tp.code=sp.src_product_ref

你可能感兴趣的:(数据库,mysql,数据库)