SlideShare a Scribd company logo
1 of 28
Download to read offline
MySQL Data Types
©w3resource
©w3resource
Introduction
★ Numeric
★ DATETIME
★ DATE
★ TIMESTAMP
★ String
► MySQL supports a number of SQL standard data types in various categories. Following
Data types are are based on MySQL community server 5.6
©w3resource
Numeric Types
Integer Types
©w3resource
Type Length
in Bytes
Minimum Value
(Signed)
Maximum Value
(Signed)
Minimum
Value
(Unsigned)
Maximum Value
(Unsigned)
TINYINT 1 -128 127 0 255
SMALLINT 2 -32768 32767 0 65535
MEDIUMINT 3 -8388608 8388607 to 0 16777215
INT 4 -2147483648 2147483647 0 4294967295
BIGINT 8 -9223372036854775808 92233720368
54775807
0 184467440737
09551615
Floating-Point Types
©w3resource
Type Length
in
Bytes
Minimum Value
(Signed)
Maximum Value
(Signed)
Minimum Value
(Unsigned)
Maximum Value
(Unsigned)
FLOAT 4 -3.402823466E+38 -1.175494351E-38 1.175494351E-38 3.402823466E+38
DOUBLE 8 -1.7976931348623
157E+ 308
-2.22507385850720
14E- 308
0, and
2.22507385850720
14E- 308
1.797693134862315
7E+ 308
Fixed-Point Types
©w3resource
► In standard SQL the syntax DECIMAL(5,2) (where 5 is the precision and 2 is the scale.) be
able to store any value with five digits and two decimals. Therefore the value range will be from
-999.99 to 999.99. The syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax
DECIMAL is equivalent to DECIMAL(M,0). MySQL supports both of these variant forms of
DECIMAL syntax. The default value of M is 10. If the scale is 0, DECIMAL values contain no
decimal point or fractional part.
The maximum number of digits for DECIMAL is 65, but the actual range for a given DECIMAL
column can be constrained by the precision or scale for a given column.
Bit Value Types
©w3resource
► The BIT data type is used to store bit-field values. A type of BIT(N) enables storage of N-bit
values. N can range from 1 to 64.
► To specify bit values, b'value' notation can be used. ‘value’ is a binary value written using
zeros and ones. For example, b'111' and b'10000000' represent 7 and 128, respectively
©w3resource
Date and Time Types
DATETIME, DATE, and TIMESTAMP
©w3resource
Types Description Display
Format
Range
DATETIME Use when you need values containing both date and time
information.
YYYY-MM-D
D
HH:MM:SS
'1000-01-01
00:00:00' to
'9999-12-31
23:59:59'.
DATE Use when you need only date information. YYYY-MM-D
D
'1000-01-01' to
'9999-12-31'.
TIMESTAMP Values are converted from the current timezone to UTC
while storing, and converted back from UTC to the
current time zone when retrieved.
YYYY-MM-D
D
HH:MM:SS
'1970-01-01
00:00:01' UTC to
'2038-01-19
03:14:07' UTC
Time Type
©w3resource
► MySQL fetches and displays TIME values in 'HH:MM:SS' format or 'HHH:MM:SS' format
The range of. TIME values from '-838:59:59' to '838:59:59'. The hours part may be rather large
because not only the TIME type can be used to represent the time of day, i.e. less than 24
hours, but also the passed time or a time of interval between two events.
► The TIME values in MySQL can be recognized in different formats, some of which can
include a trailing fractional seconds part in up to 6 digits microseconds precision. The range for
TIME values is '-838:59:59.000000' to '838:59:59.000000'.
Year Type
©w3resource
► The YEAR type is a 1-byte type used to represent year values. It can be declared as
YEAR(2) or YEAR(4) to specify a display width of two or four characters. If no width is given
the default is four characters
String length Range
4-digit string '1901' to '2155'.
4-digit number 1901 to 2155.
1- or 2-digit string '0' to '99'. Values in the ranges '0' to '69' and '70' to '99' are converted to YEAR values in the
ranges 2000 to 2069 and 1970 to 1999.
1- or 2-digit number 1 to 99. Values in the ranges 1 to 69 and 70 to 99 are converted to YEAR values in the
ranges 2001 to 2069 and 1970 to 1999.
©w3resource
String Types
CHAR and VARCHAR Types
©w3resource
►The CHAR and VARCHAR types are similar, but differ in the way they are stored and
retrieved. They also differ in maximum length and in whether trailing spaces are retained.
Types Description Display Format Range in characters
CHAR Contains non-binary strings. Length is
fixed as you declare while creating a
table. When stored, they are
right-padded with spaces to the
specified length.
Trailing spaces are
removed.
The length can be any value from
0 to 255.
VARCHA
R
Contains non-binary strings. Columns
are variable-length strings.
As stored. A value from 0 to 255 before
MySQL 5.0.3, and 0 to 65,535 in
5.0.3 and later versions.
BINARY and VARBINARY Types
©w3resource
► The BINARY and VARBINARY types are similar to CHAR and VARCHAR, except that
they contain binary strings rather than nonbinary strings.
Types Description Range in bytes
BINARY Contains binary strings. 0 to 255
VARBINARY Contains binary strings. A value from 0 to 255 before MySQL 5.0.3, and
0 to 65,535 in 5.0.3 and later versions.
BLOB and TEXT Types
©w3resource
Types Description Categories Range
BLOB Large binary object that containing a
variable amount of data. Values are
treated as binary strings.You don't
need to specify length while creating
a column.
TINYBLOB Maximum length of 255 characters.
MEDIUMBLOB Maximum length of 16777215 characters.
LONGBLOB Maximum length of 4294967295 characters
TEXT Values are treated as character
strings having a character set.
TINYBLOB Maximum length of 255 characters.
MEDIUMBLOB Maximum length of 16777215 characters.
LONGBLOB Maximum length of 4294967295 characters
Miscellaneous Type
©w3resource
A string object whose value is chosen from a list of values given at the time of
table creation. For example -
CREATE TABLE length ( length ENUM('small', 'medium', 'large') );
► ENUM Types
► Set Types
A string object having zero or more comma separated values (maximum 64).
Values are chosen from a list of values given at the time of table creation.
©w3resource
Extensions for Spatial Data
MySQL Spatial Data
©w3resource
►The Open Geospatial Consortium publishes the OpenGIS® Implementation Standard for
Geographic information - Simple feature access - Part 2: SQL option, a document that
proposes several conceptual ways for extending an SQL RDBMS to support spatial data. This
specification is available from the OGC Web site at http://www.opengeospatial.org/standards/sfs.
Following the Open Geospatial Consortium specification, MySQL implements spatial
extensions as a subset of the SQL with Geometry Types environment. This term refers to an
SQL environment that has been extended with a set of geometry types. A geometry-valued
SQL column is implemented as a column that has a geometry type.
MySQL Spatial Data Types
©w3resource
★ Geometry
★ Point
★ LineString
★ Polygon
★ MultiPoint
★ MultiLineString
★ MultiPolygon
★ GeometryCollection
MySQL Spatial Data Types
©w3resource
► Geometry
Geometry is a word that denotes a geographic feature. Originally the word geometry
meant measurement of the earth. Another meaning comes from cartography, referring to
the geometric features that cartographers use to map the world.
Example : Use the CREATE TABLE statement to create a table with a spatial column -
CREATE TABLE geotest (code int(5),descrip varchar(50), g GEOMETRY);
MySQL Spatial Data Types
©w3resource
► Point
A Point is a geometry which represents a single location in coordinate space.
Usage of Point : On a city map, a Point object could represent a rail station.
Point Properties :
➔ X-coordinate value
➔ Y-coordinate value
➔ Point is defined as a zero-dimensional geometry
➔ The boundary of a Point is the empty set
MySQL Spatial Data Types
©w3resource
► LineString Type
A LineString is a Curve with linear interpolation between points.
Usage of LineString : LineString objects could represent a river within a country map.
LineString Properties :
➔ A LineString has coordinates of segments, defined by each consecutive pair of
points
➔ A LineString is a Line if it consists of exactly two points
➔ A LineString is a LinearRing if it is both closed and simple
MySQL Spatial Data Types
©w3resource
► Polygon Type
A Polygon is a planar Surface representing a multi sided geometry. It is defined by a single
exterior boundary and zero or more interior boundaries, where each interior boundary
defines a hole in the Polygon.
Usage of Polygon: LineString objects could represent a river within a country map.
Polygon Properties :
➔ The boundary of a Polygon consists of a set of LinearRing objects that make up its
exterior and interior boundaries
➔ A Polygon has no rings that cross. The rings in the boundary of a Polygon may
intersect at a Point, but only as a tangent
➔ A Polygon has no lines, spikes, or punctures
➔ A Polygon has an interior that is a connected point set
➔ A Polygon may have holes. The exterior of a Polygon with holes is not connected
MySQL Spatial Data Types
©w3resource
► MultiPoint
A MultiPoint is a geometry collection composed of Point elements. The points are not
connected or ordered in any way.
Usage of LineString : On a world map, a MultiPoint could represent a chain of small
islands.
MultiPoint Properties :
➔ A MultiPoint is a zero-dimensional geometry.
➔ A MultiPoint is simple if no two of its Point values are equal (have identical
coordinate values).
➔ The boundary of a MultiPoint is the empty set.
MySQL Spatial Data Types
©w3resource
► MultiLineString
A MultiLineString is a MultiCurve geometry collection composed of LineString elements.
Usage of LineString : On a region map, a MultiLineString could represent a river system
or a highway system.
MySQL Spatial Data Types
©w3resource
► MultiPolygon
MultiPolygon is a MultiSurface object composed of Polygon elements.
Usage of LineString : A MultiPolygon could represent a system of lakes On a region map
MultiPolygon Properties :
➔ A MultiPolygon is a two-dimensional geometry
➔ A MultiPolygon boundary is a set of closed curves (LineString values) corresponding to
the boundaries of its Polygon elements
➔ Each Curve in the boundary of the MultiPolygon is in the boundary of exactly one
Polygon element.
➔ Every Curve in the boundary of an Polygon element is in the boundary of the
MultiPolygon
MySQL Spatial Data Types
©w3resource
► GeometryCollection
A GeometryCollection is a geometry that is a collection of one or more geometries of any
class.
All the elements in a GeometryCollection must be in the same Spatial Reference System.
There are no other constraints on the elements of a GeometryCollection, although the
subclasses of GeometryCollection described in the following sections may restrict
membership. Restrictions may be based on :
➔ Element type (for example, a MultiPoint may contain only Point elements)
➔ Dimension
➔ Constraints on the degree of spatial overlap between elements
Thank you for your Time and
Attention!

More Related Content

Similar to Copy of MySQL Data Types.pdf

Advances in ms excel
Advances in ms excelAdvances in ms excel
Advances in ms excel
Mohit Kumar
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
Rajeshkumar Reddy
 

Similar to Copy of MySQL Data Types.pdf (20)

SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)
 
MySQL Data types
MySQL Data typesMySQL Data types
MySQL Data types
 
Mysql datatypes
Mysql datatypesMysql datatypes
Mysql datatypes
 
MySql
MySqlMySql
MySql
 
Advances in ms excel
Advances in ms excelAdvances in ms excel
Advances in ms excel
 
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
 
Sql data types for various d bs by naveen kumar veligeti
Sql data types for various d bs by naveen kumar veligetiSql data types for various d bs by naveen kumar veligeti
Sql data types for various d bs by naveen kumar veligeti
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
primitive data types
 primitive data types primitive data types
primitive data types
 
Data Handling
Data HandlingData Handling
Data Handling
 
02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developer02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developer
 
Basics of Python
Basics of PythonBasics of Python
Basics of Python
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Lecture_3.pptx
Lecture_3.pptxLecture_3.pptx
Lecture_3.pptx
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
"contour.py" module
"contour.py" module"contour.py" module
"contour.py" module
 
Unit 5-hive data types – primitive and complex data
Unit 5-hive data types – primitive and complex dataUnit 5-hive data types – primitive and complex data
Unit 5-hive data types – primitive and complex data
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

Copy of MySQL Data Types.pdf

  • 2. ©w3resource Introduction ★ Numeric ★ DATETIME ★ DATE ★ TIMESTAMP ★ String ► MySQL supports a number of SQL standard data types in various categories. Following Data types are are based on MySQL community server 5.6
  • 4. Integer Types ©w3resource Type Length in Bytes Minimum Value (Signed) Maximum Value (Signed) Minimum Value (Unsigned) Maximum Value (Unsigned) TINYINT 1 -128 127 0 255 SMALLINT 2 -32768 32767 0 65535 MEDIUMINT 3 -8388608 8388607 to 0 16777215 INT 4 -2147483648 2147483647 0 4294967295 BIGINT 8 -9223372036854775808 92233720368 54775807 0 184467440737 09551615
  • 5. Floating-Point Types ©w3resource Type Length in Bytes Minimum Value (Signed) Maximum Value (Signed) Minimum Value (Unsigned) Maximum Value (Unsigned) FLOAT 4 -3.402823466E+38 -1.175494351E-38 1.175494351E-38 3.402823466E+38 DOUBLE 8 -1.7976931348623 157E+ 308 -2.22507385850720 14E- 308 0, and 2.22507385850720 14E- 308 1.797693134862315 7E+ 308
  • 6. Fixed-Point Types ©w3resource ► In standard SQL the syntax DECIMAL(5,2) (where 5 is the precision and 2 is the scale.) be able to store any value with five digits and two decimals. Therefore the value range will be from -999.99 to 999.99. The syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0). MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10. If the scale is 0, DECIMAL values contain no decimal point or fractional part. The maximum number of digits for DECIMAL is 65, but the actual range for a given DECIMAL column can be constrained by the precision or scale for a given column.
  • 7. Bit Value Types ©w3resource ► The BIT data type is used to store bit-field values. A type of BIT(N) enables storage of N-bit values. N can range from 1 to 64. ► To specify bit values, b'value' notation can be used. ‘value’ is a binary value written using zeros and ones. For example, b'111' and b'10000000' represent 7 and 128, respectively
  • 9. DATETIME, DATE, and TIMESTAMP ©w3resource Types Description Display Format Range DATETIME Use when you need values containing both date and time information. YYYY-MM-D D HH:MM:SS '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. DATE Use when you need only date information. YYYY-MM-D D '1000-01-01' to '9999-12-31'. TIMESTAMP Values are converted from the current timezone to UTC while storing, and converted back from UTC to the current time zone when retrieved. YYYY-MM-D D HH:MM:SS '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
  • 10. Time Type ©w3resource ► MySQL fetches and displays TIME values in 'HH:MM:SS' format or 'HHH:MM:SS' format The range of. TIME values from '-838:59:59' to '838:59:59'. The hours part may be rather large because not only the TIME type can be used to represent the time of day, i.e. less than 24 hours, but also the passed time or a time of interval between two events. ► The TIME values in MySQL can be recognized in different formats, some of which can include a trailing fractional seconds part in up to 6 digits microseconds precision. The range for TIME values is '-838:59:59.000000' to '838:59:59.000000'.
  • 11. Year Type ©w3resource ► The YEAR type is a 1-byte type used to represent year values. It can be declared as YEAR(2) or YEAR(4) to specify a display width of two or four characters. If no width is given the default is four characters String length Range 4-digit string '1901' to '2155'. 4-digit number 1901 to 2155. 1- or 2-digit string '0' to '99'. Values in the ranges '0' to '69' and '70' to '99' are converted to YEAR values in the ranges 2000 to 2069 and 1970 to 1999. 1- or 2-digit number 1 to 99. Values in the ranges 1 to 69 and 70 to 99 are converted to YEAR values in the ranges 2001 to 2069 and 1970 to 1999.
  • 13. CHAR and VARCHAR Types ©w3resource ►The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. They also differ in maximum length and in whether trailing spaces are retained. Types Description Display Format Range in characters CHAR Contains non-binary strings. Length is fixed as you declare while creating a table. When stored, they are right-padded with spaces to the specified length. Trailing spaces are removed. The length can be any value from 0 to 255. VARCHA R Contains non-binary strings. Columns are variable-length strings. As stored. A value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.
  • 14. BINARY and VARBINARY Types ©w3resource ► The BINARY and VARBINARY types are similar to CHAR and VARCHAR, except that they contain binary strings rather than nonbinary strings. Types Description Range in bytes BINARY Contains binary strings. 0 to 255 VARBINARY Contains binary strings. A value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.
  • 15. BLOB and TEXT Types ©w3resource Types Description Categories Range BLOB Large binary object that containing a variable amount of data. Values are treated as binary strings.You don't need to specify length while creating a column. TINYBLOB Maximum length of 255 characters. MEDIUMBLOB Maximum length of 16777215 characters. LONGBLOB Maximum length of 4294967295 characters TEXT Values are treated as character strings having a character set. TINYBLOB Maximum length of 255 characters. MEDIUMBLOB Maximum length of 16777215 characters. LONGBLOB Maximum length of 4294967295 characters
  • 16. Miscellaneous Type ©w3resource A string object whose value is chosen from a list of values given at the time of table creation. For example - CREATE TABLE length ( length ENUM('small', 'medium', 'large') ); ► ENUM Types ► Set Types A string object having zero or more comma separated values (maximum 64). Values are chosen from a list of values given at the time of table creation.
  • 18. MySQL Spatial Data ©w3resource ►The Open Geospatial Consortium publishes the OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 2: SQL option, a document that proposes several conceptual ways for extending an SQL RDBMS to support spatial data. This specification is available from the OGC Web site at http://www.opengeospatial.org/standards/sfs. Following the Open Geospatial Consortium specification, MySQL implements spatial extensions as a subset of the SQL with Geometry Types environment. This term refers to an SQL environment that has been extended with a set of geometry types. A geometry-valued SQL column is implemented as a column that has a geometry type.
  • 19. MySQL Spatial Data Types ©w3resource ★ Geometry ★ Point ★ LineString ★ Polygon ★ MultiPoint ★ MultiLineString ★ MultiPolygon ★ GeometryCollection
  • 20. MySQL Spatial Data Types ©w3resource ► Geometry Geometry is a word that denotes a geographic feature. Originally the word geometry meant measurement of the earth. Another meaning comes from cartography, referring to the geometric features that cartographers use to map the world. Example : Use the CREATE TABLE statement to create a table with a spatial column - CREATE TABLE geotest (code int(5),descrip varchar(50), g GEOMETRY);
  • 21. MySQL Spatial Data Types ©w3resource ► Point A Point is a geometry which represents a single location in coordinate space. Usage of Point : On a city map, a Point object could represent a rail station. Point Properties : ➔ X-coordinate value ➔ Y-coordinate value ➔ Point is defined as a zero-dimensional geometry ➔ The boundary of a Point is the empty set
  • 22. MySQL Spatial Data Types ©w3resource ► LineString Type A LineString is a Curve with linear interpolation between points. Usage of LineString : LineString objects could represent a river within a country map. LineString Properties : ➔ A LineString has coordinates of segments, defined by each consecutive pair of points ➔ A LineString is a Line if it consists of exactly two points ➔ A LineString is a LinearRing if it is both closed and simple
  • 23. MySQL Spatial Data Types ©w3resource ► Polygon Type A Polygon is a planar Surface representing a multi sided geometry. It is defined by a single exterior boundary and zero or more interior boundaries, where each interior boundary defines a hole in the Polygon. Usage of Polygon: LineString objects could represent a river within a country map. Polygon Properties : ➔ The boundary of a Polygon consists of a set of LinearRing objects that make up its exterior and interior boundaries ➔ A Polygon has no rings that cross. The rings in the boundary of a Polygon may intersect at a Point, but only as a tangent ➔ A Polygon has no lines, spikes, or punctures ➔ A Polygon has an interior that is a connected point set ➔ A Polygon may have holes. The exterior of a Polygon with holes is not connected
  • 24. MySQL Spatial Data Types ©w3resource ► MultiPoint A MultiPoint is a geometry collection composed of Point elements. The points are not connected or ordered in any way. Usage of LineString : On a world map, a MultiPoint could represent a chain of small islands. MultiPoint Properties : ➔ A MultiPoint is a zero-dimensional geometry. ➔ A MultiPoint is simple if no two of its Point values are equal (have identical coordinate values). ➔ The boundary of a MultiPoint is the empty set.
  • 25. MySQL Spatial Data Types ©w3resource ► MultiLineString A MultiLineString is a MultiCurve geometry collection composed of LineString elements. Usage of LineString : On a region map, a MultiLineString could represent a river system or a highway system.
  • 26. MySQL Spatial Data Types ©w3resource ► MultiPolygon MultiPolygon is a MultiSurface object composed of Polygon elements. Usage of LineString : A MultiPolygon could represent a system of lakes On a region map MultiPolygon Properties : ➔ A MultiPolygon is a two-dimensional geometry ➔ A MultiPolygon boundary is a set of closed curves (LineString values) corresponding to the boundaries of its Polygon elements ➔ Each Curve in the boundary of the MultiPolygon is in the boundary of exactly one Polygon element. ➔ Every Curve in the boundary of an Polygon element is in the boundary of the MultiPolygon
  • 27. MySQL Spatial Data Types ©w3resource ► GeometryCollection A GeometryCollection is a geometry that is a collection of one or more geometries of any class. All the elements in a GeometryCollection must be in the same Spatial Reference System. There are no other constraints on the elements of a GeometryCollection, although the subclasses of GeometryCollection described in the following sections may restrict membership. Restrictions may be based on : ➔ Element type (for example, a MultiPoint may contain only Point elements) ➔ Dimension ➔ Constraints on the degree of spatial overlap between elements
  • 28. Thank you for your Time and Attention!