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

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