Saturday, August 20, 2011

Create VIEW on MySQL

Here is the example to create a VIEW on MySQL

mysql> CREATE TABLE t (qty INT, price INT);
mysql> INSERT INTO t VALUES(3, 50);
mysql> CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
mysql> SELECT * FROM v;


Saturday, August 6, 2011

Move a table into different database on MySQL

I'm working with MySQL lately so I want to record some notes on the experience so I can refer back to this post when I need it again in the future.

Here is the command:
alter table old_db.foo rename new_db.foo

Simple, isn't it?