Resep ngopy table mysql dari table satu ke table yang lainnya,

mysql> select * from records;
+——+———————-+——–+——–+——————————————-+
| uid  | name                 | ttl    | rdtype | rdata                                     |
+——+———————-+——–+——–+——————————————-+
|    1 | sample.com           | 172800 | SOA    | ns ns01.sample.com 2003080101 3H 2M 1W 1D |
|    2 | sample.com           | 172800 | NS     | dns1.sample.com                           |
|    3 | sample.com           | 172800 | NS     | dns2.sample.com                           |
|    4 | sample.com           | 172800 | MX     | 10 ns01.sample.com                        |
|    5 | sample.com           | 172800 | MX     | 20 is01.sample.com                        |
|    6 | localhost.sample.com | 172800 | A      | 127.0.0.1                                 |
|    7 | sample.com           | 172800 | A      | 192.168.0.1                               |
|    8 | www.sample.com       | 172800 | A      | 192.168.0.2                               |
|    9 | mail.sample.com      | 172800 | MX     | 192.168.0.2                               |
|   10 | wwwmail.sample.com   | 172800 | A      | 192.168.0.2                               |
|   22 | dns1.sample.com      | 172800 | A      | 192.168.0.1                               |
|   23 | dns2.sample.com      | 172800 | A      | 192.168.0.2                               |
|   24 | nesto.sample.com     | 172800 | NS     | ns01.sample.com                           |
| 1033 |                      |      0 |        |                                           |
| 1034 |                      |      0 |        |                                           |
| 1035 |                      |      0 |        |                                           |
| 1036 |                      |      0 |        |                                           |
| 1037 |                      |      0 |        |                                           |
| 1038 |                      |      0 |        |                                           |
+——+———————-+——–+——–+——————————————-+

mysql> create table kopitabelcuk select name,ttl from records where name like ’sample.com’;
Query OK, 6 rows affected (0.04 sec)
Records: 6  Duplicates: 0  Warnings: 0

name,ttl itu adalah field-field mana saja yang mau di kopi kedalam table yang baru (table: kopitabelcuk)

mysql> show tables;
+——————+
| Tables_in_mybind |
+——————+
| kopitabelcuk     |
| records          |
+——————+

Cek ,apakah berhasil atau tidak,

mysql> select * from kopitabelcku;
+————+——–+
| name       | ttl    |
+————+——–+
| sample.com | 172800 |
| sample.com | 172800 |
| sample.com | 172800 |
| sample.com | 172800 |
| sample.com | 172800 |
| sample.com | 172800 |
+————+——–+
6 rows in set (0.00 sec)


  1. Tengkyu mAs Yud…………..jadi pingin belajar database………………
    Di tunggu posting berikutnya…………..




Leave a Comment