Mysql Hexadecimal color code store in binary datatype.

Mysql Hexadecimal color code store in binary datatype.

In this post we will give you information about Mysql Hexadecimal color code store in binary datatype.. Hear we will give you detail about Mysql Hexadecimal color code store in binary datatype.And how to use it also give you demo for it if it is necessary.

If you have thousands of record store, that time database size would be large. but you can some field can save your number of bites in the database.

you have color field then most of you choose string(6) data type and you wast 6 bites on every record, but you can save number of bites data by using BINARY(3) data type. following example through you can set data type for hexa color code with only allocate binary(3) on every records. first how to create table and assign data type with following query.

CREATE TABLE IF NOT EXISTS 'colors' (

'id' int(10) unsigned NOT NULL AUTO_INCREMENT,

'color_name' varchar(255) NOT NULL,

'color' BINARY(3) NOT NULL,

PRIMARY KEY ('id')

);

when you want to insert then data at that time with using UNHEX() that function would convert in small size.

INSERT INTO 'colors' (color_name, color) VALUES ('Green',UNHEX('f2a709'));

when you fetch or select all the records at that using HEX() that function would convert hexadecimal color code with full size.

Also see:Bootstrap Color Picker Example using mjolnic colorpicker plugin

SELECT color_name ,HEX(color) AS color FROM 'colors';

Try this and save db size……

Hope this code and post will helped you for implement Mysql Hexadecimal color code store in binary datatype.. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  52  =  62

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US