我使用的是XAMPP套件。
WangWeis-MacBook-Air:bin wangwei$ pwd
/Applications/XAMPP/bin
WangWeis-MacBook-Air:bin wangwei$ ./mysql -u root
也可以
WangWeis-MacBook-Air:bin wangwei$ ./mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
Server version: 10.1.9-MariaDB Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.00 sec)
MariaDB [(none)]>
MariaDB [(none)]> create database publications;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| publications |
| test |
+--------------------+
6 rows in set (0.00 sec)
MariaDB [(none)]>
MariaDB [(none)]> use publications;
Database changed
MariaDB [publications]>
MariaDB [publications]> grant all on publications.* to 'user1'@'localhost' identified by 'password1';
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> exit
Bye
WangWeis-MacBook-Air:bin wangwei$ ./mysql -u user1 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.1.9-MariaDB Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| publications |
| test |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> use test;
Database changed
MariaDB [test]> use publications;
Database changed
MariaDB [publications]>
MariaDB [publications]>
MariaDB [publications]>
MariaDB [publications]> create table classics( author varchar(128), title varchar(128), type varchar(16), year char(4)) engine MyISAM;
Query OK, 0 rows affected (0.03 sec)
MariaDB [publications]>
MariaDB [publications]> describe classics;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | char(4) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics add id int unsigned not null auto_increment key;
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [publications]> describe classics;
+--------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+----------------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | char(4) | YES | | NULL | |
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
+--------+------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> INSERT INTO classics(author, title, type, year)
-> VALUES('Mark Twain','The Adventures of Tom Sawyer','Fiction','1876');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO classics(author, title, type, year)
-> VALUES('Jane Austen','Pride and Prejudice','Fiction','1811');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO classics(author, title, type, year)
-> VALUES('Charles Darwin','The Origin of Species','Non-Fiction','1856');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO classics(author, title, type, year)
-> VALUES('Charles Dickens','The Old Curiosity Shop','Fiction','1841');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO classics(author, title, type, year)
-> VALUES('William Shakespeare','Romeo and Juliet','Play','1594');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> select * from classics;
+---------------------+------------------------------+-------------+------+
| author | title | type | year |
+---------------------+------------------------------+-------------+------+
| Mark Twain | The Adventures of Tom Sawyer | Fiction | 1876 |
| Jane Austen | Pride and Prejudice | Fiction | 1811 |
| Charles Darwin | The Origin of Species | Non-Fiction | 1856 |
| Charles Dickens | The Old Curiosity Shop | Fiction | 1841 |
| William Shakespeare | Romeo and Juliet | Play | 1594 |
+---------------------+------------------------------+-------------+------+
5 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics rename pre1900;
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]> describe classics;
ERROR 1146 (42S02): Table 'publications.classics' doesn't exist
MariaDB [publications]> describe pre1900;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | char(4) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
MariaDB [publications]> alter table pre1900 rename classics;
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]> describe classics;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | char(4) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
MariaDB [publications]>
MariaDB [publications]>
MariaDB [publications]> alter table classics modify year smallint;
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> describe classics;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | smallint(6) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics add pages smallint unsigned;
Query OK, 5 rows affected (0.07 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> describe classics;
+--------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| type | varchar(16) | YES | | NULL | |
| year | smallint(6) | YES | | NULL | |
| pages | smallint(5) unsigned | YES | | NULL | |
+--------+----------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
MariaDB [publications]> alter table classics change type category varchar(16);
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [publications]> describe classics;
+----------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| category | varchar(16) | YES | | NULL | |
| year | smallint(6) | YES | | NULL | |
| pages | smallint(5) unsigned | YES | | NULL | |
+----------+----------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics drop pages;
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> describe classics;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | | NULL | |
| title | varchar(128) | YES | | NULL | |
| category | varchar(16) | YES | | NULL | |
| year | smallint(6) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> CREATE TABLE disposable(trash INT);
Query OK, 0 rows affected (0.04 sec)
MariaDB [publications]> DESCRIBE disposable;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| trash | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
MariaDB [publications]> DROP TABLE disposable;
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]> SHOW tables;
+------------------------+
| Tables_in_publications |
+------------------------+
| classics |
+------------------------+
1 row in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics add index(author(20));
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> ALTER TABLE classics ADD INDEX(title(20));
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> ALTER TABLE classics ADD INDEX(category(4));
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> ALTER TABLE classics ADD INDEX(year);
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> DESCRIBE classics;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | MUL | NULL | |
| title | varchar(128) | YES | MUL | NULL | |
| category | varchar(16) | YES | MUL | NULL | |
| year | smallint(6) | YES | MUL | NULL | |
+----------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
MariaDB [publications]>
MariaDB [publications]> alter table classics add isbn char(13) primary key;
ERROR 1062 (23000): Duplicate entry '' for key 'PRIMARY'
MariaDB [publications]> ALTER TABLE classics ADD isbn CHAR(13);
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> UPDATE classics SET isbn='9781598184891' WHERE year='1876';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> UPDATE classics SET isbn='9780582506206' WHERE year='1811';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> UPDATE classics SET isbn='9780517123201' WHERE year='1856';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> UPDATE classics SET isbn='9780099533474' WHERE year='1841';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> UPDATE classics SET isbn='9780192814968' WHERE year='1594';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> ALTER TABLE classics ADD PRIMARY KEY(isbn);
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [publications]> DESCRIBE classics;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| author | varchar(128) | YES | MUL | NULL | |
| title | varchar(128) | YES | MUL | NULL | |
| category | varchar(16) | YES | MUL | NULL | |
| year | smallint(6) | YES | MUL | NULL | |
| isbn | char(13) | NO | PRI | NULL | |
+----------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> INSERT INTO classics(author, title, category, year, isbn)
-> VALUES('Charles Dickens','Little Dorrit','Fiction','1857', '9780141439969');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> select * from classics; +---------------------+------------------------------+-------------+------+---------------+
| author | title | category | year | isbn |
+---------------------+------------------------------+-------------+------+---------------+
| Mark Twain | The Adventures of Tom Sawyer | Fiction | 1876 | 9781598184891 |
| Jane Austen | Pride and Prejudice | Fiction | 1811 | 9780582506206 |
| Charles Darwin | The Origin of Species | Non-Fiction | 1856 | 9780517123201 |
| Charles Dickens | The Old Curiosity Shop | Fiction | 1841 | 9780099533474 |
| William Shakespeare | Romeo and Juliet | Play | 1594 | 9780192814968 |
| Charles Dickens | Little Dorrit | Fiction | 1857 | 9780141439969 |
+---------------------+------------------------------+-------------+------+---------------+
6 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> select author from classics;
+---------------------+
| author |
+---------------------+
| Mark Twain |
| Jane Austen |
| Charles Darwin |
| Charles Dickens |
| William Shakespeare |
| Charles Dickens |
+---------------------+
6 rows in set (0.00 sec)
MariaDB [publications]> select distinct author from classics;
+---------------------+
| author |
+---------------------+
| Mark Twain |
| Jane Austen |
| Charles Darwin |
| Charles Dickens |
| William Shakespeare |
+---------------------+
5 rows in set (0.00 sec)
MariaDB [publications]> select author from classics limit 3;
+----------------+
| author |
+----------------+
| Mark Twain |
| Jane Austen |
| Charles Darwin |
+----------------+
3 rows in set (0.00 sec)
MariaDB [publications]> select author from classics limit 3,1;
+-----------------+
| author |
+-----------------+
| Charles Dickens |
+-----------------+
1 row in set (0.00 sec)
MariaDB [publications]> select author from classics limit 1,2;
+----------------+
| author |
+----------------+
| Jane Austen |
| Charles Darwin |
+----------------+
2 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> select author,title from classics where match(author,title) against ('+charles -species');
+----------------+-----------------------+
| author | title |
+----------------+-----------------------+
| Charles Darwin | The Origin of Species |
+----------------+-----------------------+
1 row in set (0.00 sec)
MariaDB [publications]> select author,title from classics where match(author,title) against ('+charles -species' in boolean mode);
+-----------------+------------------------+
| author | title |
+-----------------+------------------------+
| Charles Dickens | The Old Curiosity Shop |
| Charles Dickens | Little Dorrit |
+-----------------+------------------------+
2 rows in set (0.00 sec)
MariaDB [publications]> update classics set author='Mark Twain(Samuel Langhorne Clemens)' where author='Mark Twain';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> update classics set category='Classic Fiction' where category='Fiction';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
MariaDB [publications]> select * from classics;
+--------------------------------------+------------------------------+-----------------+------+---------------+
| author | title | category | year | isbn |
+--------------------------------------+------------------------------+-----------------+------+---------------+
| Mark Twain(Samuel Langhorne Clemens) | The Adventures of Tom Sawyer | Classic Fiction | 1876 | 9781598184891 |
| Jane Austen | Pride and Prejudice | Classic Fiction | 1811 | 9780582506206 |
| Charles Darwin | The Origin of Species | Non-Fiction | 1856 | 9780517123201 |
| Charles Dickens | The Old Curiosity Shop | Classic Fiction | 1841 | 9780099533474 |
| William Shakespeare | Romeo and Juliet | Play | 1594 | 9780192814968 |
| Charles Dickens | Little Dorrit | Classic Fiction | 1857 | 9780141439969 |
+--------------------------------------+------------------------------+-----------------+------+---------------+
6 rows in set (0.01 sec)
MariaDB [publications]> select category,count(author) from classics;
+-----------------+---------------+
| category | count(author) |
+-----------------+---------------+
| Classic Fiction | 6 |
+-----------------+---------------+
1 row in set (0.00 sec)
MariaDB [publications]> select category,count(author) from classics group by category;
+-----------------+---------------+
| category | count(author) |
+-----------------+---------------+
| Classic Fiction | 4 |
| Non-Fiction | 1 |
| Play | 1 |
+-----------------+---------------+
3 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> CREATE TABLE customers (
-> name VARCHAR(128),
-> isbn VARCHAR(13),
-> PRIMARY KEY (isbn)) ENGINE MyISAM;
Query OK, 0 rows affected (0.03 sec)
MariaDB [publications]> INSERT INTO customers(name,isbn)
-> VALUES('Joe Bloggs','9780099533474');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO customers(name,isbn)
-> VALUES('Mary Smith','9780582506206');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO customers(name,isbn)
-> VALUES('Jack Wilson','9780517123201');
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> SELECT * FROM customers;
+-------------+---------------+
| name | isbn |
+-------------+---------------+
| Joe Bloggs | 9780099533474 |
| Mary Smith | 9780582506206 |
| Jack Wilson | 9780517123201 |
+-------------+---------------+
3 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> select * from customers,classics where customers.isbn = classics.isbn;
+-------------+---------------+-----------------+------------------------+-----------------+------+---------------+
| name | isbn | author | title | category | year | isbn |
+-------------+---------------+-----------------+------------------------+-----------------+------+---------------+
| Joe Bloggs | 9780099533474 | Charles Dickens | The Old Curiosity Shop | Classic Fiction | 1841 | 9780099533474 |
| Mary Smith | 9780582506206 | Jane Austen | Pride and Prejudice | Classic Fiction | 1811 | 9780582506206 |
| Jack Wilson | 9780517123201 | Charles Darwin | The Origin of Species | Non-Fiction | 1856 | 9780517123201 |
+-------------+---------------+-----------------+------------------------+-----------------+------+---------------+
3 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> CREATE TABLE accounts (
-> number INT, balance FLOAT, PRIMARY KEY(number)
-> ) ENGINE InnoDB;
Query OK, 0 rows affected (0.03 sec)
MariaDB [publications]> DESCRIBE accounts;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| number | int(11) | NO | PRI | NULL | |
| balance | float | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)
MariaDB [publications]> INSERT INTO accounts(number, balance) VALUES(12345, 1025.50);
Query OK, 1 row affected (0.00 sec)
MariaDB [publications]> INSERT INTO accounts(number, balance) VALUES(67890, 140.00);
Query OK, 1 row affected (0.01 sec)
MariaDB [publications]> SELECT * FROM accounts;
+--------+---------+
| number | balance |
+--------+---------+
| 12345 | 1025.5 |
| 67890 | 140 |
+--------+---------+
2 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> BEGIN;
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]> UPDATE accounts SET balance=balance-250 WHERE number=12345;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> UPDATE accounts SET balance=balance+250 WHERE number=67890;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [publications]> SELECT * FROM accounts;
+--------+---------+
| number | balance |
+--------+---------+
| 12345 | 800.61 |
| 67890 | 390 |
+--------+---------+
2 rows in set (0.00 sec)
MariaDB [publications]> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
MariaDB [publications]> SELECT * FROM accounts;
+--------+---------+
| number | balance |
+--------+---------+
| 12345 | 1050.61 |
| 67890 | 140 |
+--------+---------+
2 rows in set (0.00 sec)
MariaDB [publications]>
MariaDB [publications]> EXPLAIN SELECT * FROM accounts WHERE number='12345';
+------+-------------+----------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+-------+---------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | accounts | const | PRIMARY | PRIMARY | 4 | const | 1 | |
+------+-------------+----------+-------+---------------+---------+---------+-------+------+-------+
1 row in set (0.00 sec)
MariaDB [publications]>
WangWeis-MacBook-Air:bin wangwei$ ./mysqldump -u user1 -p password1 publications
Enter password:
-- MySQL dump 10.16 Distrib 10.1.9-MariaDB, for osx10.6 (i386)
--
-- Host: localhost Database: password1
-- ------------------------------------------------------
-- Server version 10.1.9-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
mysqldump: Got error: 1044: "Access denied for user 'user1'@'localhost' to database 'password1'" when selecting the database
WangWeis-MacBook-Air:bin wangwei$ ./mysqldump -u root publications
-- MySQL dump 10.16 Distrib 10.1.9-MariaDB, for osx10.6 (i386)
--
-- Host: localhost Database: publications
-- ------------------------------------------------------
-- Server version 10.1.9-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `classics`
--
DROP TABLE IF EXISTS `classics`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `classics` (
`author` varchar(128) DEFAULT NULL,
`title` varchar(128) DEFAULT NULL,
`category` varchar(16) DEFAULT NULL,
`year` smallint(6) DEFAULT NULL,
`isbn` char(13) NOT NULL,
PRIMARY KEY (`isbn`),
KEY `author` (`author`(20)),
KEY `title` (`title`(20)),
KEY `category` (`category`(4)),
KEY `year` (`year`),
FULLTEXT KEY `author_2` (`author`,`title`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `classics`
--
LOCK TABLES `classics` WRITE;
/*!40000 ALTER TABLE `classics` DISABLE KEYS */;
INSERT INTO `classics` VALUES ('Mark Twain(Samuel Langhorne Clemens)','The Adventures of Tom Sawyer','Classic Fiction',1876,'9781598184891'),('Jane Austen','Pride and Prejudice','Classic Fiction',1811,'9780582506206'),('Charles Darwin','The Origin of Species','Non-Fiction',1856,'9780517123201'),('Charles Dickens','The Old Curiosity Shop','Classic Fiction',1841,'9780099533474'),('William Shakespeare','Romeo and Juliet','Play',1594,'9780192814968'),('Charles Dickens','Little Dorrit','Classic Fiction',1857,'9780141439969');
/*!40000 ALTER TABLE `classics` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `customers`
--
DROP TABLE IF EXISTS `customers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `customers` (
`name` varchar(128) DEFAULT NULL,
`isbn` varchar(13) NOT NULL,
PRIMARY KEY (`isbn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `customers`
--
LOCK TABLES `customers` WRITE;
/*!40000 ALTER TABLE `customers` DISABLE KEYS */;
INSERT INTO `customers` VALUES ('Joe Bloggs','9780099533474'),('Mary Smith','9780582506206'),('Jack Wilson','9780517123201');
/*!40000 ALTER TABLE `customers` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-02-21 21:05:36
WangWeis-MacBook-Air:bin wangwei$