Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
3.5 kB
16
Indexable
Never
05/02/2024
---------------------------------------------------------------------------
delete statement:-it is used for delete the existing records
when we omit where statement all records in the table will be deleted.

syntax:-delete from tablename where condition.

exa;delete from employee1 where id=2;
delete from employee1 ; -- all rows deleted


----------------------------------------------------------------------------------------
difference between truncate and delete

delete:-1. It is DML command
        2.delete command is  use where clause.
        3.delete operations can be rolled back
        4.delete command is slower than truncate command.
        5. the de;lete command is used to delete the specific rows(as per condition)

truncate:-1. It is DML command
         2. In truncate command we are not use where clause
         3. truncate can not be rolled back
         4. truncate command is faster than delete command
         5. truncte command is used to delete all rows from the table.

--------------------------------------------------------------------------------------------
difference between having and where clause:

where:-1.where caluse is used to filter the data from the table in the specific condition.
       2. where clause cannot cointain aggregate function.
       3.where clause can be used without group by clause.
       4.where clause is used with select,update,delete.
       5.where clause is used before group by clause.
       



having:-1. having clause is uesd for filter the records from the group based on the given condition.
        2. having clause contain aggregate function.
        3. having clause cannot be used without group by clause.
        4. having clause is only used  with select clause.
        5. having clause is used after group by clause.

--------------------------------------------------------------------------------------------
differance alter and update:
alter:1. data defination lang(DDL)
      2.alter command will perform structure level.
      3.syntax alter table tablename (modify/add/rename) Drop column column_name
      4. this command make changes with the table structure.
      5. alter command works on attributes(columns) 


update:1. data manipulation lang(DML)
       2.update command will perform on data level.
       3 syntax :-update table_name set column_name=values
       4. this command make changes the data inside table.
        5. update cammand works on perticular field(rows) in the table


-------------------------------------------------------------------------------------------
Trasaction control language:TCL
    commit, rollback
Commit:-
commit is used for the permanentaly save the changes.

syntax :- update tablename set column=values where condition;
          commit;
              

rollback:-rollback command is used for undo/revert the trasaction.
         the cammand is only used to undo changes since the last commits

           update command;
           commit;
           update command ;

           rollback;    


use first;
-- select * from student;
-- update student set marks=70 where rno=4;
 update student set marks=80 where rno=1;
 -- commit;
 select * from student;
 -- rollback;
 
 update student set marks=50 where rno=1;
commit;
 update student set marks=70 where rno=2;
rollback;

-----------------------------------------------------------------------------------------
Leave a Comment