SQL Commands:
SQL Commands are instructions. It is used to communicate with the database. It is also used to perform specific tasks, functions, and queries of data. SQL can perform various tasks like creating a table. add data to tables, drop the table modify the table. set permission for users.
Types of SQL Commands: There are five types of SQL Commands:

Data Definition Language (DDL)
- DDL changes the table’s structure like creating a table deleting a table, altering a table, etc.
- All the commands of DDL are auto-committed. That means it permanently saves all the changes in the database
- Here are some commands that come under DDL:

a. CREATE
It is used to create a new table in the database Syntax:
CREATE TABLE_NAME CCOLUMN_NAME DATATYPE)
Example:
CREATE TABLE EMPLOYEE (Name VARCHAR2(20), Email V
b. DROP:
It is used to delete both the structure and record stored in the table
Syntax:
DROP TABLE table_name;
Example:
DROP TABLE EMPLOYEE;
c. ALTER:
It is used to alter the structure of the database. This could be either to modify the characteristics of an existing attribute or probably to add a new attribute.
Example:
ALTER TABLE STU-DETAILS ADD CADDRESS 'VARCHAR 2 (20 ALTER TABLE STU-DETAILS MODIFY (NAME VARCHAR 2 (20));
d. Truncate
It is used to delete all the rows from the table and free the space containing the table
Syntax
TRUNCATE TABLE table-name
TRUNCATE TABLE Employee
Data Manipulation Language
DML commands are used to modify the database. It is responsible for all the form of changes in the database. The command of DML is not auto committed.
- Insert
- UPDATE
- DELETE
a.) INSERT
The Insert Statement is SQL Query. It is used to insert data into a row of tables.
Syntax
INSERT INTO TABLE_NAME VALUES(VAL1,VAL2,VAL3,VAL4..)
b.) UPDATE
This command is used to update or modify the value of a column in the table.
Example
UPDATE Table_name set[col1=val1, col2=val2..]
c.) DELETE
It is used to remove one or more rows from a table
Example
DELETE FROM GEEKYCODES
WHERE AUTHOR="XAVIER"
3. Data Control Language
DCL Commands are used to grant and revoke authority from any database user
Example:
- GRANT
- REVOKE
a.) GRANT
It is used to give user access privileges to the database.
Example
GRANT SELECT,UPDATE ON MY_TABLE TO SOME_USER,A
b.) REVOKE
It is used to take back permissions from the user
Transaction Control Language
TCL Commands can only be used with DML commands like INSERT,DELETE and UPDATE only
- Commit
- Rollback
- SAVEPOINT
a.) COMMIT
Commit is used to save all the transactions to the database.
Example
DELETE FROM CUSTOMERS
WHERE AGE=25
COMMIT
b.) ROLLBACK
Roll back command is used to undo transactions that have not already been saved to the database.
Syntax
ROLLBACK
c.) SAVE POINT:
It is used to roll the transaction back to a certain. point without rolling back the entire transaction.
SAVE POINT SAVEPOINT-NAME
DATA QUERY LANGUAGE!
SELECT
a. SELECT: This is the same as the projection operation of relational algebra. It is used to select the attribute based on the competition.
Syntax:
SELECT expressions FROM TABLES WHERE conditions:
Important Notice for college students
If you’re a college student and have skills in programming languages, Want to earn through blogging? Mail us at geekycomail@gmail.com
For more Programming related blogs Visit Us at Geekycodes. Follow us on Instagram.