-
Notifications
You must be signed in to change notification settings - Fork 353
/
Create and Manage AlloyDB Instances: Challenge Lab
81 lines (62 loc) · 2.42 KB
/
Create and Manage AlloyDB Instances: Challenge Lab
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
export ZONE=$(gcloud compute instances list alloydb-client --format 'csv[no-heading](zone)')
export REGION="${ZONE%-*}"
gcloud beta alloydb clusters create lab-cluster \
--password=Change3Me \
--network=peering-network \
--region=$REGION \
--project=$DEVSHELL_PROJECT_ID
gcloud beta alloydb instances create lab-instance \
--instance-type=PRIMARY \
--cpu-count=2 \
--region=$REGION \
--cluster=lab-cluster \
--project=$DEVSHELL_PROJECT_ID
gcloud alloydb instances create lab-instance-rp1 \
--cluster=lab-cluster \
--region=$REGION \
--instance-type=READ_POOL \
--cpu-count=2 \
--read-pool-node-count=2
gcloud beta alloydb backups create lab-backup --region=$REGION --cluster=lab-cluster
export ALLOYDB=
Go To alloy DB Cluster: https://console.cloud.google.com/alloydb/clusters
echo $ALLOYDB > alloydbip.txt
psql -h $ALLOYDB -U postgres
Change3Me
CREATE TABLE regions (
region_id bigint NOT NULL,
region_name varchar(25)
) ;
ALTER TABLE regions ADD PRIMARY KEY (region_id);
CREATE TABLE countries (
country_id char(2) NOT NULL,
country_name varchar(40),
region_id bigint
) ;
ALTER TABLE countries ADD PRIMARY KEY (country_id);
CREATE TABLE departments (
department_id smallint NOT NULL,
department_name varchar(30),
manager_id integer,
location_id smallint
) ;
ALTER TABLE departments ADD PRIMARY KEY (department_id);
INSERT INTO regions VALUES ( 1, 'Europe' );
INSERT INTO regions VALUES ( 2, 'Americas' );
INSERT INTO regions VALUES ( 3, 'Asia' );
INSERT INTO regions VALUES ( 4, 'Middle East and Africa' );
INSERT INTO countries VALUES ('IT', 'Italy', 1 );
INSERT INTO countries VALUES ('JP', 'Japan', 3 );
INSERT INTO countries VALUES ('US', 'United States of America', 2 );
INSERT INTO countries VALUES ('CA', 'Canada', 2 );
INSERT INTO countries VALUES ('CN', 'China', 3 );
INSERT INTO countries VALUES ('IN', 'India', 3 );
INSERT INTO countries VALUES ('AU', 'Australia', 3 );
INSERT INTO countries VALUES ('ZW', 'Zimbabwe', 4 );
INSERT INTO countries VALUES ('SG', 'Singapore', 3 );
INSERT INTO departments VALUES (10, 'Administration', 200, 1700 );
INSERT INTO departments VALUES (20, 'Marketing', 201, 1800);
INSERT INTO departments VALUES (30, 'Purchasing', 114, 1700 );
INSERT INTO departments VALUES (40, 'Human Resources', 203, 2400);
INSERT INTO departments VALUES (50, 'Shipping', 121, 1500);
INSERT INTO departments VALUES (60, 'IT', 103, 1400);