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-
String Concatenation in JavaScript
5-
Tag Template literals (Strings) in JavaScript
6-
Difference between null and undefined in JavaScript
7-
localStorage, sessionStorage and cookies in JavaScript?
8-
find the nth highest salary in mysql without limit
9-
How to find greater than average salary records in MySQL
10-
how to find duplicate records in MySQL query
11-
How to use second index forcefully in MySQL
12-
How to get total number of rows in MySQL table with and without count
13-
Difference between where and having clauses
14-
What is the difference between CHAR and VARCHAR ?
15-
How to copy structure and data from one table to another table in MySQL
16-
How to delete duplicate records in MySQL
17-
Difference between DELETE, TRUNCATE and DROP commands in SQL
18-
Difference between Union, Union all, INTERSECT and MINUS
19-
ACID Properties in DBMS
20-
What is a MySQL index and types of Index ?