ALTER COMMAND



MySQL - Alter Command


The ALTER command is used to modify the existing table.
It involves adding,removing,modifying,creating,dropping,renaming,changing the engine,changing the collation of table or some columns.


SYNTAX :

ALTER TABLE table_name
  ADD new_column_name column_definition
    [ FIRST | AFTER column_name ];

Lets consider a table and check how alter command is performing :


IDNameAddressCompanySalary
1NihariHabsigudaDELL25000
2SwaraMadhapurHCL35000
3LaraSR nagarXIUS54000
4KiaraKPHBGOOGLE64000
5HarshadGachibowliHP48000

Adding a new column :


ALTER TABLE employeerecord
  ADD Gender varchar(55) NOT NULL
    AFTER Salary;

Result will be displayed as follows:


IDNameAddressCompanySalaryGender
1NihariHabsigudaDELL25000-

Removing a column from the existing table:


ALTER TABLE employeerecord DROP Column Gender;

Result will be displayed as follows:


IDNameAddressCompanySalary
1NihariHabsigudaDELL25000

Modifying the data type, name, default values of a column in the existing table :


ALTER TABLE  employeerecord
CHANGE COLUMN Salary  Compensation
Int(55) NOT NULL;  

Result will be displayed as follows :
IDNameAddressCompanyCompensation
1NihariHabsigudaDELL25000


MySQL TRIGGERS

MySQL - Triggers

posted on 2019-11-29 21:44:07 - mysql Tutorials


Grant_ Revoke Privilege

MySQL - Grant_ Revoke Privilege

posted on 2019-11-26 23:15:04 - mysql Tutorials


MySQL Vs SQL

MySQL Vs SQL

posted on 2019-11-25 05:02:26 - mysql Tutorials


how to use range in golang

how to use range in golang

posted on 2022-05-03 08:28:11 - Go lang Tutorials


find variable type in golang

find variable type in golang

posted on 2022-05-03 05:24:55 - Go lang Tutorials


for loops in golang

for loops in golang

posted on 2022-05-03 04:27:40 - Go lang Tutorials