SQL

Diwakar pratap
4 min readMar 10, 2022

--

INTRODUCTION

· SQL is a database computer language designed for the retrieval and management of data in a relational database.
· SQL stands for Structured Query Language.
· SQL is a standard language for storing, manipulating, and retrieving data in databases.

USAGE

· To execute queries against a database.
· It can retrieve data from a database.
· To insert records in a database.
· To update records in a database.
· To delete records from a database.
· To create new databases.
· To create new tables in a database.
· It can be used to create views in databases.
· It can be helpful in creating permissions on tables, views etc.

REASONS TO CHOOSE SQL

· SQL helps in creating new databases, views, and tables.
· It is used for inserting, updating, deleting, and retrieving data records in the database.
· It enables users to interact with data stored in relational database management systems.
· SQL is required to create views, stored procedures, functions in a database.
· SQL lets you access any data within the relational database
· You can describe the data in the database using SQL
· Using SQL you can manipulate the data with the relational database
· SQL can be embedded within other languages through SQL modules & libraries
· SQL lets you easily create and drop databases and tables
· SQL allows you to create views, functions, and stored procedures in databases
· Using SQL you can set permissions on procedures, tables, and views.

COMMANDS

There are some commands of SQL and we can divide these commands according to our work in three categories.

1. Data Definition Language (DDL)

· A data definition language (DDL) is a computer language used to create and modify the structure of database objects in a database.
· These database objects include views, schemas, tables, indexes, etc.

I. CREATE
Creates a new table, a view of a table, or other object in database.

Syntax:
CREATE TABLE table_name(
Col_name1 datatype(),
Col_name2 datatype(),…
Col_namen datatype(),
);

II. ALTER
Modifies an existing database object, such as a table.

a. ADD
Adding a new column to the existing table.

Syntax:
ALTER TABLE table_name
ADD Col_name datatype()…;

b. MODIFY
Modify a datatype in an existing table.

Syntax:
ALTER TABLE table_name
MODIFY (fieldname datatype()…);

III. DROP
Deletes an entire table, a view of a table or other object in the database.

Syntax:
DROP Table name;

2. Data Manipulation Language (DML)

· DML stands for Data Manipulation Language.
· It is a language used for selecting, inserting, deleting, and updating data in a database.
· It is used to retrieve and manipulate data in a relational database.

I INSERT
Used to insert values in a record.

Syntax:
INSERT INTO Table_Name VALUES();

II UPDATE
Update command is used to update any value from any table.

Syntax:
UPDATE <table name> set to(calculation);

III DELETE
Delete query is used to delete a row from a table.

Syntax:
DELETE FROM <table_name>

IV SELECT
Select query is used to fetch the data from tables.

Syntax:
SELECT * FROM <table_name>

3. Data Control Language (DCL)

· Data Control Language includes commands such as GRANT, and is concerned with rights, permissions, and other controls of the database system.
· DCL is used to grant/revoke permissions on databases and their contents.

i. GRANT
It provides the user’s access privileges to the database.

Syntax :
Statement permissions:
GRANT { ALL | statement [ ,…n ] }
TO security_account [ ,…n ]

ii. REVOKE
The REVOKE statement enables system administrators and to revoke (back permission) the privileges from MySQL accounts.

Syntax:
REVOKE
priv_type [(column_list)]
[, priv_type [(column_list)]] …
ON [object_type] priv_level
FROM user [, user] …
REVOKE ALL PRIVILEGES, GRANT OPTION
FROM user [, user] …

APPLICATIONS

· SQL is used as a Data Definition Language (DDL) meaning you can independently create a database, define its structure, use it and then discard it when you are done with it
· It is also used as a Data Manipulation Language (DML) which means you can use it for maintaining an already existing database. SQL is a powerful language for entering data, modifying data, and extracting data with regard to a database
· It is also deployed as a Data Control Language (DCL) which specifies how you can protect your database against corruption and misuse.
· It is extensively used as a Client/Server language to connect the front-end with the back-end thus supporting the client/server architecture
· It can also be used in the three-tier architecture of a client, an application server, and a database that defines the Internet architecture.

CONCLUSION

So, we can conclude by saying that, today regardless of the relational database frameworks by significant enterprises like Oracle, IBM, Microsoft, and others, the one thing that is normal to them is the SQL. So, on the chances that you learn SQL on the web, at that point, you will have the option to seek after a wide vocation crossing plenty of jobs of obligations.

--

--

No responses yet