View VS SYNONYM VS TRIGGER in SQL

Image for post
Image for post

What is a view?

A view is a virtual table based on the result set of an SQL statement.

Here is an example.

create view [sales].[v.salesbyperson2] as select salespersonid, round(totaldue,2) as salesamount from sales.sales

What is a synonym?

A synonym, like the name, is an alternate name we create for another database object.

Here is the syntax:

create synonym [synonym_name] for [server_name].[database_name].[schema_name].[object_name]

What is the trigger?

A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server.

Regardless of whether or not any table rows are affected.

Here is an example:

create trigger reminder1 on sales.customer after insert, update as raiserror ('notify customer relations', 16, 10); go

If you are interested in or have any problems with SQL or Business Intelligence, feel free to contact me.

Or you can connect with me through my LinkedIn.

Originally published at http://jacquiwu.com on February 7, 2020.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store