You are on page 1of 8

Name: Osama

Reg No: SP20-BSE-011


Subject: Database Management System
Submitted to: Mr. Waseem Khan
Lab Assignment:1
SQL DATA TYPES
SQL data types can be broadly divided into following categories

a) Numeric data types such as int, tinyint, bigint, float, real etc.

b) Date and Time data types such as Date, Time, Datetime etc.

c) Character and String data types such as char, varchar, text etc.

d) Unicode character string data types, for example nchar,


nvarchar, ntext etc.

e) Binary data types such as binary, varbinary etc.


f) Miscellaneous data types – clob, blob, xml, cursor, table etc.

1. Bigint:
The bigint datatype in SQL Server is the 64-bit
representation of an integer. It takes up 8 bytes of storage. It
ranges from -2^63 to 2^63.

2. Binary:
The binary function converts a value to a binary string. Fixed
length with maximum length of 8000 bytes.

3. Bit:
Bit is an integer data type that can take only one of these
values: 0,1, NULL. With regard to storage if there are 8-bit
data in table then they are stored as 1 byte and vice versa.
4. Char (10): Char (10) is the line feed character. The line
feed moves the cursor to the next line. It does not return to
the beginning of the line.

5. Date:
Stores date in the form YYYY-MM-DD.

6. Datetime:
stores data and time information int the format YYYY-MM-
DD HH-MI-SS
.
7. Datetime2(7):
Declare current date and time with syntax datetime2(7)
(FRACTIONAL SECONDS PRECISION). Fractional seconds
precision is 7-digit default value and it can be from 0 to 7
digit.

8. Datetimeoffset:
The datetimeoffset allows you to manipulate any single point
in time, which is a datetime value, along with an offset that
specifies how much that datetime differs from UTC
(UNIVERSAL TIME COORDINATED)

9. Decimal (18,0):
The first value is the precision and the second is the scale,
so 18,0 is essentially 18 digits with 9 digits after the decimal
place. If you had 18,2 for e.g. you would have 18 digits, two
of which would come after the decimal.

10. Float:
Float stores an approximate value and decimal stores an
exact value. In summary, exact value like money should use
decimal, and approximate values like scientific
measurements should use float.
11. Geography:
This type represents data in a round earth coordinate
system. It stores ellipsoidal (round earth) data, such as GPS
latitude and longitude coordinates.

12. Geometry:
This type represents data in Euclidean(flat) coordinate
system. SQL server supports a set of methods for the
geometry datatype.

13. Hierarchyid:
The hierarchyid is a variable length, system data type. Use
hierarchyid to represent position in a hierarchyid.

14. Image:
Use image data type when only used to store the image files
(GIF, JPEG format files).it consumes 1 byte per character.

15. Int:
The int data type is the primary integer data type in SQL
SERVER. The bigint data type is intended for use when
integer values might exceed the range that is supported by
the int data type.

16. Money:
The money data type is an abstract data type. Money values
are stored significant to two decimal places. These values
are rounded to their amounts in dollars and cents or other
currency units on input and output.

17. nchar:
nchar (10) is a fixed length Unicode string of length 10. It
stores fixed length character data. The data can be string of
single byte or multibyte letters or symbols.
18. ntext:
variable length storage with maximum size of 1GB data.

19. Varchar:
Variable length storage with maximum length of 8000
characters.

20. Varchar(max):
Variable length storage with provided maximum characters.

21. Nvarchar:
Variable length storage with maximum length of 4000
characters.

22. Nvarchar(max):
Variable length storage with provided max characters.

23. Real:
Real is an approximate number data type equivalent to a
float (24) used to store a floating-point number. Storage size
of this data type is 4 bytes.
24. Smallmoney:
It represents a monetary value storage of this data type is 4
bytes.

25. Varbinary(max):
Variable length storage with provided maximum/n bytes. n
can be a value from 1 through 8000.

26. Xml:
This data type is used for storing xml data.
27.timestamp:
It is a method for row versioning. It basically means that
every time a row is changed, this value is increased.

28. Tinyint:
It represents an integer value that can be stored in 1 byte.
The range of tinyint is 0 to 255.

29. Uniqueidentifiers:
Uniqueidentifiers is a Microsoft SQL Server data type that is
used to store globally Unique identifiers (GUIDS). It can store
16 bytes of data.

30. Text:
Variable length storage with maximum size of 2GB data.

31. Numeric (18,0):


The first value is the precision and the second is the scale, so
18,0 is essentially 18 digits with 0 digit after the decimal place.

32. Sql-variant:
Sql-variant enables these database objects to support
values of other data types. A column of type sql-variant may
contain rows of different data types.

33. Time (7):


The fractional second scale ranges from 0 to 7. By default, the
fractional second scale is 7 if you don’t explicitly specify it.
The below picture shows the creation of a database and tables.
The below picture shows the graphical view of tables.

You might also like