Sonntag, 28. September 2008

MySQL Tutorial

1. mysql -h host -u user -p

2. enter password

2.a. Show databases:
SHOW DATABASES;

3. Build a database:
CREATE DATABASE ;

4. Use the Database:
USE ;
SHOW TABLES;

5. Build a table:
CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
-> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
6. Load data from a file:

LOAD DATA INFILE 'testOne.csv' INTO TABLE ATCCode FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'(ATCCodes, genericName, tradeName, country);

where testOne.csv is the name of the data file and it must be under /var/lib/mysql/
e.g if the dir called testOne, then /var/lib/mysql/testOne/

ATCCode is the name of the table.

Keine Kommentare: