Posts

Showing posts from April, 2018

SQL Server tutorial part 5 - View

Image
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. Sample table Sample Data Create View Update View Drop View Please donate and support at https://www.paypal.me/Rajcoomar

SQL Server tutorial part 4 - Index

Image
Indexes are used in SQL server to quickly retrieve the information Type of Indexes In SQL Server indexes are one of the following two types: Clustered Index  Non-Clustered Index.  Clustered Index A clustered index is the index that will arrange the rows physically in the memory in sorted order. An advantage of a clustered index is that searching for a range of values will be fast. Non-clustered Index  A non-clustered index is an index that will not arrange the rows physically in the memory in sorted order.  An advantage of a non-clustered index is searching for the values that are in a range will be fast. You can create a maximum of 999 non-clustered indexes on a table Sample Table Create index Drop index Please donate and support at https://www.paypal.me/Rajcoomar

SQL Server tutorial part 3 - DDL (Data Definition Language) - Alter Table

Image
This SQL Server tutorial explains how to use the ALTER TABLE statement in SQL Server (Transact-SQL) to add a column, modify a column, drop a column, rename a column or rename a table with examples. Sample Table  Alter table add a column Alter table add multiple columns Amend Column Drop Column Please donate and support at https://www.paypal.me/Rajcoomar

SQL Server tutorial part 2 - DDL (Data Definition Language) - Create Table

Image
The CREATE TABLE statement is used to create a new table in a database. The following constraint can be applied when creating a table: NOT NULL  - Ensures that a column cannot have a NULL value UNIQUE  - Ensures that all values in a column are different PRIMARY KEY  - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table FOREIGN KEY  - Uniquely identifies a row/record in another table CHECK  - Ensures that all values in a column satisfy a specific condition DEFAULT  - Sets a default value for a column when no value is specified INDEX  - Used to create and retrieve data from the database very quickly Using script Create temporary table Using GUI In SQL server management studio expand the database created and right click on "TABLES" from the context menu select NEW > TABLE Create your table and right click on the column that you want to make it as a primary key constraint and from the context menu select Set Pr

SQL Server tutorial part 1 - DDL (Data Definition Language) - Create Database

Image
Definition The CREATE DATABASE statement is used to create a new SQL database. Using Script Using GUI Open Microsoft SQL Management Studio  Connect to the database engine using database administrator credentials  Expand the server node  Right-click Databases and select New Database  Enter a database name and click OK to create the database Please donate and support at https://www.paypal.me/Rajcoomar