You are on page 1of 9

SUBJECT : DBMS 1

TOPIC : INTRODUCTION TO
QUERIES (DML)

Lecturer Name: YAHYE


ADAM
 The INSERT INTO statement is used to insert a new row

 The following query inserts two rows at the RENTER table

 The fact that the ID has auto incrementing attribute, we can


ignore it

INSERT INTO INSERT INTO RENTER VALUES


('ALI',1341234,'10,18','500','HARGEYSA')

INSERT INTO RENTER VALUES


('AHMED',174544,'17,08','300','HARGEYSA')
 We can insert the data into a specific columns
that we determine

INSERT INTO RENTER


(T_NAME,PHONE_NUM,UNIT,A_LOCATION) VALUES
('OMAR',23656,'15,18','HARGEYSA')

INSERT INTO
 We can select all the rows in the table by using the
following query

SELECT * FROM RENTER

 We can determine the number of columns that we


need to display e.g.,

SELECT ID, T_NAME, A_LOCATION FROM RENTER


SELECT
 The WHERE clause specifies which record or
records that should be selected.

SELECT * FROM RENTER WHERE ID = 1

WHERE CLAUSE
If you want the data to appear in a specific order you
need to use the “order by” keyword.

Example:

SELECT * FROM RENTER ORDER BY UNIT

ORDER BY
KEYWORD

SELECT * FROM RENTER ORDER BY UNIT DESC


 The UPDATE statement is used to update existing
records in a table.

The syntax is as follows:

UPDATE table_name SET column1=value, column2=value2,...


WHERE some_column=some_value

UPDATE TENANT SET UNIT = '10-19' WHERE ID = 1


UPDATE
UPDATE TENANT SET M_PAYMENT = 250 WHERE ID = 2
 The DELETE statement is used to delete rows in a table

Syntax:

DELETE FROM table_name WHERE some_column=some_value

Note! Notice the WHERE clause in the DELETE syntax. The WHERE
clause specifies which record or records that should be deleted. If
you omit the WHERE clause, all records will be deleted!
DELETE Example:

DELETE FROM TENANT WHERE T_NAME = 'Adam'

DELETE FROM TENANT WHERE ID = 4


THE END THANKS!

You might also like