久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機(jī)端+微網(wǎng)站+自適應(yīng)網(wǎng)頁多模板選擇-建站388元起價(jià)!!!
當(dāng)前位置:主頁 > 網(wǎng)站建設(shè) > sqlserver 各種判斷是否存在(表名、函數(shù)、存儲過程

sqlserver 各種判斷是否存在(表名、函數(shù)、存儲過程

時(shí)間:2023-05-23 22:05:23 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: 網(wǎng)絡(luò)小編

導(dǎo)讀:1建站知識在sql server中,如何判斷sql server表是否存在呢?下面就將為您詳細(xì)介紹該方法,供您參考,希望對您加深理解sql serv企業(yè)網(wǎng)站建設(shè)seo網(wǎng)站優(yōu)化軟件。

企業(yè)網(wǎng)站建設(shè)seo網(wǎng)站優(yōu)化軟件

sql server中如何判斷表或者數(shù)據(jù)庫的存在,但在實(shí)際使用中,需判斷Status狀態(tài)位:其中某些狀態(tài)位可由用戶使用 sp_dboption(read only、dbo use only、single user 等)進(jìn)行設(shè)置:

1 = autoclose;使用 sp_dboption 設(shè)置。 數(shù)據(jù)庫完全關(guān)閉,其資源在最后一個(gè)用戶注銷后釋放。4 = select into/bulkcopy;使用 sp_dboption 設(shè)置。允許使用 Select INTO 語句和快速大容量復(fù)制。8 = trunc. log on chkpt;使用 sp_dboption 設(shè)置。如果數(shù)據(jù)庫處于日志截?cái)嗄J剑瑒t檢查點(diǎn)將截?cái)嗳罩局蟹腔顒拥牟糠帧V荒転?master 數(shù)據(jù)庫設(shè)置此選項(xiàng)。16 = torn page detection,使用 sp_dboption 設(shè)置。可以檢測殘缺頁。32 = loading。64 = pre recovery。128 = recovering。256 = not recovered。512 = offline;使用sp_dboption 設(shè)置。數(shù)據(jù)庫將處于脫機(jī)狀態(tài)。1024 = read only;使用 sp_dboption 設(shè)置。用戶僅能讀取數(shù)據(jù)庫中的數(shù)據(jù)而無法對其進(jìn)行修改。2048 = dbo use only;使用sp_dboption 設(shè)置。只有數(shù)據(jù)庫所有者可以使用數(shù)據(jù)庫。4096 = single user;使用 sp_dboption 設(shè)置。每次只能有一個(gè)用戶訪問數(shù)據(jù)庫。32768 = emergency mode。4194304 = autoshrink。1073741824 = cleanly shutdown。

可以同時(shí)打開多個(gè)位。

譬如:判斷一個(gè)數(shù)據(jù)庫是否offlineselect * From master.dbo.sysdatabases where and status<>512

SQL Server中判斷表對象是否存在:select count(*) from sysobjects where id = object_id('數(shù)據(jù)庫名.Owner.表名')

if exists(select count(*) from sysobjects where id = object_id('數(shù)據(jù)庫名.Owner.表名'))print '存在'elseprint '不存在'

SQL Server中判斷表中字段是否存在:if exists(select * from syscolumns where and id=object_id('數(shù)據(jù)庫名.Owner.表名'))print '存在網(wǎng)站建設(shè)教程'elseprint '不存在'代表表tablename1中存在colname1字段例:sseo網(wǎng)站優(yōu)化培訓(xùn)elect * from syscolumns where and id=object_id('dbo.test')

Access中判斷表對象是否存在:其實(shí),Access數(shù)據(jù)庫也有系統(tǒng)表,存放有對象名Select Count(*) AS Qty FROM MSysObjects Where ((MSysObjects.Name) Like '表名');

復(fù)制代碼 代碼如下:

庫是否存在 if exists(select * from master..sysdatabases where name=N'庫名') print 'exists'elseprint '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 Nulseo網(wǎng)站優(yōu)化lBeginprint '存在'EndElseBeginprint '不存在'End--------------- -- 判斷要?jiǎng)?chuàng)建的存儲過程名是否存在 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[存儲過程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) -- 刪除存儲過程 drop procedure [dbo].[存儲過程名] 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) 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 nullprint '不存在'select 1 from sysobjects where id in (select id from syscolumns where) and

關(guān)鍵詞標(biāo)簽: 函數(shù) 存儲過程

聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-23 ,文章sqlserver 各種判斷是否存在(表名、函數(shù)、存儲過程主要講述存儲過程,函數(shù),sqlserver 各種判斷是否存在(表名、網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_6067.html

我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計(jì)制作搭建開發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開發(fā)案例,網(wǎng)站推廣技術(shù)服務(wù)。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗(yàn)
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 开化县| 怀安县| 星座| 绥江县| 来凤县| 新宾| 宁晋县| 景宁| 麻江县| 宜良县| 永仁县| 吴堡县| 英山县| 梓潼县| 兴隆县| 平远县| 恭城| 仁化县| 图们市| 元谋县| 霍林郭勒市| 安多县| 鲜城| 南昌市| 汉寿县| 台东县| 林西县| 邓州市| 东莞市| 迭部县| 和硕县| 建平县| 西吉县| 历史| 德保县| 昌乐县| 仙居县| 洛扎县| 繁峙县| 唐山市| 阳江市|