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 with the databases. SQL has often pronounced Sequel. SQL stores, retrieve, manages, and manipulates data within a DBMS. The SQL shows data in a table format. SQL uses keywords for performing sets of operations, and these keywords are called statements.
How to execute SQL statements from the command prompt?
Step 1
To Install a SQL Server or XAMPP Server.
![]()
Step 2
To open a command prompt from windows explorer, go to the MySQL Server bin folder, type from the folder path section cmd, and then enter.
![]()
Before executing SQL statements, we start XAMPP Server.
![]()
Step 3
Now we check whether SQL is adequately installed or not.
mysql -u root -p
![]()
By default SQL Server password is blank. If you have created a password, enter; otherwise, press enter. It generates a response Welcome message, which means SQL is appropriately installed.
Step 4
Now we create a new database; it is very easy to create a new one; write CREATE DATABASE and the database name.
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're going to change the table, use alter table.
alter table user add age int(5);
![]()
Show a 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 allow 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 updates 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