Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there a way to serialize a record/row in SQL? And conversely, to deserialize something that has been serialized.

By serialize, I mean put all of the fields in a record into one field or string.

Preferably with MySQL compatibility.

I am guessing that xml, a udf or sproc might be necessary.

is there a way to use xml or json directly in sql/mysql?

Thanks!

share|improve this question

1 Answer 1

I feel my answer may lack what you are looking for but with out more context here are a couple options:

  1. Use the mysqldump command.

    mysqldump -u user -pPassword --no-create-db --no-create-info --where="primary_key=N"

will give you a sql insert command which you can use to reconstruct that row.

  1. run a query like

    select * into outfile '/tmp/rowdump.data' from table where primary_key=N

This will create a file /tmp/rowdump.data in tab separated format. This can be reimported with

load data infile '/tmp/rowdump.data' into table `table`;

If these don't suit your needs please elaborate on your use case on what you are trying to accomplish.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.