56,678
社区成员
发帖
与我相关
我的任务
分享
第一种
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| testtable |
+----------------+
1 row in set (0.00 sec)
mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)
mysql> \q
Bye
C:\>mysqldump -uroot -p --add-drop-table --tables test testtable>c:\\testtable.sql
Enter password: ******
C:\>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1311
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test
Database changed
mysql> truncate table testtable;
Query OK, 4 rows affected (0.02 sec)
mysql> select * from testtable;
Empty set (0.00 sec)
mysql> source c:\\testtable.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.03 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)
mysql> truncate table testtable;
Query OK, 4 rows affected (0.02 sec)
第二种
C:\>mysql -uroot -p -b test< c:\\testtable.sql
Enter password: ******
C:\>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1314
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test
Database changed
mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)
mysql>
mysql> source C:/Documents and Settings/Administrator/桌面/2.sql;
+----+-------------+--------+
| ID | adStyleName | isUsed |
+----+-------------+--------+
| 1 | 全屏广告 | 1 |
| 2 | 对联广告 | 1 |
+----+-------------+--------+
2 rows in set (0.00 sec)
mysql> use ad;
Database changed
mysql> source C:/2.sql;
+----+-------------+--------+
| ID | adStyleName | isUsed |
+----+-------------+--------+
| 1 | 全屏广告 | 1 |
| 2 | 对联广告 | 1 |
+----+-------------+--------+
2 rows in set (0.00 sec)