2

I have a table in my database with 2 columns.What I want to do is to let the admin (of the web application ) have the possibility from a simple php/html form to add multiple columns in the table already created.

Thanks.

2
  • There is something very wrong with your db schema if you need to change table structure on a regular basis. Commented May 10, 2011 at 17:11
  • There is nothing wrong with the db schema, I want to give the admin the possibility to add 2,3,4,etc extra columns if he needs for administrating the site. Commented May 10, 2011 at 18:55

3 Answers 3

1

when you access your web application as admin then try this query

ALTER TABLE Table Name
ADD (column1 col_definition,
column2 col_definition,
column3 col_definition,
....      ......
....      ......
columnN col_definition);
Sign up to request clarification or add additional context in comments.

Comments

0

so what give admin to fill the required info for the column and run query if admin enter valid info

alter table table_name add column <colname> <datatype> <otheroption>

Comments

0

To add multiple table columns if they don not exist alter table_name add column IF NOT EXISTS ( <colname1> <datatype> DEFAULT VALUE, <colname2> <datatype> DEFAULT VALUE, <colname3> <datatype> DEFAULT VALUE, <colname4> <datatype> DEFAULT VALUE)

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.