DML (Data Manipulation Language) Queries
Data Manipulation Language (DML) is a family of computer languages including commands permitting users to manipulate data in a database. This manipulation involves inserting data into database tables, retrieving existing data, deleting data from existing tables and modifying existing data. DML is mostly incorporated in SQL databases.
- In this type command you can work with the data.
- Using these types of queries you create new records/data, modify existing data, delete the data, get/retrieve the data.
- This is also known as CURD (Create Update Retrieve Delete)
- There are different type of queries
- Insert: You can create or add new data into the table
- Update: Can update/modify existing data
- Delete: Can delete the records
- Select: can get the records
Insert Query
- SyntaxINSERT INTO <tableName>(Column1, Column2,….) VALUES(val1, val2, val3,…);
- Example:
INSERT INTO employee(id, name, contact, salary, gender, isActive, doj) VALUES(1,’A’,’9988778787′,3124534.43,’M’,true,’2022-01-12′);
INSERT INTO employee VALUES(3,’C’,’9943124432′,1124534.43,’F’,true,’2022-03-12′);
In the above syntax column name is not provided, it is optional only in the case where the sequence and the values for all columns are provided.
INSERT INTO employee VALUES(6,’F’,’8923224432′,1824534.43,’M’,true,’2002-05-10′),
(7,’G’,’7713224432′,2824534.43,’F’,false,’2012-01-22′),
(8,’H’,’6723224432′,1224534.43,’M’,true,’2017-02-11′);
You can insert multiple records a t a time using this syntax.
- SyntaxINSERT INTO <tableName>(Column1, Column2,….) VALUES(val1, val2, val3,…);
Select Query
- This query is use to get the data store into the database.
- Select query can be use with clauses, operators, function(Date, String, arithmetic function), Joins.
- Syntax:Select column1, column2, column3,… from <TableName>
Select * from <TableName>
Update Query
- Using update query you can update the data from existing row.
- You can update multiple rows or single rows at a time
- Syntax:UPDATE <tableName> SET column=value;
UPDATE <tableName> SET column=value where condition
Delete Query
- Using delete query you can delete a specific record or all the records.
- Syntax:DELETE FROM <TABLENAME>;
DELETE FROM <TABLENAME> WHERE condition;
- Example:
DELETE FROM employee WHERE id = 2;
Join Telegram : Click Here
All Full Stack Java Study Material
Job’s For Fresher