stud ads orizontal

Make orders for websites and PC / mobile applications



Missed me?

Se afișează postările cu eticheta truncate. Afișați toate postările
Se afișează postările cu eticheta truncate. Afișați toate postările

sâmbătă, 5 septembrie 2009

Sql: the difference between the truncate and delete

The SQL commands are similar and they have the same result: removing the records from the table. The question about the difference is often asked from freshers and in interviews as well. The difference is pretty simple but people confuse it because they see the same result of both queries.

The list of the differences are the next:

Type of Command: Truncate is a DDL (Data Definition Language) command and Delete is a DML (Data Manipulation Language) command.

RollBack: On DDL Commands, the changes made by them are committed automatically, while DML commands are not commited and can be rolled back. Some of the DDL commands are: SHOW TABLES, CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME, and some of the DML commands are: SELECT, INSERT, UPDATE, DELETE, MERGE – UPSERT, CALL, EXPLAIN PLAN, LOCK TABLE.

Table Structure: When you use Truncate command, all the rows in the table are deleted and the structure of the table is recreated, so does the indexes. When you use Delete command, only the desired rows (using the conditions with „where”) or all the rows are deleted and the structure remains unchanged.

Syntax: The syntax for commands is:

Truncate table <tablename> #command to truncate a table.

Delete from <tablename> #command to delete all the records from table.



Articles posted here: http://www.supravirtual.ro/stiri/Sql:_the_difference_between_the_truncate_and_delete

Sql: diferenta dintre truncate si delete

Comenzile SQL commands sînt similare și au același rezultat: ștergerea înregistrărilor din tabelă. Întrebarea despre difernță este deseori întrebată de începători și în cadrul interviurilor. Diferența este destul de simplă, dar oamenii le mai confundă pentru că văd același rezultat la ambele interogări.

Lista de diferențe este următoarea:

Tipul de comandă: Truncate este o comandă DDL (Data Definition Language), iar Delete este o comandă DML (Data Manipulation Language).

Restaurarea datelor: La apelul comenzilor DDL schimbările făcute de ele sînt finalizate automat, în timp ce comenzile DDL nu sînt finalizate iar datele se pot reface. Comenzile DDL sînt: CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME, iar comenzile DML sînt: SELECT, INSERT, UPDATE, DELETE, MERGE – UPSERT, CALL, EXPLAIN PLAN, LOCK TABLE.

Structura tabelei: Cînd folosiți comanda truncate toate rîndurile tabelei sînt șterse iar structura tabelei este recreată, la fel și indecșii. Cînd folosiți comanda delete doar rîndurile dorite (folosind condiționarea cu „where”) sau toate rîndurile sînt șterse iar structura rămîne neschimbată.

Sntaxa: Sintaxa pentru comenzi este:

Truncate table <tablename> #comanda pentru a trunchia o tabelă.

Delete from <tablename> #comanda de a șterge toate înregistrările dintr-o tabelă.



Articol preluat de aici: http://www.supravirtual.ro/stiri/Sql:_diferenta_dintre_truncate_si_delete