<< BitOf(column,string) | Home | The Constitution should be Enforceable by Citizens >>

ALTER Initial

A suggested extension to MySQL

ALTER Initial

Alter table this,that (ie. ALTER with multiple changes) appears to be optimized perform a single pass thru a table (at least sometimes) to perform the multiple changes. Some changes require column expression evaluation. These could be done with the alter

 

E.g.

Alter table xxx, add column negative bit initial quantity<0, modify quantity int unsigned initial abs(quantity)

This changes the representation of a column (‘quantity’) from a signed integer to an unsigned integer with a flag (‘negative’) to indicate that quantity is negative.

Alter table sales add unitprice dec(6,2) initial totalprice/quantity , drop totalprice

This alters a table, in a single pass, from recording the quantity and total price of sales, to recording quantity and unit price of sales.  Without this extension it requires three passes through the table (1. Alter Add unitprice, 2 update set unitprice, 3 alter drop totalprice).

The meaning of the ‘initial’ clause is an expression that is computed based on the values in the row at the time the ALTER is performed for each row to set (or update) the value of the column.



Add a comment Send a TrackBack