mysql怎么导出一个表的数据

发布网友 发布时间:2022-04-24 01:55

我来回答

1个回答

热心网友 时间:2022-04-09 06:20

[php]
mysql> use dbatest;

Database changed

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 | 19-05-13 | NULL |
| Fang | Benny | dog | m | 1990-08-27 | NULL |
| Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
| 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.01 sec)

[mysql@QANEW mysql]$ mysqlmp -uroot -p dbatest pet > dbatest_pet.sql
Enter password:
[mysql@QANEW mysql]$ cat dbatest_pet.sql
-- MySQL mp 8.23
--
-- Host: localhost Database: dbatest
---------------------------------------------------------
-- Server version 5.0.27-standard-log

--
-- Table structure for table `pet`
--

CREATE TABLE pet (
`name` varchar(20) default NULL,
owner varchar(20) default NULL,
species varchar(20) default NULL,
sex char(1) default NULL,
birth date default NULL,
death date default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `pet`
--

INSERT INTO pet VALUES ('Fluffy','Harold','cat','f','1993-02-04',NULL);
INSERT INTO pet VALUES ('Claws','Gwen','cat','m','1994-03-17',NULL);
INSERT INTO pet VALUES ('Buffy','Harold','dog','f','19-05-13',NULL);
INSERT INTO pet VALUES ('Fang','Benny','dog','m','1990-08-27',NULL);
INSERT INTO pet VALUES ('Bowser','Diane','dog','m','1979-08-31','1995-07-29');
INSERT INTO pet VALUES ('Chirpy','Gwen','bird','f','1998-09-11',NULL);
INSERT INTO pet VALUES ('Whistler','Gwen','bird',NULL,'1997-12-09',NULL);
INSERT INTO pet VALUES ('Slim','Benny','snake','m','1996-04-29',NULL);

[mysql@QANEW mysql]$

[/php]

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com