婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > sql 判斷數(shù)據(jù)庫(kù),表,存儲(chǔ)過程等是否存在的代碼

sql 判斷數(shù)據(jù)庫(kù),表,存儲(chǔ)過程等是否存在的代碼

熱門標(biāo)簽:申請(qǐng)400電話在哪辦理流程 外呼運(yùn)營(yíng)商線路收費(fèi) 臨沂智能電銷機(jī)器人加盟哪家好 貴州房產(chǎn)智能外呼系統(tǒng)供應(yīng)商 小e電話機(jī)器人 電銷外呼有錄音系統(tǒng)有哪些 百度地圖標(biāo)注改顏色 鎮(zhèn)江網(wǎng)路外呼系統(tǒng)供應(yīng)商 一個(gè)導(dǎo)航軟件能用幾個(gè)地圖標(biāo)注點(diǎn)

代碼:

--庫(kù)是否存在
if exists(select * from master..sysdatabases where name=N'庫(kù)名')
print 'exists'
else
print 'not exists'
---------------
-- 判斷要?jiǎng)?chuàng)建的表名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
-- 刪除表
drop table [dbo].[表名]
GO
---------------
-----列是否存在
 IF COL_LENGTH( '表名','列名') IS NULL
  PRINT 'not exists'
ELSE
 PRINT 'exists'
alter table 表名 drop constraint 默認(rèn)值名稱
go
alter table 表名 drop column 列名
go
-----
--判斷要?jiǎng)?chuàng)建臨時(shí)表是否存在
If Object_Id('Tempdb.dbo.#Test') Is Not Null
Begin
print '存在'
End
Else
Begin
print '不存在'
End
---------------
-- 判斷要?jiǎng)?chuàng)建的存儲(chǔ)過程名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[存儲(chǔ)過程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
-- 刪除存儲(chǔ)過程
drop procedure [dbo].[存儲(chǔ)過程名]
GO
---------------
-- 判斷要?jiǎng)?chuàng)建的視圖名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[視圖名]') and OBJECTPROPERTY(id, N'IsView') = 1)
-- 刪除視圖
drop view [dbo].[視圖名]
GO
---------------
-- 判斷要?jiǎng)?chuàng)建的函數(shù)名是否存在
if exists (select * from sysobjects where xtype='fn' and name='函數(shù)名')
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[函數(shù)名]') and xtype in (N'FN', N'IF', N'TF'))
-- 刪除函數(shù)
drop function [dbo].[函數(shù)名]
GO
if col_length('表名', '列名') is null
print '不存在'
select 1 from sysobjects where id in (select id from syscolumns where name='列名') and name='表名'

sql判斷是否存在

--判斷數(shù)據(jù)庫(kù)是否存在 
if exists(select * from master..sysdatabases where name=N'庫(kù)名') 
print 'exists' 
else 
print 'not exists' 

--------------- 
-- 判斷要?jiǎng)?chuàng)建的表名是否存在 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
-- 刪除表 
drop table [dbo].[表名] 
GO 

--------------- 
--判斷要?jiǎng)?chuàng)建臨時(shí)表是否存在 
If Object_Id('Tempdb.dbo.#Test') Is Not Null 
Begin 
print '存在' 
End 
Else 
Begin 
print '不存在' 
End 

--------------- 
-- 判斷要?jiǎng)?chuàng)建的存儲(chǔ)過程名是否存在 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[存儲(chǔ)過程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) 
-- 刪除存儲(chǔ)過程 
drop procedure [dbo].[存儲(chǔ)過程名] 
GO 

--------------- 
-- 判斷要?jiǎng)?chuàng)建的視圖名是否存在 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[視圖名]') and OBJECTPROPERTY(id, N'IsView') = 1) 
-- 刪除視圖 
drop view [dbo].[視圖名] 
GO 

--------------- 
-- 判斷要?jiǎng)?chuàng)建的函數(shù)名是否存在 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[函數(shù)名]') and xtype in (N'FN', N'IF', N'TF')) 
-- 刪除函數(shù) 
drop function [dbo].[函數(shù)名] 
GO 

if col_length('表名', '列名') is null 
print '不存在' 

select 1 from sysobjects where id in (select id from syscolumns where name='列名') and name='表名' 
您可能感興趣的文章:
  • Sql Server中判斷表、列不存在則創(chuàng)建的方法
  • Mysql判斷表字段或索引是否存在
  • sql server判斷數(shù)據(jù)庫(kù)、表、列、視圖是否存在
  • 用SQL語(yǔ)句查找Access中某表是否存在的小技巧
  • MySql獲取某個(gè)字段存在于哪個(gè)表的sql語(yǔ)句
  • sqlserver 各種判斷是否存在(表名、函數(shù)、存儲(chǔ)過程等)
  • oracle用什么SQL語(yǔ)句判斷表存不存在
  • SQL判斷字段列是否存在的方法
  • Oracle判斷表、列、主鍵是否存在的方法

標(biāo)簽:延邊 合肥 保定 晉城 澳門 三明 嘉興 日照

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《sql 判斷數(shù)據(jù)庫(kù),表,存儲(chǔ)過程等是否存在的代碼》,本文關(guān)鍵詞  sql,判斷,數(shù)據(jù)庫(kù),表,存儲(chǔ),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《sql 判斷數(shù)據(jù)庫(kù),表,存儲(chǔ)過程等是否存在的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于sql 判斷數(shù)據(jù)庫(kù),表,存儲(chǔ)過程等是否存在的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 城步| 兴业县| 桦甸市| 武穴市| 章丘市| 应城市| 舟山市| 孟津县| 乌鲁木齐市| 玛纳斯县| 沧州市| 于田县| 洛浦县| 佳木斯市| 陆河县| 苏尼特左旗| 格尔木市| 柳林县| 广丰县| 石门县| 江津市| 宁城县| 科技| 长葛市| 什邡市| 门头沟区| 抚松县| 全州县| 岑溪市| 定安县| 上高县| 隆子县| 突泉县| 辰溪县| 清河县| 泊头市| 金门县| 临桂县| 仁寿县| 梓潼县| 长治县|