Structured query language(SQL) is a non-procedural computer language, aimed to Store, manipulate and query data stored in relational database and also used to create interface between user and database. Now-a-days Structured query language(SQL) is mostly used in web servers to store data.
Advantages of Structured query language(SQL) :
1. High speed
2. Easy to learn and understand
3. No coding required
4. Emergence of RDBMS
5. SQL is Portable
Structured query language(SQL) statements:
Structured query language(SQL) command or statement is a special kind of sentence that contain clauses and all end with a semicolon(;) just as a sequence end with a period.
Structured query language(SQL) statements are divided into four sub languages:
1. Data definition language (DDL): It is used to define the structure of tables in the database.
2. Data manipulation language (DML): It is used to the manipulate the data in the database.
3.Data Control Language (DCL): It is used to control data stored in the database.
4.Transaction Control Language (TCL): It is used to control the transactions in the database.
We are going to discuss about data definition language and data manipulation language:
Data definition language (DDL)
CREATE TABLE COMMAND
CREATE TABLE <table name> (<attribute_name> <datatype> (size) (constraint), <attribute_name> <datatype> (size) (constraint), <attribute_name> <datatype> (size) (constraint), <attribute_name> <datatype> (size) (constraint),.......);
ALTER TABLE COMMAND
1.ADD COLUMN
ALTER TABLE <table_name> ADD <column_name> <data_type>;
2.DROP COLUMN
ALTER TABLE <table_name> DROP COLUMN <column_name>;
3.MODIFY COLUMN DATA TYPE
ALTER TABLE <table_name> MODIFY <column_name> <new_data_type>;
4.DELETE CONSTRAINT
ALTER TABLE <table_name> DROP <constraint_name>; OR
ALTER TABLE <table_name> MODIFY <column_name> <data_type> <new_constraint_name>;
5.RENAME COLUMN
ALTER TABLE <table_name> RENAME COLUMN <old_name> TO <new_name>; OR
ALTER TABLE <table_name> CHANGE COLUMN <old_name> <new_name> <data_type>;
DROP TABLE COMMAND
DROP TABLE <table_name>;
For more queries visit contact us page. And if you want to submit your article like this please visit our submit your post.
Data manipulation language (DML)
1.INSERT COMMAND
INSERT INTO <table_name> VALUES (<value_1>,<value_1>,<value_2>,<value_3>....); OR
INSERT INTO <table_name> (<col_name_1>,<col_name_2>,<col_name_3>....) VALUES (<value_1>,<value_1>,<value_2>,<value_3>....);
2.DELETE COMMAND
DELETE FROM <table_name> WHERE <column_name>=<some_value>;
3.SELECT COMMAND
SELECT <attribute_name_1>,<attribute_name_2>... FROM <table_name>;
SELECT* FROM <table_name>; // FOR SELECTING ALL THE VALUES
4.DISTINCT KEYWORD
SELECT DISTINCT <attribute_name> FROM <table_name>;
5.WHERE CLAUSE
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name>=VALUE;
6.UPDATE COMMAND
UPDATE <table_name> SET COLUMN_1=VALUE_1 WHERE COLUMN_2=VALUE;
7.ORDER BY CLAUSE
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name><VALUES ORDER BY <attribute_name>;
8.GROUP BY CLAUSE
SELECT <attribute_name> FROM <table_name> GROUP BY <attribute_name>;
9.HAVING CLAUSE
SELECT <attribute_name> FROM <table_name> GROUP BY <attribute_name> HAVING <condition>;
OPERATORS IN STRUCTURED QUERY LANGUAGE(SQL)
1.NULL OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name>=NULL;
2.LIKE OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name> LIKE "S%"; OR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name> LIKE "S____";
3.BETWEEN OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name> BETWEEN 0 AND 45;
4.AND OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name>=RAM AND <attribute_name>=SHAM;
5.OR OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name>=RAM OR <attribute_name>=SHAM;
6. IN OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name> IN ('A','B');
7.NOT WITH IN OPERATOR
SELECT <attribute_name> FROM <table_name> WHERE <attribute_name> NOT IN ('A','B');
GROUP FUNCTION IN STRUCTURED QUERY LANGUAGE(SQL)
1.AVG FUNCTION
SELECT AVG(attribute_name) FROM <table_name>;
2.MAX FUNCTION
SELECT MAX(attribute_name) FROM <table_name>;
3.MIN FUNCTION
SELECT MIN(attribute_name) FROM <table_name>;
4.SUM FUNCTION
SELECT SUM(attribute_name) FROM <table_name>;
5.COUNT FUNCTION
SELECT COUNT(attribute_name) FROM <table_name>;
CARTESIAN PRODUCT IN STRUCTURED QUERY LANGUAGE(SQL)
SELECT* FROM <table_1> CROSS JOIN <table_2>; OR
SELECT* FROM <table_1>,<table_2>;
UNION IN STRUCTURED QUERY LANGUAGE(SQL)
SELECT <attribute_name> FROM <table_1>,<table_2> WHERE <condition> UNION SELECT <attribute_name> FROM <table_1>,<table_2> WHERE <condition>;
This is all about the DDL and DML commands in Structured query language(SQL). But keep that in mind that without practice just reading them is just waste of time. So, practice them properly. For proper tutorial check this you tube tutorial.
Video:https://youtu.be/I2W-tX85dnk
One word, before we finish.We shall be grateful for your feedback. It will help us to improve our services.
Frequently asked Questions:
What is SQL?
Structured query language(SQL) is a non-procedural computer language, aimed to Store, manipulate and query data stored in relational database and also used to create interface between user and database.
Where we are using the SQL most?
In Web-Servers to store the data of customers.
Is We can install SQL In PC?
There are many software which allow you to run SQL like Microsoft Access,MySQL,etc.
Is SQL is a Programming Language?
NO, SQL isn’t a Programming language it is a computer database language.
👌👌👌👌👌😂