DML Commands in SQL:-
Todays we will discuss about DML Commands in SQL. Below are the list of DML commands.
DML : Data Manipulation Language.
1. INSERT
2.UPDATE
3.DELETE
DML Commands are used to manipulate the data with in the table. It means using these commands, We can insert the data into table OR update the existing data OR delete the existing data.
1. INSERT: Insert command is used to insert the data to table. We can perform the insert operation in two ways. First one is general standard insert and other one is using substitutional operator.
Method 1:
syntax:
INSERT INTO tablename VALUES ( Value1,vale2.....);
Example :
Suppose assume we have a table called "TEST" and table have two columns as SNO,NAME.
SQL> Insert into TEST values (1,'KRISH');
Method 2: Using substitutional operator.
Syntax:
INSERT INTO tablename VALUES (&column1,&column2);
Example :
Insert into TEST values (&SNO,&NAME);
Now system will prompt for input values.
2. UPDATE: Update command is used to change OR update the data with in the table.
Syntax:
UPDATE TABLE SET columnName = newvalue; ( Without WHERE condition)
UPDATE TABLE SET columnName = newvalue WHERE columnName = oldValue; ( With WHERE condition)
Example :
UPDATE TEST set name = 'KRISH123' where name = 'KRISH';
3. DELETE:
Delete command is used to delete particular row or all rows from the table.
Syntax 1:
DELETE FROM tablename; (This will delete all the rows from table)
Syntax 2:
DELETE FROM tablename WHERE columnname= some value; ( This will delete based on the given where condition.
Example's :
Delete from TEST;
Delete from TEST where name='KRISH';
Thank You.
Comments
Post a Comment