線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1018
推到 Plurk!
推到 Facebook!

請問有SQL指令可以找出是否己存在該資料庫嗎?

答題得分者是:tech_state
saam
初階會員


發表:61
回覆:75
積分:27
註冊:2003-03-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-23 01:31:24 IP:218.174.xxx.xxx 未訂閱
請問各位先進: 如果我想刪除一個資料庫前,是否有有SQL指令可以 先找出是否己有該資料庫,有才做drop database的 SQL指令,我使用的是MySQL, 我知道MS SQL好像可以 使用if exists() 這個方式
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-23 10:18:54 IP:61.221.xxx.xxx 未訂閱
引言: 請問各位先進: 如果我想刪除一個資料庫前,是否有有SQL指令可以 先找出是否己有該資料庫,有才做drop database的 SQL指令,我使用的是MySQL, 我知道MS SQL好像可以 使用if exists() 這個方式
saam, 您好 可以試試這個指令 drop database [if exists] database_name 我對My SQL不熟 如果不行的話 就要請其他前輩高手幫忙囉 ============ 是非終日有 不聽自然無
saam
初階會員


發表:61
回覆:75
積分:27
註冊:2003-03-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-23 13:08:20 IP:211.75.xxx.xxx 未訂閱
謝謝tech_state大大: 在下試了以上的方式還是不行, 有其他先進可給我指導嗎?
timhuang
尊榮會員


發表:78
回覆:1815
積分:1608
註冊:2002-07-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-04-23 21:06:26 IP:61.221.xxx.xxx 未訂閱
在 my sql 的 help 有寫... 就是 tech_state前輩寫的沒錯, 只是 if exists 是選擇性參數, 所以正確要檢查已存在的話, 就直接下: DROP DATABASE IF EXISTS test_db 就可以了. --------------------- 6.5.2 DROP DATABASE Syntax DROP DATABASE [IF EXISTS] db_name DROP DATABASE drops all tables in the database and deletes the database. If you do a DROP DATABASE on a symbolic linked database, both the link and the original database is deleted. Be VERY careful with this command! DROP DATABASE returns the number of files that were removed from the database directory. Normally, this is three times the number of tables, because normally each table corresponds to a `.MYD' file, a `.MYI' file, and a `.frm' file. The DROP DATABASE command removes from the given database directory all files with the following extensions: All subdirectories that consists of 2 digits (RAID directories) are also removed. In MySQL Version 3.22 or later, you can use the keywords IF EXISTS to prevent an error from occurring if the database doesn't exist. 發表人 - timhuang 於 2003/04/23 21:08:25
saam
初階會員


發表:61
回覆:75
積分:27
註冊:2003-03-03

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-24 00:23:26 IP:218.174.xxx.xxx 未訂閱
謝謝二位先進的指導~ 唉呀~~~原來如此,  是我自己呆呆會錯意 tech_state大大 的方式是對的 , 我自己連[]都打下去難怪 不會過, 感謝 timhuang 大大告訴我, 不然誤會就大了!
系統時間:2024-04-17 4:12:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!