USE yiibaidb;CREATETABLEIFNOTEXISTS offices_bk SELECT*FROM offices;
可以通过查询office_bk表中的数据来验证副本,如下所示:
SELECT*FROM offices_bk;
执行上面查询,得到以下结果 -
+------------+---------------+------------------+--------------------------+--------------+-------+-----------+------------+-----------+
| officeCode | city | phone | addressLine1 | addressLine2 | state | country | postalCode | territory |
+------------+---------------+------------------+--------------------------+--------------+-------+-----------+------------+-----------+
| 1 | San Francisco | +1 650 219 4782 | 100 Market Street | Suite 300 | CA | USA | 94080 | NA |
| 2 | Boston | +1 215 837 0825 | 1550 Court Place | Suite 102 | MA | USA | 02107 | NA |
| 3 | NYC | +1 212 555 3000 | 523 East 53rd Street | apt. 5A | NY | USA | 10022 | NA |
| 4 | Paris | +33 14 723 4404 | 43 Rue Jouffroy Dabbans | NULL | NULL | France | 75017 | EMEA |
| 5 | Beijing | +86 33 224 5000 | 4-1 Haidian Area | NULL | BJ | China | 110000 | NA |
| 6 | Sydney | +61 2 9264 2451 | 5-11 Wentworth Avenue | Floor #2 | NULL | Australia | NSW 2010 | APAC |
| 7 | London | +44 20 7877 2041 | 25 Old Broad Street | Level 7 | NULL | UK | EC2N 1HN | EMEA |
+------------+---------------+------------------+--------------------------+--------------+-------+-----------+------------+-----------+
7rowsinset
如果我们想仅复制在美国(USA)办公室,可以将WHERE子句添加到SELECT语句中,如下所示:
USE yiibaidb;CREATETABLEIFNOTEXISTS offices_usa SELECT*FROM officesWHERE country ='USA';
验证上面查询执行,得到以下结果 -
SELECT*FROM officesWHERE country ='USA';+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+
| officeCode | city | phone | addressLine1 | addressLine2 | state | country | postalCode | territory |
+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+
| 1 | San Francisco | +1 650 219 4782 | 100 Market Street | Suite 300 | CA | USA | 94080 | NA |
| 2 | Boston | +1 215 837 0825 | 1550 Court Place | Suite 102 | MA | USA | 02107 | NA |
| 3 | NYC | +1 212 555 3000 | 523 East 53rd Street | apt. 5A | NY | USA | 10022 | NA |
+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+
3rowsinset