MySQL
  • -

MySQL

Tags : 

MySQL Data Types

  • Introduction to MySQL Data Types
  • Rules for using MySQL Data Types
  • Different MySQL Data Types

Introduction to MySQL Data Types

Before creating Tables, you should know about data types. Data types have an elegant role while creating tables. . Every column stores a different kind of value in any table. Data types are used to define what kind of value the store will store. Every column is defined when creating the data type table.

Imagine that you are creating a table that will store information about employees. In this table, you want to add a column that will store the names of the employees. For this column, you will define character data type while creating a table. This is similar to creating a variable in a programming language.

In this tutorial, I’m just telling you about data types. You can learn how to use them in the tables. MySQL data types can be divided into 4 major categories.

  1. Numeric
  2. Character String
  3. Binary String
  4. Temporal   

Mysql

Rules For Defining Data Types

Before discussing these data types in detail, let’s try to know some of the rules that you should keep in mind while decrying data types.

  1. You should use the same data type that will represent your data properly.
  2. You should define a data type that can define the data at least in memory space. By doing so you save resources.
  3. You should use a data type that can store the maximum value of your data.

Now let’s try to know more about the data types used in MySQL.

Numeric Data Types

Numeric data types are used to store numeric values. Numeric types have been divided into 4 categories. These are being given below.

Integer

Integer types are used to store whole numbers. Whole numbers are numbers that do not have fractional parts (decimal and numbers after that). Integer types have been divided into 5 categories according to size.

Types Explanation
Tinyint This is an integer data type to store a very small value. In it, you can store any number from 128 to 128.
Smallint This data type is used to store more value than tinyint. In it, you can store a value of -32768 to 32768.
Medium Int This is the data type to store a medium size value. Its range ranges from -8388608 to 8388607.
Int This is the most popular integer type, in which you can store values from -2147483648 to 2147483648.
Big Int This is the largest integer type and you can store any value up to 9223372036854775807.

      

Floating Point

Floating point numbers are numbers that include the fractional part (decimal and the number after that). Floating-point numbers have been divided into 2 categories according to size.

Type   Explanation
Float   Float single-precision (7 digits after decimals) is the floating-point type. Its size is 4 bytes.
Double   This is a double-precision floating point type. Its size is 8 bytes.

Fixed Point Types

Fixed point data types are used to store decimal numbers. Decimal numbers contain a number that is an integer, in which the fractional part can also be included. The special thing about this data type is that in it you can store only fractional parts. You can also control values ​​as if you want to store 2 values ​​after decimals, you can also do this by using this data type.

Bit Type

The bit data type presents the bit field value. In the Bit data type, you add width, it shows how many bits of the value to store.

Example – bit_column BIT (4)

Character String Data Types

Character string data types represent alphanumeric values ​​(number and character). The character string is a very valuable data type, many programming languages ​​use it. There are 3 types of character string data types in MySQL, let’s try to know them.

Type   Explanation  
Char Char is a fixed-length data type. When you define a column of char type, you have to give the maximum length (the number of bytes you want to store). You can not store a value greater than that length.
VarChar VarChar is a variable-length data type. You can also store values ​​of more size than the length you are given in it.
Text   Text type stores unstructured text. These can store the value of the text variable length.  

  

Binary String Data Type

Binary values ​​are sequences of bytes. It is stored as a pair of 8 bits. You can also store images, sounds, movies, and executable files in the Binary string data types. Because these are all in binary format. There are 2 types of binary string data types in MySQL.

Type Explanation
Binary This data type is the same as char but it stores binary byte strings.
VarBinary This is similar to the data type varchar but it stores the binary byte string.

Temporal Data Type

In MySQL, date and time types are called temporal types. In such data types, you can store temporal information such as time, year, date etc. Temporal data types are of 5 types.

Type

Explanation  

Time type Time store is done in this data type. Its size is 3 bytes.  
Year type This data type is used to store any year.
Date type The date type is used to store a single date.
DateTime type This type is used to store both date and time.
Timestamp type It also stores date and time like date Time type, just the format is different.

If you are in Chandigarh and are looking for MySQL and PHP training in Chandigarh then join CBITSS Technologies. CBitss is the Best Mysql and PHP Training Institute in Chandigarh, join now.


Contact Us

    PHP Training in Chandigarh

    PHP Training in Chandigarh
    Rated PHP training in Chandigarh 5/5 based on 11477 reviews

    Python Video

    Python Training In Chandigarh

    CBitss offers Python Training in Chandigarh with most experienced professionals. Our Python Course in Chandigarh will cover each and every aspect of python which is necessary for you to know in order to become the most sought-after candidate for the companies.

    Student Review

    Python Training in Chandigarh
    Manpreet Kaur
    Web Designing Course in Chandigarh 5/5 stars

    I joined Python Training in Chandigarh which is Provided by CBitss Technologies. The best Thing – Their Training is based on Live Projects and Hands on Practical Knowledge.

    Python Training in Chandigarh

    Python Training in Chandigarh

    Rated PHP training in Chandigarh
    5/5 based on 13969 reviews

    Chandigarh’s First Youtube Channel-Video Management Laboratory Setup

    Adwords video Certification

    SEO courses in chandigarh

    Adwords Search Certificate

    best seo training institute in Chandigarh

    Adwords Shopping Certification

    SEO course in chandigarh

    Adwords Display Certification

    SEO course in chandigarh

    Google Analytics Certification

    Best SEO training in chandigarh

    Bing Ads Certification

    digital marketing course in chandigarh

    Student Review

    Java Training in Chandigarh
    Ashutosh Kumar

    July 26, 2021

    5/5 stars

    I have done my Java Training in Chandigarh which is offered by CBitss Technologies and it is the best place to get training from basics to advanced level.

    Java Training in Chandigarh

    Java Training in Chandigarh

    Rated java Training in chandigarh5/5 based on 15933 reviews

    Student Review

    Cloud Computing Training in Chandigarh
    Robin Singh
    5/5 stars
    I completed Cloud Computing Training in Chandigarh. It does a great job of explaining the high-level concepts of Cloud to beginners like myself.

    Cloud Computing Training in Chandigarh

    Cloud Computing Training in Chandigarh

    Rated Cloud Computing Training in Chandigarh
    5/5 based on 16955 reviews

    Industrial Training

    Nothing is more Expensive than a missed Opportunity.

    Let us know

    your Customized Requirement,
    our Course Advisors are there to Serve You.!!

      no thanks

      error: Content is protected !!