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
En esta página del sitio puede ver el video en línea SQL Server Tutorials - CREATE, ALTER, DROP database in SQL Server - #2 de Duración hora minuto segunda en buena calidad , que subió el usuario Everyday Be Coding 19 marzo 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 17 veces y le gustó 0 a los espectadores. Disfruta viendo!