테이블과 필드의 존재 여부를 확인하기 위해 일반적으로 사용되는 데이터베이스 쿼리용 SQL(결과가 1이면 존재함, 0은 존재하지 않음)
MSSQL Server
테이블. :
SELECT COUNT(*) FROM dbo.sysobjects WHERE name= 'table_name';
필드:
SELECT COUNT(*) FROM syscolumns WHERE id=object_id(‘table_name’) AND name= 'column_name';
2.My SQL
테이블:
SELECT COUNT(*) FROM information_schema.tables WHERE table_name ='table_name';
필드:
SELECT COUNT(*) FROM information_schema.columns WHERE table_name ='table_name' AND column_name ='column_name';
3. Oracle
테이블:
SELECT count(*) FROM USER_OBJECTS WHERE OBJECT_NAME = 'table_name';
필드:
SELECT COUNT(*) FROM USER_TAB_COLUMNS WHERE TABLE_NAME ='table_name' AND column_name ='column_name';
4. PostgreSql
테이블:
SELECT count(*) FROM information_schema.tables WHERE table_schema='table_schema' AND table_name ='table_name';
필드:
SELECT count(*) FROM information_schema.columns WHERE table_schema='table_schema' AND table_name ='table_name' AND column_name='column_name';