January 2018
Intermediate to advanced
446 pages
12h 57m
English
If you want to add a new column to the employees table, you can execute the ADD COLUMN statement:
mysql> ALTER TABLE employees ADD COLUMN address varchar(100);Query OK, 0 rows affected (5.10 sec)Records: 0 Duplicates: 0 Warnings: 0
You can see that the number of rows affected is 0, which means that the table is not copied and the operation is done in-place.
If you want to increase the length of the varchar column, you can execute the MODIFY COLUMN statement:
mysql> ALTER TABLE employees MODIFY COLUMN address VARCHAR(255);Query OK, 0 rows affected (0.01 sec)Records: 0 Duplicates: 0 Warnings: 0
If you think that varchar(255) is not sufficient to store addresses, and you would like to change it to tinytext, you can use the
Read now
Unlock full access