This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13791|Reply: 0

[Tips] Determine whether there is a database in the sql, and delete it if it exists

[Copy link]
Posted on 10/10/2014 9:16:41 AM | | |
When we are novices creating a new database, there is no design instruction
You may need to recreate the database several times


If there is already a database in SQL when creating a new database,

Do we need to delete it little by little, it's very troublesome

Therefore, it is best to add a piece of code before creating a database to determine whether there is a change in the sql

Delete the database if it exists, the code is as follows:

  1. --判断数据库是否存在,存在则删除
  2. use master
  3. if exists (select * from sysdatabases where name='xxx' )
  4. drop database xxx
Copy code






Previous:Who needs to reinstall a computer system?
Next:【Original】Virtual machine installation RED_HAT_linux system installation tutorial
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com