Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

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?

Wednesday, November 11, 2009

import CSV into mysql

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','

Export a table on MySQL

select * into outfile '/tmp/outfile.txt' fields terminated by ',' from my_table_name;

Monday, September 28, 2009

Restore mysql database from command prompt

mysql - u user_name -p your_password database_name < file_name.sql