[IBM]Databases and SQL for Data Science with Python - DML(UPDATE, INSERT, DELETE)

2021. 4. 28. 16:11Data science/Database

반응형

INSERT INTO table_name (column1, column2, ... ) VALUES (value1, value2, ... ) ;

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition ;

DELETE FROM table_name WHERE condition ;

======================================================================================================

Insert a new instructor record with id 4 for Sandip Saha who lives in Edmonton, CA into the "Instructor" table.

-> INSERT INTO Instructor(ins_id, lastname, firstname, city, country) VALUES (4, 'Sandip', 'Saha', 'Edmonton', 'CA');

 

Insert two new instructor records into the "Instructor" table. The first record with id 5 for John Doe who lives in Sydney, AU. Second record with id 6 for Jane Doe who lives in Dhaka, BD.

-> INSERT INTO Instructor (ins_id, lastname, firstname, city, Country) VALUES (5, 'Jonh', 'Doe', 'Sydney', 'AU'), (6, 'Jane', 'Doe', 'Dhaka', 'BD');

 

Update the city of the instructor record to Markham whose id is 1.

-> UPDATE Instructor SET city='Markham' WHERE ins_id=1; 

-> SELECT * FROM Instructor;

 

Update the city and country for Sandip with id 4 to Dhaka and BD respectively.

-> UPDATE Instructor SET city='Dhaka', country='BD' WHERE ins_id = 4 ; 

-> SELECT * FROM Instructor;

 

Remove the instructor record of Hima.

-> DELETE FROM Instructor WHERE firstname = 'Hima'; 

 

Which of the following SQL statements will delete the authors with IDs of A10 and A11?

->DELETE FROM AUTHOR WHERE AUTHOR_ID IN ('A10', 'A11')

 

 

 

반응형