简单实用:Oracle/Sqlserver/Sqlite 判断某张表是否存在的SQL语句

阅读更多
简单实用:Oracle/Sqlserver/Sqlite 判断某张表是否存在的SQL语句
1.Oracle

SELECT COUNT(*) as count
FROM all_tables
WHERE table_name= 'tablename'
不存在返回0

2.Sqlserver

SELECT COUNT(*)
FROM sys.objects
WHERE object_id = OBJECT_ID(N'tablename') AND type in (N'U')
不存在放回0

3.Sqlite

SELECT COUNT(*) as count
FROM sqlite_master
WHERE type='table' and name= 'tablename'
不存在放回0

你可能感兴趣的:(sqlite,oracle,sqlserver)