top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to insert a column in a existing table in MySQL

+2 votes
902 views
How to insert a column in a existing table in MySQL
posted May 11, 2013 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+2 votes
 
Best answer

User Alter table command.
Example -
ALTER TABLE table_name MODIFY column_name datatype

answer May 15, 2013 by Sudheendra
+1 vote

Add a column
ALTER TABLE name_of_the_table ADD column_name VARCHAR(size_of_the_column_name);

answer Jan 5, 2017 by Ajay Kumar
0 votes

To add column at end of the table

ALTER TABLE table_name ADD column_name VARCHAR(10);

To insert a new column after a specific column, use this statement

ALTER TABLE table_name ADD new_column_name VARCHAR(10) AFTER existing_column_name;

If you want the new column to be first, use this statement:

ALTER TABLE table_name ADD column_name  VARCHAR(10) FIRST;
answer Dec 21, 2016 by Atindra Kumar Nath
Similar Questions
0 votes
for($i=0;$i<=feof($getdata);$i++)
{
if (filter_var($data[$i][1], FILTER_VALIDATE_EMAIL)){
echo $data[$i][1];
$email=$data[$i][1];
$conn = mysqli_connect($dbhost,$dbuser,$dbpass, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
$sql ="INSERT INTO promo_user (uid,name,email) VALUES (,'', '$email')";
mysqli_query($sql,$conn);
mysqli_close($conn);

I am using the above code but there is something wrong with it,whenever i run the code the echo is working fine but the content does go into sql table

Please help

0 votes

How can I insert data into one table from two other tables where i have three tables namely users, role and userrole.
Now I want to insert the data into userrole table from users table and role table with a single statement.

+2 votes

How I 'll check how many rows inserted into every second on an average in a table of MySQL database?

+5 votes

How can I insert the content of excel file into MySQL Table, any pointer?

...