Instruct MySQL to setup a new database
mysql
4.1.16-nt-max> create database database01;
Database "database01" created.
All that really does is create a new subdirectory in your D:\mysql40\data directory.
Open the database
mysql 4.1.16-nt-max> use
database01
Database changed
Create a table
mysql 4.1.16-nt-max> create table
table01 (field01 integer, field02 char(10));
Query OK, 0 rows affected (0.00 sec)
Enclose entire list of field names between one pair of parentheses.
Commas are used between each field.
A space may be used after the comma between fields.
A comma is not used after last field.
This, and all SQL statements, are concluded by a semicolon " ; ".
List the tables
mysql 4.1.16-nt-max> show
tables;
| Tables in database01 |
| table01 |
| table02 |
List the fields in a table
mysql 4.1.16-nt-max> show columns from table01;
| Field |
Type |
Null |
Key |
Default |
Extra |
| Field |
int(11) |
YES |
|
|
|
| Field |
char(10) |
YES |
|
|
|
Congratulations! Pretty straightforward, eh?
Putting Data into a Table
Insert a record
mysql 4.1.16-nt-max> insert into
table01 (field01, field02) values (1, 'first');
Query OK, 1 row affected (0.00 sec)
Enclose entire list of field names between one pair of parentheses.
Enclose the values to be inserted between another pair of parentheses.
Commas are used between each field and between each value.
A space may be used after the comma between fields.
List all the records in a table
mysql 4.1.16-nt-max> select * from table01;
Excellent! |