我的多个数据库中有多个表。
在不同的服务器上,我使用 MySQL / PostgreSQL / MS SQL。
我保留简短的表名
但对表的注释有完整的解释。
我想要的查询将显示以“com”结尾的表以及对每个表的注释(表的注释)。
在MySQL中,我知道:
SELECT table_name FROM information_schema.tables where table_name like "%com"
但这显示了所有数据库中的所有表。
对于 MySQL,请查看以下内容:
SELECT table_name FROM information_schema.tables;
SELECT table_name,table_comment FROM information_schema.tables
SELECT * FROM information_schema.tables;
SELECT table_name,table_comment FROM information_schema.tables
where
table_schema = 'sifr_b';
将显示“sifr_b”数据库中的所有表名+注释;
SELECT table_name,table_comment FROM information_schema.tables
where
table_schema = 'sifr_b' and
table_name like "%com";
将显示“sifr_b”数据库中那些表名+注释,其表名以“com”结尾;
SET @tables = NULL;
SET foreign_key_checks = 0;
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name,'`') INTO @tables
FROM information_schema.tables
WHERE table_schema = 'schemaname' and table_name LIKE BINARY 'text_match%';
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt1 FROM @tables;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
SET foreign_key_checks = 1;
-- Bypassing foreign key constraint since table are not sorted.