Toggle navigation
Home
Articles
PHP
JavaScript
MySQL Interview
IP tools
Converters
What is the difference between CHAR and VARCHAR ?
MySQL
Database
Difference between
Char
VARCHAR
MySQL Interview Queries
CHAR
Used to store character string value of fixed length
The maximum no. of characters the data type can hold is 255 characters.
It's 20% faster than VARCHAR.
Uses static memory allocation.
When CHAR values are stored, they are right-padded with trailing spaces to make up the specified length
VARCHAR
Used to store variable length alphanumeric data.
The maximum this data type can hold is up to - Pre-MySQL 5.0.3: 255 characters and Post-MySQL 5.0.3: 65,535 characters shared for the row.
It's slower than CHAR.
Uses dynamic memory allocation.
VARCHAR values aren’t padded during storage.Trailing spaces are retained when data is inserted into the field.
1 byte --> when the data value requires less than 255 bytes.
2 byte --> when the data value requires more than 255 bytes.
Related
find the nth highest salary in mysql without limit
How to find greater than average salary records in MySQL
how to find duplicate records in MySQL query
How to use second index forcefully in MySQL
How to get total number of rows in MySQL table with and without count
Top Articles
1-
How to get total number of records of table in mysql
2-
How to Sort an array of associative arrays by value of given key in php
3-
Destructuring assignment in JavaScript
4-
Tag Template literals (Strings) in JavaScript
5-
String Concatenation in JavaScript
6-
How to play multiple video in loop using HTML5 and JavaScript
7-
Difference between null and undefined in JavaScript
8-
localStorage, sessionStorage and cookies in JavaScript?
9-
find the nth highest salary in mysql without limit
10-
How to find greater than average salary records in MySQL
11-
how to find duplicate records in MySQL query
12-
How to use second index forcefully in MySQL
13-
How to get total number of rows in MySQL table with and without count
14-
Difference between where and having clauses
15-
What is the difference between CHAR and VARCHAR ?
16-
How to copy structure and data from one table to another table in MySQL
17-
How to delete duplicate records in MySQL
18-
Difference between DELETE, TRUNCATE and DROP commands in SQL
19-
Difference between Union, Union all, INTERSECT and MINUS
20-
ACID Properties in DBMS