第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

SQL中EXISTS怎么用

SQL中EXISTS怎么用

斯蒂芬大帝 2019-07-14 12:04:55
SQL中EXISTS怎么用
查看完整描述

2 回答

?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗(yàn) 獲得超12個(gè)贊

exists的用法如下:

1、判斷數(shù)據(jù)庫(kù)是否存在

if exists (select*fromsysdatabaseswherename= '數(shù)據(jù)庫(kù)名')

dropdatabase[數(shù)據(jù)庫(kù)名]

2、判斷表是否存在

if not exists (select * from sysobjects where [name] = '表名' and xtype='U')

begin

--這里創(chuàng)建表

end

3、判斷存儲(chǔ)過(guò)程是否存在

if exists (select*fromsysobjectswhereid = object_id(N'[存儲(chǔ)過(guò)程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)

dropprocedure[存儲(chǔ)過(guò)程名]

4、判斷視圖是否存在

(1)SQL Server 2000

IF EXISTS (SELECT*FROMsysviewsWHEREobject_id = '[dbo].[視圖名]'

(2)SQL Server 2005

IF EXISTS (SELECT*FROMsys.viewsWHEREobject_id = '[dbo].[視圖名]'

5、判斷函數(shù)是否存在

if exists (select*fromdbo.sysobjectswhereid = object_id(N'[dbo].[函數(shù)名]') and xtype in (N'FN', N'IF', N'TF'))

dropfunction[dbo].[函數(shù)名]

擴(kuò)展資料

SQL的提升

1、復(fù)制表(只復(fù)制結(jié)構(gòu),源表名:a 新表名:b) (Access可用)

法一:select * into b from a where 1<>1

法二:select top 0 * into b from a

2、拷貝表(拷貝數(shù)據(jù),源表名:a 目標(biāo)表名:b) (Access可用)

insert into b(x, y, z) select d,e,f from a;

3、跨數(shù)據(jù)庫(kù)之間表的拷貝(具體數(shù)據(jù)使用絕對(duì)路徑) (Access可用)

insert into b(x, y, z) select d,e,f from a in ‘具體數(shù)據(jù)庫(kù)’ where 條件

例子:。.from b in '"&Server.MapPath("."&"\data.mdb" &"' where..

4、子查詢(表名1:a 表名2:b)

select a,b,c from a where a IN (select d from b 或者: select a,b,c from a where a IN (1,2,3)

5、顯示文章最后時(shí)間

select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b




查看完整回答
反對(duì) 回復(fù) 2019-07-15
  • 2 回答
  • 0 關(guān)注
  • 292 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)