Cross database query between Google SQL instances PostgreSQL

Topic: Cross-database query between Google SQL instances PostgreSQL


Cross-database query between Google SQL instances PostgreSQL | GCP SQL Tutorial 2022, in this article we are going to learn Cross database query between Google SQL instances PostgreSQL.

Script used in demo:

create database sales_asia
create database sales_europe
create table public.AsiaSale(id int, name varchar(100), region varchar(100))
insert into public.AsiaSale values(1,'aamir','Asia')
Select * From public.AsiaSale create table public.EuropeSale(id int, name varchar(100), region varchar(100))
insert into public.EuropeSale values(2,'lisa','Europe')
Select * From public.europesale -- we want to execute union query in sales_asia database that should get data from sales_europe.public.EuropeSale table.
Select * From public.europesale
union all
select * from public.AsiaSale 1) Set up a Foreign User-- Do this on DB from which you would like to read the tables
CREATE USER fdwuser WITH PASSWORD 'test123$';
GRANT USAGE ON SCHEMA PUBLIC TO fdwuser;
GRANT SELECT ON europesale TO fdwuser; --Check the list of Tables
select * from information_schema.tables where table_name like '%sale%' 2) Create the Extension
CREATE EXTENSION postgres_fdw;
select * from pg_extension; 3) Create the Foreign Server
CREATE SERVER secondrydb_srv FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '34.67.244.181', port '5432', dbname 'sales_europe');
Select * From pg_foreign_server; 4) Create User Mapping
CREATE USER MAPPING FOR postgres SERVER secondrydb_srv OPTIONS(user 'fdwuser',password 'test123$');
Select * From pg_user_mappings 5) Grant the Local User Access to the Foreign Data Wrapper
GRANT USAGE ON FOREIGN SERVER secondrydb_srv TO postgres; 6) Import the Foreign Schema or Tables
IMPORT FOREIGN SCHEMA public LIMIT TO (europesale) FROM SERVER secondrydb_srv INTO public; Select * From public.europesale
union all
select * from public.AsiaSale


Video Demo: Cross database query between Google SQL instances PostgreSQL


How to Perform Cross Database Queries in PostgreSQL in GCP Cloud

Topic: How to Perform Cross Database Queries in PostgreSQL in GCP Cloud


How to Perform Cross Database Queries in PostgreSQL in GCP Cloud | GCP Cloud SQL Tutorial 2022, in this video we are going to learn How to Perform Cross Database Queries in PostgreSQL in GCP Cloud | GCP Cloud SQL Tutorial 2022


Video Demo: How to Perform Cross Database Queries in PostgreSQL in GCP Cloud




Cross database query between Google SQL instances PostgreSQL

 Topic: Cross database query between Google SQL instances PostgreSQL


Cross database query between Google SQL instances PostgreSQL | GCP SQL Tutorial 2022, in this video we are going to learn Cross database query between Google SQL instances PostgreSQL | GCP SQL Tutorial 2022



 Video Demo: Cross database query between Google SQL instances PostgreSQL

How to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs GCP Cloud SQL Tutorial

Topic:  How to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs


How to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs GCP Cloud SQL Tutorial | GCP SQL Tutorial 2022, in this video we are going to learnHow to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs GCP Cloud SQL Tutorial | GCP SQL Tutorial 2022


Video Demo: How to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs


How to Perform In place Upgrade to GCP SQL Instance | Inplace Upgrade PostgreSQL 12 to PostgreSQL 14

Topic: How to Perform In place Upgrade to GCP SQL Instance | Inplace Upgrade PostgreSQL 12 to PostgreSQL 14


How to Perform In place Upgrade to GCP SQL Instance | Inplace Upgrade PostgreSQL 12 to PostgreSQL 14 | GCP SQL Tutorial 2022, in this video we are going to learn How to Perform In place Upgrade to GCP SQL Instance | Inplace Upgrade PostgreSQL 12 to PostgreSQL 14



Video Demo: How to Perform In place Upgrade to GCP SQL Instance



How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform | GCP Tutorials 2022

Topic: How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform


How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform | GCP SQL Tutorial 2022, in this video we are going to learn How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform | GCP SQL Tutorial 2022

Script: ERROR: role "aamir" cannot be dropped because some objects depend on it DETAIL: owner of database test 1 object in database test SQL state: 2BP01 Error Invalid request: failed to delete user aamir: . role "aamir" cannot be dropped because some objects depend on it Details: owner of database test 1 object in database test. 0) Prepare the scenario Create user aamir and then create some objects create database Test create table public.mytable(id int, name varchar(100)); insert into public.mytable values(1,'aamir'); Select * from public.mytable; 1) -- Let's think about a user who has left the company and you need to drop the user. If you don't know the --password for the user, login by using postgres user and change the password of user. --How to change the password for role Alter role aamir LOGIN password 'Test123$'; 2) -- Tried to drop the role by using postgres user session drop role aamir -- you will get errot that objects are owened by user aamir GRANT postgres to aamir; --2 -- login by aamir user and run below command to assign all objects to postgres user REASSIGN OWNED BY aamir TO postgres; --3 login back to postgres and run below drop role aamir --4 Check if Objects are not dropped by dropping user.


 

Video Demo: How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform

How to Schedule Maintenance with PostgreSQL pg cron Extension | Google Cloud Platform SQL Tutorial

Topic:  How to Schedule Maintenance with PostgreSQL pg cron Extension


How to Connect to GCP SQL Server Instance by using Private IP Configuration | GCP SQL Tutorial 2022, in this video we are going to learn How to Connect to GCP SQL Server Instance by using Private IP Configuration | GCP SQL Tutorial 2022

Script:

--Postgres Instance Level Settings

cloudsql.enable_pg_cron 

value= on

cron.database_name 

Value : Provide your Database Name

  

-- check if extensions are installed

select * from pg_extension;

-- use this to create extension on db, it will create two tables job and job_run_detail

CREATE EXTENSION pg_cron;

-- list of jobs to run on schedule

Select * from cron.job;

  

-- Check executed jobs status

SELECT jobid, runid, job_pid, database, username, command, status, return_message, start_time, end_time

FROM cron.job_run_details;

  

-- Create Schedule to Delete records, insrt record or create index

SELECT cron.schedule('27 19 * * *', $$DELETE FROM public.Person$$);

SELECT cron.schedule('31 19 * * *', $$insert into public.Person values (2,'Raza',200)$$);

-- create schedule to create an index on table

SELECT cron.schedule('36 19 * * *', $$CREATE INDEX idx_pid ON public.Person(id)$$);

  

  -- Schedule to run script on another database

  -- SELECT cron.schedule('<Schedule>', '<Task>', '<Database>')

  SELECT cron.schedule('40 19 * * *', 'test2','create table public.crontab(id int)' )

  

  -- also we can insert into cron.job manually

  INSERT INTO cron.job(

jobid, schedule, command, nodename, nodeport, database, username, active, jobname)

VALUES (7, '55 19 * * *', 'create table public.crontab(id int)','localhost', '5432', 'test2', 'postgres', true,'testjob');

  

  

  

-- Delete schedule

-- SELECT cron.unschedule(<ID of the scheduled task>) -- you will get the schedule if from cron.job

  Select * from cron.job;

  -- Delete the Schedule

  select cron.unschedule(6)




Video Demo: How to Schedule Maintenance with PostgreSQL pg cron Extension

How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in GCP | GCP SQL Tutorial

Topic: How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in Google Cloud Platform


How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in GCP | GCP SQL Tutorial 2022, in this video we are going to learn How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in GCP | GCP SQL Tutorial 2022


Link: https://cloud.google.com/sql/docs/mysql/start-stop-restart-instance



Video Demo: How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in Google Cloud Platofrm

How to Connect to GCP SQL Server Instance by using Private IP Configuration | GCP SQL Tutorial 2022

Topic: How to Connect to GCP SQL Server Instance by using Private IP Configuration


How to Connect to GCP SQL Server Instance by using Private IP Configuration | GCP SQL Tutorial 2022, in this video we are going to learn How to Connect to GCP SQL Server Instance by using Private IP Configuration | GCP SQL Tutorial 2022


Video Demo: How to Connect to GCP SQL Server Instance by using Private IP Configuration 


How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP

Topic: How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP 


How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP GCP Tutorial 2022, in this video, we are going to learn How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP | GCP Tutorial 2022


Script:

Install MySQL Client

sudo apt-get install default-mysql-client 

Connect to MySQL by using Private IP
mysql -h IP -u root -p


Connect to MySQL with private IP
mysql -h 172.21.160.7 -u root -p


Video Demo: How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP 


How to Connect to PostgreSQL Instance with Private IP by using GCP VM GCP SQL Cloud Tutorial 2022

Topic:  How to Connect to PostgreSQL Instance with Private IP by using GCP VM 


How to Connect to PostgreSQL Instance with Private IP by using GCP VM GCP SQL Cloud Tutorial 2022, in this video we are going to learn How to Connect to PostgreSQL Instance with Private IP by using GCP VM GCP SQL Cloud Tutorial 2022

Script:

Install psql client

sudo apt-get update
sudo apt-get install postgresql-client


psql "host=PrivateIP port=5432 sslmode=disable dbname=postgres user=postgres"

psql "host=172.21.160.12 port=5432 sslmode=disable dbname=postgres user=postgres"
  


Video Demo: How to Connect to PostgreSQL Instance with Private IP by using GCP VM


How to Install PostgreSQL 14.5 on Windows Machine | How to Connect to PostgreSQL by using pgAdmin

Topic: How to Install PostgreSQL 14.5 on Windows Machine and How to Connect to PostgreSQL by using pgAdmin 


How to Install PostgreSQL 14.5 on Windows Machine | How to Connect to PostgreSQL by using pgAdmin GCP Tutorial 2022, in this video we are going to learn How to Install PostgreSQL 14.5 on Windows Machine | How to Connect to PostgreSQL by using pgAdmin | GCP Tutorial 2022


Video Demo: How to Install PostgreSQL 14.5 on Windows Machine and How to Connect to PostgreSQL by using pgAdmin 


How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on GCP

Topic: How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on Google Cloud Platform


How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on GCP Tutorial 2022, in this video we are going to learn How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on GCP | GCP Tutorial 2022

Script: command line tools

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

commad line tools
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads



Video Demo: How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on GCP
 

How to Enable Slow Query Logging and General Logging for MySQL to Table or File in GCP

 Topic: How to Enable Slow Query Logging and General Logging for MySQL to Table or File in GCP


How to Enable Slow Query Logging and General Logging for MySQL to Table or File in GCP Tutorial 2022, in this video we are going to learn How to Enable Slow Query Logging and General Logging for MySQL to Table or File in GCP | GCP Tutorial 2022



Video Demo: How to Enable Slow Query Logging and General Logging for MySQL to Table or File in Google Cloud Platform

How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL

Topic: How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL.


How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL GCP Tutorial 2022, in this video we are going to learn How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL


Video Demo: How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL

 

Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated and OnDemand

Topic: Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated and OnDemand



Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated and OnDemand GCP Tutorial 2022, in this video we are going to learn Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated and OnDemand.


Video Demo: Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated and OnDemand

How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition in Google Cloud

Topic:  How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition in Google Cloud Platform.


How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition GCP Tutorial 2022, in this video we are going to learn How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition.


Video Demo: How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition in Google Cloud Platform

How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File

Topic: How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File.

How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File GCP Tutorial 2022, in this video we are going to learn How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File | GCP Tutorial 2022.


Video Demo: How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File


How to Edit SQL Instance Settings on GCP | Does Restart Required if You Edit SQL Instances on GCP

 Topic: How to Edit SQL Instance Settings on Google Cloud Platform

How to Edit SQL Instance Settings on GCP | Does Restart Required if You Edit SQL Instances on GCP Tutorial 2022, in this video we are going to learn How to Edit SQL Instance Settings on GCP | Does Restart Required if You Edit SQL Instances on Google Cloud Platform.



Video Demo: How to Edit SQL Instance Settings on Google Cloud Platform.


How to Clone SQL Instances in Google Cloud Platform | Create Clone of SQL Server, MySQL, PostgreSQL

Topic: How to Clone SQL Instances in Google Cloud Platform  


How to Clone SQL Instances in Google Cloud Platform | Create Clone of SQL Server, MySQL, PostgreSQL GCP Tutorial 2022, in this video we are going to learn How to Clone SQL Instances in Google Cloud Platform | Create Clone of SQL Server, MySQL, PostgreSQL | GCP Tutorial 2022

Link: https://cloud.google.com/sql/docs/sqlserver/clone-instance#gcloud


Video Demo: How to Clone SQL Instances in Google Cloud Platform | Create Clone of SQL Server, MySQL, PostgreSQL

How to Start, Stop, & Restart SQL instances on GCP by using Console and Gcloud Commands GCP Tutorial

Topic: How to Start, Stop, & Restart SQL instances on GCP by using Console and Gcloud Commands GCP Tutorial

How to Start, Stop, & Restart SQL instances on GCP by using Console and Gcloud Commands GCP Tutorial 2022, in this video we are going to learn How to Start, Stop, & Restart SQL instances on GCP by using Console and Gcloud Commands | GCP Tutorial 2022

Link: https://cloud.google.com/sql/docs/mysql/start-stop-restart-instance


Video Demo: How to Start, Stop, & Restart SQL instances on GCP by using Console and Gcloud Commands GCP Tutorial

Google Cloud SQL Tutorial

Google Cloud SQL Tutorial


  1. How to Create SQL Instance on Google Cloud Platform and Connect by using SSMS - Google Cloud Platform SQL Tutorial 2022
  2. How to Start, Stop, & Restart SQL instances on GCP by using Console and G cloud Commands Google Cloud Platform SQL Tutorial 2022
  3. How to Clone SQL Instances in Google Cloud Platform | Create Clone of SQL Server, MySQL, PostgreSQL
  4. How to Edit SQL Instance Settings on GCP | Does Restart Required if You Edit SQL Instances  on Google Cloud Platform
  5. Understanding Backups of SQL Server, MySQL, PostgreSQL in GCP Limitation of Automated  and OnDemand
  6. How to Upgrade SQL Server Instances from Express to Standard or Enterprise Edition in Google Cloud SQL
  7. How to Migrate On Prem SQL Server Database to GCP SQL Server Instance by using BAK File & SQL File
  8. How to Setup SQL Server Instance with High Availability in GCP | How to Failover SQL Server Instance
  9. How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform GCP Tutorial
  10. How to Create Read Replicas for SQL Server Instance in GCP Availability Groups for SQL Server in GCP
  11. How to Enable Point in Time Recovery for MySQL Instance in GCP | How to Restore Database with PTR
  12. Create MySQL Instance with Read Replicas in GCP | Promote MySQL Read Replica to Stand Alone Mode
  13. How to Create PostgreSQL 14 Instance on GCP How to Connect pgAdmin From Local Computer to PostgreSQL
  14. How to Enable Slow Query Logging and General Logging for MySQL to Table or File in GCP
  15. How to Install psql Command line on Windows Machine and Connect to PostgreSQL Instance on GCP
  16. How to Install PostgreSQL 14.5 on Windows Machine | How to Connect to PostgreSQL by using pgAdmin
  17. How to Connect to PostgreSQL Instance with Private IP by using GCP VM GCP SQL Cloud Tutorial 2022
  18. How to Connect to MySQL Instance in Google Cloud Platform from Virtual Machine By Using Private IP
  19. How to Connect to GCP SQL Server Instance by using Private IP Configuration  GCP SQL Tutorial 2022
  20. How to Stop and Start SQL Instances on Schedule by using Cloud Schedule in GCP  GCP SQL Tutorial
  21. How to Schedule Maintenance with PostgreSQL pg cron Extension Google Cloud Platform SQL Tutorial
  22. How to Drop User or Role in PostgreSQL Instance on Google Cloud Platform GCP Tutorials 2022
  23. How to Perform In place Upgrade to GCP SQL Instance | Inplace Upgrade PostgreSQL 12 to PostgreSQL 14
  24. How to Stop GCP PostgreSQL from Logging Passwords in Clear Text in Logs GCP Google Cloud SQL Tutorial
  25. SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform  GCP Tutorial

SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform | GCP Tutorial

 Topic: SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform 

SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform GCP Tutorial 2022, in this video we are going to learn about SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform | GCP Tutorial 2022.



Video Tutorial: SQL Server Error 53 Could not Open Connection On SQL Server on Google Cloud Platform

Create MySQL Instance with Read Replicas in GCP | Promote MySQL Read Replica to Stand Alone Mode

Topic: Create MySQL Instance with Read Replicas in Google Cloud Platform.


Create MySQL Instance with Read Replicas in GCP | Promote MySQL Read Replica to Stand Alone Mode GCP Tutorial 2022, in this video we are going to learn Create MySQL Instance with Read Replicas in GCP | Promote MySQL Read Replica to Stand Alone Mode


Video Demo: Create MySQL Instance with Read Replicas in GCP

 

How to Enable Point in Time Recovery for MySQL Instance in GCP | How to Restore Database with PTR

Topic: How to Enable Point in Time Recovery for MySQL Instance in GCP.


How to Enable Point in Time Recovery for MySQL Instance in GCP | How to Restore Database with PTR GCP Tutorial 2022, in this video we are going to learn How to Enable Point in Time Recovery for MySQL Instance in GCP | How to Restore Database with PTR | GCP Tutorial 2022.


Video Demo: How to Enable Point in Time Recovery for MySQL Instance in Google Cloud Platform 

 

How to Create Read Replicas for SQL Server Instance in GCP Availability Groups for SQL Server in GCP

How to Create Read Replicas for SQL Server Instance in Google Cloud Platform.

How to Create Read Replicas for SQL Server Instance in GCP Availability Groups for SQL Server in GCP | GCP Tutorial 2022, in this video we are going to learn How to Create Read Replicas for SQL Server Instance in GCP Availability Groups for SQL Server in GCP.


Link: https://cloud.google.com/sql/docs/sqlserver/replication#sql-server-limitations


Video Demo: How to Create Read Replicas for SQL Server Instance in GCP Availability Groups for SQL Server in GCP

How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform

Topic: How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform.

How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform GCP Tutorial 2022, in this video we are going to learn How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform.


Vidoe Demo: How to Create MySQL 8.0 Instance with High Availability in Google Cloud Platform 

 

How to Setup SQL Server Instance with High Availability in Google Cloud Platform | How to Failover SQL Server Instance

Topic: How to Setup SQL Server Instance with High Availability in Google Cloud Platform.

How to Setup SQL Server Instance with High Availability in GCP | How to Failover SQL Server Instance GCP Tutorial 2022, in this video we are going to learn How to Setup SQL Server Instance with High Availability in GCP | How to Failover SQL Server Instance | GCP Tutorial 2022, Google Cloud Platform Step by Step - GCP Tutorial 2022 




Video Demo:How to Setup SQL Server Instance with High Availability in Google Cloud Platform

How to Create SQL Instance on Google Cloud Platform and Connect by using SSMS - GCP Tutorial

 Topic: How to Create SQL Instance on Google Cloud Platform and Connect by using SSMS


How to Create SQL Instance on Google Cloud Platform and Connect by using SSMS GCP Tutorial 2022, in this video we are going to learn How to Create SQL Instance on Google Cloud Platform and Connect by using SSMS from local Computer | GCP Tutorial 2022, Google Cloud Platform Step by Step - GCP Tutorial 2022 - GCP Tutorial 2022 Step by Step - Google Cloud Platform Tutorial 2022.


Video Tutorial: How to Create SQL Instance on Google Cloud Platform and Connect by using SQL Server Management Studio