B. Data Manipulation Language (DML)
By using DML we can modify, retrieve, delete and update the data in our database.
1. INSERT
Suppose we have a new listing we would like to add to our database, to add this new record we use the INSERT INTO command. This command allows you to add one or more rows.
TEXT/X-SQL
1INSERT INTO airbnb_listings(id, name, host_id, neighbourhood_group, price)
2VALUES (1001, 'Luxury Villa', 2345, 'Brooklyn', 225);
2. DELETE
The new listings pulls out last minute so we need to remove the data from our table. To remove data we can simply use the DELETE command based on conditions specified with the WHERE command.
TEXT/X-SQL
1DELETE FROM airbnb_listings
2WHERE id = 1001;
3. UPDATE
Imagine you need to update data in your table because one listing increased their price. The UPDATE command allows you to do this based on conditions specified after the WHERE command.
TEXT/X-SQL
1UPDATE airbnb_listings
2set price = 200
3WHERE id = 2539;