Загрузка...

Guid in SQL Server

Text version of the video
http://csharp-video-tutorials.blogspot.com/2017/03/guid-in-sql-server.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1

Slides
http://csharp-video-tutorials.blogspot.com/2017/03/guid-in-sql-server_9.html

All SQL Server Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-sql-server-video-tutorials-for.html

All SQL Server Slides
http://csharp-video-tutorials.blogspot.com/p/sql-server.html

All SQL Server Tutorial Videos
https://www.youtube.com/playlist?list=PL08903FB7ACA1C2FB

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd

All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists

In this video we will discuss
1. What is a GUID in SQL Server
2. When to use GUID
3. Advantages and disadvantages of using a GUID

What is GUID data type in SQL Server
The GUID data type is a 16 byte binary data type that is globally unique. GUID stands for Global Unique Identifier. The terms GUID and UNIQUEIDENTIFIER are used interchangeably.

To declare a GUID variable, we use the keyword UNIQUEIDENTIFIER

Declare @ID UNIQUEIDENTIFIER
SELECT @ID = NEWID()
SELECT @ID as MYGUID

How to create GUID in sql server
To create a GUID in SQL Server use NEWID() function

For example, SELECT NEWID(), creates a GUID that is guaranteed to be unique across tables, databases, and servers. Every time you execute SELECT NEWID() query, you get a GUID that is unique.

Example GUID : 0BB83607-00D7-4B2C-8695-32AD3812B6F4

When to use GUID data type : Let us understand when to use a GUID in SQL Server with an example.

For example code used in the demo please refer to the following article
http://csharp-video-tutorials.blogspot.com/2017/03/guid-in-sql-server.html

The main advantage of using a GUID is that it is unique across tables, databases and servers. It is extremely useful if you're consolidating records from multiple SQL Servers into a single table.

The main disadvantage of using a GUID as a key is that it is 16 bytes in size. It is one of the largest datatypes in SQL Server. An integer on the other hand is 4 bytes,

An Index built on a GUID is larger and slower than an index built on integer column. In addition a GUID is hard to read compared to int.

So in summary, use a GUID when you really need a globally unique identifier. In all other cases it is better to use an INT data type.

Видео Guid in SQL Server канала kudvenkat
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять