Introduction
There are many ways to create a database and many applications exist to handle them, one of them is from the command prompt. Generally, SQL is used for the manipulation of data from the database.
What is SQL?
SQL stands for Structured Query Language. It is the programming language that communicates to the databases. SQL has often pronounced Sequel basically, SQL is used to store data, retrieve data, manage data, and manipulate the data within a DBMS. The SQL shows data in a table format. SQL used keywords for performing sets of operations and these keywords are called statements.
How to execute SQL statements from command prompt?
Step 1
To Install a SQL Server or XAMPP Server.
![]()
Step 2
To open a command prompt from windows explorer and go to the MySQL Server bin folder and type from folder path section cmd then enter.
![]()
before executing SQL statements we start XAMPP Server.
![]()
Step 3
Now we check whether SQL is installed properly or not.
mysql -u root -p
![]()
By default SQL Server password is blank. If you have created a password, enter your password otherwise, press enter. It generates a response Welcome message which means SQL is installed properly.
Step 4
Now we create a new database, it is very easy to create a new database, write CREATE DATABASE and the name of the database.
create database article;
![]()
check whether the Article database creates or not.
show databases;
![]()
Step 5
Here we use the article database.
use article;
![]()
Step 6
We create a new table whose name will be the user table.
![]()
we check whether the user table is created or not.
show tables;
![]()
If you want to see the description of the table
desc user;
![]()
Step 7
If you want to change the table using alter table.
alter table user add age int(5);
![]()
Show description of the changing table
desc user;
![]()
Step 8
Let's take a look at some of the statements available in SQL
Insert
Insert statements allows for adding new information to a table.
insert into user values(1, 'Naman', 'Delhi', 28);
the select statement shows the table data
Multi-Row Insert
If you want to add multiple rows at a time.
insert into user values(2,'Naman','Delhi',28),(3,'Vinod','Lucknow',26),(4,'Rajat','Unnao',30),(5,'Shailja','Fatehpur',24);
![]()
Update
An update statement is used to update one or more records within a table.
update user set city='Kanpur' where id=2;
![]()
Delete
Delete statement allows removing data from a table.
delete from user where id=5;
![]()
Conclusion
The SQL is directly Communicated to the RDBMS.
Simplify query commands
Enhance programming productivity
Contain most current base table data
Use little storage space