MySQL on Milkshake

database graphic

Binary Installation on Windows

To install MyODBC on Windows, you should download the appropriate distribution file for your operating system from http://www.mysql.com/downloads/api-myodbc.html, unpack it, and execute the SETUP.EXE file.


How to acess MySQL command line

milk:~# mysql -u username -p database name 
Enter password:

How to create a table in a MySQL database

	CREATE TABLE table name
	(
		column name TYPE, CONDITIONS
	);

For example

	CREATE TABLE contacts
	(
		firstname varchar(30) not null,
		lastname varchar(30) primary key,
		age int(9) not null
	);

How to insert data into a MySQL database


	INSERT INTO table name (column name)
	VALUES ("values");

For example

	INSERT INTO contacts (firstname,lastname,age)
	VALUES ("Andrew","Och","27");


How to query a MySQL database

	SELECT column name
	FROM table name
	WHERE condition
	AND more conditions
	ORDER BY column name 

For example

        SELECT firstname, lastname, age
        FROM contacts 
        WHERE firstname="andrew"
        AND age >= "20" 
        ORDER BY lastname;

How to delete from a MySQL database


	DELETE FROM table name
	WHERE condition;

For example

	DELETE FROM contacts
	WHERE lastname = "och";
	

FORGETTING the WHERE clause will delete ALL data in database!!!

Site Contents and Design (c) Andrew Och 2002