MySQL part 6
MySQL part 6
INSERTION of Records
SYNTAX
INSERT INTO tablename
VALUES(value 1, value 2,....);
EXAMPLE
Considering the 'Student' table, to insert the data as given
Srno Name Class DateOfBirth
1011 Amit Sharma XI Sc 2005-02-12
SYNTAX
INSERT INTO tablename (column1, column2, ...)
VALUES (value1, value2, ...);
EXAMPLE
INSERT INTO STUDENT (SRNO, CLASS, NAME)
VALUES (1017,'XI Sc', 'Aditya Jain');
Data Updation
We may need to make changes in the value(s)
of existing records in a table.
EXAMPLE:
UPDATE STUDENT
SET CLASS = 'XI Arts'
WHERE SRNO = 1011;
Updating multiple values
Suppose we want to change multiple values for a record
we can do so by specifying values after set clause.
UPDATE STUDENT
SET CLASS = 'XI COMM', DATEOFBIRTH= '2004-1-2'
WHERE SRNO = 1015;
Updating all records
If we want to change the value of a particular column in
all the records, then we can skip the where clause.
UPDATE STUDENT
SET CLASS = 'XI Sc' ;
Data Deletion
The DELETE statement is used to delete one or
more record(s) from a table.
SYNTAX:
DELETE FROM table_name
WHERE condition;
Example Example
Example Example
Alter table student Update student
add address varchar(20); set marks=90
where rollno=1;
Difference between Drop and Delete
DROP DELETE
Example Example