- Add a column to an existing MySQL table : MySQL tables are easy to extend with additional columns. To add a column called email to table type the following command:
ALTER TABLE tablename ADD email VARCHAR(20);
- To insert the new column after a specific column, such as name, use this statement:
ALTER TABLE tablename ADD email VARCHAR(20) AFTER name;
- If you want the new column to be first, use this statement:
ALTER TABLE tablename ADD email VARCHAR(20) FIRST;
- Query to alter column data type of the table: The Alter Query redefine the table and change the data type of column ’empid’.
mysql> alter table tablename change empid empid varchar(100);
- To see what types and values you specify for each field. You give the following command. The describe employee describe the field name ,data type ,null ,key etc in table.
mysql> describe tablename;
- To see myql version:
select version();
or
SHOW VARIABLE LIKE “%version%”;
- To load data from a file in Mysql
LOAD DATA LOCAL INFILE ‘form.txt’ INTO TABLE form;
- Column delete:
alter table tablename drop column rollno;
- Multiple Column delete:
ALTER TABLE tablename Drop (column1,column2,column3);