DML Commands b6-56
DML Commands b6-56
INSERT :
The INSERT INTO statement of SQL is used to insert a new row in a table. There are two
ways of using INSERT INTO statement for inserting rows:
1.Only values: First method is to specify only the value of data to be inserted without the
column names.
Syntax:
INSERT INTO table_name VALUES(value1,value2,value3,.........);
2.Column names and values both: In the second method we will specify both the
columns which we want to fill and their corresponding values as shown below:
Syntax:
INSERT INTO table_name(column1,column2,column3,.......) VALUES(value1,value2,value3,.....);
Output:
SELECT:
Select is the most commonly used statement in SQL. The SELECT Statement in SQL is used
to retrieve or fetch data from a database. We can fetch either the entire table or according to
some specified rules. The data returned is stored in a result table. This result table is also
called result-set.
Syntax:
SELECT column1,column2 FROM table_name
To fetch the entire table or all the fields in the table:
SELECT *FROM table_name;
Query to fetch the fields ROLL_NO, NAME, AGE from the table Student:
SELECT ROLL_NO, NAME, AGE FROM Student;
Output:
UPDATE:
The UPDATE statement in SQL is used to update the data of an existing table in database.
We can update single columns as well as multiple columns using UPDATE statement as per
our requirement.
Syntax :
UPDATE table_name SET column1=value1,column2=value2,.............WHERE condition;
Output :
DELETE:
The DELETE Statement in SQL is used to delete existing records from a table. We can delete
a single record or multiple records depending on the condition we specify in the WHERE
clause.
Syntax:
DELETE FROM table_name WHERE some condition;
Output: