top of page

CREATE, ALTER and DROP SQL Database | SQL Server Tutorial

Schema management in MS SQL Server involves creating, altering, and dropping database schema elements such as tables, views, stored procedures, and indexes. It ensures that the database structure is optimized for data storage and retrieval.

In this article, we will be discussing schema and how to create, alter, and drop the schema.




Create ALTER and DROP SQL Database






1 - SQL CREATE DATABASE


The CREATE DATABASE statement is a foundational SQL command used to create new databases in SQL-based Database Management Systems (DBMS), including MySQL, PostgreSQL, SQL Server, and others. Understanding how to use this command effectively is crucial for developers, database administrators, and anyone working with relational databases.

In this article, we’ll provide a comprehensive overview of how to use the CREATE DATABASE command effectively. We will begin with the basics, explaining the syntax and structure of the command.

Syntax:-

CREATE DATABASE database_name;

Example:-

SQL Query: CREATE DATABASE SoliTeh;



2 - SQL DROP DATABASE


The DROP DATABASE command in SQL is used to completely delete a database and all of its objects, such as tables, indexes, views, and other dependent objects. Once executed, this operation cannot be undone, so it's crucial to back up the database before performing this action.

Syntax:-

DROP DATABASE database_name;

Example:-

SQL Query: DROP DATABASE SoliTeh;


3 - SQL Query to Rename Database


To rename a database in SQL, you’ll need to use the ALTER DATABASE command. The syntax varies slightly between different SQL platforms, but the core functionality remains the same. The ALTER DATABASE statement allows you to modify the properties of a database, including its name.

Syntax:-

ALTER DATABASE [current_database_name]


MODIFY NAME = [new_database_name];

Example:-

SQL Query: Alter DATABASE SoliTeh MODIFY NAME Test;



Summary


From the preceding all examples we have learned how to CREATE, ALTER and DROP SQL Database . I hope you understand it.

 
 
 

Comments


bottom of page