Understanding Queries and Creating Database
Hello, and welcome to the blog. In this blog we are going to talk about "Queries" in database.
As we discussed in my previous blog ( https://learntocodewithmustafapinjari.blogspot.com/2020/07/basics-of-sql.html) that SQL is used for performing different operations on database. But how SQL do it?
It is actually actually done by "Queries". Don't worry here "Query" doesn't meant doubt. In this blog we will talk about :
- What is a Query?
- Types of Query.
- Creating our database with the help of query.
Let's start with
1) What is Query?
- Query is nothing but a statement or instruction to communicate with manipulate database or to manipulate database.
- By using queries you can create a database, insert values in table, update those values, delete rows and many more operations can be performed.
2) Types of Query.
There are 5 types of query:
- DDL : Data Definition Language.
- DML : Data Manipulation Language.
- DCL : Data Control Language.
- TCL : Transaction Control Language.
- DQL : Data Query Language.
DDL
- DDL includes commands like Create, Alter, Drop, Trucate. DDL is used for manipulating database and database tables.
- For example: creating database, creating tables, deleting table, adding column in table , renaming a table column, etc.
DML
- DML includes commands like insert, update and delete.
- DML is used for inserting records in the table, updating and deleting records present in the table.
DCL
- DCL includes commands like "Grant" and "Revoke".
- These commands are used for granting and taking back authority from any database user.
TCL
- TCL includes commands like "Commit", "Rollback" and "Savepoint".
- These commands are transaction specific. We will have a detailed blog coming up for these 2 commands and transaction.
DQL
- DQL has only one command i.e "Select".
- This command is used for retriving data from the database.
3) Creating our first Database.
- Now we are done with understanding queries. So let's create our first database and eventually we are going write our first query.
- Here goes the syntax: create database database_name
- Example: create database EmployeeManagementSystem
- You can use any DBMS Software you want I am using "Microsoft SQL Server".
- Just go to your DBMS Software and then press "ctrl + N" or click on "New Query". Then a window will open. You have to type "create database EmployeeManagementSystem" in the window and your database will be created.
Note: While naming database and database table make sure there is no blank space in any word or character.
Congratulations on creating your first database. Now we are all set to creating tables and handling data. See you in some another blog till then "Keep coding, keep learning because trust me you can make it big".
"Have a great day".
ReplyDeleteVery informative 👍