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


What Is Oracle

What Is Oracle

posted on 2019-11-29 01:11:21 - ORACLE Tutorials


TRIGGER

ORACLE - Trigger

posted on 2019-11-28 22:14:22 - ORACLE Tutorials


CURSOR

ORACLE - Cursor

posted on 2019-11-28 22:13:54 - ORACLE Tutorials