Using MySQL Navigator
Preliminaries
To find out how to start MySQL and to install MySQL Navigator, visit
http://sql.kldp.org/mysql/, click on Document in the left frame, and follow the instructions.
To create a database
- Start MySQL as root user
- Start MySQL Navigator
- In the server window, double click on the server: root@localhost
- In the schema window, right click on Database
- Click on Create Database
- Enter name for database: new When naming databases, use only alphanumeric characters
and substitute underscores for spaces. Database names are case-sensitive.
Do not use MySQL reserved words. For a list of reserved words, see http://www.mysql.com/doc/en/Reserved_words.html
- Click on OK
The screen after step 6:
To delete a database
- In the server window, double click on the server: root@localhost
- In schema window, open Database by clicking on the plus in the check box
- Right click on database: new
- Click on Delete database
- Click on Yes
The screen after step 4:
To create a MySQL table
Below is a row of field names with data for four records in the remaining rows:
id | make | purchase_date | hd_gb | ram_mb | cpu | comments |
1 | EMachine | 1999-10-27 | 4.30 | 64 | Celeron 400 | High#14 |
2 | PC Magic | 2000-07-07 | 10.00 | 64 | Celeron 533 | High#2 |
3 | EMachine | 2000-04-09 | 4.30 | 32 | Celeron 500 | High#11 |
4 | PC Magic | 2000-11-15 | 30.00 | 128 | Celeron 667 | High#12 |
- Double click on server: root@localhost
- Click on MySQL on the menu bar
- Click on Table
- On the table form, choose a database: test
- Enter a name for the table: inventory When naming tables, use only alphanumeric
characters and substitute underscores for spaces. In Linux MySQL, table names
are case-sensitive. Do not use MySQL reserved words. For a list of reserved
words, see http://www.mysql.com/doc/en/Reserved_words.html
Enter the following data:
- Field
Name: id Unlike database and table names, field names are case insensitive
Type: SMALLINT
Length: 2
Null: NOT NULL
Extra: AUTO_INCREMENT
Click on Save
The screen before clicking on Save:
- Field
Name: make
Type: VARCHAR
Length: 20
Null: NULL
Click on Save
- Field
Name: purchase_date
Type: DATE
Null: NULL
Click on Save
- Field
Name: hd_gb
Type: DECIMAL
Length: 2,2
Null: NOT NULL
Click on Save
- Field
Name: ram_mb
Type: MEDIUM
Length: 3
Null: NOT NULL
Click on Save
- Field
Name: cpu
Type: VARCHAR
Length: 20
Null: NOT NULL
Click on Save
- Field
Name: comments
Type: VARCHAR
Length: 30
Null: NULL
Click on Save
- Click on Key tab
Name: id
Type: PRIMARY KEY
Click on Save
- Click on Fire
To delete a table
- In server window, double click on server: root@localhost
- In schema window, click on database containing table to be deleted
- Right click on table to be deleted and click on Delete
To move a table from one database to another:
- In server window, double click on server: root@localhost
- In schema window, open database containing table to be moved: test
- In schema window, right click on table to be moved: inventory
- Click on Move table
- Type in name of database destination for table: hsccomputer, for example
- Click Ok
The screen after step 5:
To open an existing table
- In server window, double click on server: root@localhost
- In schema window, open database: test
- Double click on table: inventory
To load data into an existing table
- Open MySQL Navigator
- In the menu bar, click on MySQL and on Schema
- Open database: test
- Right click on table inventory and click on Record in table
- In table window, click on Tools and click on Insert
- Insert into Values list data corresponding to the table field names.
Number of entries must match number of field names and be in the same order
- To view results: double click on table name inventory in the schema window
The screen after step 7:
To remove a record
- Double click on server: root@localhost
- Open database: test
- Double click on table name: inventory
- Right click on check box for record created in previous section
- Click on Delete
To edit existing table contents
- Double click on server: root@localhost
- Click on MySQL in the menu bar
- Click on Edit
- In the Edit window, click on File and on Open
- Find file and open it
- Make your changes
- Click on Save in the file menu
- To view results: double click on table name inventory in the schema window
The screen after step 5:
Querying an existing table using MySQL statements
To retrieve information
- Double click on server: root@localhost
- In drop down menu, click database: test
- Enter query in query box: select * from inventory where hd_gb >5
- Press Enter or click the Fire button (just to the right of the query box)
The screen after step 4:
- Enter query in query box: select * from inventory where source = "PC Magic"
- Press Enter or click the Fire button
- Enter query in query box: select * from inventory where hd_gb > 10 and ram > 128
- Press Enter or click the Fire button
To update a table
- In server window, double click on server: root@localhost
- In dropdown menu, click database: test
- Enter query in query box: update inventory set comments = "High#10" where id = 4
- Press Enter or click the Fire button
- To view result: double click on the table name in the schema window
To insert a row
- In server window, double click on server: root@localhost
- Choose database: test
- Enter query in query box: insert into inventory values ("5","PC Magic","2002-02-06","40","256","AMD TB 900","High#6")
- Press Enter or click the Fire button
- To view result: double click on the table name in the schema window
To delete a row
- In server window, double click on server: root@localhost
- Choose database: test
- Enter query in query box: delete from inventory where id = 5
- Press Enter or click the Fire button
- To view result: double click on the table name in the schema window