DROP TABLE IF EXISTS customers;
CREATE TABLE customers (
lastname varchar(30) DEFAULT '' NOT NULL,
firstname varchar(30) DEFAULT '' NOT NULL,
address varchar(100) DEFAULT '' NOT NULL,
state varchar(30) DEFAULT '' NOT NULL,
country varchar(30) DEFAULT '' NOT NULL,
KEY lastn_index (lastname(6),state(2),country(3))
);
# Dumping data for table 'customers'
#
LOCK TABLES customers WRITE;
INSERT INTO customers VALUES ('Shepherd','Tom','33 Madison
Drive,Oakland','CA','USA'),('Chapman','Frederick','52 Ocean St,
Sacramento','CA','USA'),('Lowe','Justin','3 Hill Walk, Twin Creeks','WI','USA'),('Spokes','Chris','Red Fern
House, Bradwell','Oxford','UK');
UNLOCK TABLES;
Note the DROP TABLE, LOCK TABLES, and UNLOCK TABLES statements and the fact that the INSERT
is an extended line; these are the effects of using the --opt option with mysqldump.
Alternatively, you may want to save your database as separate files for SQL statements and tab-
delimited data files. You might type the following:
mysqldump --tab=/root book
This produces two files per table, one with the SQL CREATE statements (customers.sql):
MySQL dump 6.4
Host: localhost Database: book
#--------------------------------------------------------
Server version 3.22.27
Table structure for table 'customers'
CREATE TABLE customers (
lastname varchar(30) DEFAULT '' NOT NULL,
firstname varchar(30) DEFAULT '' NOT NULL,
address varchar(100) DEFAULT '' NOT NULL,
state varchar(30) DEFAULT '' NOT NULL,
country varchar(30) DEFAULT '' NOT NULL,
KEY lastn_index (lastname(6),state(2),country(3))
);
and one with the data, tab-delimited, in customers.txt:
Shepherd Tom 33 Madison Drive, Oakland CA USA
Chapman Frederick 52 Ocean St, Sacramento CA USA