drop database [数据库名] if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] 2 判断表是否存在 Sql代码 if exists (select * from sysobjects where id = object_id(N’[表名]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1) drop table [表名]...
DROP DATABASE:表示删除数据库的操作。 IF EXISTS:是一个可选的子句,用于检查数据库是否存在。如果存在,执行删除操作;如果不存在,不会报错。 database_name:要删除的数据库的名称。 以下是一个简单的例子,假设要删除名为 my_database 的数据库: 实例 DROPDATABASEIFEXISTSmy_database; 在执行DROP DATABASE之前,...
判断数据库是否存在if exists (select*fromsysdatabaseswherename= '数据库名')dropdatabase[数据库名]2...
drop function [dbo].[函数名] -- 判断要创建的函数名是否存在 if exists (select * from dbo.sysobjects where id = object_id(N’[dbo].[函数名]’) and xtype in (N’FN’, N’IF’, N’TF’)) drop function [dbo].[函数名] 7 获取用户创建的对象信息 Sql代码 SELECT [name],[id],crdat...
DROP DATABASE IF EXISTS DataBase_Name; If the database exists, then the query will remove the database from the SQL Server, but if the database doesn't exist, the warning output is displayed. Example 1:Write a query to remove the database with the IF EXISTS parameter. ...
SQL Server Drop Database To drop a database in SQL Server, use the Drop Database command: DROPDATABASE[IFEXISTS]{database_name|database_snapshot_name}; You can run this when you are connected to your server. The IF EXISTS keyword is optional and will drop the database if it exists....
DROPDATABASE[IFEXISTS] {database_name|database_snapshot_name} [ ,...n ] [ ; ] Azure SQL 数据库、Azure Synapse Analytics 和 Analytics Platform System 语法。 syntaxsql DROPDATABASEdatabase_name[ ; ] 参数 IF EXISTS 适用于:SQL Server 2016 (13.x) 及更高版本 ...
1 判断 数据库是否存在 Sql代码 if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] if exists (select * from sys.databases where name = ’数据库名’) drop databa…
Drop Database 该语句用于删除数据库(database) 语法: DROP DATABASE [IF EXISTS] db_name; 举例: 删除数据库 db_test DROP DATABASE db_test; Drop Table 该语句用于删除表(table) 语法: DROP TABLE [IF EXISTS] [db_name.]table_name; 举例: 1.删除一个 table DROP TABLE my_table; 2.如果存在,删...