判斷數據庫中的“存在”

 一、判斷該數據庫中該表是否存在

sqlserver:

select count(*) from SysObjects where XType='U' and name ='table'

XType='U' 可以不要

 

二、判斷該數據庫中的某個字段是否存在

sqlserver:

select count(1) from syscolumns where id=object_id('表名') and name='字段名'

oracle:

select count(column_name) from cols where table_name = upper('表名') and column_name = upper('字段名')




 

發佈了29 篇原創文章 · 獲贊 29 · 訪問量 41萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章