90 likes | 242 Views
Data Manipulation Language. DML. insert into. insert used to insert only one record at time. insert statement will rejected if it: violates constraints Insert duplicate value in unique/primary key attribute Insert a value does not has a reference (foreign key)
E N D
insert into • insert used to insert only one record at time. • insert statement will rejected if it: • violates constraints • Insert duplicate value in unique/primary key attribute • Insert a value does not has a reference (foreign key) • Insert a value does not satisfies the condition (check) • there is data mismatch • Insert char value to number attribute • What about insert number value to char?
insert into insert into TABLENAME(Att1, Att2,…, Attn) values(value1,value2, … , valuen); • Explanation: • Att1, Att2,…, Attn are attributes in the table the order is not important • value1,value2, … , valuenthe values for Att1, Att2,…, Attn respectively.
insert into insert into TABLENAME values(value1,value2, … , valuen); • Explanation: • value1,value2, … , valuen the values for the attributes in the order which in the table respectively.
examples • INSERT INTO COLLEGE(CID,CNAME) VALUES(10,’INFORMATIONS TECHNO.’); ____________________________________________ • INSERT INTO COLLEGE VALUES(30,’Arts’); ____________________________________________ • INSERT INTO STUDENTS(SID,SNAME,CID,SAVERAGE) VALUES(12345,'ALI',10,85.23); ____________________________________________ • INSERT INTO STUDENTS(SID,SNAME,CID,SGENDER) VALUES(22345,‘MONA',30,’f’);
update update TABLENAME set Att1=Newvalue, Att2=Newvalue, …Attn=Newvalue where(codition); • Explanation: • You can use update to modify the row data • The condition used to determine which row (s) will be affected by the update.
example • update students set saverage=90; _____________________________________________________________ • update students set saverage=90, sgender=‘f’; ______________________________________ • Update students • set saverage=90 • where sid = 12345;
delete delete TABLENAME where(condition); • Explanation: • The condition used to determine which row (s) will be affected by the delete command.