Thursday, July 19, 2012

MySQL useful query

-- Show all columns of all tables in database
select table_name, coumn_name from information_schema.columns where table_schema = '<database name>' order by table_name;

-- Export results
SELECT order_id,product_name,qty FROM orders
INTO OUTFILE '/tmp/orders.txt'

SELECT order_id,product_name,qty FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

No comments: