-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgres-basics.sql
More file actions
65 lines (53 loc) · 1.22 KB
/
postgres-basics.sql
File metadata and controls
65 lines (53 loc) · 1.22 KB
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
--https://www.postgresqltutorial.com/ & Corey Schaffer Videos
--Table Creation
--Data Type Reference: https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-data-types/
/*
* CREATE TABLE people (
* id INTEGER,
* name VARCHAR (255)
* )
*/
-- Insert Information
-- insert into people (id, name) values (3, 'Jim');
-- Retrieve all records from a Table
-- select * from people;
-- Retrieve records from specific fields.
-- select id, name from people;
-- Results using where clause to filer
/*
* SELECT * FROM PEOPLE
* WHERE name = 'Tom'
* OR name = 'Jim'
*/
-- Ordering the Results
/*
* SELECT * FROM PEOPLE
* WHERE name = 'Tom'
* OR name = 'Jim'
* order by name asc; --can use "desc" or multiple variables like "ORDER BY first_name, last_name desc;"
*/
/*
* SELECT * FROM PEOPLE
* WHERE name = 'Tom'
* OR name = 'Jim'
* order by name asc; --can use "desc"
*/
-- Updating
-- update people
-- set name = 'Confidential'
-- Clear table
-- delete from people;
-- UPDATE Data
-- select data before updating
-- select * from people
/*
* update people
* set name = 'Janice'
* where name = 'Jane'
* and id = '1'
*/
-- Delete Data
-- select * from people
-- delete from people
-- where name = 'Janice'
-- and id = 1