SQL Database

HTML
CSS
C#
SQL

SQL Database

What is Database?
A database is an organized collection of data so that it can be easily accessed and managed. You can organize data into tables, rows, and columns, and index it to make it easier to find relevant information. Database handlers create a database in such a way that only one set of software programs provides access to data to all the users. The main purpose of the database is to operate a large amount of information by storing, retrieving, and managing data. There are many dynamic websites on the World Wide Web nowadays which are handled through databases.

For example, a model that checks the availability of rooms in a hotel. It is an example of a dynamic website that uses a database.

What is RDBMS?
RDBMS stands for Relational Database Management Systems. All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and Microsoft Access are based on RDBMS. Data is represented in terms of tuples (rows) in RDBMS. Relational database is the most commonly used database. It contains several tables and each table has its primary key. Due to a collection of organized sets of tables, data can be accessed easily in RDBMS.

What is Data?
Data is a collection of a distinct small unit of information. It can be used in a variety of forms like text, numbers, media, bytes, etc. it can be stored in pieces of paper or electronic memory, etc. The word ‘Data’ originated from the word ‘datum’ which means ‘single piece of information.’ It is the plural of the word datum.

Create Database:

In SQL, the ‘Create Database’ statement is a first step for storing the structured data in the database.

The database developers and the users use this statement in SQL for creating the new database in the database systems. It creates the database with the name which has been specified in the Create Database statement.

CREATE DATABASE database_name;

In this syntax, Database_Name specifies the name of the database which we want to create in the system. We have to type the database name in query just after the ‘Create Database’ keyword.

The database we want to create should be a simple and unique name, which can be easily identified.

Rename Database:

In some situations, database users and administrators want to change the name of the database for some technical reasons. So, the Rename Database statement in SQL is used to change the name of the existing database.

Sometimes, the Rename Database statement is used because the developers think that the original name is not more relevant to the data of the database, or they want to give a temporary name to that database.

Example

ALTER DATABASE old_database_name MODIFY NAME = new_database_name; 

EXEC sp_renamedb’old_database_name’, ‘new_database_name’ 

Drop Database:

The SQL Drop Database statement deletes the existing database permanently from the database system. This statement deletes all the views and tables if stored in the database, so be careful while using this query in SQL.

This statement deletes all the data from the database. If you want to restore the deleted data in the future, you should keep the backup of the data of that database that you want to delete. Another important point is that you cannot delete that database from the system that is currently in use by another database user.

DROP DATABASE Database_Name; 

Select Database:

Suppose database users and administrators want to perform some operations on tables, views, and indexes on the specific existing database in SQL. Firstly, they have to select the database on which they want to run the database queries.

Any database user and administrator can easily select the particular database from the current database server using the USE statement in SQL.

USE database_name;  

Course Video

1.Write a sql query to create simple database.

2.Write sql query to rename the database from practice to newpractice.

3.Write sql query to rename the database from newpractice to practice without using Alter statement.

4.Write sql query to select the specific Database

5.Write a sql query to delete the database