0

I have a query, could you please tell me.

  • Is there any possibility to create a dynamic columns in MySQL?
  • Is there any way to create a columns at the time of querying(inserting, updating)?
  • Is there any way to create columns, just like creating rows at the time row insertion.
5
  • you should have a look at some nosql engine. nosql-database.org Commented Dec 10, 2012 at 10:23
  • If you want Schema to be changing dynamically then why don't you use MongoDB? You can add new columns using DDL statements through any programming language at run time when ever you require. Commented Dec 10, 2012 at 10:23
  • Can you clarify what you mean by "dynamic" columns? Commented Dec 10, 2012 at 10:31
  • @neville K , i mean adding columns dynamically , Commented Dec 10, 2012 at 11:00
  • @shubhansh , i had almost developed the schema in mysql , so now i cant migrate to mongodb, so kindly request that tell me , if there is a way in mysql Commented Dec 10, 2012 at 11:00

1 Answer 1

1

You can add a column to a table by using the ALTER TABLE command; add a column while you are doing an INSERT doesn't sound feasible to me, and even if it's possible I would descourage it. You should know which columns you are inserting values in before running the INSERT statement. My choice would be to ALTER your table before the INSERT statement.

That said, why are you needing this? I sense a disturbance in your database design, if you really need to add columns dynamically :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.