Create a MySQL instance database (menagerie)

Source: Internet
Author: User
Related Script: http://downloads.mysql.com/docs/menagerie-db.zip

1. Establish and connect to the database

C: \ Program Files \ mysql \ MySQL Server 5.0 \ bin> mysql-H localhost-u root-P
Enter Password :*****
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 9
Server version: 5.0.51b-Community-nt MySQL Community edition (GPL)

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql> Create Database menagerie;
Query OK, 1 row affected (0.00 Sec)

Mysql> Use menagerie;
Database changed

2. Create a pet table and load data.

Mysql> load data local infile 'pet.txt 'into Table PET;
Query OK, 8 rows affected (0.06 Sec)
Records: 8 deleted: 0 skipped: 0 Warnings: 0

Mysql> select * from PET;
+ ---------- + -------- + --------- + ------ + ------------ +
| Name | Owner | species | sex | birth | death |
+ ---------- + -------- + --------- + ------ + ------------ +
| Fluffy | Harold | cat | f | 1993-02-04 | null |
| Claws | Gwen | cat | M | 1994-03-17 | null |
| Buffy | Harold | dog | f | 1989-05-13 | null |
| Fang | Benny | dog | M | 1990-08-27 | null |
| Boane | Diane | dog | M |
| Chirpy | Gwen | bird | f | 1998-09-11 | null |
| Whistler | Gwen | bird | null | 1997-12-09 | null |
| Slim | Benny | snake | M | 1996-04-29 | null |
+ ---------- + -------- + --------- + ------ + ------------ +
8 rows in SET (0.00 Sec)

Add a new record through the script
Mysql> source ins_puff_rec. SQL
Query OK, 1 row affected (0.06 Sec)

3. Create an event table and load data.

Mysql> source cr_event_tbl. SQL
Query OK, 0 rows affected, 1 warning (0.00 Sec)

Query OK, 0 rows affected (0.09 Sec)

Mysql> load data local infile 'event.txt 'into table event;
Query OK, 10 rows affected, 2 warnings (0.06 Sec)
Records: 10 deleted: 0 skipped: 0 Warnings: 2

Mysql> select * from event;
+ ---------- + ------------ + ---------- + ----------------------------- +
| Name | date | type | remark |
+ ---------- + ------------ + ---------- + ----------------------------- +
| Fluffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male |
| Buffy | 1993-06-23 | litter | 5 puppies, 2 female, 3 male |
| Buffy | 1994-06-19 | litter | 3 puppies, 3 female |
| Chirpy | maid | vet | needed beak straightened |
| Slim | 1997-08-03 | vet | broken rib |
| Bonel | 1991-10-12 | kennel | null |
| Fang | 1991-10-12 | kennel | null |
| Fang | 1998-08-28 | birthday | gave him a new chew toy |
| Claws | 1998-03-17 | birthday | gave him a new flea collar |
| Whistler | 1998-12-09 | birthday | first birthday |
+ ---------- + ------------ + ---------- + ----------------------------- +
10 rows in SET (0.00 Sec)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.