How to install and configure Dbeaver in Ubunut for MySQL and PostgreSQL

In this artivle, we will see how to install and configure Dbeaver in Ubunut for MySQL and PostgreSQL step by step.

Dbeaver is cross-platform database tool for developers, database administrators, analysts, and everyone working with data. It supports all popular SQL databases like MySQL, MariaDB, PostgreSQL, SQLite, Apache Family, and more.

Continue reading How to install and configure Dbeaver in Ubunut for MySQL and PostgreSQL

What is the difference between Stored Procedure and Trigger in SQL

In this article, we will see the difference between Stored Procedure and Trigger in SQL. Following are the main differences between Stored Procedure and Trigger:

Continue reading What is the difference between Stored Procedure and Trigger in SQL

Stored Procedure Trigger
Store Procedures are invoked explicitly Triggers are invoked implicitly
Stored procedure is a user defined piece of code which may return a value (making it a function) that is invoked by calling it explicitly. A trigger is a stored procedure that runs automatically when various events happen (eg update, insert, delete).

What is the difference between synchronous and asynchronous Replication

Following are the difference between synchronous and asynchronous Replication.

1. Asynchronous Replication: There is delay between Master and Slave(Secondary). In this data can be replicated after the transaction has been committed on the master. Which means the slave is never ahead of the master. So, in the case of writing it is usually a little behind the master. This delay also called lag.

2. Synchronous Replication: Continue reading What is the difference between synchronous and asynchronous Replication

Difference between Stored procedure and Function in SQL

Following are the main differences between Stored procedure and Function in SQL.

Continue reading Difference between Stored procedure and Function in SQL

Stored Procedure Function
Stored procedure may or may not return values A Function must return a value
Stored procedures can have input/output parameters Functions can have only input parameters
Stored Procedure may take 0 to n input parameters For a Function it is mandatory to take one input parameter

What is the difference between union and join

Following are the differences between union and join in relational database engines.
A union returns the results of two different queries as a single recordset and A join allows you to relate similar data in different tables.

UNION JOIN
UNION puts lines from queries after each other, JOIN makes a cartesian product and subsets it
Union Operation is combined result of the Vertical Aggregate of the rows JOIN Operation is combined result of the Horizontal Aggregate of the Columns
Union combines rows JOIN links the rows
Performed only on two similar structures Performed only on two dissimilar structures also
A union returns the results of two different queries as a single recordset. A join allows you to relate similar data in different tables.

Visual depiction of a join. Table A and B’s columns are combined into a single result:

Continue reading What is the difference between union and join

How to count the number of emails per domain in PostgreSQL MySQL Oracle

In this article, we will see how to count the number of emails per domain, we can use the following query in SQL Server or PostgreSQL or MySQL or Oracle or any RDBMS:

To count the number of emails per domain in PostgreSQL MySQL Oracle:

SELECT SUBSTRING( email, CHARINDEX('@', email)+1, LEN(email)-CHARINDEX('@', email) ) domain_name, COUNT(email) emails_count FROM sales.customers GROUP BY SUBSTRING( email, CHARINDEX('@', email)+1, LEN(email)-CHARINDEX('@', email) );

Continue reading How to count the number of emails per domain in PostgreSQL MySQL Oracle

How to connect to PostgreSQL using Python script

In this article, we will see how to connect to PostgreSQL Server using Python script. To connect to PostgreSQL Server from Python, we have to install psycopg2 on Linux or Windows.

Steps to connect to PostgreSQL using Python:

Continue reading How to connect to PostgreSQL using Python script

ModuleNotFoundError: No module named ‘psycopg2’

psycopg2 module is used to connect to PostgreSQL Server using Python. But, if you receive below error means,you have not installed psycopg2 module.

Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'psycopg2'

Solution:

Continue reading ModuleNotFoundError: No module named ‘psycopg2’

How to Install pgAdmin4 on Ubuntu

In this article, we will see how to Install pgAdmin4 on Ubuntu.

What is pgAdmin?

pgAdmin is the leading Open Source management tool for Postgres, the world’s most advanced Open Source database.

Steps to Install pgAdmin4 on Ubuntu:

1. Run the command

sudo apt-get install pgadmin4 pgadmin4-apache2

Continue reading How to Install pgAdmin4 on Ubuntu

How to start stop PostgreSQL on Ubuntu

This article covers how to start, stop and restart PostgreSQL on Ubuntu. This is PostgreSQL DBA routine task.
We are going to cover stop, start and restart using service and systemctl commands. But, not covering to kill the PostgreSQL process from Linux shell.

Stop Start and Restart PostgreSQL using service:

sudo service postgresql stop sudo service postgresql start sudo service postgresql restart

Examples for How to start stop PostgreSQL on Ubuntu:
Continue reading How to start stop PostgreSQL on Ubuntu