To delete records in a table in DB2 database DELETE command is used, this command is well known in other databases and their use is similar in DB2.
DELETE FROM [Table]
As shown in the above syntax, the DELETE command only needs to receive as parameter the name of the table, but there is a very important item to be considered. When using the command as shown before all records are deleted and in many cases this format does not apply, due the WHERE clause is used with it.
DELETE FROM [Table] WHERE [Conditional]
In the syntax shown earlier, only records that satisfy the conditional will be deleted. As a practical example we will delete products from a table using both formats.
DELETE FROM product
DELETE FROM product WHERE cod_prod = 1
n the first example all products will be deleted from the table, in the second only the product that has the code 1 will be deleted.
DB2 has gained more space in web development environments and because it understand it works becomes a great advantage. So, discover the advantages of working with DB2 on PHP projects on our official site.