如下表名:
aaa,bb,cc,ccs,dds,csdf,csdfs,sdfa,werwe,csdfsd
在MySQL库中,查询哪些表名在数据库中
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'your_database_name_here'
AND table_name IN ('aaa', 'bb', 'cc', 'ccs', 'dds', 'csdf', 'csdfs', 'sdfa', 'werwe', 'csdfsd');
'your_database_name_here':替换为实际的数据库
MySQL库中,查询哪些表不在数据库中
SELECT table_name
FROM
(
SELECT 'aaa' AS table_name UNION
SELECT 'bb' UNION
SELECT 'cc' UNION
SELECT 'ccs' UNION
SELECT 'dds' UNION
SELECT 'csdf' UNION
SELECT 'csdfs' UNION
SELECT 'sdfa' UNION
SELECT 'werwe' UNION
SELECT 'csdfsd'
) AS tables_to_check
WHERE table_name NOT IN
(
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'your_database_name_here'
);
'your_database_name_here':替换为实际的数据库
达梦库需要登陆指定模式的帐号,这样才不会出错。
达梦库中,查询哪些表名在数据库中
SELECT OBJECT_NAME
FROM user_objects
WHERE object_type='TABLE'
AND OBJECT_NAME IN ('aaa', 'bb', 'cc', 'ccs', 'dds', 'csdf', 'csdfs', 'sdfa', 'werwe', 'csdfsd');
达梦库中,查询哪些表不在数据库中
SELECT table_name
FROM
(
SELECT 'aaa' AS table_name UNION
SELECT 'bb' UNION
SELECT 'cc' UNION
SELECT 'ccs' UNION
SELECT 'dds' UNION
SELECT 'csdf' UNION
SELECT 'csdfs' UNION
SELECT 'sdfa' UNION
SELECT 'werwe' UNION
SELECT 'csdfsd'
) AS tables_to_check
WHERE table_name NOT IN
(
SELECT table_name
FROM user_objects
WHERE object_type='TABLE'
);