How to Create, Use, and Drop a SQL Database ?

A database contains records, and to create, modify, or delete these records SQL queries are used. An SQL query can either be an action query like delete or create or a select query like select or use. These queries are used to find specific data, perform actions on it, or just display data by filtering based on specific criteria.

Interested in learning SQL? Enroll in our SQL Training now!

SQL Database Queries How to Create, Use, and Drop a SQL Database ? A database contains records, and to create, modify, or delete these records SQL queries are used. An SQL query can either be an action query like delete or create or a select query like select or use. These queries are

A database is an organized collection of data. How do we create or insert data into the database? Well, that’s done by writing a database query. In this SQL Database tutorial section, we will discuss the queries related to the SQL Database

How to Create a Database in SQL?

To Create a Database in SQL

Syntax:

CREATE DATABASE databasename;

where CREATE DATABASE is the keyword and databasename is the name of the database, followed by a semicolon.

Here are the steps how to Create a Database in SQL

  • Open the SQL software and create a new query by clicking on New Query
  • Type the syntax and give a name for your database (Here, we are creating a database ‘happy’)
CREATE DATABASE happy;
  • Then hit You will see that your commands are executed successfully, and your table is created.
  • Click on Refresh [ ] and you will find a database happy created in Object Explorer

Steps to Create a Database in SQL

How do we Use a SQL Database?

To Select and use a Database in SQL

Syntax:

USE databasename;

where USE is the keyword, and databasename is the name that we want to use (select it from the existing database names), followed by a semicolon.
Once the database is selected, it remains default until another USE statement with a different database is used. To check which database you’re using, place your mouse pointer over the file where you’re executing the query.

Visit our SQL Community to get answers to all your queries!

How to Select a Database?

  • Here in the above image, the default database is the previously selected as SPARATA
  • To select the ‘happy’ database, give the command
USE happy;
  • Hit Execute and the database is selected

Steps 2 to Create a Database in SQL

How do we Delete or Drop a SQL Database?

To delete a database

Syntax:

DROP DATABASE databasename;

where DROP DATABASE is the keyword and databasename is the name of the database we want to delete, followed by semicolon.

Get familiar with the top SQL Interview Questions to get a head start in your career!

Delete a SQL Database

  • Here, we are deleting the igneous database; hence give the following command:
DROP DATABASE igneous;
  • Then hit Execute and Click on Refresh [    ], and the igneous database would not be displayed on Object Explorer

Steps 3 to Create a Database in SQL
This bring us to the end of this SQL Database tutorial part. Now you’re ready to get started with creating and modifying your database! Now you know how to create a database in SQL. Meanwhile, there is a lot more you can do using SQL Database which we will see in the next tutorial sections.

Wish to get certified in SQL! Learn from our SQL expert and do excel in your career with intellipaat’s SQL certification.

Leave a Reply

Your email address will not be published. Required fields are marked *