-
Notifications
You must be signed in to change notification settings - Fork 6
/
notes.txt
108 lines (84 loc) · 2.93 KB
/
notes.txt
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
DON'T PUT ANYTHING YOU DON'T WANT THE WORLD TO SEE:
================================================================
TODO: CREATE DUMP OF DB TO PASS ON TO ITERATORS
TODO: REMAKE ERD WITH NEW NAMING
================================================================
ENTER YOUR POSTGRESQL ENVIRONMENT USING THE HEROKU CLI:
heroku pg:psql -a jobsmith
================================================================
https://www.postgresql.org/docs/9.1/sql-createtable.html
NOTE: remove ; in command line
CREATE TABLE
CREATE TABLE users (
id integer PRIMARY KEY DEFAULT nextval('serial'),
password varchar NOT NULL,
username varchar NOT NULL,
);
code char(5) CONSTRAINT firstkey PRIMARY KEY,
title varchar(40) NOT NULL,
did integer NOT NULL,
date_prod date,
kind varchar(10),
len interval hour to minute
CREATE TABLE distributors (
did integer PRIMARY KEY DEFAULT nextval('serial'),
name varchar(40) NOT NULL CHECK (name <> '')
);
================================================================
INSERT INTO TABLE
INSERT INTO users(password, username)
VALUES (test123, Jaloe)
RETURNING *;
================================================================
READ ALL IN TABLE:
SELECT * FROM users;
PostgreSQL DocumentationPostgreSQL Documentation
CREATE TABLE
================================================================
https://stackoverflow.com/questions/6677517/update-if-different-changed
update table1
set col1 = 'hello',
col2 = 'hello',
col3 = 'hello'
/* Only update rows from CustomerId 100, 101, 102 & 103 */
where table1.CustomerId IN (100, 101, 102, 103)
/* AVOID NET ZERO CHANGES */
and exists
(
/* DESTINATION */
select table1.col1
table1.col2
table1.col3
except
/* SOURCE */
select z.col1,
z.col2,
z.col3
from #anytemptableorsubquery z
where z.CustomerId = table1.CustomerId
)
================================================================
CURL COMMANDS:
================================================================
ROLE:
/**
* title: String
* department: String
*/
curl -X POST -H "Content-Type: application/json" \
-d '{"title": "Grub Harvester", "department": "Accounting"}' \
http://localhost:3000/api/role
curl -X GET -H "Content-Type: application/json" \
http://localhost:3000/api/role/1
curl -X GET -H "Content-Type: application/json" \
http://localhost:3000/api/role/
curl -X PUT -H "Content-Type: application/json" \
-d '{"title": "Onion Washer", "department": "Development"}' \
http://localhost:3000/api/role/1
curl -X DELETE -H "Content-Type: application/json" \
http://localhost:3000/api/role/1
================================================================
LOOK AT TABLES
SELECT * FROM information_schema.tables
================================================================
JOIN APPLICATION AND INTERVIEW