postgresql - How to change JSON text of MySql database to JSON datatype of postgres sql -


how change json text of mysql database json datatype of postgres sql.i storing json data in database table of mysql , want convert json datatype of postgres sql

mysql create table

create table if not exists `employee` (   `id` bigint(40) not null auto_increment,   `employee_id` bigint(40) not null,   `employee_info` text not null,   ) 

in employee_info storing {"employee_name":"abc","address":"1","emloyee_weight":"30","age":"100","phone":"9845236775"} in mysql database json .

and wanted convert json datatype of postgressql

question shouldn't left unanswered :-)

it's pretty simple:

postgresql create table

create table employee (   id bigserial primary key,   employee_id bigint not null,   employee_info json not null ); 

and can magic like:

select * employee employee_info->>'address' '%kr%'; 

or

select * employee cast(employee_info->>'emloyee_weight' integer)>30; 

heed on postgres version, should 9.3 or greater

http://sqlfiddle.com/#!15/edb87/1


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -