-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01 Creating_Table.sql
More file actions
70 lines (50 loc) · 2.02 KB
/
01 Creating_Table.sql
File metadata and controls
70 lines (50 loc) · 2.02 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
-- Creating the database
-- Initial Database Setup
-- Creating the table pg4e_debug
CREATE TABLE pg4e_debug (
id SERIAL,
query VARCHAR(4096),
result VARCHAR(4096),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(id)
);
-- Inserting data into the pg4e_debug table
INSERT INTO pg4e_debug (query, result) VALUES
('SELECT id, query, result, created_at FROM pg4e_debug', 'Success'),
('SELECT id, keystr, valstr FROM pg4e_meta', 'Success'),
('SELECT track.title, album.title FROM track JOIN album ON track.album_id = album.id ORDER BY track.title LIMIT 3', 'Success');
-- Retrieving it's content
SELECT query, result, created_at FROM pg4e_debug;
query | result | created_at
------------------------------------------------------+---------+----------------------------
SELECT id, query, result, created_at FROM pg4e_debug | Success | 2023-10-04 23:52:32.767675
SELECT id, keystr, valstr FROM pg4e_meta | Success | 2023-10-04 23:52:32.775473
SELECT track.title, album.title +| Success | 2023-10-04 23:52:32.791638
FROM track +| |
JOIN album ON track.album_id = album.id +| |
ORDER BY track.title LIMIT 3; | |
(3 rows)
--
CREATE TABLE pg4e_result (
id SERIAL,
link_id INTEGER UNIQUE,
score FLOAT,
title VARCHAR(4096),
note VARCHAR(4096),
debug_log VARCHAR(8192),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP
);
# Inserting some data
-- Create the table ages
CREATE TABLE ages (
name VARCHAR(128),
age INTEGER
);
-- Make sure the table is empty by deleting any rows that you previously inserted, then insert values
DELETE FROM ages;
INSERT INTO ages (name, age) VALUES ('Cody', 34);
INSERT INTO ages (name, age) VALUES ('Darla', 35);
INSERT INTO ages (name, age) VALUES ('Franko', 38);
INSERT INTO ages (name, age) VALUES ('Saman', 31);
INSERT INTO ages (name, age) VALUES ('Toluwani', 15);