3-Manipuler Des Données
3-Manipuler Des Données
3-Manipuler Des Données
… insérer une
nouvelle ligne
dans la table
DEPARMENTS …
INSERT
INSERT INTO
INTO table
table [(column
[(column [,
[, column...])]
column...])]
VALUES
VALUES (value
(value [,
[, value...]);
value...]);
• Vérifiez l'ajout.
1 row created.
4 rows created.
UPDATE
UPDATE table
table
SET
SET column
column == value
value [,
[, column
column == value,
value, ...]
...]
[WHERE
[WHERE condition];
condition];
UPDATE
UPDATE employees
employees
SET
SET department_id
department_id == 55
55
WHERE
WHERE department_id
department_id == 110;
110;
UPDATE
UPDATE employees
employees
**
ERROR
ERROR at
at line
line 1:
1:
ORA-02291:
ORA-02291: integrity
integrity constraint
constraint (HR.EMP_DEPT_FK)
(HR.EMP_DEPT_FK)
violated
violated -- parent
parent key
key not
not found
found
DELETE
DELETE [FROM]
[FROM] table
table
[WHERE
[WHERE condition];
condition];
DELETE
DELETE FROM
FROM departments
departments
WHERE
WHERE department_id
department_id == 60;
60;
DELETE
DELETE FROM
FROM departments
departments
**
ERROR
ERROR at
at line
line 1:
1:
ORA-02292:
ORA-02292: integrity
integrity constraint
constraint (HR.EMP_DEPT_FK)
(HR.EMP_DEPT_FK)
violated
violated -- child
child record
record found
found
INSERT
INSERT INTO
INTO
(SELECT
(SELECT employee_id,
employee_id, last_name,
last_name,
email,
email, hire_date,
hire_date, job_id,
job_id, salary,
salary,
department_id
department_id
FROM
FROM employees
employees
WHERE
WHERE department_id
department_id == 50)
50)
VALUES
VALUES (99999,
(99999, 'Taylor',
'Taylor', 'DTAYLOR',
'DTAYLOR',
TO_DATE('07-JUN-99',
TO_DATE('07-JUN-99', 'DD-MON-RR'),
'DD-MON-RR'),
'ST_CLERK',
'ST_CLERK', 5000,
5000, 50);
50);
11 row
row created.
created.
• Verify
SELECT
SELECT the results last_name,
employee_id,
employee_id, last_name, email,
email, hire_date,
hire_date,
job_id,
job_id, salary,
salary, department_id
department_id
FROM
FROM employees
employees
WHERE
WHERE department_id
department_id == 50;
50;
SELECT
SELECT **
FROM
FROM COPY_EMP;
COPY_EMP;
no
no rows
rows selected
selected
MERGE
MERGE INTO
INTO copy_emp
copy_emp cc
USING
USING employees
employees ee
ON
ON (c.employee_id
(c.employee_id == e.employee_id)
e.employee_id)
WHEN MATCHED THEN
WHEN MATCHED THEN
UPDATE
UPDATE SET
SET
...
...
WHEN
WHEN NOT MATCHED
NOT MATCHED THEN
THEN
INSERT VALUES...;
INSERT VALUES...;
SELECT
SELECT **
FROM
FROM COPY_EMP;
COPY_EMP;
20
20 rows
rows selected.
selected.
DELETE
SAVEPOINT A
INSERT
UPDATE
SAVEPOINT B
INSERT
INSERT INTO
INTO departments
departments
VALUES
VALUES (290,
(290, 'Corporate
'Corporate Tax',
Tax', NULL,
NULL, 1700);
1700);
11 row
row inserted.
inserted.
Utilisateur A
UPDATE employees Blocs de
SET salary = 7000 données
WHERE last_name = 'Goyal';
Segments
d'annulation
Données
SELECT * modifiées
FROM userA.employees; Image et non
cohérente modifiées
en lecture avant modi-
fication des
"anciennes"
Utilisateur B données