Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database systems Lecture 2 – Data Types

Similar presentations


Presentation on theme: "Database systems Lecture 2 – Data Types"— Presentation transcript:

1 Database systems Lecture 2 – Data Types
Roman Danel 2016

2 Data types Numeric String Date and Time Others (binary, spatial, XML…)

3 Numeric data types Integer Real (with decimal point) Decimal, Numeric
Float - floating point

4 Numeric in MySQL (Integer)
Tinyint −128 až 127 nebo 0 až 255 pro UNSIGNED, 1 byte Smallint −32768 to or 0 to for UNSIGNED, 2 bytes MediumInt − to or 0 to for UNSIGNED, 3 bytes Int − to or 0 to for UNSIGNED, 4 bytes Bigint − to or 0 to pro UNSIGNED, 8 bytes

5 Numeric Data Types in MySQL
Float(p) Float(M,D) Double(M,D) Decimal(M,D) - large numbers in floating point stored as a string (1 byte per numeral)

6 Numeric – Microsoft SQL Server
Data Type Range Memmory Allocation bigint -263 až 263 8 bytes int -231 až 231 4 bytes smallint -215 až 215 2 bytes tinyint 0 až 255 1 byte Data Type Precision Memmory Allocation decimal 1-9 5 bytes 10-19 9 bytes 20-28 13 bytes 29-38 17 bytes

7 Numeric – Microsoft SQL Server
Data type Range Memory Allocation money -922,337,203,6­85, to 922,337,203,6­85,477.58 8 bytes smallmoney - 214, to 214, 4 bytes

8 Numeric – Microsoft SQL Server
Data type Range Memory Allocation float(n) 1-24 4 bajty 25-53 9 bajtů

9 Numeric Numeric(5,2) = 99.99

10 String Data Types - MySQL
Char(m), m=0-255, longer will be „lost“ Varchar(m), m=0-255 Tinyblob - 0 to 255 Bytes Blob - 0 to 65535 Bytes Mediumblob, Longblob TinyText -  0 až 255 bajtů Text, MediumText, LongText Enum - enumeration values; the values in the column can be assigned just one value from a list of values

11 Date Data Types DATE TIME DATETIME SMALLDATETIME

12 Date – Microsoft SQL Server
Data type Range Memory Allocation date to 3 bytes Time 00:00: to 23:59:59.999 5 bytes Datetime Rozsah pro datum až Rozsah pro čas 00:00:00 až 23:59:59.997 8 bytes Datetime2(n) Range for Date to Range for time 00:00:00 to 23:59: According precission from 6 to 8 bytes Datetimeoffset Range for Date to Range for time00:00:00 to 23:59: Time zone-14:00 až +14:00 10 bytes Smalldatetime Range for Date to Range for time 00:00:00 to 23:59:00 4 bytes

13 Others Data Types – MS SQL
Bit – 1/0, memmory allocation - 1 bit Timestamp – It is a data type that generates unique binary number, which is used for version resolution lines "rowversion". This data type does not store date and time! To store the date and time should be used datetime2. In memory occupies 8 bytes. Uniqueidentifier – It is a data type that, for example, in conjunction with the function NEWID () generates a unique identifier. In memory it takes up 16 bytes.

14 Value NULL Value, which is not intended
Property of the column: NULL/NOT NULL Example in SELECT: SELECT * from table where column_name IS NULL;

15 Primary Key Primary Key – defined over one or more columns of the table. The main purpose of a primary key is ensure the uniqueness of records in a table. Primary key values can not contain duplicate or null.

16 Automatically generated number
MySQL – AUTO_INCREMENT MS SQL – IDENTITY Oracle – sequence Access – Automatic Number create table Table_name ( column_name int IDENTITY(1,1) primary key,

17 Default Value Apply if during operation insert the value is not determined If we want to avoid NULL values

18 Column Properties UNIQUE NULL/NOT NULL PRIMARY KEY DEFAULT

19 Converting Data Types CONVERT CAST CAST ( $157.27 AS VARCHAR(10) )
Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] )


Download ppt "Database systems Lecture 2 – Data Types"

Similar presentations


Ads by Google