In MySql4.0.12, with the "CREATE TABLE Bak_name as SELECT * from Original_name" statement
, the generated Bak table does not have a primary key and the index, the use of the time to pay attention to. You can build a table structure that you want to back up first
Methods 1:create Table MMM select * from BBB; Note: This command requires MMM this table in the database tutorial
Methods 2:insert into MMM select * BBB; This statement implements the same function as the previous statement, and only requires
Mysql>
mysql> CREATE TABLE Topic (
-> topicid SMALLINT not NULL auto_increment PRIMARY KEY,
-> name & nbsp; VARCHAR not NULL,
-> instock SMALLINT UNSIGNED not NULL,
-> onorder SMALLINT UNSIGNED not NULL,
-> reserved SMALLINT UNSIGNED not NULL,
-> department ENUM (' Classical ', ' Popular ') not NULL,
-> category VARCHAR is not NULL,
-> rowupdate TIMESTAMP not NULL
->) ;
Query OK, 0 rows affected (0.03 sec)
Mysql>
Mysql>
Mysql> INSERT into Topic (Name, Instock, Onorder, Reserved, Department,
Category) VALUES
-> (' Java ', 5, 3, ' popular ',
' Rock '),
-> (' JavaScript ', 10, 5, 3,
' Classical ', ' Opera ',
-> (' C Sharp ', 4, 1, ' popular ',
' Jazz '),
-> (' C ', 9, 4, 2,
' Classical ', ' dance '),
-> (' C + + ', 24, 2, 5,
' Classical ', ' General ',
-> (' Perl ', 16, 6, 8,
' Classical ', ' vocal '),
-> (' Python ', 2, 6, ' popular ',
' Blues '),
-> (' Php ', 3, ten, ' Popular ',
' Jazz '),
-> (' asp.net ', A, A, ' popular ',
' Country '),
-> (' vb.net ', 5, ten, ' Popular ',
' New age '),
-> (' vc.net ', all, one, one, ' popular ',
' New age '),
-> (' UML ', 42, 17, 17,
' Classical ', ' General ',
-> (' www.java2s.com ', 25, 44, 28,
' Classical ', ' dance '),
-> (' Oracle ', 32, 15, 12,
' Classical ', ' General ',
-> (' Pl/sql ', 20, 10, 5,
' Classical ', ' Opera ',
-> (' SQL Server ', 23, 12, 8,
' Classical ', ' general ');
Query OK, Rows Affected (0.00 sec)
Records:16 duplicates:0 warnings:0
Mysql>
Mysql> select * from Topic;
+---------+----------------+---------+---------+----------+------------+--------
--+---------------------+
| TopicID | Name | Instock | Onorder | Reserved | Department | Category
| Rowupdate |
+---------+----------------+---------+---------+----------+------------+--------
--+---------------------+
| 1 | Java | 10 | 5 | 3 | Popular | Rock
| 2007-07-23 19:09:52 |
| 2 | JavaScript | 10 | 5 | 3 | Classical | Opera
| 2007-07-23 19:09:52 |
| 3 | C Sharp | 17 | 4 | 1 | Popular | Jazz
| 2007-07-23 19:09:52 |
| 4 | C | 9 | 4 | 2 | Classical | Dance
| 2007-07-23 19:09:52 |
| 5 | C + + | 24 | 2 | 5 | Classical | General
| 2007-07-23 19:09:52 |
| 6 | Perl | 16 | 6 | 8 | Classical | Vocal
| 2007-07-23 19:09:52 |
| 7 | Python | 2 | 25 | 6 | Popular | Blues
| 2007-07-23 19:09:52 |
| 8 | PHP | 32 | 3 | 10 | Popular | Jazz
| 2007-07-23 19:09:52 |
| 9 | asp.net | 12 | 15 | 13 | Popular | Country
| 2007-07-23 19:09:52 |
| 10 | vb.net | 5 | 20 | 10 | Popular | New Age
| 2007-07-23 19:09:52 |
| 11 | vc.net | 24 | 11 | 14 | Popular | New Age
| 2007-07-23 19:09:52 |
| 12 | UML | 42 | 17 | 17 | Classical | General
| 2007-07-23 19:09:52 |
| 13 | www.java2s.com | 25 | 44 | 28 | Classical | Dance
| 2007-07-23 19:09:52 |
| 14 | Oracle | 32 | 15 | 12 | Classical | General
| 2007-07-23 19:09:52 |
| 15 | Pl/sql | 20 | 10 | 5 | Classical | Opera
| 2007-07-23 19:09:52 |
| 16 | SQL Server | 23 | 12 | 8 | Classical | General
| 2007-07-23 19:09:52 |
+---------+----------------+---------+---------+----------+------------+--------
--+---------------------+
Rows in Set (0.00 sec)
Mysql>
mysql> CREATE TABLE Topic2
-> (
-> & nbsp TopicID SMALLINT NOT null PRIMARY KEY,
-> Name VARCHAR (x) not NULL,
&NBSP ; -> instock SMALLINT UNSIGNED not NULL
->)
-> SELECT TopicID, Name, Instock
-> from Topic
-> WHERE Cate Gory= ' Blues ' or category= ' Jazz ';
Query OK, 3 rows affected (0.01 sec)
records:3 duplicates:0 warnings:0
Mysql>
Mysql> select * from Topic2;
+---------+---------+---------+
| TopicID | name | Instock |
+---------+---------+---------+
| 3 | C Sharp | 17 |
| 7 | python | 2 |
| 8 | php | 32 |
+---------+---------+---------+
3 rows in Set (0.00 sec)