To delete the records in a table , there are 2 ways . 1.Using the delete statement 2.using the truncate statement . To delete the entire table drop statement is used .
Deleting a record from a table : use the following statement. delete from table_name where column_name = some_value; . The above statement deletes a single record at a time.
To delete all the records in a table the following statement is used. delete * from table_name;
coming to the truncate statement , its like a delete statement without a where clause. the syntax is Truncate table table_name. It also removes all the records in the table. In case of delete * from table_name and truncate table table_name all the records in the table is deleted but the table structure and its columns , constraints , indexes remain the same .
To remove the table from the database,use the drop table statement. drop table table_name;
RE: How many ways you can delete the table records ?
To delete the records in a table there are 2 ways . 1.Using the delete statement 2.using the truncate statement . To delete the entire table drop statement is used .
Deleting a record from a table : use the following statement. delete from table_name where column_name some_value; . The above statement deletes a single record at a time.
To delete all the records in a table the following statement is used. delete * from table_name;
coming to the truncate statement its like a delete statement without a where clause. the syntax is Truncate table table_name. It also removes all the records in the table. In case of delete * from table_name and truncate table table_name all the records in the table is deleted but the table structure and its columns constraints indexes remain the same .
To remove the table from the database use the drop table statement. drop table table_name;
RE: How many ways you can delete the table records ?
There are two ways To delete all records in the table. 1. using delete 2. using truncate In delete option we have used drop command. eg. drop table table_name; for second one eg. truncate tablename; Both are delete the records in a table.
RE: How many ways you can delete the table records ?
We have 2 options :
1. Delete
2.Truncate
Delete : It is DML concepts.
Syntax: Delete from <table_name>;
Example: Delete from emp;
Explain: The above query will delete all the record from the tale. Supose need to delete the particular record from the table we can give the condition.
Syntax: Delete from <table_name> where <condition>
Example: Delete from emp where emp_no 101;
Explain: By default You gave the condition 101 instead of 1001. You can Rollback and get the 101 record before doing commit.
Truncate : It is DDL commend.
Syntax: Truncate Table <Table_Name>;
Example: Truncate Table Emp;
Explain: The above query will delete all the record from the table. Suppose need to delete the particular record from the table we cannot give the condition.
RE: How many ways you can delete the table records ?
Two ways 1. DELETE 2. TRANCATE
BY using delete---- U can delete one nd all rows by using delete command syntax- delete from tablename where column_name column_value; (it will delete the row related to given column value) delete * from tablename; (it will remove all the rows from the table) NOTE-1- In case of delete stil high water mark remain set to same position even after deleteing all the rows. 2- Also the rows never release the memory space . 3- U can rollback in case of delete.
BY using trancate----- U can delete all the rows by using the trancate command. syntax- trancate table tablename;
NOTE- 1- in case of trancate high water mark get set to zero. 2- all the rows get deleted nd relase the memory space but structure index nd constraint remain the same. 3- U can never rollback in case of trancate command.
1. Delete: This is used to delete the one or all the records. The thing with this is that only data is been deleted but the table structure and the memory allocated to it is safe.
2. Truncate: Truncate is similar to Delete the only difference is that it keeps the structure but removes the memory allocated to the table.
3. Drop: This is used to delete the entire table along with the table structure and memory allocated to it.