-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql.sql
61 lines (55 loc) · 893 Bytes
/
sql.sql
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
57
58
59
60
61
/* DATABASE */
CREATE DATABASE IF NOT EXISTS tasks_manager DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
/* TABLE TASKS */
CREATE TABLE tasks (
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
content VARCHAR(255) NOT NULL,
is_completed BOOLEAN NOT NULL,
date_created DATETIME NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB;
/* CRUD QUERIES */
/* Create one */
INSERT INTO
tasks (
id,
title,
content,
is_completed,
date_created
)
VALUES
(
NULL,
'Prueba',
'bla bla bla bla',
'0',
'2022-04-25 18:55:43.000000'
);
/* Read all */
SELECT
*
FROM
tasks;
/* Read one by id */
SELECT
*
FROM
tasks
WHERE
id = 1;
/* Update one by id */
UPDATE
tasks
SET
title = 'Prueba changed',
content = 'bla changed',
is_completed = '1'
WHERE
id = 1;
/* Delete one by id */
DELETE FROM
tasks
WHERE
id = 1;