In this article, We’ll go over the different types of views in SQL Server through examples. In addition, we will learn how to create, alter, update, and delete views in SQL Server.
What is a view in SQL?
In this post, we will discuss about the different types of triggers in the SQL Server.
What is a trigger in the SQL server?
Triggers in SQL Server are a type of stored procedure that is automatically executed when an event occurs in the database object.
DML triggers: A DML trigger is triggered when a user attempts to modify the data through a data manipulation language (DML) event such as INSERT, UPDATE, and DELETE statements on a table or view.
DML events are executed when any legitimate event occurs, regardless of whether or not table rows are affected.
DDL triggers: Data definition language (DDL) triggers are fire in response to a range of DDL events such as CREATE, ALTER, and DROP statements in Transact-SQL.
How To Create SQL Server Trigger For Update Event?
In this article, we will learn SQL Delete Cascade rules with foreign key constraints having multiple examples.
SQL Delete Cascade–Overview
1. SQL DELETE CASCADE : In the SQL server, when we create a foreign key using the SQL delete cascade option, it deletes all the related rows from the child table when the referenced row is deleted from the parent table having primary key constraint.
The following are the SQL scripts that create a parent (Departments), child (Employees) table, and a foreign key on the child table without the SQL delete cascade rule.
SQL Comparison Operators
The PRIMARY KEY constraint in SQL Server ensures that each entry in a table is uniquely recognized.
Primary keys must have UNIQUE values and cannot have NULL values.
In SQL Server, a table can only have one primary key, which can be made up of one or more columns (fields).
What is the primary key in SQL Server?
In SQL Server, a Primary Key is a field or column which uniquely identifies each and every record in a table.
- A primary key column doesn’t allow to insert null or duplicate values.
- A Primary key can consist of up to 16 columns.
- A table can have only one primary key which can be applied on single or multiple columns.
- The primary key consist of multiple columns or fields is known as the Composite primary key.
- A Primary Key constraint can be applied to the columns having any data types.
- A primary key by default creates a clustered index on the column.
A primary key can be created at the column or table level.
Syntax to create a primary key
The following are the syntax to create a primary key in SQL server.