CommencerCommencez gratuitement

Inserting and updating a table

A very important task when working with tables is inserting and updating the values in a database. The syntax for both operations is shown below.

Insert value1 and value2 into the Employee table:

INSERT INTO Employee 
VALUES (value1, value2);

Update field1 from table Employee with value1 for the ID=1:

UPDATE Employee 
SET field1 = value1 
WHERE ID = 1;

Your task is to insert two new values into the Person table and to update the entries of the table.

Cet exercice fait partie du cours

<cours>Hierarchical and Recursive Queries in SQL Server</cours>
Voir le cours

Exercice interactif pratique

Essayez cet exercice en complétant ce code d’exemple.

-- Insert the records for the person with ID=1
___ INTO ___ 
____ (1,'Andrew','Anderson','Union Ave 10','New York','1986-12-30');
-- Insert the records for the person with ID=2
INSERT INTO Person 
VALUES (___,___,___,___,___,___);

SELECT * 
FROM Person;
Modifier et exécuter le code