-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDML commands.sql
More file actions
56 lines (45 loc) · 983 Bytes
/
DML commands.sql
File metadata and controls
56 lines (45 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- INSERT INTO customers (id, first_name, country, score)
-- SELECT * FROM customers
/*VALUES(6,'Anna','USA',NULL),
(7,'Sam',NULL,100)
*/
/*INSERT INTO customers (id,first_name)
VALUES(10,'Sarah')
*/
-- SELECT * FROM customers
/*CREATE TABLE persons(
id INT NOT NULL,
person_name VARCHAR(50) NOT NULL,
birth_date DATE,
phone VARCHAR(50) NOT NULL,
CONSTRAINT pk_prson PRIMARY KEY(id)
)
*/
/*INSERT INTO persons (id, person_name, birth_date, phone)
SELECT
id, -- maps to persons.id
first_name, -- maps to persons.person_name
NULL, -- maps to persons.birth_date
'unknown' -- maps to persons.phone
FROM customers; */
-- SELECT * FROM persons
/*UPDATE customers
SET score = 0
WHERE id>6
*/
/*UPDATE customers
SET score=0,
country='UK'
WHERE id=10
*/
-- SELECT * FROM customers
/*UPDATE customers
SET score=0
WHERE score=0
*/
/*DELETE FROM customers
WHERE id>5
*/
-- SELECT * FROM customers
-- TRUNCATE TABLE persons
DROP TABLE persons