You will need
- Basic knowledge of SQL language
Instruction
1
Use to clean tables, the truncate statement of SQL, specifying in the request the name of the desired table. For example, if you want to clear a table named TableToClear, then the query should look like this:
truncate table `TableToClear`
truncate table `TableToClear`
2
Use as an alternative to the truncate statement line-by-line deleting data from the table - this is what the delete operator. The syntax of this command requires that you specify the table name and the conditions under which the string should be removed from it. If you enter a condition that is obviously true, regardless of the content of the row, will be deleted all records in the table. For example, for the table TableToClear query with this operator it is possible to make so:
delete from `TableToClear` where 1
Unlike the truncate statement, this query will return the number of deleted rows. Another difference of this command is blocking not the entire table, but only the currently processed record. This option would require the implementation of more time that will become visible when a large number of lines in the cleaned table.
delete from `TableToClear` where 1
Unlike the truncate statement, this query will return the number of deleted rows. Another difference of this command is blocking not the entire table, but only the currently processed record. This option would require the implementation of more time that will become visible when a large number of lines in the cleaned table.
3
There are more exotic options - for example, remove the table completely and recreate it again in one Sql query. To uninstall, use the drop statement, and to create - create. For example, if the table TableToClear consists of a text Name field length is 50 characters and integer Code values are not null, then record the action of deleting and recreating, you can:
drop table `TableToClear`;
create table `TableToClear` (
Code integer not null,
Name char (50) not null
);
drop table `TableToClear`;
create table `TableToClear` (
Code integer not null,
Name char (50) not null
);