SQL Server Tutorials - CREATE, ALTER, DROP database in SQL Server - #2

Published: 19 March 2024
on channel: Everyday Be Coding
17
0

SQL Server Tutorials - CREATE, ALTER, DROP database in SQL Server

To create, alter, and drop a SQL Server database, you'll typically use SQL commands within SQL Server Management Studio (SSMS) or another SQL client. Below are the steps for each operation:

1. Creating a Database:
To create a new database in SQL Server, you use the CREATE DATABASE statement. Here's an example:

CREATE DATABASE YourDatabaseName;
Replace YourDatabaseName with the desired name for your database.

2. Altering a Database:
You can alter a database to modify its properties. For instance, you might want to change its collation, set options, or modify file properties. Here's an example of altering the database collation:

ALTER DATABASE YourDatabaseName
COLLATE Latin1_General_CI_AS; -- Change collation to case-insensitive, accent-sensitive
3. Dropping a Database:
Dropping a database permanently removes it and its contents from the SQL Server instance. This operation cannot be undone, so use it with caution.

DROP DATABASE YourDatabaseName;
Example:
Let's put it all together:

Creating a Database:

CREATE DATABASE ExampleDB;
Altering the Database:

For example, changing the database collation:

ALTER DATABASE ExampleDB
COLLATE Latin1_General_CI_AS;
Dropping the Database:

DROP DATABASE ExampleDB;

Make sure to execute these statements in a SQL query window or execute them through a script in SQL Server Management Studio (SSMS) or any other SQL client. Always exercise caution, especially when dropping a database, as it permanently deletes all its data.

Chapter :
00:00 Intro
00:15 Creating a Database
00:40 Altering a Database
01:10 Dropping a Database
01:30 Summery

Thanks
EVERYDAY BE CODING


On this page of the site you can watch the video online SQL Server Tutorials - CREATE, ALTER, DROP database in SQL Server - #2 with a duration of hours minute second in good quality, which was uploaded by the user Everyday Be Coding 19 March 2024, share the link with friends and acquaintances, this video has already been watched 17 times on youtube and it was liked by 0 viewers. Enjoy your viewing!