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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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/' from table where primary_key=N

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

load data infile '/tmp/' 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


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.