bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat

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.

Check out this video on What is SQL Database and How to Create Database in SQL?

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.

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.

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.

Previous Next

Download Interview Questions asked by top MNCs in 2019?

"0 Responses on SQL Database Queries"

    Leave a Message

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
    top

    Sales Offer

    Sign Up or Login to view the Free SQL Database Queries.