Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

3. Data maintenance - Select, Insert, Delete, Update

The following demonstrates how to insert, updates and deletes entries from a database.

3.1. Select

Table 2. Select

CommandDescription
SELECT * FROM TABLE table_name; Selects all the data from table "table_name"

3.2. Insert

Table 3. Insert

CommandDescription
MISSING MISSING

3.3. Update

Table 4. Update

CommandDescription
update table_name SET field = value WHERE condition; Updates field with value in table_name given then the where condition is met.

3.4. Delete

Table 5. Delete

CommandDescription
DELETE FROM table_name WHERE id='8'; Deletes an entry from table "table_name"which has the id 8. Requires that the table has a column "id".
delete from table_name where id <> 1 and id <> 29;; Deletes all entries from table "table_name" except the entries with id "1" and "29".